Skip to content

Commit 374b756

Browse files
committedJan 21, 2017
Avoid "Failed to load file "/style.qss"" startup error
1 parent 56fd6e0 commit 374b756

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
 

‎src/core/qgsapplication.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,14 @@ void QgsApplication::setUITheme( const QString &themeName )
533533
{
534534
// Loop all style sheets, find matching name, load it.
535535
QHash<QString, QString> themes = QgsApplication::uiThemes();
536-
QString themename = themeName;
537-
if ( !themes.contains( themename ) )
538-
themename = QStringLiteral( "default" );
536+
if ( themeName == QStringLiteral( "default" ) || !themes.contains( themeName ) )
537+
{
538+
setThemeName( QStringLiteral( "default" ) );
539+
qApp->setStyleSheet( QString() );
540+
return;
541+
}
539542

540-
QString path = themes[themename];
543+
QString path = themes.value( themeName );
541544
QString stylesheetname = path + "/style.qss";
542545
QString autostylesheet = stylesheetname + ".auto";
543546

@@ -554,7 +557,6 @@ void QgsApplication::setUITheme( const QString &themeName )
554557
return;
555558
}
556559

557-
QHash<QString, QString> variables;
558560
QString styledata = file.readAll();
559561
QTextStream in( &variablesfile );
560562
while ( !in.atEnd() )
@@ -580,7 +582,7 @@ void QgsApplication::setUITheme( const QString &themeName )
580582
QString styleSheet = QStringLiteral( "file:///" );
581583
styleSheet.append( stylesheetname );
582584
qApp->setStyleSheet( styleSheet );
583-
setThemeName( themename );
585+
setThemeName( themeName );
584586
}
585587

586588
QHash<QString, QString> QgsApplication::uiThemes()

0 commit comments

Comments
 (0)
Please sign in to comment.