Results 1 to 5 of 5

Thread: QDialog::exec() Segmentation fault

  1. #1
    Join Date
    May 2013
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QDialog::exec() Segmentation fault

    Hi all,
    I'm new, so please feel free to question me on the obvious stuff, and to recommend any relevant reading. Also, I'll do my best to supply any additional information that might help you help me. Please ask!

    I'm seeing a segmentation fault with the following backtrace:

    Qt Code:
    1. Program received signal SIGSEGV, Segmentation fault.
    2. 0x06fcc04f in QWidget::testAttribute_helper(Qt::WidgetAttribute) const ()
    3. from /usr/lib/qt4/lib/libQtGui.so.4
    4. (gdb) backtrace
    5. #0 0x06fcc04f in QWidget::testAttribute_helper(Qt::WidgetAttribute) const ()
    6. from /usr/lib/qt4/lib/libQtGui.so.4
    7. #1 0x06fd433f in QWidget::setAttribute(Qt::WidgetAttribute, bool) () from /usr/lib/qt4/lib/libQtGui.so.4
    8. #2 0x07301008 in QDialog::exec() () from /usr/lib/qt4/lib/libQtGui.so.4
    To copy to clipboard, switch view to plain text mode 

    Here's the code in question:
    Qt Code:
    1. QProgressDialog* m_pProgressDialog;
    2.  
    3. // Create the progress dialog.
    4. m_pProgressDialog = new QProgressDialog( "Operation in Progress", "&Cancel", 0, 100 );
    5. m_pProgressDialog->setWindowTitle( "Operation in Progress" );
    6. m_pProgressDialog->setFixedSize( 300, 100 );
    7. m_pProgressDialog->setModal( true );
    8.  
    9. // Connect to the cancel button.
    10. connect( m_pProgressDialog, SIGNAL( canceled() ), SLOT( CancelOperation() ) );
    11.  
    12. // Show the dialog and continue
    13. m_pProgressDialog->exec();
    To copy to clipboard, switch view to plain text mode 

    I've been Googling, reading your forums, debugging, and scratching my head for hours, and I can't figure out what to look for next. If you have any suggestions, I'd really appreciate it.
    Thanks!

    Qt4, Linux, g++
    Last edited by csavarese; 20th May 2013 at 22:59.

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

    Default Re: QDialog::exec() Segmentation fault

    Is this your actual code?
    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
    May 2013
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDialog::exec() Segmentation fault

    I inherited it from a previous designer, and the pointer declaration is actually in a different file, but otherwise, yes. It's a snippet of the actual code I'm compiling and running.
    Did I already miss something obvious?

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

    Default Re: QDialog::exec() Segmentation fault

    Show us your actual code. Make sure you call exec on the same variable as the one you initialize in line #4 of what you posted. Note that I mean the same variable, not variable with the same name.
    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
    May 2013
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDialog::exec() Segmentation fault

    Hi wysota,
    I was in the process of sorting through code to honor your request as best I could. I'm not at liberty to show it all unfortunately. Doing so helped me find the problem! I'm back to say thank you, and to share what I found in case someone else Googles their way here.

    There's a warning in the Qt docs to never delete an object in a thread other than the one that created it. Oops. This code juggles a few threads, and sure enough I was guilty of this. I changed "delete obj" to "obj->deleteLater()", and the crashes went away.

    Thanks again!

  6. The following user says thank you to csavarese for this useful post:


Similar Threads

  1. QDialog::exec() problem
    By zgulser in forum Newbie
    Replies: 1
    Last Post: 27th March 2012, 18:18
  2. QTcpsocket and QDialog::exec()
    By timewolf in forum Qt Programming
    Replies: 2
    Last Post: 25th August 2011, 08:27
  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. QDialog problem with exec()
    By nomadscarecrow in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2010, 18:40

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.