diff options
author | Michael BrĂ¼ning <michael.bruning@theqtcompany.com> | 2015-03-30 12:41:03 +0200 |
---|---|---|
committer | Michael BrĂ¼ning <michael.bruning@theqtcompany.com> | 2015-04-09 10:59:19 +0000 |
commit | 16b93c2d7dad73c33a745dce2a2eb7eac0e9826e (patch) | |
tree | 8a191ba1854e17509eabef5930d64ae20fde2834 /src/core/web_engine_library_info.cpp | |
parent | 12ac4dd0d8d7e5fa33043d86e2effa77183f3122 (diff) |
Add a fallback for discovering plugins and translations.
This should fix problems with deployed applications and remove
the need to use a qt.conf file to configure the PluginsPath and
TranslationsPath in order to get for example ffmpegsumo loaded by
default.
It should also fix the creation of empty directories from the Chromium
layer.
Task-number: QTBUG-44331
Change-Id: I08bb5ac1b308820bed2c758b30ce43f1209038e1
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'src/core/web_engine_library_info.cpp')
-rw-r--r-- | src/core/web_engine_library_info.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index ce862aae6..835fe8bba 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -60,6 +60,11 @@ using namespace QtWebEngineCore; namespace { +QString fallbackDir() { + static QString directory = QDir::homePath() % QLatin1String("/.") % QCoreApplication::applicationName(); + return directory; +} + QString location(QLibraryInfo::LibraryLocation path) { #if defined(Q_OS_BLACKBERRY) @@ -173,7 +178,22 @@ QString pluginsPath() #if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) return getPath(frameworkBundle()) % QLatin1String("/Libraries"); #else - return location(QLibraryInfo::PluginsPath) % QLatin1String("/qtwebengine"); + static bool initialized = false; + static QString potentialPluginsPath = location(QLibraryInfo::PluginsPath) % QDir::separator() % QLatin1String("qtwebengine"); + + if (!initialized) { + initialized = true; + if (!QFileInfo::exists(potentialPluginsPath)) { + qWarning("Installed Qt plugins directory not found at location %s. Trying application directory...", qPrintable(potentialPluginsPath)); + 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)); + potentialPluginsPath = fallbackDir(); + } + } + + return potentialPluginsPath; #endif } @@ -182,13 +202,23 @@ QString localesPath() #if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) return getResourcesPath(frameworkBundle()) % QLatin1String("/qtwebengine_locales"); #else - return location(QLibraryInfo::TranslationsPath) % QDir::separator() % QLatin1String("qtwebengine_locales"); -#endif -} + static bool initialized = false; + static QString potentialLocalesPath = location(QLibraryInfo::TranslationsPath) % QDir::separator() % QLatin1String("qtwebengine_locales"); -QString fallbackDir() { - static QString directory = QDir::homePath() % QLatin1String("/.") % QCoreApplication::applicationName(); - return directory; + if (!initialized) { + initialized = true; + if (!QFileInfo::exists(potentialLocalesPath)) { + qWarning("Installed Qt WebEngine locales directory not found at location %s. Trying application directory...", qPrintable(potentialLocalesPath)); + 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)); + potentialLocalesPath = fallbackDir(); + } + } + + return potentialLocalesPath; +#endif } } // namespace |