Results 1 to 10 of 10

Thread: Unexplained Segmentation Fault with QDialog::show() and QDialog::exec()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Unexplained Segmentation Fault with QDialog::show() and QDialog::exec()

    2) When a QObject are destroyed, it delete all children. You have not need to delete them explicitly
    Thanks for that, I wasn't aware of it!

    For the 1) I suggest you to define a difficulty() public methods that returns m_difficulty and call it after exec from calling code
    I would definitely do that, if exec() didn't cause a segmentation fault

    As some additional information, I tried to recreate the error with a very small program consisting of only a button with the same dialog window. In this case there was no seg fault and the window was displayed successfully. Could the complication of my program's main window (4 QDockWidgets and a QStatusBar) be causing the seg fault in my main program? Otherwise I used the same code and called it in the same way, so I'm getting more confused...

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 86 Times in 81 Posts

    Default Re: Unexplained Segmentation Fault with QDialog::show() and QDialog::exec()

    Probably there is something wrong in your code. Check where you explicitly delete Widget and verify if there are logical errors.
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Feb 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Unexplained Segmentation Fault with QDialog::show() and QDialog::exec()

    Here is the relevant part of my main window code... I'm registering a generateNew slot to receive signals triggered by a new action. Then elsewhere I'm pressing the new button (in a dock widget), causing me to enter my generateNew() slot, and then the seg fault is always occurring on the call to exec(). Could there be a problem with a button press in a dock widget triggering an action and causing a dialog window in the main widget?

    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QDesktopWidget>
    3. #include <QApplication>
    4. #include <QResizeEvent>
    5. #include "engine/engine.h"
    6. #include "storage/storage.h"
    7. #include "gui/actionmanager.h"
    8.  
    9. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
    10. {
    11. //Test something manually
    12. //test();
    13.  
    14. //Create actions
    15. createActions();
    16.  
    17. //Create window internals
    18. createMainSceneAndView();
    19.  
    20. //Create dock windows
    21. createDockWindows();
    22.  
    23. //Additional Settings for this Window
    24. configureWindow();
    25.  
    26. restoreSettings();
    27.  
    28. show();
    29. }
    30. void MainWindow::createActions(){
    31.  
    32. ActionManager::generateNewAction = new QAction(this);
    33. connect(ActionManager::generateNewAction, SIGNAL(triggered()), this, SLOT(generateNew()));
    34.  
    35. }
    36. void MainWindow::generateNew(){
    37. qDebug() << "MainWindow got generate new event.";
    38.  
    39. //Create a dialog window to get the requested difficulty
    40. this->generateNewDialog = new GenerateNewDialog(this);
    41. connect(this->generateNewDialog, SIGNAL(difficultySelected(int)), this, SLOT(generationDifficultySelected(int)));
    42.  
    43. this->generateNewDialog->exec();
    44. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Unexplained Segmentation Fault with QDialog::show() and QDialog::exec()

    I am having similar problems with a class that inherits from QDialog. In my program i have a QVector<dialog*> with pointers to a number of different instances of the QDialog-derived class. I have a QComboBox that I want to use to activate (show()) these dialogs.

    I have two items in the QComboBox and when I activate one dialog everything is fine. But opening the second one leads to a segmentation fault. Note that it does not matter which of the dialogs I open first. But the segmentation fault itself is not caused by me calling show()...

    #0 0x00000008 in ?? () at c:/Qt/2010.05/qt/include/QtGui/../../src/gui/kernel/qwidget.h:487
    #1 0x00bc0119 in QPainter (this=0x22d468, pd=0x9f504a0) at painting\qpainter.cpp:1489
    #2 0x00aed236 in QWidgetPrivate::drawWidget (this=0x9f51600, pdev=0x9fa27c8, rgn=..., offset=..., flags=5, sharedPainter=0x0, backingStore=0x9fa2780) at kernel\qwidget.cpp:5397
    #3 0x00c74b31 in QWidgetBackingStore::sync (this=0x9fa2780) at painting\qbackingstore.cpp:1328
    #4 0x00ae4f50 in QWidgetPrivate::syncBackingStore (this=0x9f51600) at kernel\qwidget.cpp:1805
    #5 0x00af4e75 in QWidget::event (this=0x9f50498, event=0x9f4d360) at kernel\qwidget.cpp:8480
    #6 0x00aa9706 in QApplicationPrivate::notify_helper (this=0x3e4c18, receiver=0x9f50498, e=0x9f4d360) at kernel\qapplication.cpp:4396
    #7 0x00aa9586 in QApplication::notify (this=0x22fe98, receiver=0x9f50498, e=0x9f4d360) at kernel\qapplication.cpp:4361
    #8 0x6a1ff9dc in QCoreApplication::notifyInternal (this=0x22fe98, receiver=0x9f50498, event=0x9f4d360) at kernel\qcoreapplication.cpp:732
    #9 0x6a265fbc in QCoreApplication::sendEvent (receiver=0x9f50498, event=0x9f4d360) at kernel//qcoreapplication.h:215
    #10 0x6a200a87 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x3e5798) at kernel\qcoreapplication.cpp:1373
    #11 0x6a222d2e in qt_internal_proc (hwnd=0x105026c, message=1025, wp=0, lp=0) at kernel\qeventdispatcher_win.cpp:503
    #12 0x7e418734 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
    #13 0x0105026c in QGraphicsScenePrivate::drawSubtreeRecursive (this=0x6a222a8a, item=0x105026c, painter=0x401, viewTransform=0x0, exposedRegion=0x0, widget=0x22fcdc, parentOpacity=1.6853403962263272e-307, effectTransform=0x14) at graphicsview\qgraphicsscene.cpp:4717
    #14 0x7e418816 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
    #15 0x6a222a8a in qt_fast_timer_proc (timerId=0, user=17105516) at kernel\qeventdispatcher_win.cpp:432
    #16 0x7e4189cd in USER32!GetWindowLongW () from C:\WINDOWS\system32\user32.dll
    #17 0x00000000 in ?? ()
    The QDialog-derived class is generated using Qt Creator and has not been changed by me.

Similar Threads

  1. QDialog.exec() exiting without calling QDialog::accept()
    By doggrant in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2011, 11:35
  2. QDialog problem with exec()
    By nomadscarecrow in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2010, 18:40
  3. exec() not blocking, derived QDialog, Qt 4.4.3
    By wdezell in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2009, 18:56
  4. problem with show/exec of Qdialog
    By dudedude in forum Qt Programming
    Replies: 1
    Last Post: 23rd December 2008, 11:20
  5. QDialog: show() and exec() together in constructor?
    By Teuniz in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2007, 11:43

Tags for this Thread

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.