summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2017-03-31 07:07:02 (GMT)
committerTobias Markmann <tm@ayena.de>2017-03-31 07:07:02 (GMT)
commit4d0391d824aaf94fbe152778581d51fecd588f6c (patch)
tree87fd793d0c60309cfcb0d5e54d5c2626378f9dd8 /Swift/QtUI
parent3611f7cbdcc1a9c96a542d40a439712cf5c3818a (diff)
downloadswift-4d0391d824aaf94fbe152778581d51fecd588f6c.zip
swift-4d0391d824aaf94fbe152778581d51fecd588f6c.tar.bz2
Handle potential boost::bad_any_cast exception
Coverity raised this issue. Test-Information: Builds and unit tests pass on macOS 10.12.4. Switching different application languages via --language parameter still works and passing numbers as languages has it correctly fallback to the default system language. Change-Id: Ide1ffdba7a13c27856304aa96b78067147568a95
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/main.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/Swift/QtUI/main.cpp b/Swift/QtUI/main.cpp
index 472c99a..81dc670 100644
--- a/Swift/QtUI/main.cpp
+++ b/Swift/QtUI/main.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -89,8 +89,15 @@ int main(int argc, char* argv[]) {
QTranslator qtTranslator;
if (!someTranslationPath.empty()) {
#if QT_VERSION >= 0x040800
+ std::string language;
if (vm.count("language") > 0) {
- qtTranslator.load(QString(SWIFT_APPLICATION_NAME).toLower() + "_" + P2QSTRING(vm["language"].as<std::string>()), P2QSTRING(Swift::pathToString(someTranslationPath.parent_path())));
+ try {
+ language = vm["language"].as<std::string>();
+ } catch (const boost::bad_any_cast&) {
+ }
+ }
+ if (!language.empty()) {
+ qtTranslator.load(QString(SWIFT_APPLICATION_NAME).toLower() + "_" + P2QSTRING(language), P2QSTRING(Swift::pathToString(someTranslationPath.parent_path())));
}
else {
qtTranslator.load(QLocale::system(), QString(SWIFT_APPLICATION_NAME).toLower(), "_", P2QSTRING(Swift::pathToString(someTranslationPath)));