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
(cherry picked from commit abc5a632942c23496d75c49b3b0b4a674cdafdf8)
This commit is contained in:
Fabien Freling 2011-04-12 16:23:57 +02:00
parent e7de0c2e12
commit e27baeff28
2 changed files with 3 additions and 1 deletions

View File

@ -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);

View File

@ -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 &region, const QPoint &offset)