Crash in Qt and unrelated to my code.
-
I have an application like almost exactly in the following image. It basically has three major parts (Tree, Table, and Table). The first table on the right, next to QTreeView is split into two tables using QHorizontalSplit that are connected such that the Properties gets updated for every selection in the top table.
The way it works is that, in the tree view (like directory structure), I double click and the table on the right gets populated. I can click on each row of this table and I can see it's properties below it. This works to some extent.
However, when I select (single click or double click) any row in the Property table and then go back to the QTreeView to click any hierarchical structure in the TreeView, the application crashes.I had no luck debugging using gdb because the crash isn't coming from my code. Can you anyone point me to address this Qt crash?
Stack trace:
QSortFilterProxyModel: index from wrong model passed to mapFromSource QSortFilterProxyModel: index from wrong model passed to mapFromSource QSortFilterProxyModel: index from wrong model passed to mapFromSource QSortFilterProxyModel: index from wrong model passed to mapFromSource qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 4631, resource id: 21340232, major code: 40 (TranslateCoords), minor code: 0 Thread 1 "browser_bin" received signal SIGSEGV, Segmentation fault. 0x00007ffff559715d in QSortFilterProxyModel::parent(QModelIndex const&) const () from /lib64/libQt5Core.so.5 (gdb) where #0 0x00007ffff559715d in QSortFilterProxyModel::parent(QModelIndex const&) const () from /lib64/libQt5Core.so.5 #1 0x00007ffff5575653 in QPersistentModelIndex::parent() const () from /lib64/libQt5Core.so.5 #2 0x00007ffff558b64d in QItemSelectionRange::isValid() const () from /lib64/libQt5Core.so.5 #3 0x00007ffff5586dc0 in QItemSelection::merge(QItemSelection const&, QFlags<QItemSelectionModel::SelectionFlag>) () from /lib64/libQt5Core.so.5 #4 0x00007ffff55876c3 in QItemSelectionModel::rowIntersectsSelection(int, QModelIndex const&) const () from /lib64/libQt5Core.so.5 #5 0x00007ffff66d2aae in QHeaderView::paintSection(QPainter*, QRect const&, int) const () from /lib64/libQt5Widgets.so.5 #6 0x00007ffff66cee3e in QHeaderView::paintEvent(QPaintEvent*) () from /lib64/libQt5Widgets.so.5 #7 0x00007ffff6499ee8 in QWidget::event(QEvent*) () from /lib64/libQt5Widgets.so.5 #8 0x00007ffff65437c2 in QFrame::event(QEvent*) () from /lib64/libQt5Widgets.so.5 #9 0x00007ffff66c23c3 in QAbstractItemView::viewportEvent(QEvent*) () from /lib64/libQt5Widgets.so.5 #10 0x00007ffff66d1e8b in QHeaderView::viewportEvent(QEvent*) () from /lib64/libQt5Widgets.so.5 #11 0x00007ffff55c34b5 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () from /lib64/libQt5Core.so.5 #12 0x00007ffff6459242 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib64/libQt5Widgets.so.5 #13 0x00007ffff645ffc0 in QApplication::notify(QObject*, QEvent*) () from /lib64/libQt5Widgets.so.5 #14 0x00007ffff55c36c2 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib64/libQt5Core.so.5 #15 0x00007ffff64922d9 in QWidgetPrivate::sendPaintEvent(QRegion const&) () from /lib64/libQt5Widgets.so.5 #16 0x00007ffff6492b9c in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) () from /lib64/libQt5Widgets.so.5 #17 0x00007ffff64695d6 in QWidgetRepaintManager::paintAndFlush() () from /lib64/libQt5Widgets.so.5 #18 0x00007ffff646a114 in QWidgetRepaintManager::sync() () from /lib64/libQt5Widgets.so.5 #19 0x00007ffff6493975 in QWidgetPrivate::syncBackingStore() () from /lib64/libQt5Widgets.so.5 #20 0x00007ffff649a0b8 in QWidget::event(QEvent*) () from /lib64/libQt5Widgets.so.5 #21 0x00007ffff65aa738 in QMainWindow::event(QEvent*) () from /lib64/libQt5Widgets.so.5 #22 0x00007ffff6459252 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib64/libQt5Widgets.so.5 #23 0x00007ffff645ffc0 in QApplication::notify(QObject*, QEvent*) () from /lib64/libQt5Widgets.so.5 #24 0x00007ffff55c36c2 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib64/libQt5Core.so.5 #25 0x00007ffff55c64b1 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /lib64/libQt5Core.so.5 #26 0x00007ffff5617c97 in postEventSourceDispatch(_GSource*, int (*)(void*), void*) () from /lib64/libQt5Core.so.5 #27 0x00007fffee8f3aed in g_main_context_dispatch () from /lib64/libglib-2.0.so.0 #28 0x00007fffee8f3ea8 in g_main_context_iterate.isra () from /lib64/libglib-2.0.so.0 #29 0x00007fffee8f3f40 in g_main_context_iteration () from /lib64/libglib-2.0.so.0 --Type <RET> for more, q to quit, c to continue without paging-- #30 0x00007ffff5617a44 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5 #31 0x00007ffff55c23bb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5 #32 0x00007ffff55ca814 in QCoreApplication::exec() () from /lib64/libQt5Core.so.5 #33 0x0000000003128002 in main (argc=2, argv=0x7fffffff9928) at main.cc:97
-
Sorry to say, but the issue is in your code, not in Qt.
It occurs, when a model is called with a QModelIndex from another model.
That can happen either, when there the wrong model is called, or when the index is mal-constructed.
Please boil the problem down to a minmal, cmplilable reproducer. Just showing the App architecture is helpful but not sufficient. Please post the minimal reproducer here, using code tags.