Results 1 to 20 of 20

Thread: QTableWidget Crash in Destructor

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget Crash in Destructor

    What prevents Qt from sorting during inserts (please read the full message before answering)?

    Does the following sound plausible?
    1. A user presses a QTableWidget column header to initiate a sort of 215 rows of 6 cells each (1290 items).
    2. I receive a notification to add a row and disable sorting BEFORE Qt has finished the previous sort.
    If Qt is not done sorting when I disable sorting and start adding row items, could the item pointers become confused and account for the problems outlined above?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableWidget Crash in Destructor

    Can (2) happen from within the sort() method of the proxy or the base model? Remember that sorting is synchronous, so unless you provided your own implementation of sort(), the answer will be "no". If you are using multiple threads, then you shouldn't be accessing the same QObject from more than one thread.

  3. #3
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget Crash in Destructor

    This one appears unsolvable so I'll just have to change my design. I'll collect all notifications in the main app. When the dialog is constructed, the table will only contain a snapshot of devices known at the time of dialog instantiation.

    The table in the dialog will not be updated dynamically. Not a big deal but the original problem still irritates...

    Thanks to all who tried to help!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableWidget Crash in Destructor

    But do you use more than one thread in your application?

  5. #5
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget Crash in Destructor

    Quote Originally Posted by wysota View Post
    But do you use more than one thread in your application?
    Yes, multiple threads are running in the app. In the offending dialog, a notification thread was running. The notification handler was locked using a QMutexLocker, where the mutex was declared as a class member. This should protect the table insertion code, no?
    Qt Code:
    1. QMutexLocker locker( &m_NotifyMutex );
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableWidget Crash in Destructor

    You can't access QObjects from more than one thread and no mutex will help here. You have to make sure that you follow that rule.

Similar Threads

  1. Confused - QGraphicsItem destructor
    By durbrak in forum Qt Programming
    Replies: 7
    Last Post: 13th February 2008, 20:27
  2. Crash in QTableWidget
    By ghorwin in forum Qt Programming
    Replies: 3
    Last Post: 29th October 2007, 16:57
  3. Crash on QString Destructor
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2007, 14:28
  4. QList crash in destructor
    By mclark in forum Newbie
    Replies: 7
    Last Post: 6th December 2006, 15:27

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.