Skip to content

Commit

Permalink
Avoid "Failed to load file "/style.qss"" startup error
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 21, 2017
1 parent 56fd6e0 commit 374b756
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/qgsapplication.cpp
Expand Up @@ -533,11 +533,14 @@ void QgsApplication::setUITheme( const QString &themeName )
{
// Loop all style sheets, find matching name, load it.
QHash<QString, QString> themes = QgsApplication::uiThemes();
QString themename = themeName;
if ( !themes.contains( themename ) )
themename = QStringLiteral( "default" );
if ( themeName == QStringLiteral( "default" ) || !themes.contains( themeName ) )
{
setThemeName( QStringLiteral( "default" ) );
qApp->setStyleSheet( QString() );
return;
}

QString path = themes[themename];
QString path = themes.value( themeName );
QString stylesheetname = path + "/style.qss";
QString autostylesheet = stylesheetname + ".auto";

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

QHash<QString, QString> variables;
QString styledata = file.readAll();
QTextStream in( &variablesfile );
while ( !in.atEnd() )
Expand All @@ -580,7 +582,7 @@ void QgsApplication::setUITheme( const QString &themeName )
QString styleSheet = QStringLiteral( "file:///" );
styleSheet.append( stylesheetname );
qApp->setStyleSheet( styleSheet );
setThemeName( themename );
setThemeName( themeName );
}

QHash<QString, QString> QgsApplication::uiThemes()
Expand Down

0 comments on commit 374b756

Please sign in to comment.