Commit 62bffaca authored by Sergey Belyashov's avatar Sergey Belyashov

Fix theme loading problem

Error caused by any file named as current theme and placed to directory
which is used for starting Qt Creator (formely user home directory).
For example, create empty file with name 'default', place it to your
home directory (for example: /home/user) and run Qt Creator. As result
you will see black corrupted screen.

To fix this bug I add checks of theme name. Now Qt Creator will only
load theme from current directory if name is explicitly provided by
the user or it is an absolute path.

Change-Id: I0255c8d220d84bd5b51de7ef9d64c66f7f57959c
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarSergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 28971701
......@@ -91,21 +91,22 @@ CorePlugin::~CorePlugin()
setCreatorTheme(0);
}
static QString absoluteThemePath(const QString &themeName)
static QString absoluteThemePath(const QString &themeName, bool userProvidedTheme)
{
if (themeName.isEmpty())
return themeName;
QString res = QDir::fromNativeSeparators(themeName);
QFileInfo fi(res);
bool tryRawName = userProvidedTheme || fi.isAbsolute();
// Try the given name
if (fi.exists())
if (tryRawName && fi.exists())
return fi.absoluteFilePath();
const QString suffix = QLatin1String("creatortheme");
// Try name.creatortheme
if (fi.suffix() != suffix) {
res = themeName + QLatin1Char('.') + suffix;
fi.setFile(res);
if (fi.exists())
if (tryRawName && fi.exists())
return fi.absoluteFilePath();
}
if (fi.path().isEmpty())
......@@ -122,6 +123,7 @@ void CorePlugin::parseArguments(const QStringList &arguments)
QLatin1String(Constants::SETTINGS_THEME), defaultTheme).toString();
QColor overrideColor;
bool presentationMode = false;
bool userProvidedTheme = false;
for (int i = 0; i < arguments.size(); ++i) {
if (arguments.at(i) == QLatin1String("-color")) {
......@@ -133,11 +135,12 @@ void CorePlugin::parseArguments(const QStringList &arguments)
presentationMode = true;
if (arguments.at(i) == QLatin1String("-theme")) {
themeName = arguments.at(i + 1);
userProvidedTheme = true;
i++;
}
}
QString themeURI = absoluteThemePath(themeName);
QString themeURI = absoluteThemePath(themeName, userProvidedTheme);
if (themeURI.isEmpty()) {
themeName = defaultTheme;
themeURI = QStringLiteral("%1/themes/%2.creatortheme").arg(ICore::resourcePath()).arg(themeName);
......
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