[Qt-interest] Linux core dump with Qt::WA_DeleteOnClose in QMainWindow class

Tim Dewhirst tim at bugless.co.uk
Tue May 5 16:47:32 CEST 2009


Hi,

Stephen Collyer wrote:
> I have the following class derived from QMainWindow:
> 
> class MDPMainWindow : public QMainWindow
> {
>     Q_OBJECT
> 
>     public:
>         MDPMainWindow(QWidget* parent = 0);
>         ~MDPMainWindow();
> 
>     private:
>         void createActions();
>         void createMenus();
> 
>         QMenu*   fileMenu_;
>         QAction* exitAction_;
> };
> 
> with implementation:
> 
> MDPMainWindow::MDPMainWindow(QWidget* parent)
> {
>     createActions();
>     createMenus();
> 
> //    setAttribute(Qt::WA_DeleteOnClose);
> }
> 
> MDPMainWindow::~MDPMainWindow()
> {
> }
> 
> void MDPMainWindow::createActions()
> {
>     exitAction_ = new QAction(tr("E&xit"), this);
>     connect(exitAction_, SIGNAL( triggered() ),
>             this,        SLOT( close() ));
> }
> 
> void MDPMainWindow::createMenus()
> {
>     fileMenu_ = menuBar()->addMenu(tr("E&xit"));
>     fileMenu_->addAction(exitAction_);
> }
> 
> If I set the Qt::WA_DeleteOnClose attribute, then the application dumps 
> core with the following stacktrace:

How is the instance of MDPMainWindow allocated?

Tim



More information about the Qt-interest-old mailing list