Results 1 to 9 of 9

Thread: ASSERT Failure in QAbstractItemModel Pure Virtual Function

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: ASSERT Failure in QAbstractItemModel Pure Virtual Function

    Well then, if it is the mouse button press that seems to trigger the bad behavior, I would start by putting a breakpoint at the start of that slot and stepping through the code line by line (including stepping into any functions called from within the slot) to see if there is something funny going on.

    Another test would be to -not- try to reproduce the problem, but to just use whatever you can of the program -without- clicking the button. If at some point it breaks, then it would indicate that the button click is also a red herring and that the corruption is occurring earlier or somewhere else.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. The following user says thank you to d_stranz for this useful post:

    Corny (23rd May 2018)

  3. #2
    Join Date
    Nov 2016
    Location
    Ridgecrest California
    Posts
    33
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android
    Thanks
    11
    Thanked 1 Time in 1 Post

    Default Re: ASSERT Failure in QAbstractItemModel Pure Virtual Function

    Thanks again for your assistance. I'll give what you suggest a try.

  4. #3
    Join Date
    Jul 2012
    Posts
    248
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    29
    Thanked 15 Times in 14 Posts

    Default Re: ASSERT Failure in QAbstractItemModel Pure Virtual Function

    Sine you are lucky and Qt tells you exactly where you went wrong, you also breakpoint the QVector::at function shorty before the error occurs and backtrack from there, with the stack intact.

  5. #4
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 86 Times in 81 Posts

    Default Re: ASSERT Failure in QAbstractItemModel Pure Virtual Function

    Qt Code:
    1. 121 if(index.isValid())
    2. 122 pItem = static_cast<ModelItem*>(index.internalPointer());
    3. 123 else
    4. 124 pItem = pRoot;
    5. 125 return pItem->getData(index.column());
    To copy to clipboard, switch view to plain text mode 
    What would you expect here instead of an assertion when index is not valid? Hint: when index is not valid, index.column() will not contain a valid column but -1...

  6. #5
    Join Date
    Nov 2016
    Location
    Ridgecrest California
    Posts
    33
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android
    Thanks
    11
    Thanked 1 Time in 1 Post

    Default Re: ASSERT Failure in QAbstractItemModel Pure Virtual Function

    Quote Originally Posted by ChristianEhrlicher View Post
    Qt Code:
    1. 121 if(index.isValid())
    2. 122 pItem = static_cast<ModelItem*>(index.internalPointer());
    3. 123 else
    4. 124 pItem = pRoot;
    5. 125 return pItem->getData(index.column());
    To copy to clipboard, switch view to plain text mode 
    What would you expect here instead of an assertion when index is not valid? Hint: when index is not valid, index.column() will not contain a valid column but -1...
    Thanks! That pointed out the error of my ways. It seems so obvious now.
    Thanks again.

  7. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: ASSERT Failure in QAbstractItemModel Pure Virtual Function

    Yes, I did a dope slap on my head as well. Sorry for sending you on a wild goose chase when the problem was staring us in the face. Sometimes no matter how carefully you read code, the obvious escapes you.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 11
    Last Post: 14th August 2014, 09:08
  2. Assert failure with tablet installed
    By Spectralist in forum Qt Programming
    Replies: 2
    Last Post: 21st April 2011, 13:31
  3. Problem debugging Assert failure.
    By Doug Broadwell in forum Qt Programming
    Replies: 3
    Last Post: 3rd January 2009, 18:39
  4. Debugging ASSERT failure in Qt header.
    By Doug Broadwell in forum Qt Programming
    Replies: 6
    Last Post: 27th December 2008, 01:40
  5. QWT assert failure
    By Andimat in forum Qwt
    Replies: 1
    Last Post: 21st June 2007, 14:36

Tags for this Thread

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.