summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindow.cpp
diff options
context:
space:
mode:
authorAndré Somers <andre.somers@kdab.com>2016-10-25 16:27:58 +0200
committerAndre Somers <andre.somers@kdab.com>2016-10-28 14:11:42 +0000
commit4c00246fea63c348a2992f5a54499f2928bf0605 (patch)
treea3b32ae5304f2034ecd487f33d2ba897f43442a3 /src/widgets/widgets/qmainwindow.cpp
parentdbf35d75714fac1e836e697650e32365a2a3493e (diff)
Fixed crash taking null central widget
When no central widget has been set, calling takeCentralWidget should just return a null pointer instead of crashing. [ChangeLog][QtWidgets][QMainWindow] Fixed crash using takeCentralWidget when the central widget was not set. Task-number: QTBUG-56628 Change-Id: I240ccf4caa41d2716a78851571fbfbf444a4922e Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets/widgets/qmainwindow.cpp')
-rw-r--r--src/widgets/widgets/qmainwindow.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 50ba7f97ec..e454e3e991 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -664,8 +664,10 @@ QWidget *QMainWindow::takeCentralWidget()
{
Q_D(QMainWindow);
QWidget *oldcentralwidget = d->layout->centralWidget();
- oldcentralwidget->setParent(0);
- d->layout->setCentralWidget(0);
+ if (oldcentralwidget) {
+ oldcentralwidget->setParent(0);
+ d->layout->setCentralWidget(0);
+ }
return oldcentralwidget;
}