Results 1 to 8 of 8

Thread: QProgressDialog::setValue crash( Mac )

  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QProgressDialog::setValue crash( Mac )

    Has anyone experienced any crashes in setValue?

    QProgressDialog::setValue is called after receiving a custom event posted from another thread in the GUI thread. It does not crash every time( it has its moments ).

    Thanks.

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

    Default Re: QProgressDialog::setValue crash( Mac )

    Do you call it from the GUI thread? Do you call any GUI related methods from within a worker thread?

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProgressDialog::setValue crash( Mac )

    No, of course there aren't any GUI calls from the other thread.
    setValue is called from an event(...) method. The value to be set comes with the custom event, from the worker thread.
    This is why it's so weird...

    Also, I haven't set the progress dialog to be Window Modal, because this would have caused QApplication:rocessEvents() to be called from setValue.

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

    Default Re: QProgressDialog::setValue crash( Mac )

    Can we see the handler code?

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProgressDialog::setValue crash( Mac )

    I am not at work right now, but I can reproduce it:

    Qt Code:
    1. bool MyWidget::event( QEvent *e )
    2. {
    3. if( e->type() == QEvent::User )
    4. {
    5. MyEvent *customEvent = dynamic_cast<MyEvent*>(e);
    6. if( customEvent && mProgressDlg )
    7. {
    8. if( customEvent->id == MyEvent::eUpdateProgress )
    9. mProgressDlg->setValue( customEvent->progressValue );
    10. else if( customEvent->id == MyEvent::eDone )
    11. {
    12. mProgressDlg->reset();
    13. delete mProgressDlg;
    14. mProgressDlg = NULL;
    15. // ... Other code
    16. }
    17. e->accept();
    18. return true;
    19. }
    20. }
    21.  
    22. return false;
    23. }
    To copy to clipboard, switch view to plain text mode 
    mProgressDlg is of type QProgressDialog* and is created with:

    Qt Code:
    1. mProgressDlg = new QProgressDialog( "...", "...", 0, 100, mainWindow, 0 );
    2. mProgressDlg->setMinimumDuration( 2000 );
    3. mProgressDlg->setValue( 0 );
    4. mProgressDlg->setAutoClose( true );
    To copy to clipboard, switch view to plain text mode 
    where mainWindow is a pointer to my app QMainWindow. Does QProgressDialog posts some events (maybe QTimerEvent's ?? ) to it's parent event queue?

    So, this is a minimal version of the code. I hope I didn't forget anything.

    Thanks.
    Last edited by marcel; 11th April 2007 at 20:18. Reason: forgot something

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

    Default Re: QProgressDialog::setValue crash( Mac )

    First of all I don't see you call the base implementation of event(). Second of all, is there a special reason why you handle the event in event() instead of customEvent()?

  7. #7
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProgressDialog::setValue crash( Mac )

    Ok.

    1. The base impl of event() is called, just forgot it here .
    2. No reason at all for handling this in event(). Is there any major difference between customEvent() and event(), except the fact that only user defined events enter customEvent()?

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

    Default Re: QProgressDialog::setValue crash( Mac )

    Probably no "major" difference, but still you should handle the event in customEvent() I doubt that will change your situation - I can't see anything wrong with the code but it's worth to try. Is it possible for you to isolate and stop the other threads so that only the GUI thread runs and see if the application still crashes? If not, at least try debugging with a debugger and print a backtrace of the crash.

Similar Threads

  1. QList crash in destructor
    By mclark in forum Newbie
    Replies: 7
    Last Post: 6th December 2006, 15:27
  2. Crash caused by QVariant (mis)use
    By mclark in forum Newbie
    Replies: 2
    Last Post: 31st October 2006, 15:05
  3. sendPostedEvents crash
    By stinos in forum Qt Programming
    Replies: 5
    Last Post: 29th October 2006, 09:43
  4. Replies: 5
    Last Post: 24th April 2006, 15:42
  5. Crash: using a dialog in a model
    By Brandybuck in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2006, 01:39

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.