From aff7468baf9a27fad9fa8a180b90d2a0db8b8c10 Mon Sep 17 00:00:00 2001
From: Simon Hausmann <simon.hausmann@nokia.com>
Date: Fri, 5 Mar 2010 09:09:56 +0100
Subject: Updated WebKit from /home/shausman/src/webkit/trunk to
 qtwebkit/qtwebkit-4.6 ( f3110d2f94c825477afac054ed448e45d47f5670 )

Changes in WebKit/qt since the last update:

++ b/WebKit/qt/ChangeLog
2010-03-04  Simon Hausmann  <simon.hausmann@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        [Qt] qwebelement.h does not include QtCore headers correctly
        https://bugs.webkit.org/show_bug.cgi?id=35748

        The header files of QtCore must be included as QtCore/foo.h.

        See also http://bugreports.qt.nokia.com/browse/QTBUG-8661

        * Api/qwebelement.h:
---
 src/3rdparty/webkit/VERSION                             |  2 +-
 src/3rdparty/webkit/WebCore/WebCore.pro                 |  2 +-
 src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp |  2 +-
 src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h         | 10 +++++-----
 src/3rdparty/webkit/WebKit/qt/ChangeLog                 | 13 +++++++++++++
 5 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION
index cc0e04f..6a2e75f 100644
--- a/src/3rdparty/webkit/VERSION
+++ b/src/3rdparty/webkit/VERSION
@@ -8,4 +8,4 @@ The commit imported was from the
 
 and has the sha1 checksum
 
-        ffae5e11181a3961193fa21ea405851cad714d4b
+        f3110d2f94c825477afac054ed448e45d47f5670
diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro
index c9b622a..5654a18 100644
--- a/src/3rdparty/webkit/WebCore/WebCore.pro
+++ b/src/3rdparty/webkit/WebCore/WebCore.pro
@@ -26,7 +26,7 @@ symbian: {
 
     # RO text (code) section in qtwebkit.dll exceeds allocated space for gcce udeb target.
     # Move RW-section base address to start from 0xE00000 instead of the toolchain default 0x400000.
-    QMAKE_LFLAGS.ARMCC += --rw-base 0xE00000
+    MMP_RULES += "LINKEROPTION  armcc --rw-base 0xE00000"
 }
 
 include($$PWD/../WebKit.pri)
diff --git a/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp
index 714cac9..d13c9a9 100644
--- a/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp
@@ -39,7 +39,7 @@
 #include <QGraphicsProxyWidget>
 #include <QGraphicsScene>
 #include <QGraphicsView>
-#include <QGraphicsWebView>
+#include <qgraphicswebview.h>
 #include <QListWidget>
 #include <QListWidgetItem>
 #include <QMenu>
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
index 3833070..13c341c 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
@@ -20,11 +20,11 @@
 #ifndef QWEBELEMENT_H
 #define QWEBELEMENT_H
 
-#include <QString>
-#include <QStringList>
-#include <QRect>
-#include <QVariant>
-#include <QExplicitlySharedDataPointer>
+#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qshareddata.h>
 
 #include "qwebkitglobal.h"
 namespace WebCore {
diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog
index 1026ac5..e54c176 100644
--- a/src/3rdparty/webkit/WebKit/qt/ChangeLog
+++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog
@@ -1,3 +1,16 @@
+2010-03-04  Simon Hausmann  <simon.hausmann@nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] qwebelement.h does not include QtCore headers correctly
+        https://bugs.webkit.org/show_bug.cgi?id=35748
+
+        The header files of QtCore must be included as QtCore/foo.h.
+
+        See also http://bugreports.qt.nokia.com/browse/QTBUG-8661
+
+        * Api/qwebelement.h:
+
 2010-01-28  Kenneth Rohde Christiansen  <kenneth@webkit.org>
 
         Reviewed by Simon Hausmann.
-- 
cgit v0.12


From 3fdad84b40b62979844c2d37d16093a0b67222df Mon Sep 17 00:00:00 2001
From: Carlos Manuel Duclos Vergara <carlos.duclos@nokia.com>
Date: Fri, 5 Mar 2010 11:53:39 +0100
Subject: QPrintPreviewDialog number of pages is partially blocked from view in
 OSX

The problem here is caused by the FormLayout. This patch queries the
widget for its sizeHint and then forces it to resize to that size.
Once that is done, we add the widget to the layout.
Code is #ifdef protected so other platforms are not affected by it.

Task-number: QTBUG-7760
Reviewed-by: Trond
---
 src/gui/dialogs/qprintpreviewdialog.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp
index 6723b53..f21343e 100644
--- a/src/gui/dialogs/qprintpreviewdialog.cpp
+++ b/src/gui/dialogs/qprintpreviewdialog.cpp
@@ -273,7 +273,20 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
     QWidget *pageEdit = new QWidget(toolbar);
     QVBoxLayout *vboxLayout = new QVBoxLayout;
     vboxLayout->setContentsMargins(0, 0, 0, 0);
+#ifdef Q_WS_MAC
+    // We query the widgets about their size and then we fix the size.
+    // This should do the trick for the laying out part...
+    QSize pageNumEditSize, pageNumLabelSize;
+    pageNumEditSize = pageNumEdit->minimumSizeHint();
+    pageNumLabelSize = pageNumLabel->minimumSizeHint();
+    pageNumEdit->resize(pageNumEditSize);
+    pageNumLabel->resize(pageNumLabelSize);
+#endif
     QFormLayout *formLayout = new QFormLayout;
+#ifdef Q_WS_MAC
+    // We have to change the growth policy in Mac.
+    formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+#endif
     formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit);
     formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel);
     vboxLayout->addLayout(formLayout);
-- 
cgit v0.12


From 4b3b9b792dfe2d25a271f042f23df22e8b9684f6 Mon Sep 17 00:00:00 2001
From: Peter Hartmann <peter.hartmann@nokia.com>
Date: Fri, 5 Mar 2010 11:28:32 +0100
Subject: QDom: prevent infinite loop when cloning a DTD

we forgot to advance the pointer to the current node.

Reviewed-by: Frans Englich
Task-number: QTBUG-8398
---
 src/xml/dom/qdom.cpp         |  1 +
 tests/auto/qdom/tst_qdom.cpp | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 8d9ae4f..0150515 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -3487,6 +3487,7 @@ QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentTypePrivate* n, boo
         if (p->isNotation())
             // Dont use normal insert function since we would create infinite recursion
             notations->map.insertMulti(p->nodeName(), p);
+        p = p->next;
     }
 }
 
diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp
index d1b2ea5..caf08d6 100644
--- a/tests/auto/qdom/tst_qdom.cpp
+++ b/tests/auto/qdom/tst_qdom.cpp
@@ -131,6 +131,7 @@ private slots:
     void setContentWhitespace_data() const;
 
     void taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() const;
+    void cloneDTD_QTBUG8398() const;
 
     void cleanupTestCase() const;
 
@@ -1912,5 +1913,29 @@ void tst_QDom::taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() co
     QVERIFY(true);
 }
 
+void tst_QDom::cloneDTD_QTBUG8398() const
+{
+    QString dtd("<?xml version='1.0' encoding='UTF-8'?>\n"
+                   "<!DOCTYPE first [\n"
+                   "<!ENTITY secondFile SYSTEM 'second.xml'>\n"
+                   "<!ENTITY thirdFile SYSTEM 'third.xml'>\n"
+                   "]>\n"
+                   "<first/>\n");
+    QDomDocument domDocument;
+    QVERIFY(domDocument.setContent(dtd));
+    QDomDocument domDocument2 = domDocument.cloneNode(true).toDocument();
+
+    // for some reason, our DOM implementation reverts the order of entities
+    QString expected("<?xml version='1.0' encoding='UTF-8'?>\n"
+                   "<!DOCTYPE first [\n"
+                   "<!ENTITY thirdFile SYSTEM 'third.xml'>\n"
+                   "<!ENTITY secondFile SYSTEM 'second.xml'>\n"
+                   "]>\n"
+                   "<first/>\n");
+    QString output;
+    QTextStream stream(&output);
+    domDocument2.save(stream, 0);
+    QCOMPARE(output, expected);
+}
 QTEST_MAIN(tst_QDom)
 #include "tst_qdom.moc"
-- 
cgit v0.12


From 856f76e44a00a710b1c34eddee5a893a3c0ada6a Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Fri, 5 Mar 2010 11:08:33 +0100
Subject: Fixed key mappings on X11

Merge request #1742 (6c8c1c5322a26d789165783d7df3e29c672690cb) changed the
behavior of one of the keys on X11, this fixes it back and documents that on
X11 the key binding is a bit weird - XF86XK_MyComputer is mapped to
Qt::Key_Launch0, XF86XK_Launch0 is mapped to Qt::Key_Launch3 and so on.

Task-number: QTBUG-7063
Reviewed-by: Marius Storm-Olsen
---
 src/corelib/global/qnamespace.qdoc | 34 +++++++++++++++++-----------------
 src/gui/kernel/qkeymapper_x11.cpp  |  6 +++---
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 6968773..a756565 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1622,22 +1622,22 @@
     \value Key_OpenUrl
     \value Key_LaunchMail
     \value Key_LaunchMedia
-    \value Key_Launch0
-    \value Key_Launch1
-    \value Key_Launch2
-    \value Key_Launch3
-    \value Key_Launch4
-    \value Key_Launch5
-    \value Key_Launch6
-    \value Key_Launch7
-    \value Key_Launch8
-    \value Key_Launch9
-    \value Key_LaunchA
-    \value Key_LaunchB
-    \value Key_LaunchC
-    \value Key_LaunchD
-    \value Key_LaunchE
-    \value Key_LaunchF
+    \value Key_Launch0 On X11 this key is mapped to "My Computer" (XF86XK_MyComputer) key for legacy reasons.
+    \value Key_Launch1 On X11 this key is mapped to "Calculator" (XF86XK_Calculator) key for legacy reasons.
+    \value Key_Launch2 On X11 this key is mapped to XF86XK_Launch0 key for legacy reasons.
+    \value Key_Launch3 On X11 this key is mapped to XF86XK_Launch1 key for legacy reasons.
+    \value Key_Launch4 On X11 this key is mapped to XF86XK_Launch2 key for legacy reasons.
+    \value Key_Launch5 On X11 this key is mapped to XF86XK_Launch3 key for legacy reasons.
+    \value Key_Launch6 On X11 this key is mapped to XF86XK_Launch4 key for legacy reasons.
+    \value Key_Launch7 On X11 this key is mapped to XF86XK_Launch5 key for legacy reasons.
+    \value Key_Launch8 On X11 this key is mapped to XF86XK_Launch6 key for legacy reasons.
+    \value Key_Launch9 On X11 this key is mapped to XF86XK_Launch7 key for legacy reasons.
+    \value Key_LaunchA On X11 this key is mapped to XF86XK_Launch8 key for legacy reasons.
+    \value Key_LaunchB On X11 this key is mapped to XF86XK_Launch9 key for legacy reasons.
+    \value Key_LaunchC On X11 this key is mapped to XF86XK_LaunchA key for legacy reasons.
+    \value Key_LaunchD On X11 this key is mapped to XF86XK_LaunchB key for legacy reasons.
+    \value Key_LaunchE On X11 this key is mapped to XF86XK_LaunchC key for legacy reasons.
+    \value Key_LaunchF On X11 this key is mapped to XF86XK_LaunchD key for legacy reasons.
     \value Key_MonBrightnessUp
     \value Key_MonBrightnessDown
     \value Key_KeyboardLightOnOff
@@ -1663,7 +1663,7 @@
     \value Key_ApplicationRight
     \value Key_Book
     \value Key_CD
-    \value Key_Calculator
+    \value Key_Calculator On X11 this key is not mapped for legacy reasons. Use Qt::Key_Launch1 instead.
     \value Key_ToDoList
     \value Key_ClearGrab
     \value Key_Close
diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp
index 4e6c847..b32b626 100644
--- a/src/gui/kernel/qkeymapper_x11.cpp
+++ b/src/gui/kernel/qkeymapper_x11.cpp
@@ -1073,8 +1073,8 @@ static const unsigned int KeyTbl[] = {
     XF86XK_AudioNext,           Qt::Key_MediaNext,
     XF86XK_AudioRecord,         Qt::Key_MediaRecord,
     XF86XK_Mail,                Qt::Key_LaunchMail,
-    XF86XK_MyComputer,          Qt::Key_Launch0,
-    XF86XK_Calculator,          Qt::Key_Calculator,
+    XF86XK_MyComputer,          Qt::Key_Launch0,  // ### Qt 5: remap properly
+    XF86XK_Calculator,          Qt::Key_Launch1,
     XF86XK_Memo,                Qt::Key_Memo,
     XF86XK_ToDoList,            Qt::Key_ToDoList,
     XF86XK_Calendar,            Qt::Key_Calendar,
@@ -1172,7 +1172,7 @@ static const unsigned int KeyTbl[] = {
     XF86XK_Bluetooth,           Qt::Key_Bluetooth,
     XF86XK_Suspend,             Qt::Key_Suspend,
     XF86XK_Hibernate,           Qt::Key_Hibernate,
-    XF86XK_Launch0,             Qt::Key_Launch2,
+    XF86XK_Launch0,             Qt::Key_Launch2, // ### Qt 5: remap properly
     XF86XK_Launch1,             Qt::Key_Launch3,
     XF86XK_Launch2,             Qt::Key_Launch4,
     XF86XK_Launch3,             Qt::Key_Launch5,
-- 
cgit v0.12


From ddaa4643c1ee96c9dfc16b1c247481a240e2e16b Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Fri, 5 Mar 2010 15:59:37 +0100
Subject: fix "using namespace" recursion crash

Task-number: QTBUG-8360
---
 .../lupdate/testdata/good/namespaces/main.cpp      | 60 ++++++++++++++++++++++
 .../testdata/good/namespaces/project.ts.result     | 24 +++++++++
 tools/linguist/lupdate/cpp.cpp                     | 28 +++++++---
 3 files changed, 104 insertions(+), 8 deletions(-)

diff --git a/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp b/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp
index 42cc55b..a5b36ca 100644
--- a/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp
@@ -135,4 +135,64 @@ Q_OBJECT
     }
 };
 
+// QTBUG-8360
+namespace A {
+
+void foo()
+{
+    using namespace A;
+}
+
+void goo()
+{
+    return QObject::tr("Bla");
+}
+
+}
+
+
+namespace AA {
+namespace B {
+
+using namespace AA;
+
+namespace C {
+
+class Test : public QObject {
+    Q_OBJECT
+};
+
+}
+
+}
+
+using namespace B;
+using namespace C;
+
+void goo()
+{
+    AA::Test::tr("howdy?");
+}
+
+}
+
+
+namespace A1 {
+namespace B {
+
+class Test : public QObject {
+    Q_OBJECT
+};
+
+using namespace A1;
+
+void foo()
+{
+    B::B::B::Test::tr("yeeee-ha!");
+}
+
+}
+}
+
+
 #include "main.moc"
diff --git a/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result
index c1a34bd..94df9d3 100644
--- a/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result
@@ -2,6 +2,22 @@
 <!DOCTYPE TS>
 <TS version="2.0">
 <context>
+    <name>A1::B::Test</name>
+    <message>
+        <location filename="main.cpp" line="191"/>
+        <source>yeeee-ha!</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>AA::B::C::Test</name>
+    <message>
+        <location filename="main.cpp" line="174"/>
+        <source>howdy?</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
     <name>Class</name>
     <message>
         <location filename="main.cpp" line="52"/>
@@ -79,4 +95,12 @@
         <translation type="unfinished"></translation>
     </message>
 </context>
+<context>
+    <name>QObject</name>
+    <message>
+        <location filename="main.cpp" line="148"/>
+        <source>Bla</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
 </TS>
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index 6bd9108..2d5620e 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -260,6 +260,8 @@ private:
     bool qualifyOneCallbackOwn(const Namespace *ns, void *context) const;
     bool qualifyOneCallbackUsing(const Namespace *ns, void *context) const;
     bool qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
+                    NamespaceList *resolved, QSet<HashStringList> *visitedUsings) const;
+    bool qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
                     NamespaceList *resolved) const;
     bool fullyQualify(const NamespaceList &namespaces, int nsCnt,
                       const QList<HashString> &segments, bool isDeclaration,
@@ -1036,15 +1038,16 @@ QStringList CppParser::stringListifySegments(const QList<HashString> &segments)
 }
 
 struct QualifyOneData {
-    QualifyOneData(const NamespaceList &ns, int nsc, const HashString &seg, NamespaceList *rslvd)
-        : namespaces(ns), nsCount(nsc), segment(seg), resolved(rslvd)
+    QualifyOneData(const NamespaceList &ns, int nsc, const HashString &seg, NamespaceList *rslvd,
+                   QSet<HashStringList> *visited)
+        : namespaces(ns), nsCount(nsc), segment(seg), resolved(rslvd), visitedUsings(visited)
     {}
 
     const NamespaceList &namespaces;
     int nsCount;
     const HashString &segment;
     NamespaceList *resolved;
-    QSet<HashStringList> visitedUsings;
+    QSet<HashStringList> *visitedUsings;
 };
 
 bool CppParser::qualifyOneCallbackOwn(const Namespace *ns, void *context) const
@@ -1078,18 +1081,19 @@ bool CppParser::qualifyOneCallbackUsing(const Namespace *ns, void *context) cons
 {
     QualifyOneData *data = (QualifyOneData *)context;
     foreach (const HashStringList &use, ns->usings)
-        if (!data->visitedUsings.contains(use)) {
-            data->visitedUsings.insert(use);
-            if (qualifyOne(use.value(), use.value().count(), data->segment, data->resolved))
+        if (!data->visitedUsings->contains(use)) {
+            data->visitedUsings->insert(use);
+            if (qualifyOne(use.value(), use.value().count(), data->segment, data->resolved,
+                           data->visitedUsings))
                 return true;
         }
     return false;
 }
 
 bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
-                           NamespaceList *resolved) const
+                           NamespaceList *resolved, QSet<HashStringList> *visitedUsings) const
 {
-    QualifyOneData data(namespaces, nsCnt, segment, resolved);
+    QualifyOneData data(namespaces, nsCnt, segment, resolved, visitedUsings);
 
     if (visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackOwn, &data))
         return true;
@@ -1097,6 +1101,14 @@ bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const Has
     return visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackUsing, &data);
 }
 
+bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
+                           NamespaceList *resolved) const
+{
+    QSet<HashStringList> visitedUsings;
+
+    return qualifyOne(namespaces, nsCnt, segment, resolved, &visitedUsings);
+}
+
 bool CppParser::fullyQualify(const NamespaceList &namespaces, int nsCnt,
                              const QList<HashString> &segments, bool isDeclaration,
                              NamespaceList *resolved, QStringList *unresolved) const
-- 
cgit v0.12


From a4a1cfe900ab06ff1f8dbe30d73476937a122582 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Fri, 5 Mar 2010 14:57:01 +0100
Subject: Reset the byte order in the iconv codec after using it.

Otherwise, if you try run
    QString(QChar(0xfffe)).toLocal8Bit()
iconv will be left in byte-swapping mode.

Reviewed-by: Denis Dzyubenko
---
 src/corelib/codecs/qiconvcodec.cpp | 41 +++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp
index 0f73d9b..0fcdf96 100644
--- a/src/corelib/codecs/qiconvcodec.cpp
+++ b/src/corelib/codecs/qiconvcodec.cpp
@@ -299,6 +299,32 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
 
 Q_GLOBAL_STATIC(QThreadStorage<QIconvCodec::IconvState *>, fromUnicodeState)
 
+static bool setByteOrder(iconv_t cd)
+{
+#if !defined(NO_BOM)
+    // give iconv() a BOM
+    char buf[4];
+    ushort bom[] = { QChar::ByteOrderMark };
+
+    char *outBytes = buf;
+    char *inBytes = reinterpret_cast<char *>(bom);
+    size_t outBytesLeft = sizeof buf;
+    size_t inBytesLeft = sizeof bom;
+
+#if defined(GNU_LIBICONV)
+    const char **inBytesPtr = const_cast<const char **>(&inBytes);
+#else
+    char **inBytesPtr = &inBytes;
+#endif
+
+    if (iconv(cd, inBytesPtr, &inBytesLeft, &outBytes, &outBytesLeft) == (size_t) -1) {
+        return false;
+    }
+#endif // NO_BOM
+
+    return true;
+}
+
 QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *convState) const
 {
     char *inBytes;
@@ -325,17 +351,8 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
     IconvState *&state = ts->localData();
     if (!state) {
         state = new IconvState(QIconvCodec::createIconv_t(0, UTF16));
-        if (state->cd != reinterpret_cast<iconv_t>(-1)) {
-            size_t outBytesLeft = len + 3; // +3 for the BOM
-            QByteArray ba(outBytesLeft, Qt::Uninitialized);
-            outBytes = ba.data();
-
-#if !defined(NO_BOM)
-            // give iconv() a BOM
-            QChar bom[] = { QChar(QChar::ByteOrderMark) };
-            inBytes = reinterpret_cast<char *>(bom);
-            inBytesLeft = sizeof(bom);
-            if (iconv(state->cd, inBytesPtr, &inBytesLeft, &outBytes, &outBytesLeft) == (size_t) -1) {
+        if (state->cd == reinterpret_cast<iconv_t>(-1)) {
+            if (!setByteOrder(state->cd)) {
                 perror("QIconvCodec::convertFromUnicode: using ASCII for conversion, iconv failed for BOM");
 
                 iconv_close(state->cd);
@@ -343,7 +360,6 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
 
                 return QString(uc, len).toAscii();
             }
-#endif // NO_BOM
         }
     }
     if (state->cd == reinterpret_cast<iconv_t>(-1)) {
@@ -422,6 +438,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
 
     // reset to initial state
     iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft);
+    setByteOrder(state->cd);
 
     ba.resize(ba.size() - outBytesLeft);
 
-- 
cgit v0.12


From e0534e6cb81894e1fb69ab5c1855aee09db31ead Mon Sep 17 00:00:00 2001
From: Bernhard Rosenkraenzer <br@blankpage.ch>
Date: Fri, 5 Mar 2010 17:06:36 +0100
Subject: Fix build with Mesa 7.8's EGL implementatioon

Without this change, when Mesa 7.8 is used, qtextstream.h (included
by qdebug.h) complains that it has to be included before any header
that defines Status

Merge-request: 483
Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
---
 src/gui/egl/qeglproperties.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp
index 236ec37..d0d5de7 100644
--- a/src/gui/egl/qeglproperties.cpp
+++ b/src/gui/egl/qeglproperties.cpp
@@ -39,13 +39,13 @@
 **
 ****************************************************************************/
 
+#include <QtCore/qdebug.h>
+#include <QtCore/qstringlist.h>
+
 #include "qeglproperties_p.h"
 
 QT_BEGIN_NAMESPACE
 
-#include <QtCore/qdebug.h>
-#include <QtCore/qstringlist.h>
-
 #include "qegl_p.h"
 
 
-- 
cgit v0.12