From 32973995423007a59cd18799c63383150811d1a7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 17 Apr 2018 19:44:26 +0200 Subject: [PATCH] fix possible crash when saving preferences --- src/Gui/DlgGeneralImp.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index 0ec847af0d..4126a8046b 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -130,14 +130,16 @@ void DlgGeneralImp::saveSettings() PythonWordWrap->onSave(); QWidget* pc = DockWindowManager::instance()->getDockWindow("Python console"); - PythonConsole *pcPython = static_cast(pc); - bool pythonWordWrap = App::GetApplication().GetUserParameter(). - GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("General")->GetBool("PythonWordWrap", true); + PythonConsole *pcPython = qobject_cast(pc); + if (pcPython) { + bool pythonWordWrap = App::GetApplication().GetUserParameter(). + GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("General")->GetBool("PythonWordWrap", true); - if (pythonWordWrap) { - pcPython->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); - } else { - pcPython->setWordWrapMode(QTextOption::NoWrap); + if (pythonWordWrap) { + pcPython->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); + } else { + pcPython->setWordWrapMode(QTextOption::NoWrap); + } } // set new user defined style