diff options
author | Fabien Freling <fabien.freling@nokia.com> | 2011-04-12 14:23:57 (GMT) |
---|---|---|
committer | Fabien Freling <fabien.freling@nokia.com> | 2011-04-12 14:23:57 (GMT) |
commit | abc5a632942c23496d75c49b3b0b4a674cdafdf8 (patch) | |
tree | 55246c581af5dbe5b9eae1ae8bffdc75b17a0266 | |
parent | a5d40fd3814ab7c8e865912c03a918bfd5994998 (diff) | |
download | Qt-abc5a632942c23496d75c49b3b0b4a674cdafdf8.zip Qt-abc5a632942c23496d75c49b3b0b4a674cdafdf8.tar.gz Qt-abc5a632942c23496d75c49b3b0b4a674cdafdf8.tar.bz2 |
Fix a race condition when the main window is being destructed.
During the destructor of QWidget, we delete the
layout. If the layout is not set to 0 afterwards,
a check on the layout might turn true, but any access
will end with a segfault.
Reviewed-by: João Abecasis
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 1 | ||||
-rw-r--r-- | src/gui/painting/qunifiedtoolbarsurface_mac.cpp | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5705214..758ccce 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1588,6 +1588,7 @@ QWidget::~QWidget() // delete layout while we still are a valid widget delete d->layout; + d->layout = 0; // Remove myself from focus list Q_ASSERT(d->focus_next->d_func()->focus_prev == this); diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp index 3876c3d..2fda6b9 100644 --- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp +++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp @@ -152,7 +152,8 @@ void QUnifiedToolbarSurface::beginPaint(const QRegion &rgn) void QUnifiedToolbarSurface::updateToolbarOffset(QWidget *widget) { QMainWindowLayout *mlayout = qobject_cast<QMainWindowLayout*> (widget->window()->layout()); - mlayout->updateUnifiedToolbarOffset(); + if (mlayout) + mlayout->updateUnifiedToolbarOffset(); } void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) |