r24215 by jghali - Fix potential crash on startup if UI theme specified in preferences is not available or cannot be created

scribus-commit scribus-commit at lists.scribus.net
Mon Nov 9 12:59:31 UTC 2020


Author: jghali
Date: Mon Nov  9 12:59:31 2020
New Revision: 24215

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24215
Log:
Fix potential crash on startup if UI theme specified in preferences is not available or cannot be created

Modified:
    trunk/Scribus/scribus/prefsmanager.cpp

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24215&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp	(original)
+++ trunk/Scribus/scribus/prefsmanager.cpp	Mon Nov  9 12:59:31 2020
@@ -2751,10 +2751,14 @@
 	appPrefs.ui_SystemTheme = qApp->style()->objectName();
 	if (appPrefs.uiPrefs.style.length() > 0)
 	{
-		qApp->setStyle(QStyleFactory::create(appPrefs.uiPrefs.style));
-		// Plain wrong, a style may set a palette different from the standard palette
-		// Eg : Windows XP and Windows Vista styles
-		// qApp->setPalette(qApp->style()->standardPalette());
+		QStyle* qtStyle = nullptr;
+		QStringList availableStyles = QStyleFactory::keys();
+		if (availableStyles.contains(appPrefs.uiPrefs.style))
+			qtStyle = QStyleFactory::create(appPrefs.uiPrefs.style);
+		if (qtStyle)
+			qApp->setStyle(qtStyle);
+		else
+			appPrefs.uiPrefs.style.clear();
 	}
 	QFont apf = qApp->font();
 	apf.setPointSize(appPrefs.uiPrefs.applicationFontSize);




More information about the scribus-commit mailing list