summaryrefslogtreecommitdiffstats
path: root/src/tools/qwebengine_convert_dict/main.cpp
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2017-01-27 18:21:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-02-21 23:56:52 +0000
commit16d8518e58fcaf6495604ae2d9188cc59b3e661b (patch)
tree31457ddfb5979ed7d1ff5d66c7bcbf3cef2caeb6 /src/tools/qwebengine_convert_dict/main.cpp
parent37206c2baf013b07cd26d416a8ab0db493d7d651 (diff)
Fix building spellchecker example when Qt is not yet installed
During the build of the spellchecker example, the dictionary conversion tool is executed to convert some dictionaries. The tool will fail to find the ICU data file because the file is not present at the Qt install location at examples build time. The fix is to allow passing the ICU data directory via an environment variable. Specifically the QtWebEngine build directory which contains the ICU data file will be passed when the spellchecker example is built. Task-number: QTBUG-58451 Change-Id: I6188f0b7aabe8b2e55cd2e0d59553282058c5035 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/tools/qwebengine_convert_dict/main.cpp')
-rw-r--r--src/tools/qwebengine_convert_dict/main.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/tools/qwebengine_convert_dict/main.cpp b/src/tools/qwebengine_convert_dict/main.cpp
index 2142b5f0d..61e26c4a3 100644
--- a/src/tools/qwebengine_convert_dict/main.cpp
+++ b/src/tools/qwebengine_convert_dict/main.cpp
@@ -120,9 +120,34 @@ int main(int argc, char *argv[])
return 1;
}
- PathService::Override(base::DIR_QT_LIBRARY_DATA,
- toFilePath(QLibraryInfo::location(QLibraryInfo::DataPath) %
- QLatin1String("/resources")));
+ bool icuDataDirFound = false;
+ QString icuDataDir = QLibraryInfo::location(QLibraryInfo::DataPath)
+ % QLatin1String("/resources");
+
+ // Try to look up the path to the ICU data directory via an environment variable
+ // (e.g. for the case when the tool is ran during build phase, and regular installed
+ // ICU data file is not available).
+ QString icuPossibleEnvDataDir = QString::fromLatin1(qgetenv("QT_WEBENGINE_ICU_DATA_DIR"));
+ if (!icuPossibleEnvDataDir.isEmpty() && QFileInfo::exists(icuPossibleEnvDataDir)) {
+ icuDataDir = icuPossibleEnvDataDir;
+ icuDataDirFound = true;
+ }
+ // Try to find the ICU data directory in the installed Qt location.
+ else if (QFileInfo::exists(icuDataDir)) {
+ icuDataDirFound = true;
+ }
+
+ if (icuDataDirFound) {
+ PathService::Override(base::DIR_QT_LIBRARY_DATA, toFilePath(icuDataDir));
+ } else {
+ QTextStream out(stdout);
+ out << "Couldn't find ICU data directory. Please check that the following path exists: "
+ << icuDataDir
+ << "\nAlternatively provide the directory path via the QT_WEBENGINE_ICU_DAT_DIR "
+ "environment variable.\n" << endl;
+ return 1;
+ }
+
base::AtExitManager exit_manager;
base::i18n::InitializeICU();