From 02a962207bca0c9719a5e28d10881ecb16a9ca9e Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 12 Mar 2012 10:11:27 +0100 Subject: [PATCH] Fix possible crash when cleaning up MDI views --- src/Gui/MDIView.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp index 6aef8cd64e..3b7c07b602 100644 --- a/src/Gui/MDIView.cpp +++ b/src/Gui/MDIView.cpp @@ -56,15 +56,17 @@ MDIView::~MDIView() //the application crashes when accessing this deleted view. //This effect only occurs if this widget is not in Child mode, because otherwise //the focus stuff is done correctly. - QWidget* foc = getMainWindow()->focusWidget(); - if (foc) { - QWidget* par = foc; - while (par) { - if (par == this) { - getMainWindow()->setFocus(); - break; + if (getMainWindow()) { + QWidget* foc = getMainWindow()->focusWidget(); + if (foc) { + QWidget* par = foc; + while (par) { + if (par == this) { + getMainWindow()->setFocus(); + break; + } + par = par->parentWidget(); } - par = par->parentWidget(); } } }