Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Multiple QSortFilterProxyModel on single data model segmentation fault
Forum Updated to NodeBB v4.3 + New Features

Multiple QSortFilterProxyModel on single data model segmentation fault

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 297 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sisco
    wrote on last edited by
    #1

    Hello Qt experts,

    I am using Qt 6.5 LTS and am running into trouble when updating my data model when using a QSortFIlterProxyModel to display data from my model in multiple different views.

    I have a main window in which i display my component. whenever i click a certain button on the component, i want the component to be displayed in a new window and be removed from the main window.

    I am using a repeater to display the filtered model in DockableView.qml:

    Item {
        id: rootView
        anchors.fill: parent
    
        property int view_id: 0 
    
        Repeater {
            id: mainRepeater
            model: FeatureModelFilter {
                sourceModel: featureModel
                view_id: rootView.view_id
            }
                        
            Button {
                id: detachButton
                                
                onClicked: {
                    console.log(view_id)
                    var windowComponent = Qt.createComponent("qrc:/src/gui/components/miscellaneous/DockableWindow.qml")
                    var windowObject = windowComponent.createObject(null,  {view_id: new_view_id})
                      
                     view_id = new_view_id
                     new_view_id++
    
                     windowObject.visible = true
                     windowObject.closing.connect(closeEvent)
                     data.push(windowObject)
                                                                   
                     function closeEvent(event){
                         view_id = rootView.view_id
                     }
                 }
             }
         }
    

    DockableWindow.qml:

    Window {
        id: rootWindow
        property int view_id
    
        DockableView{
            anchors.fill: parent
            view_id: rootWindow.view_id
        }
    }
    

    This displays all components perfectly fine in the main window but when the component is moved to the new window by setting the view_id property of the repeater item, things go wrong and i end up in a segmentation fault

    Exception thrown at 0x00007FFFED6DCF17 (Qt6Qmld.dll) in app.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
    

    Call stack:

    Qt6Qmld.dll!QQmlData::wasDeleted(const QObjectPrivate * priv) Line 303	C++
     	Qt6Qmld.dll!QQmlData::wasDeleted(const QObject * object) Line 317	C++
     	Qt6Qmld.dll!QV4::QObjectWrapper::wrap(QV4::ExecutionEngine * engine, QObject * object) Line 232	C++
     	Qt6Qmld.dll!QV4::QQmlContextWrapper::lookupInParentContextHierarchy(QV4::Lookup * l, QV4::ExecutionEngine * engine, QV4::Value * base) Line 756	C++
     	Qt6Qmld.dll!QV4::Runtime::LoadQmlContextPropertyLookup::call(QV4::ExecutionEngine * engine, unsigned int index) Line 1123	C++
     	[External Code]	
     	Qt6Qmld.dll!QV4::Moth::VME::exec(QV4::JSTypesStackFrame * frame, QV4::ExecutionEngine * engine) Line 552	C++
     	Qt6Qmld.dll!QV4::doCall(QV4::Function * self, const QV4::Value * thisObject, const QV4::Value * argv, int argc, QV4::ExecutionContext * context) Line 54	C++
     	Qt6Qmld.dll!QV4::Function::call(const QV4::Value * thisObject, const QV4::Value * argv, int argc, QV4::ExecutionContext * context) Line 80	C++
     	Qt6Qmld.dll!QQmlJavaScriptExpression::evaluate(QV4::CallData * callData, bool * isUndefined) Line 238	C++
     	Qt6Qmld.dll!QQmlBinding::evaluate(bool * isUndefined) Line 188	C++
     	Qt6Qmld.dll!QQmlBinding::doUpdate(const QQmlJavaScriptExpression::DeleteWatcher & watcher, QFlags<enum QQmlPropertyData::WriteFlag> flags, QV4::Scope & scope) Line 698	C++
     	Qt6Qmld.dll!QQmlBinding::update(QFlags<enum QQmlPropertyData::WriteFlag> flags) Line 166	C++
     	Qt6Qmld.dll!QQmlBinding::expressionChanged() Line 604	C++
     	Qt6Qmld.dll!QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint * e, void * * __formal) Line 549	C++
     	Qt6Qmld.dll!QQmlNotifier::emitNotify(QQmlNotifierEndpoint * endpoint, void * * a) Line 71	C++
     	Qt6Qmld.dll!QQmlData::signalEmitted(QAbstractDeclarativeData * __formal, QObject * object, int index, void * * a) Line 359	C++
     	Qt6Cored.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 3888	C++
     	Qt6Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 4053	C++
     	Qt6QuickTemplates2d.dll!QQuickContainer::currentIndexChanged() Line 566	C++
     	Qt6QuickTemplates2d.dll!QQuickContainer::setCurrentIndex(int index) Line 669	C++
     	Qt6QuickTemplates2d.dll!QQuickContainerPrivate::removeItem(int index, QQuickItem * item) Line 268	C++
     	Qt6QuickTemplates2d.dll!QQuickContainerPrivate::itemParentChanged(QQuickItem * item, QQuickItem * parent) Line 327	C++
     	Qt6Quickd.dll!QQuickItemPrivate::notifyChangeListeners<void (__cdecl QQuickItemChangeListener::*)(QQuickItem *,QQuickItem *),QQuickItem * const &,QQuickItem * const &>(QFlags<enum QQuickItemPrivate::ChangeType> changeTypes, void(QQuickItemChangeListener::*)(QQuickItem *, QQuickItem *) && function, QQuickItem * const & <args_0>, QQuickItem * const & <args_1>) Line 347	C++
     	Qt6Quickd.dll!QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData & data) Line 6767	C++
     	Qt6Quickd.dll!QQuickItem::setParentItem(QQuickItem * parentItem) Line 2760	C++
     	Qt6Quickd.dll!QQuickRepeater::modelUpdated(const QQmlChangeSet & changeSet, bool reset) Line 459	C++
     	Qt6Quickd.dll!QQuickRepeater::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 277	C++
     	Qt6Quickd.dll!QQuickRepeater::qt_metacall(QMetaObject::Call _c, int _id, void * * _a) Line 388	C++
     	Qt6Cored.dll!QMetaObject::metacall(QObject * object, QMetaObject::Call cl, int idx, void * * argv) Line 330	C++
     	Qt6Cored.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 4021	C++
     	Qt6Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 4053	C++
     	Qt6QmlModelsd.dll!QQmlInstanceModel::modelUpdated(const QQmlChangeSet & _t1, bool _t2) Line 349	C++
     	Qt6QmlModelsd.dll!QQmlDelegateModelPrivate::emitModelUpdated(const QQmlChangeSet & changeSet, bool reset) Line 1790	C++
     	Qt6QmlModelsd.dll!QQmlDelegateModelGroupPrivate::emitModelUpdated(bool reset) Line 2785	C++
     	Qt6QmlModelsd.dll!QQmlDelegateModelPrivate::emitChanges() Line 1834	C++
     	Qt6QmlModelsd.dll!QQmlDelegateModel::_q_itemsRemoved(int index, int count) Line 1724	C++
     	Qt6QmlModelsd.dll!QQmlDelegateModel::_q_rowsRemoved(const QModelIndex & parent, int begin, int end) Line 1927	C++
     	Qt6QmlModelsd.dll!QQmlDelegateModel::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 484	C++
     	Qt6QmlModelsd.dll!QQmlDelegateModel::qt_metacall(QMetaObject::Call _c, int _id, void * * _a) Line 613	C++
     	Qt6Cored.dll!QMetaObject::metacall(QObject * object, QMetaObject::Call cl, int idx, void * * argv) Line 330	C++
     	Qt6Cored.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 4021	C++
     	Qt6Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 4053	C++
     	Qt6Cored.dll!QAbstractItemModel::rowsRemoved(const QModelIndex & _t1, int _t2, int _t3, QAbstractItemModel::QPrivateSignal _t4) Line 1367	C++
     	Qt6Cored.dll!QAbstractItemModel::endRemoveRows() Line 2952	C++
     	Qt6Cored.dll!QSortFilterProxyModelPrivate::remove_proxy_interval(QList<int> & source_to_proxy, QList<int> & proxy_to_source, int proxy_start, int proxy_end, const QModelIndex & proxy_parent, Qt::Orientation orient, bool emit_signal) Line 803	C++
     	Qt6Cored.dll!QSortFilterProxyModelPrivate::remove_source_items(QList<int> & source_to_proxy, QList<int> & proxy_to_source, const QList<int> & source_items, const QModelIndex & source_parent, Qt::Orientation orient, bool emit_signal) Line 772	C++
     	Qt6Cored.dll!QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex & source_top_left, const QModelIndex & source_bottom_right, const QList<int> & roles) Line 1467	C++
     	Qt6Cored.dll!QSortFilterProxyModel::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 584	C++
     	Qt6Cored.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 4007	C++
     	Qt6Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 4053	C++
     	Qt6Cored.dll!QAbstractItemModel::dataChanged(const QModelIndex & _t1, const QModelIndex & _t2, const QList<int> & _t3) Line 1318	C++
    	app.exe!FeatureModel::setData(const QModelIndex & index, const QVariant & value, int role) Line 56	C++
     	app.exe!FeatureModelFilter::setData(const QModelIndex & index, const QVariant & value, int role) Line 130	C++
    

    I have implemented my filter by overriding filterAcceptsRow and the filtering seems to be done correctly. When not using the filter (filter always returns true) the qml code works fine, the new windows get opened with the components but they predictably stay visible in the main window.

    Please advise.

    Sisco

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      The best thing to do in that case is to provide a minimal compilable example so people can reproduce your issue.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        The best thing to do in that case is to provide a minimal compilable example so people can reproduce your issue.

        S Offline
        S Offline
        Sisco
        wrote on last edited by Sisco
        #3

        @SGaist I have been able to create a minimal example that shows the problem i am running into.

        Drive link here.

        Not that is i set the data directly on the source model, the segfault disappears but then the external window shows no layout at all.

        // Replacing this with setting the data directly in teh source model causes the external window ui not to display
        view_id = window_view_id
        // model.sourceModel.setData(item_index, window_view_id, 257)
        

        Regards,
        Sisco

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved