Skip to content
Browse files

Fix crash with script engine debugger in use

If parent is set on our custom QStyle instance, gammaray's QMainWindow
destructor is going to delete the style right away -
qscriptenginedebugger still seems to hold an internal reference to it
and crashes accessing it on destruction.

Backtrace (trimmed):
Thread 1 (Thread 0x7fd1ec642780 (LWP 15343)):
[KCrash Handler]
4  0x00000000000000e0 in ?? ()
5  0x00007fd1eafb53b5 in QStyleSheetStyle::pixelMetric (this=0x2d00a70,
m=QStyle::PM_DockWidgetTitleBarButtonMargin, opt=0x0, w=0x2d90ee0) at
styles/qstylesheetstyle.cpp:4790
6  0x00007fd1eb06943f in QDockWidgetTitleButton::sizeHint
(this=0x2d90ee0) at widgets/qdockwidget.cpp:138
7  0x00007fd1eb06acf6 in QDockWidgetLayout::minimumTitleWidth
(this=0x2d77b80) at widgets/qdockwidget.cpp:416
8  0x00007fd1eb06adf0 in QDockWidgetLayout::sizeFromContent
(this=0x2d77b80, content=..., floating=false) at
widgets/qdockwidget.cpp:274
9  0x00007fd1eb06b1af in QDockWidgetItem::maximumSize (this=0x3202c40)
at widgets/qdockwidget.cpp:558
10 0x00007fd1eb06eba8 in QDockAreaLayoutItem::maximumSize
(this=0x3215620) at widgets/qdockarealayout.cpp:154
11 0x00007fd1eb06ee5f in QDockAreaLayoutInfo::saveState
(this=0x30a2338, stream=...) at widgets/qdockarealayout.cpp:1828
12 0x00007fd1eb06f9b1 in QDockAreaLayout::saveState (this=0x30a22f8,
stream=...) at widgets/qdockarealayout.cpp:2306
13 0x00007fd1eb0989d0 in QMainWindowLayoutState::saveState
(this=0x30a2220, stream=...) at widgets/qmainwindowlayout.cpp:598
14 0x00007fd1eb096cb7 in QMainWindow::saveState (this=0x3081810,
version=0) at widgets/qmainwindow.cpp:1237
15 0x00007fd1c5046ea5 in
QScriptEngineDebuggerPrivate::~QScriptEngineDebuggerPrivate
(this=0x2ddf810, __in_chrg=<optimized out>) at
debugging/qscriptenginedebugger.cpp:314
16 0x00007fd1c50470b9 in
QScriptEngineDebuggerPrivate::~QScriptEngineDebuggerPrivate
(this=0x2ddf810, __in_chrg=<optimized out>) at
debugging/qscriptenginedebugger.cpp:320
17 0x00007fd1eb903bd0 in cleanup (pointer=<optimized out>) at
../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:62
18 ~QScopedPointer (this=0x2ddf8e8, __in_chrg=<optimized out>) at
../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:100
19 QObject::~QObject (this=0x2ddf8e0, __in_chrg=<optimized out>) at
kernel/qobject.cpp:817
20 0x00007fd1c5046bb9 in QScriptEngineDebugger::~QScriptEngineDebugger
(this=0x2ddf8e0, __in_chrg=<optimized out>) at
debugging/qscriptenginedebugger.cpp:366
21 0x00007fd1eb8fd935 in QObjectPrivate::deleteChildren
(this=0x3092650) at kernel/qobject.cpp:1908
22 0x00007fd1eacb8740 in QWidget::~QWidget (this=0x2924f70,
_in_chrg=<optimized out>) at kernel/qwidget.cpp:1676
23 0x00007fd1c52c849d in
GammaRay::ScriptEngineDebugger::~ScriptEngineDebugger (this=0x2924f70,
__in_chrg=<optimized out>) at
/home/krf/devel/src/kdab/GammaRay/tools/scriptenginedebugger/scriptenginedebugger.cpp:65
24 0x00007fd1c52c850c in
GammaRay::ScriptEngineDebugger::~ScriptEngineDebugger (this=0x2924f70,
__in_chrg=<optimized out>) at
/home/krf/devel/src/kdab/GammaRay/tools/scriptenginedebugger/scriptenginedebugger.cpp:68
25 0x00007fd1eb8fd935 in QObjectPrivate::deleteChildren
(this=0x2d36a60) at kernel/qobject.cpp:1908
26 0x00007fd1eacb8740 in QWidget::~QWidget (this=0x2d36a30,
__in_chrg=<optimized out>) at kernel/qwidget.cpp:1676
27 0x00007fd1eb0d94b9 in QStackedWidget::~QStackedWidget
(this=0x2d36a30, __in_chrg=<optimized out>) at
widgets/qstackedwidget.cpp:193
28 0x00007fd1eb8fd935 in QObjectPrivate::deleteChildren
(this=0x2d00ac0) at kernel/qobject.cpp:1908
29 0x00007fd1eacb8740 in QWidget::~QWidget (this=0x25dcfc0,
__in_chrg=<optimized out>) at kernel/qwidget.cpp:1676
30 0x00007fd1eacb8a19 in QWidget::~QWidget (this=0x25dcfc0,
__in_chrg=<optimized out>) at kernel/qwidget.cpp:1700
31 0x00007fd1eb8fd935 in QObjectPrivate::deleteChildren
(this=0x2cf2b10) at kernel/qobject.cpp:1908
32 0x00007fd1eacb8740 in QWidget::~QWidget (this=0x2bb8ff0,
__in_chrg=<optimized out>) at kernel/qwidget.cpp:1676
33 0x00007fd1ec3160f8 in GammaRay::MainWindow::~MainWindow
(this=0x2bb8ff0, __in_chrg=<optimized out>) at
/home/krf/devel/src/kdab/GammaRay/core/mainwindow.h:34
34 0x00007fd1ec316130 in GammaRay::MainWindow::~MainWindow
(this=0x2bb8ff0, __in_chrg=<optimized out>) at
/home/krf/devel/src/kdab/GammaRay/core/mainwindow.h:34
  • Loading branch information...
1 parent 88b9790 commit e3cc00d339d9d9ec4a10da7b06dc0c4696d9ff0d @krf krf committed Apr 8, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 core/mainwindow.cpp
View
4 core/mainwindow.cpp
@@ -58,7 +58,9 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent)
setStyleSheet(QLatin1String("I_DONT_EXIST {}"));
QGuiPlatformPlugin defaultGuiPlatform;
if (QStyle *defaultStyle = QStyleFactory::create(defaultGuiPlatform.styleName())) {
- defaultStyle->setParent(this);
+ // do not set parent of default style
+ // this will cause the style being deleted too early through ~QObject()
+ // other objects (e.g. the script engine debugger) still might have a reference on the style during destruction
setStyle(defaultStyle);
}

0 comments on commit e3cc00d

Please sign in to comment.
Something went wrong with that request. Please try again.