Results 1 to 10 of 10

Thread: Mysterious crash on Mac when QDialog::exec() returns

  1. #1
    Join Date
    Feb 2009
    Posts
    79
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Mysterious crash on Mac when QDialog::exec() returns

    Hi,
    I am getting a strange error here on Mac OS X Lion, with Qt 4.8.0.

    PLEASE NOTE THAT MY APP WORKS FINE ON WINDOWS, WITH Qt 4.5.2 !!!!

    Qt Code:
    1. class MyDiag : public QDialog
    2. {
    3. ....
    4. public slots:
    5. void reject(){
    6. //do sth
    7. QDialog::reject();
    8. }
    9. };
    10.  
    11. // in my code
    12. MyDiag d(qApp->activeWindow());
    13. d.exec();
    To copy to clipboard, switch view to plain text mode 

    Why does this code crash in the line where I call the QDialog::reject() ???
    On Windows this runs abloutely fine.
    Perhaps it is related to the new version of Qt?

    Thanks for your help in advance....

  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: Mysterious crash on Mac when QDialog::exec() returns

    Does your application do anything while the dialog is open?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2009
    Posts
    79
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mysterious crash on Mac when QDialog::exec() returns

    yes, it does a lot
    In particular, it execs other dialogs, or, shows other from QWidget derived classes.

  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: Mysterious crash on Mac when QDialog::exec() returns

    Could it be that while this dialog is open something else causes something that might want to open the same dialog again?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2009
    Posts
    79
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mysterious crash on Mac when QDialog::exec() returns

    No.
    Would this be a problem?
    I mean, I create a new instance of MyDiag and exec it. There should not be a problem anyway, right?

    Moreover, I can't figure one single dialog or widget out that causes the crash,
    now I found another scenario where anothr widget crashes as soon as it is closed.

    What could I do wrong, such that the qt-window-system gets into trouble?
    could an invalid signal-slot-connection have long-run-effects?


    Here's a backtrace of such a Crash:

    Program received signal EXC_BAD_ACCESS, Could not access memory.
    Reason: KERN_PROTECTION_FAILURE at address: 0x0000011f
    0x00826712 in qt_post_window_change_event ()
    (gdb) bt
    #0 0x00826712 in qt_post_window_change_event ()
    #1 0x0082686a in qt_event_request_window_change ()
    #2 0x00832f1f in QWidgetPrivate::hide_sys ()
    #3 0x008e5185 in QWidgetPrivate::hide_helper ()
    #4 0x008e46d5 in QWidget::setVisible ()
    #5 0x00d13808 in QDialog::setVisible ()
    #6 0x00d14320 in QDialog::done ()
    #7 0x00d12860 in QDialog::reject ()
    #8 0x0003fad3 in CustomerDetailDialog::reject (this=0xbfffe758) at CustomerDetailDialog.cpp:194
    #9 0x000ea92d in CustomerDetailDialog::qt_static_metacall (_o=0xbfffe758, _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0xbfffd94c) at moc_CustomerDetailDialog.cpp:64
    #10 0x014df4d1 in QMetaObject::activate ()
    #11 0x00ec1c2f in QAbstractButton::clicked ()
    #12 0x00c180de in QAbstractButtonPrivate::emitClicked ()
    #13 0x00c18dab in QAbstractButtonPrivate::click ()
    #14 0x00c18f67 in QAbstractButton::mouseReleaseEvent ()
    #15 0x008e2fdb in QWidget::event ()
    #16 0x00c180a4 in QAbstractButton::event ()
    #17 0x00cae4ac in QPushButton::event ()
    #18 0x00892eba in QApplicationPrivate::notify_helper ()
    #19 0x00893917 in QApplication::notify ()
    #20 0x014ca0d6 in QCoreApplication::notifyInternal ()
    #21 0x0089bae4 in QApplicationPrivate::sendMouseEvent ()
    #22 0x008470c6 in qt_mac_handleMouseEvent ()
    #23 0x008397db in -[QCocoaView mouseUp:] ()
    #24 0x9ab738af in -[NSWindow sendEvent:] ()
    #25 0x0083e277 in -[QCocoaWindow sendEvent:] ()
    #26 0x9ab0b6ff in -[NSApplication sendEvent:] ()
    #27 0x00841d1b in -[QNSApplication sendEvent:] ()
    #28 0x9ad75b83 in -[NSApplication _modalSession:sendEvent:] ()
    #29 0x9ad7574d in -[NSApplication _realDoModalLoopeek:] ()
    #30 0x9ad709e1 in -[NSApplication _doModalLoopeek:] ()
    #31 0x9ad6c9bc in -[NSApplication runModalSession:] ()
    #32 0x0084b751 in QEventDispatcherMac:rocessEvents ()
    #33 0x014c75b0 in QEventLoop::exec ()
    #34 0x00d144d4 in QDialog::exec ()
    // <=======this is where I call MyDiag::exec() =======================
    #35 0x000517a9 in CustomerLibrary::addCustomer (this=0xbffff7a0, gotoStyler=true) at CustomerLibrary.cpp:212
    #36 0x00051b95 in CustomerLibrary::addNewCustomerAndGotoHairstyler (this=0xbffff7a0) at CustomerLibrary.cpp:237
    #37 0x000ebc64 in CustomerLibrary::qt_static_metacall (_o=0xbffff7a0, _c=QMetaObject::InvokeMetaMethod, _id=4, _a=0xbfffe9bc) at moc_CustomerLibrary.cpp:68
    #38 0x014df4d1 in QMetaObject::activate ()
    #39 0x00ec1c2f in QAbstractButton::clicked ()
    #40 0x00c180de in QAbstractButtonPrivate::emitClicked ()
    #41 0x00c18dab in QAbstractButtonPrivate::click ()
    #42 0x00c18f67 in QAbstractButton::mouseReleaseEvent ()
    #43 0x008e2fdb in QWidget::event ()
    #44 0x00c180a4 in QAbstractButton::event ()
    #45 0x00cae4ac in QPushButton::event ()
    #46 0x00892eba in QApplicationPrivate::notify_helper ()
    #47 0x00893917 in QApplication::notify ()
    #48 0x014ca0d6 in QCoreApplication::notifyInternal ()
    #49 0x0089bae4 in QApplicationPrivate::sendMouseEvent ()
    #50 0x008470c6 in qt_mac_handleMouseEvent ()
    #51 0x008397db in -[QCocoaView mouseUp:] ()
    #52 0x9ab738af in -[NSWindow sendEvent:] ()
    #53 0x0083e277 in -[QCocoaWindow sendEvent:] ()
    #54 0x9ab0b6ff in -[NSApplication sendEvent:] ()
    #55 0x00841d1b in -[QNSApplication sendEvent:] ()
    #56 0x9aa9cc82 in -[NSApplication run] ()
    #57 0x0084b87a in QEventDispatcherMac:rocessEvents ()
    #58 0x014c75b0 in QEventLoop::exec ()
    #59 0x014ca857 in QCoreApplication::exec ()
    #60 0x000ce038 in main (argc=1, argv=0xbffffc38) at main.cpp:120
    Last edited by olidem; 12th January 2012 at 21:37.

  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: Mysterious crash on Mac when QDialog::exec() returns

    Quote Originally Posted by olidem View Post
    Would this be a problem?
    Yes, it's a common crashing pattern

    I mean, I create a new instance of MyDiag and exec it. There should not be a problem anyway, right?
    If something else doesn't try to exec the same instance then no.

    Moreover, I can't figure one single dialog or widget out that causes the crash,
    now I found another scenario where anothr widget crashes as soon as it is closed.

    What could I do wrong, such that the qt-window-system gets into trouble?
    could an invalid signal-slot-connection have long-run-effects?
    Run your app under a debugger and print a backtrace upon a crash.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Feb 2009
    Posts
    79
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mysterious crash on Mac when QDialog::exec() returns

    see my post above, i edited it

    Uhhh,
    I just found that...
    I AM using QGLWidget....
    https://bugreports.qt.nokia.com/browse/QTBUG-20652

  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: Mysterious crash on Mac when QDialog::exec() returns

    Program received signal EXC_BAD_ACCESS, Could not access memory.
    Reason: KERN_PROTECTION_FAILURE at address: 0x0000011f
    You have a null pointer somewhere. Looks like an event is sent to some widget that doesn't exist anymore. You should be looking in the CustomerDetailDialog.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    olidem (14th January 2012)

  10. #9
    Join Date
    Feb 2009
    Posts
    79
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mysterious crash on Mac when QDialog::exec() returns

    Still, I have not found a solution.
    One question about the bug I found (see last post):

    Can I expect such a known bug to be fixed in the foreseeable future?

    If not, then I would maybe have to revoke my support of Mac OS or go back to an older verison of Qt.

  11. #10
    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: Mysterious crash on Mac when QDialog::exec() returns

    Quote Originally Posted by olidem View Post
    Can I expect such a known bug to be fixed in the foreseeable future?
    You can expect anything you want although I wouldn't bet on it getting fixed soon.

    If not, then I would maybe have to revoke my support of Mac OS or go back to an older verison of Qt.
    Or you can work around the problem. Where do you change the parent of your GL widget?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QTcpsocket and QDialog::exec()
    By timewolf in forum Qt Programming
    Replies: 2
    Last Post: 25th August 2011, 08:27
  2. Crash on QApplication::exec()
    By Nivek in forum Qt Programming
    Replies: 13
    Last Post: 6th April 2011, 22:18
  3. Replies: 9
    Last Post: 25th March 2011, 21:22
  4. QDialog.exec() exiting without calling QDialog::accept()
    By doggrant in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2011, 11:35
  5. app.exec() never returns?
    By stealth86 in forum Qt Programming
    Replies: 3
    Last Post: 17th July 2007, 18:41

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.