Mercurial > hg > svcore
diff base/ResourceFinder.cpp @ 1527:710e6250a401 zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 17 Sep 2018 13:51:14 +0100 |
parents | 5ac102155409 |
children | 57833933cc75 |
line wrap: on
line diff
--- a/base/ResourceFinder.cpp Mon Dec 12 15:18:52 2016 +0000 +++ b/base/ResourceFinder.cpp Mon Sep 17 13:51:14 2018 +0100 @@ -35,6 +35,8 @@ #include <iostream> #include <stdexcept> +#include "system/System.h" + /** Resource files may be found in three places: @@ -67,10 +69,11 @@ QStringList list; #ifdef Q_OS_WIN32 - char *programFiles = getenv("ProgramFiles"); - if (programFiles && programFiles[0]) { + std::string programFiles; + (void)getEnvUtf8("ProgramFiles", programFiles); + if (programFiles != "") { list << QString("%1/%2/%3") - .arg(programFiles) + .arg(QString::fromStdString(programFiles)) .arg(qApp->organizationName()) .arg(qApp->applicationName()); } else { @@ -133,14 +136,22 @@ } #if QT_VERSION >= 0x050000 + // This is expected to be much more reliable than // getOldStyleUserResourcePrefix(), but it returns a different // directory because it includes the organisation name (which is // fair enough). Hence migrateOldStyleResources() which moves // across any resources found in the old-style path the first time // we look for the new-style one +#if QT_VERSION >= 0x050400 return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); #else + cerr << "WARNING: ResourceFinder::getOldStyleUserResourcePrefix: Building with older version of Qt (pre 5.4), resource location may be incompatible with future versions" << endl; + return QStandardPaths::writableLocation(QStandardPaths::DataLocation); +#endif + +#else + cerr << "WARNING: ResourceFinder::getOldStyleUserResourcePrefix: Building with very old version of Qt (pre 5.0?), resource location may be incompatible with future versions" << endl; return getOldStyleUserResourcePrefix(); #endif } @@ -239,12 +250,12 @@ QString prefix = *i; - SVDEBUG << "ResourceFinder::getResourcePath: Looking up file \"" << fileName << "\" for category \"" << resourceCat << "\" in prefix \"" << prefix << "\"" << endl; +// cerr << "ResourceFinder::getResourcePath: Looking up file \"" << fileName << "\" for category \"" << resourceCat << "\" in prefix \"" << prefix << "\"" << endl; QString path = QString("%1%2/%3").arg(prefix).arg(resourceCat).arg(fileName); if (QFileInfo(path).exists() && QFileInfo(path).isReadable()) { - cerr << "Found it!" << endl; +// cerr << "Found it!" << endl; return path; } }