Results 1 to 3 of 3

Thread: Openning QMessageBox from asyncroniously called slot leads to crash

  1. #1
    Join Date
    Apr 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Openning QMessageBox from asyncroniously called slot leads to crash

    I have an QHttp embedded into my wrapper that has :
    Qt Code:
    1. connect(
    2. _http , SIGNAL( requestFinished(int , bool) ),
    3. this , SLOT( requestProcessingFinished(int , bool) )
    4. );
    To copy to clipboard, switch view to plain text mode 

    and has a slot:

    Qt Code:
    1. void
    2. GetFile::requestProcessingFinished(int id_ , bool error_ )
    3. {
    4. ...
    5. emit sig_done(_fileName);
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 
    In main window I do:
    Qt Code:
    1. connect(
    2. &_getUpdateFile , SIGNAL( sig_done( QString ) ),
    3. this , SLOT( upgradeDownloaded(QString) ) /* ,
    4. Qt::QueuedConnection */
    5. );
    To copy to clipboard, switch view to plain text mode 
    where _getUpdateFile is an instance of my wrapper.
    Inside upgradeDownloaded I call some function that put's QMessage Box on the
    desktop like this:
    Qt Code:
    1. QMessageBox msgBox(0L);
    2. msgBox.addButton(tr("Run"), QMessageBox::ActionRole);
    3. QPushButton *snoozeButton = msgBox.addButton(tr("Snooze and Run
    4. later"),
    5. QMessageBox::ActionRole);
    6. msgBox.setText(tr("Update has been downloaded. Run update file or
    7. snooze and
    8. run later?"));
    9. msgBox.setIcon(QMessageBox::Icon::Question);
    10. msgBox.exec();
    To copy to clipboard, switch view to plain text mode 
    or just with QMessageBox convinience function.
    If I do connect without placing explicit Qt:QueuedConnection - I get
    segmentation fault. If I put QueuedConnection explicitelly - everything is
    working well.
    like this:
    Qt Code:
    1. connect(
    2. &_getUpdateFile , SIGNAL( sig_done( QString ) ),
    3. this , SLOT( upgradeDownloaded(QString) ) ,
    4. Qt::QueuedConnection
    5. );
    To copy to clipboard, switch view to plain text mode 

    Is that should be the case that I MUST state what kind of connection I want?
    Should not it be automatic and be the care of QT?
    I am more the sure that I miss something... but the question is what.
    The code compiled with VS2003.
    Platform Windows XP SP2.

    The backtrace (under windows is):
    QtCored4.dll!QEventLoop::exit(int returnCode=0) Line 237 + 0x3 C++
    QtGuid4.dll!QDialog::setVisible(bool visible=false) Line 692 C++
    QtGuid4.dll!QWidget::hide() Line 434 + 0x14 C++
    QtGuid4.dll!QDialog::~QDialog() Line 253 C++
    QtGuid4.dll!QMessageBox::~QMessageBox() Line 677 + 0x8 C++
    msvcr71d.dll!_CallSettingFrame(unsigned long funclet=1228936, unsigned
    long
    pRN=259, unsigned long dwInCode=0) + 0x27 Asm
    msvcr71d.dll!__FrameUnwindToState(EHRegistrationNo de * pRN=0x0012c088,
    void
    * pDC=0x00128f00, const _s_FuncInfo * pFuncInfo=0x65812f34, int
    targetState=-1) +
    0xbf C++
    msvcr71d.dll!__InternalCxxFrameHandler(EHException Record *
    pExcept=0x00129408, EHRegistrationNode * pRN=0x0012c088, _CONTEXT *
    pContext=0x00128f0c, void *
    pDC=0x00128f00, const _s_FuncInfo * pFuncInfo=0x65812f34, int CatchDepth=0,
    EHRegistrationNode * pMarkerRN=0x00000000, unsigned char recursive=0) + 0x4d
    C++
    > msvcr71d.dll!__CxxFrameHandler(EHExceptionRecord * pExcept=0x00129408,
    EHRegistrationNode * pRN=0x0012c088, void * pContext=0x00128f0c, void *
    pDC=0x00128f00) +
    0x2c C++
    ntdll.dll!7c9037bf()
    ntdll.dll!7c90378b()
    ntdll.dll!7c937b48()
    kernel32.dll!7c81eb33()

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

    Default Re: Openning QMessageBox from asyncroniously called slot leads to crash

    I assume your wrapper class is a separate Thread. If so then the answer is - yes you always need the queued connection as only the main-thread can do graphical output (this was discussed here very often already).

  3. #3
    Join Date
    Apr 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Openning QMessageBox from asyncroniously called slot leads to crash

    No... My wrapper is not running additional thread.
    QT's documentation is stating that if I do not specify connection type it is set to automatic... meaning that if receiver owner is a different thread then the signal will be delivered through message queue.
    Also there are examples for QHttp that do not have any specific connection type stated.

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.