OSDN Git Service

assert that setupLocaleMapper() should not be called with locale mapper set
authorIvailo Monev <xakepa10@gmail.com>
Tue, 23 Mar 2021 15:04:47 +0000 (17:04 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 23 Mar 2021 15:12:32 +0000 (17:12 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/codecs/qtextcodec.cpp

index e622f0f..af36821 100644 (file)
@@ -97,25 +97,25 @@ static QTextCodec *checkForCodec(const QByteArray &name) {
 
 static void setupLocaleMapper()
 {
-    if (!localeMapper) {
-        // Get the first nonempty value from $LC_ALL, $LC_CTYPE, and $LANG
-        // environment variables.
-        QByteArray lang = qgetenv("LC_ALL");
-        if (lang.isEmpty()) {
-            lang = qgetenv("LC_CTYPE");
-        }
-        if (lang.isEmpty()) {
-            lang = qgetenv("LANG");
-        }
+    Q_ASSERT(!localeMapper);
 
-        const int indexOfDot = lang.indexOf('.');
-        if (indexOfDot != -1) {
-            localeMapper = checkForCodec(lang.mid(indexOfDot + 1));
-        }
+    // Get the first nonempty value from $LC_ALL, $LC_CTYPE, and $LANG
+    // environment variables.
+    QByteArray lang = qgetenv("LC_ALL");
+    if (lang.isEmpty()) {
+        lang = qgetenv("LC_CTYPE");
+    }
+    if (lang.isEmpty()) {
+        lang = qgetenv("LANG");
+    }
 
-        if (!localeMapper && !lang.isEmpty()) {
-            localeMapper = checkForCodec(lang);
-        }
+    const int indexOfDot = lang.indexOf('.');
+    if (indexOfDot != -1) {
+        localeMapper = checkForCodec(lang.mid(indexOfDot + 1));
+    }
+
+    if (!localeMapper && !lang.isEmpty()) {
+        localeMapper = checkForCodec(lang);
     }
 
     // Fallback to implementation-defined default locale