Commit bc353921 authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Core: Handle an invalid theme id from the settings



Don't crash if the settings contain an outdated/invalid "CreatorTheme"
entry.

This change makes ThemeEntry::themeSetting() validate the entry. If no
theme with that id exists, it returs the default/first theme instead.

Task-number: QTCREATORBUG-17517
Change-Id: I87658fade33ba4d956d3a4c5591dd86db4051426
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 4fcbf91d
......@@ -221,8 +221,16 @@ QList<ThemeEntry> ThemeEntry::availableThemes()
Id ThemeEntry::themeSetting()
{
return Id::fromSetting(ICore::settings()->value(QLatin1String(Constants::SETTINGS_THEME),
QLatin1String(Constants::DEFAULT_THEME)));
const Id setting =
Id::fromSetting(ICore::settings()->value(QLatin1String(Constants::SETTINGS_THEME),
QLatin1String(Constants::DEFAULT_THEME)));
const QList<ThemeEntry> themes = availableThemes();
if (themes.empty())
return Id();
const bool settingValid = Utils::contains(themes, Utils::equal(&ThemeEntry::id, setting));
return settingValid ? setting : themes.first().id();
}
Theme *ThemeEntry::createTheme(Id id)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment