Hi There, I have got an application that always crashes when having moved a dockwidget outside the mainwindow. When I leave the dockwidget at its iriginal Place on the left docking area the application will close fine.
App ist build up with this code (Control will instantiate and destroy mainwindow):
int main(int argc, char *argv[])
{
// app will destroy Control
// because it becomes Control's
// parent object via constructur
Control::getSingleton(&app);
int ret = app.exec();
return ret;
} // app Object will be destroyed (and its children)
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// app will destroy Control
// because it becomes Control's
// parent object via constructur
Control::getSingleton(&app);
int ret = app.exec();
return ret;
} // app Object will be destroyed (and its children)
To copy to clipboard, switch view to plain text mode
IMHO the ~Control() Destructor will be called by the Application at last, so when finishing the application there will be (the destr. ist definitively called):
/* singleton-private Constructor */
Control
::Control(QObject *parent
) :{
...
if(!mainWindow)
mainWindow = new MainWindow();
...
}
Control::~Control()
{
...
if(mainWindow) {
delete mainWindow; // will delete the ui including dockwidgets
mainWindow = NULL;
}
}
/* singleton-private Constructor */
Control::Control(QObject *parent) :
QObject(parent),
{
...
if(!mainWindow)
mainWindow = new MainWindow();
...
}
Control::~Control()
{
...
if(mainWindow) {
delete mainWindow; // will delete the ui including dockwidgets
mainWindow = NULL;
}
}
To copy to clipboard, switch view to plain text mode
The Problem now is that when I have App destroying the mainwindow there comes a segmentation fault along - ending always in qwidget.cpp...
....
else if (!internalWinId() && isVisible()) {
qApp->d_func()->sendSyntheticEnterLeave(this);
....
....
else if (!internalWinId() && isVisible()) {
qApp->d_func()->sendSyntheticEnterLeave(this);
....
To copy to clipboard, switch view to plain text mode
...where the d_func() with its scoped pointer will fail.
But: This only happens, when I have moved the DockWidet "Floating" away from its orignial Place in the main window. If I leave it there, everthing is ok.
As someone may see the stacktrace shows that the Dockwidget will make use of the qapplication d_func(). Am I wrong, or why do at least two parents try to delete the Widget (Mainwindow and App) ?
0 QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::data qscopedpointer.h 135 0x00ff01e6
1 qGetPtrHelper<QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> > > qglobal.h 2314 0x008a63ff
3 ~
QWidget qwidget.
cpp 1438 0x008ec5f8
5 QObjectPrivate::deleteChildren qobject.cpp 1978 0x6a20f1b0
6 ~
QWidget qwidget.
cpp 1476 0x008ec6dc
8 ~MainWindow mainwindow.cpp 50 0x004018c0
9 ~Control control.cpp 83 0x00408feb
10 QObjectPrivate::deleteChildren qobject.cpp 1978 0x6a20f1b0
11 ~
QObject qobject.
cpp 975 0x6a20d0f9
14 qMain main.cpp 14 0x00401400
15 WinMain@16 qtmain_win.cpp 131 0x0040e612
16 main 0 0x0040e338
0 QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::data qscopedpointer.h 135 0x00ff01e6
1 qGetPtrHelper<QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> > > qglobal.h 2314 0x008a63ff
2 QApplication::d_func qapplication.h 376 0x00eef9c4
3 ~QWidget qwidget.cpp 1438 0x008ec5f8
4 ~QDockWidget qdockwidget.cpp 1181 0x00c51fce
5 QObjectPrivate::deleteChildren qobject.cpp 1978 0x6a20f1b0
6 ~QWidget qwidget.cpp 1476 0x008ec6dc
7 ~QMainWindow qmainwindow.cpp 329 0x00c82888
8 ~MainWindow mainwindow.cpp 50 0x004018c0
9 ~Control control.cpp 83 0x00408feb
10 QObjectPrivate::deleteChildren qobject.cpp 1978 0x6a20f1b0
11 ~QObject qobject.cpp 975 0x6a20d0f9
12 ~QCoreApplication qcoreapplication.cpp 642 0x6a1fd127
13 ~QApplication qapplication.cpp 1118 0x008aa05e
14 qMain main.cpp 14 0x00401400
15 WinMain@16 qtmain_win.cpp 131 0x0040e612
16 main 0 0x0040e338
To copy to clipboard, switch view to plain text mode
Any Comments ?
Bookmarks