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

List:       kde-commits
Subject:    Re: qt-copy
From:       Alexis_Ménard <menard () kde ! org>
Date:       2009-02-23 21:51:30
Message-ID: 81941aea0902231351w6885993ao7c13b633b15c737d () mail ! gmail ! com
[Download RAW message or body]

Same why patching the src file directly? It can be a big mess especially if
i don't want to apply the patch or write another one that doesn't need this
one to work...

On Thu, Feb 19, 2009 at 6:18 PM, David Faure <faure@kde.org> wrote:

> SVN commit 928628 by dfaure:
>
> Fix for the toLocal8Bit() regression (broken if used once before
> QCoreApplication), provided by Thiago
>
>
>  A             patches/0272-qiconvcodec-fix.diff
>  M  +1 -1      patches/README
>  M  +12 -4     src/corelib/codecs/qiconvcodec.cpp
>  M  +3 -0      src/corelib/kernel/qcoreapplication.cpp
>
>
> --- trunk/qt-copy/patches/README #928627:928628
> @@ -1,5 +1,5 @@
>  Please assign the numbers incrementally, and don't reuse them. The next
> one:
> -#0272
> +#0273
>
>  This directory contains patches for Qt that haven't been accepted by
> TrollTech
>  yet. All patches in this directory itself shouldn't make qt-copy
> incompatible
> --- trunk/qt-copy/src/corelib/codecs/qiconvcodec.cpp #928627:928628
> @@ -83,6 +83,8 @@
>
>  QT_BEGIN_NAMESPACE
>
> +extern bool qt_locale_initialized;
> +
>  QIconvCodec::QIconvCodec()
>     : utf16Codec(0)
>  {
> @@ -182,8 +184,9 @@
>         }
>     } else {
>         QThreadStorage<QIconvCodec::IconvState *> *ts = toUnicodeState();
> -        if (!ts) {
> +        if (!qt_locale_initialized || !ts) {
>             // we're running after the Q_GLOBAL_STATIC has been deleted
> +            // or before the QCoreApplication initialization
>             // bad programmer, no cookie for you
>             return QString::fromLatin1(chars, len);
>         }
> @@ -305,9 +308,14 @@
>  #endif
>
>     QThreadStorage<QIconvCodec::IconvState *> *ts = fromUnicodeState();
> -    if (!ts) {
> +    if (!qt_locale_initialized || !ts) {
>         // we're running after the Q_GLOBAL_STATIC has been deleted
> +        // or before the QCoreApplication initialization
>         // bad programmer, no cookie for you
> +        if (!len)
> +            // this is a special case - zero-sized string should be
> +            // translated to empty but not-null QByteArray.
> +            return QByteArray("");
>         return QString::fromRawData(uc, len).toLatin1();
>     }
>     IconvState *&state = ts->localData();
> @@ -384,8 +392,8 @@
>                 // fall through
>             case EINVAL:
>                 {
> -                    ++inBytes;
> -                    --inBytesLeft;
> +                    inBytes += sizeof(QChar);
> +                    inBytesLeft -= sizeof(QChar);
>                     break;
>                 }
>             case E2BIG:
> --- trunk/qt-copy/src/corelib/kernel/qcoreapplication.cpp #928627:928628
> @@ -163,6 +163,8 @@
>  bool QCoreApplicationPrivate::is_app_running = false;
>  // app closing down if true
>  bool QCoreApplicationPrivate::is_app_closing = false;
> +// initialized in qcoreapplication and in qtextstream autotest when
> setlocale is called.
> +Q_AUTOTEST_EXPORT bool qt_locale_initialized = false;
>
>
>  Q_CORE_EXPORT uint qGlobalPostedEventsCount()
> @@ -440,6 +442,7 @@
>
>  #ifdef Q_OS_UNIX
>     setlocale(LC_ALL, "");                // use correct char set mapping
> +    qt_locale_initialized = true;
>  #endif
>
>  #ifdef Q_WS_WIN
>

[Attachment #3 (text/html)]

Same why patching the src file directly? It can be a big mess especially if i \
don&#39;t want to apply the patch or write another one that doesn&#39;t need this one \
to work...<br><br><div class="gmail_quote">On Thu, Feb 19, 2009 at 6:18 PM, David \
Faure <span dir="ltr">&lt;<a href="mailto:faure@kde.org">faure@kde.org</a>&gt;</span> \
wrote:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, \
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">SVN commit 928628 by \
dfaure:<br> <br>
Fix for the toLocal8Bit() regression (broken if used once before QCoreApplication), \
provided by Thiago<br> <br>
<br>
&nbsp;A &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
patches/0272-qiconvcodec-fix.diff<br> &nbsp;M &nbsp;+1 -1 &nbsp; &nbsp; \
&nbsp;patches/README<br> &nbsp;M &nbsp;+12 -4 &nbsp; &nbsp; \
src/corelib/codecs/qiconvcodec.cpp<br> &nbsp;M &nbsp;+3 -0 &nbsp; &nbsp; \
&nbsp;src/corelib/kernel/qcoreapplication.cpp<br> <br>
<br>
--- trunk/qt-copy/patches/README #928627:928628<br>
@@ -1,5 +1,5 @@<br>
&nbsp;Please assign the numbers incrementally, and don&#39;t reuse them. The next \
                one:<br>
-#0272<br>
+#0273<br>
<br>
&nbsp;This directory contains patches for Qt that haven&#39;t been accepted by \
TrollTech<br> &nbsp;yet. All patches in this directory itself shouldn&#39;t make \
                qt-copy incompatible<br>
--- trunk/qt-copy/src/corelib/codecs/qiconvcodec.cpp #928627:928628<br>
@@ -83,6 +83,8 @@<br>
<br>
&nbsp;QT_BEGIN_NAMESPACE<br>
<br>
+extern bool qt_locale_initialized;<br>
+<br>
&nbsp;QIconvCodec::QIconvCodec()<br>
 &nbsp; &nbsp; : utf16Codec(0)<br>
&nbsp;{<br>
@@ -182,8 +184,9 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; } else {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; QThreadStorage&lt;QIconvCodec::IconvState *&gt; *ts = \
                toUnicodeState();<br>
- &nbsp; &nbsp; &nbsp; &nbsp;if (!ts) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;if (!qt_locale_initialized || !ts) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // we&#39;re running after the \
Q_GLOBAL_STATIC has been deleted<br> + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// or \
before the QCoreApplication initialization<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; // bad programmer, no cookie for you<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; return QString::fromLatin1(chars, len);<br>  &nbsp; &nbsp; &nbsp; &nbsp; }<br>
@@ -305,9 +308,14 @@<br>
&nbsp;#endif<br>
<br>
 &nbsp; &nbsp; QThreadStorage&lt;QIconvCodec::IconvState *&gt; *ts = \
                fromUnicodeState();<br>
- &nbsp; &nbsp;if (!ts) {<br>
+ &nbsp; &nbsp;if (!qt_locale_initialized || !ts) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; // we&#39;re running after the Q_GLOBAL_STATIC has been \
deleted<br> + &nbsp; &nbsp; &nbsp; &nbsp;// or before the QCoreApplication \
initialization<br>  &nbsp; &nbsp; &nbsp; &nbsp; // bad programmer, no cookie for \
you<br> + &nbsp; &nbsp; &nbsp; &nbsp;if (!len)<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// this is a special case - zero-sized \
string should be<br> + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// translated to \
empty but not-null QByteArray.<br> + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return \
QByteArray(&quot;&quot;);<br>  &nbsp; &nbsp; &nbsp; &nbsp; return \
QString::fromRawData(uc, len).toLatin1();<br>  &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; IconvState *&amp;state = ts-&gt;localData();<br>
@@ -384,8 +392,8 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // fall through<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case EINVAL:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;++inBytes;<br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;--inBytesLeft;<br> + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp;inBytes += sizeof(QChar);<br> + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inBytesLeft -= sizeof(QChar);<br>  &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>  &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
                &nbsp; case E2BIG:<br>
--- trunk/qt-copy/src/corelib/kernel/qcoreapplication.cpp #928627:928628<br>
@@ -163,6 +163,8 @@<br>
&nbsp;bool QCoreApplicationPrivate::is_app_running = false;<br>
 &nbsp;// app closing down if true<br>
&nbsp;bool QCoreApplicationPrivate::is_app_closing = false;<br>
+// initialized in qcoreapplication and in qtextstream autotest when setlocale is \
called.<br> +Q_AUTOTEST_EXPORT bool qt_locale_initialized = false;<br>
<br>
<br>
&nbsp;Q_CORE_EXPORT uint qGlobalPostedEventsCount()<br>
@@ -440,6 +442,7 @@<br>
<br>
&nbsp;#ifdef Q_OS_UNIX<br>
 &nbsp; &nbsp; setlocale(LC_ALL, &quot;&quot;); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;// use correct char set mapping<br> + &nbsp; \
&nbsp;qt_locale_initialized = true;<br> &nbsp;#endif<br>
<br>
&nbsp;#ifdef Q_WS_WIN<br>
</blockquote></div><br>



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

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