diff options
author | Jonathan White <support@dmapps.us> | 2020-06-04 15:16:47 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2020-06-04 17:03:40 +0300 |
commit | 6f5e13815c656486b8bd1fb0a0c2b3bcfb06dfd9 (patch) | |
tree | cb317956246eb502a7f56e7a5b39d3470939c3b7 /src/core/Resources.cpp | |
parent | c830f85c09573a70a39e401e0c6184312e11efea (diff) |
Fix resolving resources when running from build directory
* Copy wordlists to build dir share folder
* Change resource path resolution to only test the provided directory, not finding a specific file
Diffstat (limited to 'src/core/Resources.cpp')
-rw-r--r-- | src/core/Resources.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core/Resources.cpp b/src/core/Resources.cpp index 799475bb1..ad1ff5fa0 100644 --- a/src/core/Resources.cpp +++ b/src/core/Resources.cpp @@ -224,19 +224,18 @@ Resources::Resources() { const QString appDirPath = QCoreApplication::applicationDirPath(); #if defined(Q_OS_UNIX) && !(defined(Q_OS_MACOS) && defined(WITH_APP_BUNDLE)) - testResourceDir(KEEPASSX_DATA_DIR) || testResourceDir(QStringLiteral("%1/../%2").arg(appDirPath, KEEPASSX_DATA_DIR)) - || testResourceDir(QStringLiteral("%1/%2").arg(KEEPASSX_PREFIX_DIR, KEEPASSX_DATA_DIR)); + trySetResourceDir(KEEPASSX_DATA_DIR) || trySetResourceDir(QString("%1/../%2").arg(appDirPath, KEEPASSX_DATA_DIR)) + || trySetResourceDir(QString("%1/%2").arg(KEEPASSX_PREFIX_DIR, KEEPASSX_DATA_DIR)); #elif defined(Q_OS_MACOS) && defined(WITH_APP_BUNDLE) - testResourceDir(appDirPath + QStringLiteral("/../Resources")); + trySetResourceDir(appDirPath + QStringLiteral("/../Resources")); #elif defined(Q_OS_WIN) - testResourceDir(appDirPath + QStringLiteral("/share")); + trySetResourceDir(appDirPath + QStringLiteral("/share")); #endif if (m_dataPath.isEmpty()) { // Last ditch check if we are running from inside the src or test build directory - testResourceDir(appDirPath + QStringLiteral("/../../share")) - || testResourceDir(appDirPath + QStringLiteral("/../share")) - || testResourceDir(appDirPath + QStringLiteral("/../../../share")); + trySetResourceDir(appDirPath + QStringLiteral("/../share")) + || trySetResourceDir(appDirPath + QStringLiteral("/../../share")); } if (m_dataPath.isEmpty()) { @@ -244,10 +243,11 @@ Resources::Resources() } } -bool Resources::testResourceDir(const QString& dir) +bool Resources::trySetResourceDir(const QString& path) { - if (QFile::exists(dir + QStringLiteral("/icons/application/256x256/apps/keepassxc.png"))) { - m_dataPath = QDir::cleanPath(dir); + QDir dir(path); + if (dir.exists()) { + m_dataPath = dir.canonicalPath(); return true; } return false; |