Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.6.0, 6.6.2
-
None
-
-
4b53c9408 (dev), 0627e9c19 (6.8), bf0a7ae5a (6.7), cd4253908 (tqtc/lts-6.5)
Description
Hello, while trying to develop a Typewriter effect for my block editor (https://get-notes.com/) I came into this bug. To reproduce the crash very easily with the code below, compile and run the app and then:
- Focus on the first text input.
- Press return/enter x2 (two times).
- Press backspace x2 (two times).
- Press return/enter one time.
- App crashes.
I've tested this currently only on macOS (EDIT: crashes on Linux too). I also didn't test this with Qt 5. In my own code I'm using a C++ model (QAbstractListModel) but it seems to crash even with a QML ListModel.
The program does NOT crash if `reuseitems` is not used. Also, it does NOT crash if `reuseitems` is used but `positionViewAtIndex` is not used.
I hope you could get this fixed. `reuseitems` is essential for a huge performance gain in my application. But it's very buggy (see another issue I encountered: https://bugreports.qt.io/browse/QTBUG-115262).
Thanks!
pastebin: https://pastebin.com/D2dPycnA
import QtQuick import QtQuick.Window import QtQuick.Controls Window { id: root width: 240 height: 300 visible: true title: qsTr("Test") ListModel { id: listModel ListElement { txt: "Item 1" } } ListView { id: listView anchors.fill: parent clip: true model: listModel reuseItems: true topMargin: root.height / 2 bottomMargin: root.height / 2 delegate: TextArea { id: delegate required property int index required property string txt width: root.width text: txt onCursorPositionChanged: { listView.positionViewAtIndex(delegate.index, ListView.Center); } Keys.onReturnPressed: { listModel.append({txt: "Item " + (listModel.count + 1)}); } Keys.onPressed: (event) => { if (event.key === Qt.Key_Backspace) { if (delegate.index > 0) { listView.positionViewAtIndex(delegate.index - 1, ListView.Center); listView.itemAtIndex(delegate.index - 1).forceActiveFocus(); } listModel.remove(delegate.index); } } ListView.onAdd: { delegate.forceActiveFocus(); delegate.cursorPosition = delegate.text.length; listView.positionViewAtIndex(delegate.index , ListView.Center); } } ScrollBar.vertical: ScrollBar {} } }
Call stack:
1 QQuickItemViewPrivate::updateVisibleIndex() qquickitemview.cpp 2577 0x100f3a554 2 QQuickListViewPrivate::applyInsertionChange(QQmlChangeSet::Change const&, QQuickItemViewPrivate::ChangeResult *, QList<FxViewItem *> *, QList<QQuickItemViewPrivate::MovedItem> *) qquicklistview.cpp 3828 0x100f51185 3 QQuickItemViewPrivate::applyModelChanges(QQuickItemViewPrivate::ChangeResult *, QQuickItemViewPrivate::ChangeResult *) qquickitemview.cpp 2066 0x100f39503 4 QQuickItemViewPrivate::layout() qquickitemview.cpp 1887 0x100f351ac 5 QQuickWindowPrivate::polishItems() qquickwindow.cpp 347 0x100d595bb 6 QSGThreadedRenderLoop::polishAndSync(QSGThreadedRenderLoop::Window *, bool) qsgthreadedrenderloop.cpp 1588 0x100f09aa8 7 QSGThreadedRenderLoop::handleUpdateRequest(QQuickWindow *) qsgthreadedrenderloop.cpp 1375 0x100f0a22b 8 QQuickWindow::event(QEvent *) qquickwindow.cpp 1544 0x100d5de47 9 QCoreApplicationPrivate::notify_helper(QObject *, QEvent *) qcoreapplication.cpp 1288 0x102b3bea6 10 QCoreApplication::notifyInternal2(QObject *, QEvent *) qcoreapplication.cpp 1121 0x102b3baba 11 QPlatformWindow::deliverUpdateRequest() qplatformwindow.cpp 783 0x102368c25 12 QCocoaWindow::deliverUpdateRequest() qcocoawindow.mm 1626 0x102046dc6 13 QCocoaScreen::deliverUpdateRequests() qcocoascreen.mm 488 0x102030106 14 _dispatch_client_callout (x86_64) /usr/lib/system/libdispatch.dylib 0x7ff808f8a317 15 _dispatch_continuation_pop (x86_64) /usr/lib/system/libdispatch.dylib 0x7ff808f8cd7c 16 _dispatch_source_invoke (x86_64) /usr/lib/system/libdispatch.dylib 0x7ff808f9e208 17 _dispatch_main_queue_drain (x86_64) /usr/lib/system/libdispatch.dylib 0x7ff808f96bb1 18 _dispatch_main_queue_callback_4CF (x86_64) /usr/lib/system/libdispatch.dylib 0x7ff808f968bb 19 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ (x86_64h) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7ff809246e67 20 __CFRunLoopRun (x86_64h) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7ff809207eff 21 CFRunLoopRunSpecific (x86_64h) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7ff809206d6c 22 RunCurrentEventLoopInMode (x86_64) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox 0x7ff811eb95e6 23 ReceiveNextEventCommon (x86_64) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox 0x7ff811eb934a 24 _BlockUntilNextEventMatchingListInModeWithFilter (x86_64) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox 0x7ff811eb90e5 25 _DPSNextEvent (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7ff80bc45f6d 26 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7ff80bc4462a 27 -[NSApplication run] (x86_64) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7ff80bc36cd9 28 QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) qcocoaeventdispatcher.mm 405 0x102016f1d 29 QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) qeventloop.cpp 100 0x102b455a6 30 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) qeventloop.cpp 182 0x102b45588 31 QCoreApplication::exec() qcoreapplication.cpp 1442 0x102b3c0a7 32 main main.cpp 24 0x100006038 33 start (x86_64) /usr/lib/dyld 0x10001d52e
Attachments
Issue Links
- relates to
-
QTBUG-108214 List view crash in FxListItemSG::itemPosition()
- Closed
-
QTBUG-110451 emitting dataChanged trips on freed delegate memory
- Closed