QupZilla / qupzilla

Cross-platform Qt web browser
http://www.qupzilla.com
GNU General Public License v3.0
1.12k stars 347 forks source link

fixed crash with 1 tab #2619

Closed tarptaeya closed 6 years ago

tarptaeya commented 6 years ago

when only 1 tab is present, then pressing ctrl + tab causes crash due to event->ignore

It seems like infinite recursion, Backtrace - (on Fedora 27, Qt 5.10)


(gdb) backtrace
#0  0x00007fffef7e9247 in  ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#1  0x00007fffef7e9c35 in  ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#2  0x00007fffef7ec713 in  ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#3  0x00007fffef8cf49a in QMenuBar::eventFilter(QObject*, QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#4  0x00007fffed5fe792 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5
#5  0x00007fffef74e525 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#6  0x00007fffef7571d6 in QApplication::notify(QObject*, QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#7  0x00007fffed5fe9f8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5
#8  0x00007ffff78e438b in BrowserWindow::keyPressEvent(QKeyEvent*) ()
    at /lib/libQupZilla.so.2
#9  0x00007fffef78b6d7 in QWidget::event(QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#10 0x00007fffef897891 in QMainWindow::event(QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#11 0x00007fffef74e54c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ---Type <return> to continue, or q <return> to quit---
() at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#12 0x00007fffef7571d6 in QApplication::notify(QObject*, QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#13 0x00007fffed5fe9f8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5
#14 0x00007ffff78e438b in BrowserWindow::keyPressEvent(QKeyEvent*) ()
    at /lib/libQupZilla.so.2
#15 0x00007fffef78b6d7 in QWidget::event(QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#16 0x00007fffef897891 in QMainWindow::event(QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#17 0x00007fffef74e54c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#18 0x00007fffef7571d6 in QApplication::notify(QObject*, QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#19 0x00007fffed5fe9f8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Core.so.5
#20 0x00007ffff78e438b in BrowserWindow::keyPressEvent(QKeyEvent*) ()
    at /lib/libQupZilla.so.2
#21 0x00007fffef78b6d7 in QWidget::event(QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
#22 0x00007fffef897891 in QMainWindow::event(QEvent*) ()
    at /home/tarptaeya/Qt/5.10.0/gcc_64/lib/libQt5Widgets.so.5
---Type <return> to continue, or q <return> to quit---

``
nowrep commented 6 years ago

No crash here, can you please post backtrace? I don't really see how this could fix it.

tarptaeya commented 6 years ago

Posted backtrace above, event->ignore seems like recurssion overflow, If we prints something in the keypress function above if, its printed continuously untill seg fault

nowrep commented 6 years ago
diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp
index 031bee19..7254b654 100644
--- a/src/lib/app/browserwindow.cpp
+++ b/src/lib/app/browserwindow.cpp
@@ -1338,12 +1338,14 @@ void BrowserWindow::keyPressEvent(QKeyEvent* event)
     case Qt::Key_Tab:
         if (event->modifiers() == Qt::ControlModifier) {
             QApplication::sendEvent(m_tabWidget, event);
+            event->accept();
         }
         break;

     case Qt::Key_Backtab:
         if (event->modifiers() == (Qt::ControlModifier + Qt::ShiftModifier)) {
             QApplication::sendEvent(m_tabWidget, event);
+            event->accept();
         }
         break;

Does this fixes it? EDIT: No, it won't fix it.

tarptaeya commented 6 years ago

No, It crashes again with similar backtrace

nowrep commented 6 years ago

Alright, but that code is definitely to blame, not TabStackedWidget. It is wrong to resend events this way.

tarptaeya commented 6 years ago

It didn't crashed with event->accept() in TabStackedWidget