Windows: Resolve QStandardPaths config location without qApp instance
Calling QCoreApplication::applicationDirPath() requires an app instance, but on Windows the implementation just relies on qAppFileName(), which does not require any instance. As resolving the standard paths could be needed before QCoreApplication instantiation, e.g. for categorized logging, we use qAppFileName() directly. Change-Id: Id882cebd528bcb8e945e73a83f1dc3d599b74d1d Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>bb10
parent
fb2e795c6e
commit
eade2255ea
|
|
@ -201,6 +201,10 @@ QString QStandardPaths::writableLocation(StandardLocation type)
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
extern QString qAppFileName();
|
||||
#endif
|
||||
|
||||
QStringList QStandardPaths::standardLocations(StandardLocation type)
|
||||
{
|
||||
QStringList dirs;
|
||||
|
|
@ -217,8 +221,13 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
|
|||
dirs.append(programData);
|
||||
}
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
dirs.append(QCoreApplication::applicationDirPath());
|
||||
dirs.append(QCoreApplication::applicationDirPath() + QLatin1String("/data"));
|
||||
// Note: QCoreApplication::applicationDirPath(), while static, requires
|
||||
// an application instance. But we might need to resolve the standard
|
||||
// locations earlier than that, so we fall back to qAppFileName().
|
||||
QString applicationDirPath = qApp ? QCoreApplication::applicationDirPath()
|
||||
: QFileInfo(qAppFileName()).path();
|
||||
dirs.append(applicationDirPath);
|
||||
dirs.append(applicationDirPath + QLatin1String("/data"));
|
||||
#endif // !QT_BOOTSTRAPPED
|
||||
} // isConfigLocation()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue