Results 1 to 2 of 2

Thread: QAbstractItemModel question

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Qt products
    Qt4
    Platforms
    Windows Android
    Thanks
    14
    Thanked 13 Times in 13 Posts

    Default Re: QAbstractItemModel question

    Hi,

    The code following crashes sometimes. When I debugged the code, I saw that something went wrong in the layoutAboutToBeChanged() but couldn't figured it out. Am I missing something here?

    Qt Code:
    1. void BuddyListModel::onProfileRefreshed(Contact* contact)
    2. {
    3. if(!_contacts.contains(contact))
    4. {
    5. return;
    6. }
    7.  
    8. int row = _contacts.indexOf(contact);
    9. QModelIndex contactIndex = index(row, 0, QModelIndex());
    10.  
    11. /* code crashes here sometimes */
    12. Q_EMIT layoutAboutToBeChanged();
    13. Q_EMIT dataChanged(contactIndex, contactIndex);
    14. Q_EMIT layoutChanged();
    15. /* end of crash zone */
    16. }
    To copy to clipboard, switch view to plain text mode 


    Added after 1 18 minutes:


    This is where the program crashes actually. "it" seems to be null. So in it.value(), it crashes.

    Qt Code:
    1. inline QHash<QModelIndex, Mapping *>::const_iterator index_to_iterator(
    2. const QModelIndex &proxy_index) const
    3. {
    4. Q_ASSERT(proxy_index.isValid());
    5. Q_ASSERT(proxy_index.model() == q_func());
    6. const void *p = proxy_index.internalPointer();
    7. Q_ASSERT(p);
    8. QHash<QModelIndex, Mapping *>::const_iterator it =
    9. static_cast<const Mapping*>(p)->map_iter;
    10. Q_ASSERT(it != source_index_mapping.constEnd());
    11. Q_ASSERT(it.value());
    12. return it;
    13. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by zgulser; 5th June 2012 at 11:08.

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Qt products
    Qt4
    Platforms
    Windows Android
    Thanks
    14
    Thanked 13 Times in 13 Posts

    Default Re: QAbstractItemModel question

    And finally this is the partial debug log..



    QtGuid4.dll!QSortFilterProxyModelPrivate::index_to _iterator(const QModelIndex & proxy_index={...}) Line 174 + 0x8 bytes C++
    QtGuid4.dll!QSortFilterProxyModelPrivate:roxy_to_source(const QModelIndex & proxy_index={...}) Line 350 C++
    QtGuid4.dll!QSortFilterProxyModel::mapToSource(con st QModelIndex & proxyIndex={...}) Line 2483 + 0x10 bytes C++
    QtGuid4.dll!QSortFilterProxyModelPrivate::store_pe rsistent_indexes() Line 977 + 0x18 bytes C++
    QtGuid4.dll!QSortFilterProxyModelPrivate::_q_sourc eLayoutAboutToBeChanged() Line 1225 + 0xc bytes C++
    QtGuid4.dll!QSortFilterProxyModel::qt_static_metac all(QObject * _o=0x05cae320, QMetaObject::Call _c=InvokeMetaMethod, int _id=9, void * * _a=0x001ebab4) Line 111 + 0xf bytes C++
    QtCored4.dll!QMetaObject::activate(QObject * sender=0x05cadc48, const QMetaObject * m=0x66f18230, int local_signal_index=3, void * * argv=0x00000000) Line 3528 + 0x2e bytes C++
    > QtCored4.dll!QAbstractItemModel::layoutAboutToBeCh anged() Line 183 + 0x12 bytes C++

Similar Threads

  1. QAbstractItemModel question
    By awhite1159 in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2008, 10:11
  2. QAbstractItemModel to different views
    By ganeshshenoy in forum Qt Programming
    Replies: 3
    Last Post: 19th February 2008, 14:43
  3. QAbstractItemModel newbie question
    By okellogg in forum Qt Programming
    Replies: 14
    Last Post: 18th February 2008, 13:30
  4. Question on QAbstractItemModel vs. QTableView
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2007, 08:29
  5. Help needed with QAbstractItemModel
    By Harvey West in forum Qt Programming
    Replies: 11
    Last Post: 27th November 2006, 13:06

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
  •  
Qt is a trademark of The Qt Company.