Results 1 to 2 of 2

Thread: Updating QSortFIlterProxyModel with setData causes segmentation fault.

  1. #1
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    4

    Exclamation Updating QSortFIlterProxyModel with setData causes segmentation fault.

    Hello Qt experts,

    I 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:
    Qt Code:
    1. Item {
    2. id: rootView
    3. anchors.fill: parent
    4.  
    5. property int view_id: 0
    6.  
    7. Repeater {
    8. id: mainRepeater
    9. model: FeatureModelFilter {
    10. sourceModel: featureModel
    11. view_id: rootView.view_id
    12. }
    13.  
    14. Button {
    15. id: detachButton
    16.  
    17. onClicked: {
    18. console.log(view_id)
    19. var windowComponent = Qt.createComponent("qrc:/src/gui/components/miscellaneous/DockableWindow.qml")
    20. var windowObject = windowComponent.createObject(null, {view_id: new_view_id})
    21.  
    22. view_id = new_view_id
    23. new_view_id++
    24.  
    25. windowObject.visible = true
    26. windowObject.closing.connect(closeEvent)
    27. data.push(windowObject)
    28.  
    29. function closeEvent(event){
    30. view_id = rootView.view_id
    31. }
    32. }
    33. }
    34. }
    To copy to clipboard, switch view to plain text mode 

    DockableWindow.qml:
    Qt Code:
    1. Window {
    2. id: rootWindow
    3. property int view_id
    4.  
    5. DockableView{
    6. anchors.fill: parent
    7. view_id: rootWindow.view_id
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 


    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:
    Qt Code:
    1. Qt6Qmld.dll!QQmlData::wasDeleted(const QObjectPrivate * priv) Line 303 C++
    2. Qt6Qmld.dll!QQmlData::wasDeleted(const QObject * object) Line 317 C++
    3. Qt6Qmld.dll!QV4::QObjectWrapper::wrap(QV4::ExecutionEngine * engine, QObject * object) Line 232 C++
    4. Qt6Qmld.dll!QV4::QQmlContextWrapper::lookupInParentContextHierarchy(QV4::Lookup * l, QV4::ExecutionEngine * engine, QV4::Value * base) Line 756 C++
    5. Qt6Qmld.dll!QV4::Runtime::LoadQmlContextPropertyLookup::call(QV4::ExecutionEngine * engine, unsigned int index) Line 1123 C++
    6. [External Code]
    7. Qt6Qmld.dll!QV4::Moth::VME::exec(QV4::JSTypesStackFrame * frame, QV4::ExecutionEngine * engine) Line 552 C++
    8. Qt6Qmld.dll!QV4::doCall(QV4::Function * self, const QV4::Value * thisObject, const QV4::Value * argv, int argc, QV4::ExecutionContext * context) Line 54 C++
    9. Qt6Qmld.dll!QV4::Function::call(const QV4::Value * thisObject, const QV4::Value * argv, int argc, QV4::ExecutionContext * context) Line 80 C++
    10. Qt6Qmld.dll!QQmlJavaScriptExpression::evaluate(QV4::CallData * callData, bool * isUndefined) Line 238 C++
    11. Qt6Qmld.dll!QQmlBinding::evaluate(bool * isUndefined) Line 188 C++
    12. Qt6Qmld.dll!QQmlBinding::doUpdate(const QQmlJavaScriptExpression::DeleteWatcher & watcher, QFlags<enum QQmlPropertyData::WriteFlag> flags, QV4::Scope & scope) Line 698 C++
    13. Qt6Qmld.dll!QQmlBinding::update(QFlags<enum QQmlPropertyData::WriteFlag> flags) Line 166 C++
    14. Qt6Qmld.dll!QQmlBinding::expressionChanged() Line 604 C++
    15. Qt6Qmld.dll!QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint * e, void * * __formal) Line 549 C++
    16. Qt6Qmld.dll!QQmlNotifier::emitNotify(QQmlNotifierEndpoint * endpoint, void * * a) Line 71 C++
    17. Qt6Qmld.dll!QQmlData::signalEmitted(QAbstractDeclarativeData * __formal, QObject * object, int index, void * * a) Line 359 C++
    18. Qt6Cored.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 3888 C++
    19. Qt6Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 4053 C++
    20. Qt6QuickTemplates2d.dll!QQuickContainer::currentIndexChanged() Line 566 C++
    21. Qt6QuickTemplates2d.dll!QQuickContainer::setCurrentIndex(int index) Line 669 C++
    22. Qt6QuickTemplates2d.dll!QQuickContainerPrivate::removeItem(int index, QQuickItem * item) Line 268 C++
    23. Qt6QuickTemplates2d.dll!QQuickContainerPrivate::itemParentChanged(QQuickItem * item, QQuickItem * parent) Line 327 C++
    24. 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++
    25. Qt6Quickd.dll!QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData & data) Line 6767 C++
    26. Qt6Quickd.dll!QQuickItem::setParentItem(QQuickItem * parentItem) Line 2760 C++
    27. Qt6Quickd.dll!QQuickRepeater::modelUpdated(const QQmlChangeSet & changeSet, bool reset) Line 459 C++
    28. Qt6Quickd.dll!QQuickRepeater::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 277 C++
    29. Qt6Quickd.dll!QQuickRepeater::qt_metacall(QMetaObject::Call _c, int _id, void * * _a) Line 388 C++
    30. Qt6Cored.dll!QMetaObject::metacall(QObject * object, QMetaObject::Call cl, int idx, void * * argv) Line 330 C++
    31. Qt6Cored.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 4021 C++
    32. Qt6Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 4053 C++
    33. Qt6QmlModelsd.dll!QQmlInstanceModel::modelUpdated(const QQmlChangeSet & _t1, bool _t2) Line 349 C++
    34. Qt6QmlModelsd.dll!QQmlDelegateModelPrivate::emitModelUpdated(const QQmlChangeSet & changeSet, bool reset) Line 1790 C++
    35. Qt6QmlModelsd.dll!QQmlDelegateModelGroupPrivate::emitModelUpdated(bool reset) Line 2785 C++
    36. Qt6QmlModelsd.dll!QQmlDelegateModelPrivate::emitChanges() Line 1834 C++
    37. Qt6QmlModelsd.dll!QQmlDelegateModel::_q_itemsRemoved(int index, int count) Line 1724 C++
    38. Qt6QmlModelsd.dll!QQmlDelegateModel::_q_rowsRemoved(const QModelIndex & parent, int begin, int end) Line 1927 C++
    39. Qt6QmlModelsd.dll!QQmlDelegateModel::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 484 C++
    40. Qt6QmlModelsd.dll!QQmlDelegateModel::qt_metacall(QMetaObject::Call _c, int _id, void * * _a) Line 613 C++
    41. Qt6Cored.dll!QMetaObject::metacall(QObject * object, QMetaObject::Call cl, int idx, void * * argv) Line 330 C++
    42. Qt6Cored.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 4021 C++
    43. Qt6Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 4053 C++
    44. Qt6Cored.dll!QAbstractItemModel::rowsRemoved(const QModelIndex & _t1, int _t2, int _t3, QAbstractItemModel::QPrivateSignal _t4) Line 1367 C++
    45. Qt6Cored.dll!QAbstractItemModel::endRemoveRows() Line 2952 C++
    46. 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++
    47. 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++
    48. Qt6Cored.dll!QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex & source_top_left, const QModelIndex & source_bottom_right, const QList<int> & roles) Line 1467 C++
    49. Qt6Cored.dll!QSortFilterProxyModel::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 584 C++
    50. Qt6Cored.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 4007 C++
    51. Qt6Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 4053 C++
    52. Qt6Cored.dll!QAbstractItemModel::dataChanged(const QModelIndex & _t1, const QModelIndex & _t2, const QList<int> & _t3) Line 1318 C++
    53. app.exe!FeatureModel::setData(const QModelIndex & index, const QVariant & value, int role) Line 56 C++
    54. app.exe!FeatureModelFilter::setData(const QModelIndex & index, const QVariant & value, int role) Line 130 C++
    To copy to clipboard, switch view to plain text mode 

    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 openened with the components but they predictably stay visible in the main window.

    Please advise.

    Sisco
    Last edited by sisco; 5th June 2024 at 14:07.

  2. #2
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    4

    Default Re: Updating QSortFIlterProxyModel with setData causes segmentation fault.

    I have been able to create a minimal example showcasing the problem.

    Link here

Similar Threads

  1. segmentation fault
    By lawrence Anthony in forum Newbie
    Replies: 1
    Last Post: 30th November 2011, 22:58
  2. a segmentation fault
    By yaohao@qtcentre in forum Qt Programming
    Replies: 4
    Last Post: 17th March 2011, 10:01
  3. segmentation fault
    By navid in forum Qt Programming
    Replies: 3
    Last Post: 20th December 2009, 12:40
  4. Segmentation Fault?!
    By r07f1 in forum Newbie
    Replies: 2
    Last Post: 11th April 2008, 16:10
  5. segmentation fault
    By shamik in forum Qt Programming
    Replies: 3
    Last Post: 24th November 2006, 08:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.