[Qt-interest] Linux core dump with Qt::WA_DeleteOnClose inQMainWindow class
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Tue May 5 16:41:11 CEST 2009
You probably have a pointer to the main window somewhere that is not a QPointer and is now pointing to a deleted memory location.
Scott
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Stephen Collyer
Sent: Tuesday, May 05, 2009 7:36 AM
To: qtInterest
Subject: [Qt-interest] Linux core dump with Qt::WA_DeleteOnClose inQMainWindow class
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:
*** glibc detected *** /opt/MDP_MAIN_1.0.0/bin/mdp_main: free(): invalid pointer: 0xbffdaea4 ***
======= Backtrace: =========
/lib/libc.so.6[0xb6f4a654]
/lib/libc.so.6(cfree+0x9c)[0xb6f4bf3c]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb712cec1]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4(_Z21qDeleteInEventHandlerP7QObject+0x15)[0xb73cdb55]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4(_ZN7QObject5eventEP6QEvent+0x2eb)[0xb73cf3cb]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtGui.so.4(_ZN7QWidget5eventEP6QEvent+0x50)[0xb7871540]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtGui.so.4(_ZN11QMainWindow5eventEP6QEvent+0x77)[0xb7c611c7]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtGui.so.4(_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent+0xbc)[0xb781b0cc]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtGui.so.4(_ZN12QApplication6notifyEP7QObjectP6QEvent+0x1a2)[0xb7823472]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4(_ZN16QCoreApplication14notifyInternalEP7QObjectP6QEvent+0x7b)[0xb73bebcb]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4(_ZN23QCoreApplicationPrivate16sendPostedEventsEP7QObjectiP11QThreadData+0x2a5)[0xb73bf815]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4(_ZN16QCoreApplication16sendPostedEventsEP7QObjecti+0x2d)[0xb73bfa0d]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4[0xb73ea7ff]
/usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1e8)[0xb71e29a8]
/usr/lib/libglib-2.0.so.0[0xb71e6063]
/usr/lib/libglib-2.0.so.0(g_main_context_iteration+0x71)[0xb71e6221]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x58)[0xb73ea448]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtGui.so.4[0xb78b9d65]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4(_ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE+0x4a)[0xb73bd1ea]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4(_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE+0xea)[0xb73bd62a]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtCore.so.4(_ZN16QCoreApplication4execEv+0xb9)[0xb73bfad9]
/usr/local/Trolltech/Qt-4.5.0/lib/libQtGui.so.4(_ZN12QApplication4execEv+0x27)[0xb781af47]
/opt/MDP_MAIN_1.0.0/bin/mdp_main(main+0x63)[0x804a653]
/lib/libc.so.6(__libc_start_main+0xe5)[0xb6ef4705]
/opt/MDP_MAIN_1.0.0/bin/mdp_main[0x804a551]
Is this expected behaviour, or am I doing something wrong ?
--
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090505/a49f6616/attachment.html
More information about the Qt-interest-old
mailing list