From f5ec28285ab7f71d6d75af963ae499603da6630e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Thu, 16 Apr 2015 14:45:20 +0200 Subject: Add a fallback for QLibraryInfo::DataPath as well. This should remove the necessity to have a qt.conf file for deployed Windows applications. Also, be consistent about three dots in the messages that get printed when trying fallback directories. Task-number: QTBUG-45614 Change-Id: If46c93a0e8f150b91cff188517187a58edff9144 Reviewed-by: Allan Sandfeld Jensen --- src/core/web_engine_library_info.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 573e16319..17f6b2a05 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -188,7 +188,7 @@ QString pluginsPath() potentialPluginsPath = QCoreApplication::applicationDirPath() % QDir::separator() % QLatin1String("qtwebengine"); } if (!QFileInfo::exists(potentialPluginsPath)) { - qWarning("Qt WebEngine Plugins directory not found at location %s. Trying fallback directory. Plugins as for example video codecs MAY NOT work.", qPrintable(potentialPluginsPath)); + qWarning("Qt WebEngine Plugins directory not found at location %s. Trying fallback directory... Plugins as for example video codecs MAY NOT work.", qPrintable(potentialPluginsPath)); potentialPluginsPath = fallbackDir(); } } @@ -212,7 +212,7 @@ QString localesPath() potentialLocalesPath = QCoreApplication::applicationDirPath() % QDir::separator() % QLatin1String("qtwebengine_locales"); } if (!QFileInfo::exists(potentialLocalesPath)) { - qWarning("Qt WebEngine locales directory not found at location %s. Trying fallback directory. Translations MAY NOT not be correct.", qPrintable(potentialLocalesPath)); + qWarning("Qt WebEngine locales directory not found at location %s. Trying fallback directory... Translations MAY NOT not be correct.", qPrintable(potentialLocalesPath)); potentialLocalesPath = fallbackDir(); } } @@ -221,6 +221,28 @@ QString localesPath() #endif } +QString libraryDataPath() +{ +#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) + return getResourcesPath(frameworkBundle()); +#else + static bool initialized = false; + static QString potentialDataPath = location(QLibraryInfo::DataPath); + if (!initialized) { + initialized = true; + if (!QFileInfo::exists(potentialDataPath)) { + qWarning("Qt WebEngine data directory not found at location %s. Trying application directory...", qPrintable(potentialDataPath)); + potentialDataPath = QCoreApplication::applicationDirPath(); + } + if (!QFileInfo::exists(potentialDataPath)) { + qWarning("Qt WebEngine data directory not found at location %s. Trying fallback directory... The application MAY NOT work.", qPrintable(potentialDataPath)); + potentialDataPath = fallbackDir(); + } + } + + return potentialDataPath; +#endif +} } // namespace base::FilePath WebEngineLibraryInfo::getPath(int key) @@ -248,11 +270,7 @@ base::FilePath WebEngineLibraryInfo::getPath(int key) directory = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); break; case base::DIR_QT_LIBRARY_DATA: -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) - return toFilePath(getResourcesPath(frameworkBundle())); -#else - return toFilePath(location(QLibraryInfo::DataPath)); -#endif + return toFilePath(libraryDataPath()); case content::DIR_MEDIA_LIBS: return toFilePath(pluginsPath()); case ui::DIR_LOCALES: -- cgit v1.2.3