[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Fix i18n regression
From:       Albert Astals Cid <aacid () kde ! org>
Date:       2010-09-13 21:37:38
Message-ID: 201009132237.39303.aacid () kde ! org
[Download RAW message or body]

Hi, 

r1170981 | dfaure | 2010-09-02 12:42:10 +0100 (dj, 02 set 2010) | 4 lines

Fix crash in KGlobal::locale() when using a kde dialog from a pure-Qt 
application
 (e.g. Open File in Qt Creator...)
BUG: 248194

caused a regression for some programs (i tested with kpat, but people says 
koffice and amarok are also affected) in that i18n did not work at all.

I've traced the problem to a klocale over a fake component being created for 
some reason before the klocale with the correct component and thus the klocale 
with the correct component never being set.

This patch fixes the problem for me.

Comments?

Albert

["klocale.patch" (text/x-patch)]

Index: kernel/kglobal.cpp
===================================================================
--- kernel/kglobal.cpp	(revision 1174986)
+++ kernel/kglobal.cpp	(working copy)
@@ -73,7 +73,8 @@
         inline KGlobalPrivate()
             : stringDict(0),
             locale(0),
-            charsets(0)
+            charsets(0),
+            localeIsFromFakeComponent(false)
         {
             // the umask is read here before any threads are created to avoid race \
conditions  mode_t tmp = 0;
@@ -96,6 +97,7 @@
         KStringDict *stringDict;
         KLocale *locale;
         KCharsets *charsets;
+        bool localeIsFromFakeComponent;
 
         /**
          * This component may be used in applications that doesn't have a
@@ -148,8 +150,11 @@
 KLocale *KGlobal::locale()
 {
     PRIVATE_DATA;
-    if (d->locale == 0) {
+    if (d->locale == 0 || (d->localeIsFromFakeComponent && \
d->mainComponent.isValid() && d->mainComponent.config())) { +        delete \
d->locale; +        d->locale = 0;
         d->locale = new KLocale(mainComponent().catalogName());
+        d->localeIsFromFakeComponent = !d->mainComponent.isValid();
         QTextCodec::setCodecForLocale(d->locale->codecForEncoding());
         mainComponent().aboutData()->translateInternalProgramName();
         QCoreApplication* coreApp = QCoreApplication::instance();



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic