Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.7.3
-
None
-
linux and android
Description
I've noticed a crash tied to ListView items having a defined section.delegate on model reset.
I get the following stacktrace:
1 QQuickListViewPrivate::setSectionHelper(QQmlContext *, QQuickItem *, QString const&) 0x7ffff3b88fe5 2 QQuickListViewPrivate::getSectionItem(QString const&) 0x7ffff3b8f58a 3 QQuickListViewPrivate::updateStickySections() [clone .part.0] 0x7ffff3b914a2 4 QQuickItemViewPrivate::layout() 0x7ffff3b73655 5 QQuickWindowPrivate::polishItems() 0x7ffff38d12ad 6 QSGThreadedRenderLoop::polishAndSync(QSGThreadedRenderLoop::Window *, bool) 0x7ffff3b36b73 7 QQuickWindow::event(QEvent *) 0x7ffff38d4c5e 8 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x7ffff3f8b7c5 9 QgsApplication::notify(QObject *, QEvent *) 0x555557276773 10 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x7ffff197cd58 11 QPlatformWindow::deliverUpdateRequest() 0x7ffff21f7785 12 QPlatformWindow::windowEvent(QEvent *) 0x7ffff21f536d 13 QApplication::notify(QObject *, QEvent *) 0x7ffff3f97773 14 QgsApplication::notify(QObject *, QEvent *) 0x555557276773 15 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x7ffff197cd58 16 QTimerInfoList::activateTimers() 0x7ffff1b332ca 17 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) 0x7ffff1b377a5 18 QXcbUnixEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) 0x7fffefd75d92 19 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) 0x7ffff19896e2 20 QCoreApplication::exec() 0x7ffff19857a8}}
The crash occurs due to the context pointer being null. With the following patch, Qt doesn't crash anymore:
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 54b1157881..9f757ed5ee 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -1080,7 +1080,8 @@ QQuickItem * QQuickListViewPrivate::getSectionItem(const QString §ion) sectionCache[i] = nullptr; sectionItem->setVisible(true); QQmlContext *context = QQmlEngine::contextForObject(sectionItem)->parentContext(); - setSectionHelper(context, sectionItem, section); + if (context) + setSectionHelper(context, sectionItem, section); } else { QQmlComponent* delegate = sectionCriteria->delegate(); const bool reuseExistingContext = delegate->isBound();
(Note: I'm not sure the patch is merely addressing a symptom or adequately fixing the problem.)