Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.11.0, 5.11.1, 5.11.2
-
None
-
Was tested with Qt 5.11.1 and 5.11.2 on a Debian 9.5 VM and Qt 5.11.0 on Windows 10 x64. They all crash.
-
-
80ba7e03afe18cc44715f7cf9a038bedff01f328 (qt/qtquickcontrols/5.12)
Description
Hi
The following miminal example, basically a stripped-down version of
https://doc.qt.io/qt-5.11/qtquickcontrols-filesystembrowser-example.html
crashes when in a multi selection mode (e.g. SelectionMode.MultiSelection or SelectionMode.ExtendedSelection), the selection mouse pointer is dragged beyond row 0.
Note: The example below is using `QFileSystemModel`, but I have the same behavior with another model derived from `QAbstractItemModel` that crashes in the same way when used in a QML TreeView.
filesystembrowser.pro:
TEMPLATE = app TARGET = filesystembrowser QT += qml quick widgetsSOURCES += main.cppRESOURCES += qml.qrc CONFIG += c++11INSTALLS += target
main.cpp:
#include <QApplication> #include <QQmlApplicationEngine> #include <QtQml> #include <QFileSystemModel> class DisplayFileSystemModel : public QFileSystemModel { Q_OBJECT public: explicit DisplayFileSystemModel(QObject *parent = nullptr) : QFileSystemModel(parent) {} QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override { return QFileSystemModel::data(index, role); } QHash<int,QByteArray> roleNames() const override { QHash<int, QByteArray> result = QFileSystemModel::roleNames(); return result; } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlApplicationEngine engine; qmlRegisterUncreatableType<DisplayFileSystemModel>("io.qt.examples.quick.controls.filesystembrowser", 1, 0, "FileSystemModel", "Cannot create a FileSystemModel instance."); QFileSystemModel *fsm = new DisplayFileSystemModel(&engine); fsm->setRootPath(QDir::homePath()); fsm->setResolveSymlinks(true); engine.rootContext()->setContextProperty("fileSystemModel", fsm); engine.rootContext()->setContextProperty("rootPathIndex", fsm->index(fsm->rootPath())); engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); } #include "main.moc"
main.qml:
import QtQuick 2.11 import QtQuick.Controls 1.4 import QtQml.Models 2.11 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("File System") ItemSelectionModel { id: selectionModel model: fileSystemModel } TreeView { id: view anchors.fill: parent model: fileSystemModel rootIndex: rootPathIndex selection: selectionModel selectionMode: SelectionMode.MultiSelection //SelectionMode.ExtendedSelection TableViewColumn { title: "Name" role: "fileName" resizable: true } } }
Stack backtrace:
1 QPersistentModelIndex::operator QModelIndex const& qabstractitemmodel.cpp 272 0x7ffff585c0d0 2 QQuickTreeModelAdaptor1::selectionForRowRange qquicktreemodeladaptor.cpp 292 0x7fffd8cdc9b8 3 QQuickTreeModelAdaptor1::qt_static_metacall moc_qquicktreemodeladaptor_p.cpp 212 0x7fffd8cf3eb8 4 QQuickTreeModelAdaptor1::qt_metacall moc_qquicktreemodeladaptor_p.cpp 337 0x7fffd8cf46d8 5 QQmlObjectOrGadget::metacall qqmlpropertycache.cpp 1733 0x7ffff637c389 6 CallMethod qv4qobjectwrapper.cpp 1175 0x7ffff62e9d7d 7 CallPrecise qv4qobjectwrapper.cpp 1437 0x7ffff62eb2cd 8 QV4::QObjectMethod::callInternal qv4qobjectwrapper.cpp 1975 0x7ffff62ec056 9 QV4::FunctionObject::call qv4functionobject_p.h 163 0x7ffff6306f60 10 QV4::Runtime::method_callProperty qv4runtime.cpp 1062 0x7ffff6306f60 11 QV4::Moth::VME::exec qv4vme_moth.cpp 800 0x7ffff62f9d4a 12 QV4::FunctionObject::call qv4functionobject_p.h 163 0x7ffff6306f60 13 QV4::Runtime::method_callProperty qv4runtime.cpp 1062 0x7ffff6306f60 14 QV4::Moth::VME::exec qv4vme_moth.cpp 800 0x7ffff62f9d4a 15 QV4::Moth::VME::exec qv4vme_moth_p.h 72 0x7ffff63ab1b6 16 QV4::Function::call qv4function_p.h 72 0x7ffff63ab1b6 17 QQmlJavaScriptExpression::evaluate qqmljavascriptexpression.cpp 217 0x7ffff63ab1b6 18 QQmlBoundSignalExpression::evaluate qqmlboundsignal.cpp 237 0x7ffff63411e9 19 QQmlBoundSignal_callback qqmlboundsignal.cpp 370 0x7ffff63426d3 20 QQmlNotifier::emitNotify qqmlnotifier.cpp 106 0x7ffff63865f4 21 QQmlData::signalEmitted qqmlengine.cpp 861 0x7ffff6325114 22 QMetaObject::activate qobject.cpp 3649 0x7ffff58d57f2 23 QMetaObject::activate qobject.cpp 3633 0x7ffff58d5a97 24 QQmlTimer::triggered moc_qqmltimer_p.cpp 261 0x7ffff6412740 25 QQmlTimer::ticked qqmltimer.cpp 323 0x7ffff6412b6f 26 QQmlTimer::event qqmltimer.cpp 335 0x7ffff6412e3c 27 QApplicationPrivate::notify_helper qapplication.cpp 3727 0x7ffff7083e2c 28 QApplication::notify qapplication.cpp 3486 0x7ffff708af60 29 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1048 0x7ffff58aa2d8 30 QCoreApplication::sendEvent qcoreapplication.h 234 0x7ffff58acceb 31 QCoreApplicationPrivate::sendPostedEvents qcoreapplication.cpp 1745 0x7ffff58acceb 32 QCoreApplication::sendPostedEvents qcoreapplication.cpp 1599 0x7ffff58ad1d8 33 postEventSourceDispatch qeventdispatcher_glib.cpp 276 0x7ffff58fed93 34 g_main_context_dispatch 0x7ffff18537f7 35 ?? 0x7ffff1853a60 36 g_main_context_iteration 0x7ffff1853b0c 37 QEventDispatcherGlib::processEvents qeventdispatcher_glib.cpp 422 0x7ffff58fe3ff 38 QPAEventDispatcherGlib::processEvents qeventdispatcher_glib.cpp 69 0x7fffee8740d1 39 QEventLoop::exec qeventloop.cpp 214 0x7ffff58a8c3a 40 QCoreApplication::exec qcoreapplication.cpp 1336 0x7ffff58b1640 41 main main.cpp 43 0x5555555572f5
Offending line:
QPersistentModelIndex::operator const QModelIndex&() const { static const QModelIndex invalid; if (d) <--- DEBUGGER HALTS HERE return d->index; return invalid; }
Attachments
For Gerrit Dashboard: QTBUG-71789 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
245710,4 | QQuickTreeModelAdaptor1: fix out of range issue in selectionForRowRange | 5.12 | qt/qtquickcontrols | Status: MERGED | +2 | 0 |