1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
From 3349c1dba99da9963eb275ae6ac7cdb8ed0c0e1b Mon Sep 17 00:00:00 2001
From: Boudewijn Rempt <boud@valdyas.org>
Date: Sat, 11 Apr 2020 16:33:09 +0200
Subject: [PATCH] Check whether the uiLanguages list isn't empty
Because Qt can crash or assert on list.first() if the list is
empty.
BUG:419947
---
krita/main.cc | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/krita/main.cc b/krita/main.cc
index e01fd10969..908f7abe03 100644
--- a/krita/main.cc
+++ b/krita/main.cc
@@ -334,7 +334,6 @@ extern "C" int main(int argc, char **argv)
qputenv("LANG", locale.name().toLocal8Bit());
#endif
-
const QStringList rtlLanguages = QStringList()
<< "ar" << "dv" << "he" << "ha" << "ku" << "fa" << "ps" << "ur" << "yi";
@@ -366,28 +365,30 @@ extern "C" int main(int argc, char **argv)
}
}
- QString envLanguage = uiLanguages.first();
- envLanguage.replace(QChar('-'), QChar('_'));
+ if (uiLanguages.size() > 0 ) {
+ QString envLanguage = uiLanguages.first();
+ envLanguage.replace(QChar('-'), QChar('_'));
- for (int i = 0; i < uiLanguages.size(); i++) {
- QString uiLanguage = uiLanguages[i];
- // Strip the country code
- int idx = uiLanguage.indexOf(QChar('-'));
+ for (int i = 0; i < uiLanguages.size(); i++) {
+ QString uiLanguage = uiLanguages[i];
+ // Strip the country code
+ int idx = uiLanguage.indexOf(QChar('-'));
- if (idx != -1) {
- uiLanguage = uiLanguage.left(idx);
- uiLanguages.replace(i, uiLanguage);
+ if (idx != -1) {
+ uiLanguage = uiLanguage.left(idx);
+ uiLanguages.replace(i, uiLanguage);
+ }
}
- }
- dbgKrita << "Converted ui languages:" << uiLanguages;
+ dbgKrita << "Converted ui languages:" << uiLanguages;
#ifdef Q_OS_MAC
- // See https://bugs.kde.org/show_bug.cgi?id=396370
- KLocalizedString::setLanguages(QStringList() << uiLanguages.first());
- qputenv("LANG", (envLanguage + ".UTF-8").toLocal8Bit());
+ // See https://bugs.kde.org/show_bug.cgi?id=396370
+ KLocalizedString::setLanguages(QStringList() << uiLanguages.first());
+ qputenv("LANG", (envLanguage + ".UTF-8").toLocal8Bit());
#else
- KLocalizedString::setLanguages(QStringList() << uiLanguages);
- qputenv("LANG", envLanguage.toLocal8Bit());
+ KLocalizedString::setLanguages(QStringList() << uiLanguages);
+ qputenv("LANG", envLanguage.toLocal8Bit());
#endif
+ }
}
}
--
2.26.0
|