From 349e04eb7c173ad6e01b866d4c0d517f89e2a201 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 22 Feb 2012 09:25:01 +0200 Subject: [PATCH 001/166] Migrate evdev plugins to the new plugin system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7eb283646b7529080c8c2f41c267b0135c8f57e4 Reviewed-by: Samuel Rødal --- src/plugins/generic/evdevkeyboard/evdevkeyboard.json | 3 +++ src/plugins/generic/evdevkeyboard/evdevkeyboard.pro | 3 +++ src/plugins/generic/evdevkeyboard/main.cpp | 7 +++++-- src/plugins/generic/evdevmouse/evdevmouse.json | 3 +++ src/plugins/generic/evdevmouse/evdevmouse.pro | 3 +++ src/plugins/generic/evdevmouse/main.cpp | 7 +++++-- src/plugins/generic/evdevtouch/evdevtouch.json | 3 +++ src/plugins/generic/evdevtouch/evdevtouch.pro | 3 +++ src/plugins/generic/evdevtouch/main.cpp | 7 +++++-- 9 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 src/plugins/generic/evdevkeyboard/evdevkeyboard.json create mode 100644 src/plugins/generic/evdevmouse/evdevmouse.json create mode 100644 src/plugins/generic/evdevtouch/evdevtouch.json diff --git a/src/plugins/generic/evdevkeyboard/evdevkeyboard.json b/src/plugins/generic/evdevkeyboard/evdevkeyboard.json new file mode 100644 index 0000000000..0e24bb0568 --- /dev/null +++ b/src/plugins/generic/evdevkeyboard/evdevkeyboard.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "EvdevKeyboard" ] +} diff --git a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro index 997a58ef6e..47608b7154 100644 --- a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro +++ b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro @@ -17,3 +17,6 @@ LIBS += -ludev SOURCES = main.cpp \ qevdevkeyboardhandler.cpp \ qevdevkeyboardmanager.cpp + +OTHER_FILES += \ + evdevkeyboard.json diff --git a/src/plugins/generic/evdevkeyboard/main.cpp b/src/plugins/generic/evdevkeyboard/main.cpp index 6df4e29fcb..71d15720bd 100644 --- a/src/plugins/generic/evdevkeyboard/main.cpp +++ b/src/plugins/generic/evdevkeyboard/main.cpp @@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE class QEvdevKeyboardPlugin : public QGenericPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevkeyboard.json") + public: QEvdevKeyboardPlugin(); @@ -72,6 +75,6 @@ QObject* QEvdevKeyboardPlugin::create(const QString &key, return 0; } -Q_EXPORT_PLUGIN2(qevdevkeyboardplugin, QEvdevKeyboardPlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/generic/evdevmouse/evdevmouse.json b/src/plugins/generic/evdevmouse/evdevmouse.json new file mode 100644 index 0000000000..00ddd3a9cf --- /dev/null +++ b/src/plugins/generic/evdevmouse/evdevmouse.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "EvdevMouse" ] +} diff --git a/src/plugins/generic/evdevmouse/evdevmouse.pro b/src/plugins/generic/evdevmouse/evdevmouse.pro index f25199161b..c5d162fb2f 100644 --- a/src/plugins/generic/evdevmouse/evdevmouse.pro +++ b/src/plugins/generic/evdevmouse/evdevmouse.pro @@ -11,3 +11,6 @@ QT += core-private platformsupport-private SOURCES = main.cpp \ qevdevmouse.cpp + +OTHER_FILES += \ + evdevmouse.json diff --git a/src/plugins/generic/evdevmouse/main.cpp b/src/plugins/generic/evdevmouse/main.cpp index 34ca62f960..47a4ddf56b 100644 --- a/src/plugins/generic/evdevmouse/main.cpp +++ b/src/plugins/generic/evdevmouse/main.cpp @@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE class QEvdevMousePlugin : public QGenericPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevmouse.json") + public: QEvdevMousePlugin(); @@ -72,6 +75,6 @@ QObject* QEvdevMousePlugin::create(const QString &key, return 0; } -Q_EXPORT_PLUGIN2(qevdevmouseplugin, QEvdevMousePlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/generic/evdevtouch/evdevtouch.json b/src/plugins/generic/evdevtouch/evdevtouch.json new file mode 100644 index 0000000000..6a6959c8e6 --- /dev/null +++ b/src/plugins/generic/evdevtouch/evdevtouch.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "EvdevTouch" ] +} diff --git a/src/plugins/generic/evdevtouch/evdevtouch.pro b/src/plugins/generic/evdevtouch/evdevtouch.pro index 78fe551aa2..284f1d1221 100644 --- a/src/plugins/generic/evdevtouch/evdevtouch.pro +++ b/src/plugins/generic/evdevtouch/evdevtouch.pro @@ -12,3 +12,6 @@ SOURCES = main.cpp \ qevdevtouch.cpp QT += core-private platformsupport-private + +OTHER_FILES += \ + evdevtouch.json diff --git a/src/plugins/generic/evdevtouch/main.cpp b/src/plugins/generic/evdevtouch/main.cpp index 526e336fd8..47b026ac96 100644 --- a/src/plugins/generic/evdevtouch/main.cpp +++ b/src/plugins/generic/evdevtouch/main.cpp @@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE class QTouchScreenPlugin : public QGenericPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevtouch.json") + public: QTouchScreenPlugin(); @@ -71,6 +74,6 @@ QObject* QTouchScreenPlugin::create(const QString &key, return 0; } -Q_EXPORT_PLUGIN2(qevdevtouchplugin, QTouchScreenPlugin) - QT_END_NAMESPACE + +#include "main.moc" From 82fb03546bdc5d71b9cb389b68b3c0d4d5a0b241 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 22 Feb 2012 09:26:27 +0100 Subject: [PATCH 002/166] Fix QJson autotest on Windows. - Fix warning: "Character represented by universal-character-name '\uFFFF' cannot be represented in the current code page (1252). - Fix character conversion - Change source file to plain ASCII, add defines for special characters. Change-Id: I8557e6ba7488f746247f0d78181f14bfb7d5aaae Reviewed-by: Miikka Heikkinen Reviewed-by: Lars Knoll --- tests/auto/corelib/json/tst_qtjson.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 2ac0574ec5..4edbd14305 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -45,6 +45,9 @@ #include "qjsonvalue.h" #include "qjsondocument.h" +#define INVALID_UNICODE "\357\277\277" // "\uffff" +#define UNICODE_DJE "\320\202" // Character from the Serbian Cyrillic alphabet + class TestQtJson: public QObject { Q_OBJECT @@ -1205,7 +1208,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"foo\uffffbar\"]"; + QByteArray json = "[\n \"foo"INVALID_UNICODE"bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1221,7 +1224,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"cЂa\\u12\"]"; + QByteArray json = "[\n \"c"UNICODE_DJE"a\\u12\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringEscapeSequence); @@ -1229,7 +1232,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"cЂa\uffffbar\"]"; + QByteArray json = "[\n \"c"UNICODE_DJE"a"INVALID_UNICODE"bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1237,7 +1240,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"cЂa ]"; + QByteArray json = "[\n \"c"UNICODE_DJE"a ]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::EndOfString); @@ -1378,7 +1381,7 @@ void TestQtJson::parseStrings() "abc\\rabc", "abc\\tabc", "abc\\u0019abc", - "abcЂabc", + "abc"UNICODE_DJE"abc", }; int size = sizeof(strings)/sizeof(const char *); @@ -1404,7 +1407,7 @@ void TestQtJson::parseStrings() }; Pairs pairs [] = { { "abc\\/abc", "abc/abc" }, - { "abc\\u0402abc", "abcЂabc" }, + { "abc\\u0402abc", "abc"UNICODE_DJE"abc" }, { "abc\\u0065abc", "abceabc" } }; size = sizeof(pairs)/sizeof(Pairs); @@ -1547,7 +1550,7 @@ void TestQtJson::validation() // only test the first 1000 bytes. Testing the full file takes too long for (int i = 0; i < 1000; ++i) { QByteArray corrupted = binary; - corrupted[i] = 0xff; + corrupted[i] = char(0xff); QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted); if (doc.isNull()) continue; @@ -1567,7 +1570,7 @@ void TestQtJson::validation() for (int i = 0; i < binary.size(); ++i) { QByteArray corrupted = binary; - corrupted[i] = 0xff; + corrupted[i] = char(0xff); QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted); if (doc.isNull()) continue; From 7401832a7d45de99562b94340375393a39267f41 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Wed, 22 Feb 2012 11:34:37 +0200 Subject: [PATCH 003/166] Refactor input context tests Combined test input context instances and adapted changed interfaces a bit. Change-Id: Id5422cac5967d45dcaf2eb71b941d9c45e3b4dee Reviewed-by: Joona Petrell --- .../kernel/qinputmethod/tst_qinputmethod.cpp | 128 +++++++----------- .../shared/platforminputcontext.h | 20 ++- .../qgraphicsscene/tst_qgraphicsscene.cpp | 2 +- .../qgraphicsview/tst_qgraphicsview.cpp | 2 +- 4 files changed, 68 insertions(+), 84 deletions(-) rename tests/auto/{widgets => }/shared/platforminputcontext.h (85%) diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index c10d954489..2ca921b557 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -44,88 +44,20 @@ #include #include #include - -class PlatformInputContext : public QPlatformInputContext -{ -public: - PlatformInputContext() : - m_animating(false), - m_visible(false), - m_updateCallCount(0), - m_resetCallCount(0), - m_commitCallCount(0), - m_localeCallCount(0), - m_inputDirectionCallCount(0), - m_lastQueries(Qt::ImhNone), - m_action(QInputMethod::Click), - m_cursorPosition(0), - m_lastEventType(QEvent::None) - {} - - virtual QRectF keyboardRect() const { return m_keyboardRect; } - virtual bool isAnimating() const { return m_animating; } - virtual void reset() { m_resetCallCount++; } - virtual void commit() { m_commitCallCount++; } - - virtual void update(Qt::InputMethodQueries queries) - { - m_updateCallCount++; - m_lastQueries = queries; - } - virtual void invokeAction(QInputMethod::Action action, int cursorPosition) - { - m_action = action; - m_cursorPosition = cursorPosition; - } - virtual bool filterEvent(const QEvent *event) - { - m_lastEventType = event->type(); return false; - } - virtual void showInputPanel() - { - m_visible = true; - } - virtual void hideInputPanel() - { - m_visible = false; - } - virtual bool isInputPanelVisible() const - { - return m_visible; - } - virtual QLocale locale() const - { - m_localeCallCount++; - return QLocale::c(); - } - virtual Qt::LayoutDirection inputDirection() const - { - m_inputDirectionCallCount++; - return Qt::LeftToRight; - } - - bool m_animating; - bool m_visible; - int m_updateCallCount; - int m_resetCallCount; - int m_commitCallCount; - mutable int m_localeCallCount; - mutable int m_inputDirectionCallCount; - Qt::InputMethodQueries m_lastQueries; - QInputMethod::Action m_action; - int m_cursorPosition; - int m_lastEventType; - QRectF m_keyboardRect; -}; +#include "../../../shared/platforminputcontext.h" class InputItem : public QObject { Q_OBJECT public: + InputItem() : m_enabled(true) {} + bool event(QEvent *event) { if (event->type() == QEvent::InputMethodQuery) { QInputMethodQueryEvent *query = static_cast(event); + if (query->queries() & Qt::ImEnabled) + query->setValue(Qt::ImEnabled, m_enabled); if (query->queries() & Qt::ImCursorRectangle) query->setValue(Qt::ImCursorRectangle, QRectF(1, 2, 3, 4)); if (query->queries() & Qt::ImPreferredLanguage) @@ -136,9 +68,39 @@ public: } return false; } + + void setEnabled(bool enabled) { + if (enabled != m_enabled) { + m_enabled = enabled; + qApp->inputMethod()->update(Qt::ImEnabled); + } + } + Qt::InputMethodQueries m_lastQueries; + bool m_enabled; }; + +class DummyWindow : public QWindow +{ +public: + DummyWindow() : m_focusObject(0) {} + + virtual QObject *focusObject() const + { + return m_focusObject; + } + + void setFocusObject(QObject *object) + { + m_focusObject = object; + emit focusObjectChanged(object); + } + + QObject *m_focusObject; +}; + + class tst_qinputmethod : public QObject { Q_OBJECT @@ -249,17 +211,22 @@ void tst_qinputmethod::cursorRectangle() { QCOMPARE(qApp->inputMethod()->cursorRectangle(), QRectF()); + DummyWindow window; + window.show(); + QTest::qWaitForWindowShown(&window); + window.requestActivateWindow(); + QTRY_COMPARE(qApp->focusWindow(), &window); + window.setFocusObject(&m_inputItem); + QTransform transform; transform.translate(10, 10); transform.scale(2, 2); transform.shear(2, 2); qApp->inputMethod()->setInputItemTransform(transform); - qApp->inputMethod()->setInputItem(&m_inputItem); QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4))); // reset - qApp->inputMethod()->setInputItem(0); qApp->inputMethod()->setInputItemTransform(QTransform()); } @@ -297,7 +264,13 @@ void tst_qinputmethod::commit() void tst_qinputmethod::update() { - qApp->inputMethod()->setInputItem(&m_inputItem); + DummyWindow window; + window.show(); + QTest::qWaitForWindowShown(&window); + window.requestActivateWindow(); + QTRY_COMPARE(qApp->focusWindow(), &window); + window.setFocusObject(&m_inputItem); + QCOMPARE(m_platformInputContext.m_updateCallCount, 0); QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImhNone)); @@ -310,9 +283,6 @@ void tst_qinputmethod::update() QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImQueryAll)); QCOMPARE(qApp->inputMethod()->keyboardRectangle(), QRectF(10, 20, 30, 40)); - - // reset - qApp->inputMethod()->setInputItem(0); } void tst_qinputmethod::query() diff --git a/tests/auto/widgets/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h similarity index 85% rename from tests/auto/widgets/shared/platforminputcontext.h rename to tests/auto/shared/platforminputcontext.h index 759123a4a6..cddeca3945 100644 --- a/tests/auto/widgets/shared/platforminputcontext.h +++ b/tests/auto/shared/platforminputcontext.h @@ -50,8 +50,10 @@ public: m_updateCallCount(0), m_resetCallCount(0), m_commitCallCount(0), + m_localeCallCount(0), + m_inputDirectionCallCount(0), m_lastQueries(Qt::ImhNone), - m_action(QInputPanel::Click), + m_action(QInputMethod::Click), m_cursorPosition(0), m_lastEventType(QEvent::None) {} @@ -66,7 +68,7 @@ public: m_updateCallCount++; m_lastQueries = queries; } - virtual void invokeAction(QInputPanel::Action action, int cursorPosition) + virtual void invokeAction(QInputMethod::Action action, int cursorPosition) { m_action = action; m_cursorPosition = cursorPosition; @@ -87,14 +89,26 @@ public: { return m_visible; } + virtual QLocale locale() const + { + m_localeCallCount++; + return QLocale::c(); + } + virtual Qt::LayoutDirection inputDirection() const + { + m_inputDirectionCallCount++; + return Qt::LeftToRight; + } bool m_animating; bool m_visible; int m_updateCallCount; int m_resetCallCount; int m_commitCallCount; + mutable int m_localeCallCount; + mutable int m_inputDirectionCallCount; Qt::InputMethodQueries m_lastQueries; - QInputPanel::Action m_action; + QInputMethod::Action m_action; int m_cursorPosition; int m_lastEventType; QRectF m_keyboardRect; diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 3257e7efea..220c89ec2f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -51,7 +51,7 @@ #include #include #include "../../../gui/painting/qpathclipper/pathcompare.h" -#include "../../shared/platforminputcontext.h" +#include "../../../shared/platforminputcontext.h" #include #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 7ceeaaa0d3..84dea04c45 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -71,7 +71,7 @@ #include #include #include "../../../platformquirks.h" -#include "../../shared/platforminputcontext.h" +#include "../../../shared/platforminputcontext.h" #include Q_DECLARE_METATYPE(QList) From 5d49ca960c942465adf0644ee382b91c35dfb650 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Thu, 16 Feb 2012 14:24:22 +0200 Subject: [PATCH 004/166] Fix typos Change-Id: Ic0389d36bad001935376fb29d8c925b7ff908e4f Reviewed-by: Joona Petrell --- src/gui/text/qabstracttextdocumentlayout.cpp | 2 +- src/widgets/util/qscrollerproperties.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index 7bf2a631ea..86de48b1dc 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -239,7 +239,7 @@ QT_BEGIN_NAMESPACE /*! \fn int QAbstractTextDocumentLayout::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const - Returns the cursor postion for the given \a point with the specified + Returns the cursor position for the given \a point with the specified \a accuracy. Returns -1 if no valid cursor position was found. */ diff --git a/src/widgets/util/qscrollerproperties.cpp b/src/widgets/util/qscrollerproperties.cpp index 6a61e4dfd1..8d6ad36014 100644 --- a/src/widgets/util/qscrollerproperties.cpp +++ b/src/widgets/util/qscrollerproperties.cpp @@ -314,7 +314,7 @@ void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &v \value MousePressEventDelay This is the time a mouse press event is delayed when starting a flick gesture in \c{[s]}. If the gesture is triggered within that time, no mouse press or release is sent to the scrolled object. If it triggers after that delay the delayed - mouse press plus a faked release event at global postion \c{QPoint(-QWIDGETSIZE_MAX, + mouse press plus a faked release event at global position \c{QPoint(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX)} is sent. If the gesture is canceled, then both the delayed mouse press plus the real release event are delivered. From 9d173c92183c30144e8bd4f115b2cd93c3da0d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 20 Feb 2012 14:11:29 +0100 Subject: [PATCH 005/166] Updated QApplication / QGuiApplication to match Qt 5 reality. Removed obsolete Q_WS_X11/WIN/MAC stuff as well. Change-Id: I8b65a0348a8cb170f3f060023fc6d9d982949b7e Reviewed-by: Casper van Donderen Reviewed-by: Laszlo Agocs --- src/gui/kernel/qguiapplication.cpp | 236 ++++++- src/widgets/kernel/qapplication.cpp | 627 +------------------ src/widgets/kernel/qapplication.h | 52 +- src/widgets/kernel/qwidgetbackingstore.cpp | 2 - src/widgets/widgets/qwidgetresizehandler.cpp | 2 - 5 files changed, 248 insertions(+), 671 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 7cb3d4b488..17208643ef 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -145,6 +145,141 @@ static bool qt_detectRTLLanguage() } +/*! + \class QGuiApplication + \brief The QGuiApplication class manages the GUI application's control + flow and main settings. + + \inmodule QtGui + + QGuiApplication contains the main event loop, where all events from the window + system and other sources are processed and dispatched. It also handles the + application's initialization and finalization. In addition, QGuiApplication handles + most of the system-wide and application-wide settings. + + For any GUI application using Qt, there is precisely \bold one QGuiApplication + object no matter whether the application has 0, 1, 2 or more windows at + any given time. For non-GUI Qt applications, use QCoreApplication instead, + as it does not depend on the \l QtGui library. + + The QGuiApplication object is accessible through the instance() function, which + returns a pointer equivalent to the global \l qApp pointer. + + QGuiApplication's main areas of responsibility are: + \list + \o It initializes the application with the user's desktop settings, + such as palette(), font() and styleHints(). It keeps + track of these properties in case the user changes the desktop + globally, for example, through some kind of control panel. + + \o It performs event handling, meaning that it receives events + from the underlying window system and dispatches them to the + relevant widgets. You can send your own events to windows by + using sendEvent() and postEvent(). + + \o It parses common command line arguments and sets its internal + state accordingly. See the \l{QGuiApplication::QGuiApplication()} + {constructor documentation} below for more details. + + \o It provides localization of strings that are visible to the + user via translate(). + + \o It provides some magical objects like the clipboard(). + + \o It knows about the application's windows. You can ask which + window is at a certain position using topLevelAt(), get a list of + topLevelWindows(), etc. + + \o It manages the application's mouse cursor handling, see + setOverrideCursor() + \endlist + + Since the QGuiApplication object does so much initialization, it \e{must} be + created before any other objects related to the user interface are created. + QGuiApplication also deals with common command line arguments. Hence, it is + usually a good idea to create it \e before any interpretation or + modification of \c argv is done in the application itself. + + \table + \header + \o{2,1} Groups of functions + + \row + \o System settings + \o desktopSettingsAware(), + setDesktopSettingsAware(), + styleHints(), + palette(), + setPalette(), + font(), + setFont(). + + \row + \o Event handling + \o exec(), + processEvents(), + exit(), + quit(). + sendEvent(), + postEvent(), + sendPostedEvents(), + removePostedEvents(), + hasPendingEvents(), + notify(). + + \row + \o Windows + \o allWindows(), + topLevelWindows(), + focusWindow(), + clipboard(), + topLevelAt(). + + \row + \o Advanced cursor handling + \o overrideCursor(), + setOverrideCursor(), + restoreOverrideCursor(). + + \row + \o Miscellaneous + \o startingUp(), + closingDown(), + type(). + \endtable + + \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop +*/ + +/*! + Initializes the window system and constructs an application object with + \a argc command line arguments in \a argv. + + \warning The data referred to by \a argc and \a argv must stay valid for + the entire lifetime of the QGuiApplication object. In addition, \a argc must + be greater than zero and \a argv must contain at least one valid character + string. + + The global \c qApp pointer refers to this application object. Only one + application object should be created. + + This application object must be constructed before any \l{QPaintDevice} + {paint devices} (including pixmaps, bitmaps etc.). + + \note \a argc and \a argv might be changed as Qt removes command line + arguments that it recognizes. + + All Qt programs automatically support the following command line options: + \list + \o -reverse, sets the application's layout direction to + Qt::RightToLeft + \o -qmljsdebugger=, activates the QML/JS debugger with a specified port. + The value must be of format port:1234[,block], where block is optional + and will make the application wait until a debugger connects to it. + \endlist + + \sa arguments() +*/ QGuiApplication::QGuiApplication(int &argc, char **argv, int flags) : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags)) { @@ -159,6 +294,9 @@ QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p) d_func()->init(); } +/*! + Destructs the application. +*/ QGuiApplication::~QGuiApplication() { Q_D(QGuiApplication); @@ -194,6 +332,10 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags application_type = QCoreApplication::GuiClient; } +/*! + Returns the QWindow that receives events tied to focus, + such as key events. +*/ QWindow *QGuiApplication::focusWindow() { return QGuiApplicationPrivate::focus_window; @@ -208,7 +350,7 @@ QWindow *QGuiApplication::focusWindow() /*! Returns the QObject in currently active window that will be final receiver of events - tied focus, such as key events. + tied to focus, such as key events. */ QObject *QGuiApplication::focusObject() { @@ -249,6 +391,11 @@ QWindowList QGuiApplication::topLevelWindows() return topLevelWindows; } +/*! + Returns the primary (or default) screen of the application. + + This will be the screen where QWindows are shown, unless otherwise specified. +*/ QScreen *QGuiApplication::primaryScreen() { if (QGuiApplicationPrivate::screen_list.isEmpty()) @@ -256,11 +403,18 @@ QScreen *QGuiApplication::primaryScreen() return QGuiApplicationPrivate::screen_list.at(0); } +/*! + Returns a list of all the screens associated with the + windowing system the application is connected to. +*/ QList QGuiApplication::screens() { return QGuiApplicationPrivate::screen_list; } +/*! + Returns the top level window at the given position, if any. +*/ QWindow *QGuiApplication::topLevelAt(const QPoint &pos) { QList screens = QGuiApplication::screens(); @@ -557,27 +711,62 @@ static QClipboard *clipboard(); #endif #endif +/*! + Returns the currently held keyboard modifiers. +*/ Qt::KeyboardModifiers QGuiApplication::keyboardModifiers() { return QGuiApplicationPrivate::modifier_buttons; } +/*! + Returns the currently held mouse buttons. +*/ Qt::MouseButtons QGuiApplication::mouseButtons() { return QGuiApplicationPrivate::mouse_buttons; } +/*! + Returns the platform's native interface, for platform specific + functionality. +*/ QPlatformNativeInterface *QGuiApplication::platformNativeInterface() { QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); return pi->nativeInterface(); } +/*! + Enters the main event loop and waits until exit() is called, and then + returns the value that was set to exit() (which is 0 if exit() is called + via quit()). + + It is necessary to call this function to start event handling. The main + event loop receives events from the window system and dispatches these to + the application widgets. + + Generally, no user interaction can take place before calling exec(). + + To make your application perform idle processing, e.g., executing a special + function whenever there are no pending events, use a QTimer with 0 timeout. + More advanced idle processing schemes can be achieved using processEvents(). + + We recommend that you connect clean-up code to the + \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your + application's \c{main()} function. This is because, on some platforms, the + QApplication::exec() call may not return. + + \sa quitOnLastWindowClosed, quit(), exit(), processEvents(), + QCoreApplication::exec() +*/ int QGuiApplication::exec() { return QCoreApplication::exec(); } +/*! \reimp +*/ bool QGuiApplication::notify(QObject *object, QEvent *event) { #ifndef QT_NO_SHORTCUT @@ -595,6 +784,8 @@ bool QGuiApplication::notify(QObject *object, QEvent *event) return QCoreApplication::notify(object, event); } +/*! \reimp +*/ bool QGuiApplication::event(QEvent *e) { if(e->type() == QEvent::LanguageChange) { @@ -603,6 +794,9 @@ bool QGuiApplication::event(QEvent *e) return QCoreApplication::event(e); } +/*! + \internal +*/ bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) { return QCoreApplication::compressEvent(event, receiver, postedEvents); @@ -1364,6 +1558,9 @@ Qt::DropAction QGuiApplicationPrivate::processDrop(QWindow *w, QMimeData *dropDa } #ifndef QT_NO_CLIPBOARD +/*! + Returns the object for interacting with the clipboard. +*/ QClipboard * QGuiApplication::clipboard() { if (QGuiApplicationPrivate::qt_clipboard == 0) { @@ -1378,9 +1575,9 @@ QClipboard * QGuiApplication::clipboard() #endif /*! - Returns the application palette. + Returns the default application palette. - \sa setPalette(), QWidget::palette() + \sa setPalette() */ QPalette QGuiApplication::palette() { @@ -1392,6 +1589,11 @@ QPalette QGuiApplication::palette() return *QGuiApplicationPrivate::app_pal; } +/*! + Changes the default application palette to \a palette. + + \sa palette() +*/ void QGuiApplication::setPalette(const QPalette &pal) { if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal)) @@ -1402,6 +1604,11 @@ void QGuiApplication::setPalette(const QPalette &pal) *QGuiApplicationPrivate::app_pal = pal; } +/*! + Returns the default application font. + + \sa setFont() +*/ QFont QGuiApplication::font() { QMutexLocker locker(&applicationFontMutex); @@ -1411,6 +1618,11 @@ QFont QGuiApplication::font() return *QGuiApplicationPrivate::app_font; } +/*! + Changes the default application font to \a font. + + \sa font() +*/ void QGuiApplication::setFont(const QFont &font) { QMutexLocker locker(&applicationFontMutex); @@ -1631,7 +1843,7 @@ void QGuiApplication::restoreOverrideCursor() /*! \since 5.0 - returns the style hints. + Returns the application's style hints. The style hints encapsulate a set of platform dependent properties such as double click intervals, full width selection and others. @@ -1675,6 +1887,14 @@ bool QGuiApplication::desktopSettingsAware() return QGuiApplicationPrivate::obey_desktop_settings; } +QInputMethod *QGuiApplication::inputMethod() const +{ + Q_D(const QGuiApplication); + if (!d->inputMethod) + const_cast(d)->inputMethod = new QInputMethod(); + return d->inputMethod; +} + /*! \since 5.0 @@ -1686,14 +1906,6 @@ bool QGuiApplication::desktopSettingsAware() \sa QInputPanel */ -QInputMethod *QGuiApplication::inputMethod() const -{ - Q_D(const QGuiApplication); - if (!d->inputMethod) - const_cast(d)->inputMethod = new QInputMethod(); - return d->inputMethod; -} - QInputPanel *QGuiApplication::inputPanel() const { return inputMethod(); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index f7153a0f32..134b1809bb 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -76,10 +76,6 @@ #include "private/qkeymapper_p.h" -#ifdef Q_WS_X11 -#include -#endif - #include #include @@ -87,10 +83,6 @@ #include -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) -#include -#endif - #include "qapplication_p.h" #include "private/qevent_p.h" #include "qwidget_p.h" @@ -114,10 +106,6 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp #include "qdatetime.h" -#ifdef Q_WS_MAC -#include -#endif - //#define ALIEN_DEBUG static void initResources() @@ -156,24 +144,11 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T is_session_restored = false; #endif -#if defined(Q_WS_QWS) && !defined(QT_NO_DIRECTPAINTER) - directPainters = 0; -#endif - #ifndef QT_NO_GESTURES gestureManager = 0; gestureWidget = 0; #endif // QT_NO_GESTURES -#if defined(Q_WS_X11) || defined(Q_WS_WIN) - move_cursor = 0; - copy_cursor = 0; - link_cursor = 0; -#endif -#if defined(Q_WS_WIN) - ignore_cursor = 0; -#endif - if (!self) self = this; } @@ -191,16 +166,14 @@ QApplicationPrivate::~QApplicationPrivate() \inmodule QtWidgets - QApplication contains the main event loop, where all events from the window - system and other sources are processed and dispatched. It also handles the - application's initialization, finalization, and provides session - management. In addition, QApplication handles most of the system-wide and - application-wide settings. + QApplication specializes QGuiApplication with some functionality needed + for QWidget-based applications. It handles widget specific initialization, + finalization, and provides session management. For any GUI application using Qt, there is precisely \bold one QApplication object, no matter whether the application has 0, 1, 2 or more windows at - any given time. For non-GUI Qt applications, use QCoreApplication instead, - as it does not depend on the \l QtGui library. + any given time. For non-QWidget based Qt applications, use QGuiApplication instead, + as it does not depend on the \l QtWidgets library. The QApplication object is accessible through the instance() function that returns a pointer equivalent to the global qApp pointer. @@ -241,9 +214,6 @@ QApplicationPrivate::~QApplicationPrivate() \o It manages the application's mouse cursor handling, see setOverrideCursor() - \o On the X window system, it provides functions to flush and sync - the communication stream, see flushX() and syncX(). - \o It provides support for sophisticated \l{Session Management} {session management}. This makes it possible for applications to terminate gracefully when the user logs out, to cancel a @@ -291,12 +261,7 @@ QApplicationPrivate::~QApplicationPrivate() sendPostedEvents(), removePostedEvents(), hasPendingEvents(), - notify(), - macEventFilter(), - qwsEventFilter(), - x11EventFilter(), - x11ProcessEvent(), - winEventFilter(). + notify(). \row \o GUI Styles @@ -306,8 +271,7 @@ QApplicationPrivate::~QApplicationPrivate() \row \o Color usage \o colorSpec(), - setColorSpec(), - qwsSetCustomColors(). + setColorSpec(). \row \o Text handling @@ -333,11 +297,6 @@ QApplicationPrivate::~QApplicationPrivate() setOverrideCursor(), restoreOverrideCursor(). - \row - \o X Window System synchronization - \o flushX(), - syncX(). - \row \o Session management \o isSessionRestored(), @@ -391,9 +350,6 @@ QApplicationPrivate::~QApplicationPrivate() */ void qt_init(QApplicationPrivate *priv, int type -#ifdef Q_WS_X11 - , Display *display = 0, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0 -#endif ); void qt_cleanup(); @@ -560,19 +516,6 @@ void QApplicationPrivate::process_cmdline() \note \a argc and \a argv might be changed as Qt removes command line arguments that it recognizes. - Qt debugging options (not available if Qt was compiled without the QT_DEBUG - flag defined): - \list - \o -nograb, tells Qt that it must never grab the mouse or the - keyboard. - \o -dograb (only under X11), running under a debugger can cause an - implicit -nograb, use -dograb to override. - \o -sync (only under X11), switches to synchronous mode for - debugging. - \endlist - - See \l{Debugging Techniques} for a more detailed explanation. - All Qt programs automatically support the following command line options: \list \o -style= \e style, sets the application GUI style. Possible values @@ -598,45 +541,6 @@ void QApplicationPrivate::process_cmdline() and will make the application wait until a debugger connects to it. \endlist - The X11 version of Qt supports some traditional X11 command line options: - \list - \o -display \e display, sets the X display (default is $DISPLAY). - \o -geometry \e geometry, sets the client geometry of the first window - that is shown. - \o -fn or \c -font \e font, defines the application font. The font - should be specified using an X logical font description. Note that - this option is ignored when Qt is built with fontconfig support enabled. - \o -bg or \c -background \e color, sets the default background color - and an application palette (light and dark shades are calculated). - \o -fg or \c -foreground \e color, sets the default foreground color. - \o -btn or \c -button \e color, sets the default button color. - \o -name \e name, sets the application name. - \o -title \e title, sets the application title. - \o -visual \c TrueColor, forces the application to use a TrueColor - visual on an 8-bit display. - \o -ncols \e count, limits the number of colors allocated in the color - cube on an 8-bit display, if the application is using the - QApplication::ManyColor color specification. If \e count is 216 - then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green, - and 6 of blue); for other values, a cube approximately proportional - to a 2x3x1 cube is used. - \o -cmap, causes the application to install a private color map on an - 8-bit display. - \o -im, sets the input method server (equivalent to setting the - XMODIFIERS environment variable) - \o -inputstyle, defines how the input is inserted into the given - widget, e.g., \c onTheSpot makes the input appear directly in the - widget, while \c overTheSpot makes the input appear in a box - floating over the widget and is not inserted until the editing is - done. - \endlist - - \section1 X11 Notes - - If QApplication fails to open the X11 display, it will terminate - the process. This behavior is consistent with most X11 - applications. - \sa arguments() */ @@ -651,26 +555,18 @@ QApplication::QApplication(int &argc, char **argv, int _internal) /*! Constructs an application object with \a argc command line arguments in - \a argv. If \a GUIenabled is true, a GUI application is constructed, - otherwise a non-GUI (console) application is created. + \a argv. \warning The data referred to by \a argc and \a argv must stay valid for the entire lifetime of the QApplication object. In addition, \a argc must be greater than zero and \a argv must contain at least one valid character string. - Set \a GUIenabled to false for programs without a graphical user interface - that should be able to run without a window system. - - On X11, the window system is initialized if \a GUIenabled is true. If - \a GUIenabled is false, the application does not connect to the X server. - On Windows and Mac OS, currently the window system is always initialized, - regardless of the value of GUIenabled. This may change in future versions - of Qt. - The following example shows how to create an application that uses a graphical interface when available. + \obsolete + \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0 */ @@ -692,10 +588,6 @@ QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _intern the entire lifetime of the QApplication object. In addition, \a argc must be greater than zero and \a argv must contain at least one valid character string. - - With Qt for Embedded Linux, passing QApplication::GuiServer for \a type - makes this application the server (equivalent to running with the - \c -qws option). */ QApplication::QApplication(int &argc, char **argv, Type type) : QGuiApplication(*new QApplicationPrivate(argc, argv, type, 0x040000)) @@ -705,22 +597,10 @@ QApplication::QApplication(int &argc, char **argv, Type type , int _internal) : QGuiApplication(*new QApplicationPrivate(argc, argv, type, _internal)) { Q_D(QApplication); d->construct(); } -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) -static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data) -{ - const char *name = static_cast(data); - return strstr(info->dlpi_name, name) != 0; -} -#endif - /*! \internal */ -void QApplicationPrivate::construct( -#ifdef Q_WS_X11 - Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap -#endif - ) +void QApplicationPrivate::construct() { initResources(); @@ -728,11 +608,7 @@ void QApplicationPrivate::construct( process_cmdline(); // Must be called before initialize() - qt_init(this, application_type -#ifdef Q_WS_X11 - , dpy, visual, cmap -#endif - ); + qt_init(this, application_type); initialize(); eventDispatcher->startingUp(); @@ -759,82 +635,6 @@ void QApplicationPrivate::construct( #endif } -#if defined(Q_WS_X11) -// ### a string literal is a cont char* -// ### using it as a char* is wrong and could lead to segfaults -// ### if aargv is modified someday -// ########## make it work with argc == argv == 0 -static int aargc = 1; -static char *aargv[] = { (char*)"unknown", 0 }; - -/*! - \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap) - - Creates an application, given an already open display \a display. If - \a visual and \a colormap are non-zero, the application will use those - values as the default Visual and Colormap contexts. - - \warning Qt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This function is only available on X11. -*/ -QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap) - : QGuiApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, 0x040000)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); -} - -QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) - : QGuiApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, _internal)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); - QApplicationPrivate::app_compile_version = _internal; -} - -/*! - \fn QApplication::QApplication(Display *display, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap) - - Creates an application, given an already open \a display and using \a argc - command line arguments in \a argv. If \a visual and \a colormap are - non-zero, the application will use those values as the default Visual - and Colormap contexts. - - \warning Qt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This function is only available on X11. -*/ -QApplication::QApplication(Display *dpy, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap) - : QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); -} - -QApplication::QApplication(Display *dpy, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) - : QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); - QApplicationPrivate::app_compile_version = _internal; -} - -#endif // Q_WS_X11 - #ifndef QT_NO_STATEMACHINE void qRegisterGuiStateMachine(); void qUnregisterGuiStateMachine(); @@ -981,15 +781,6 @@ QApplication::~QApplication() delete qt_desktopWidget; qt_desktopWidget = 0; -#if defined(Q_WS_X11) || defined(Q_WS_WIN) - delete d->move_cursor; d->move_cursor = 0; - delete d->copy_cursor; d->copy_cursor = 0; - delete d->link_cursor; d->link_cursor = 0; -#endif -#if defined(Q_WS_WIN) - delete d->ignore_cursor; d->ignore_cursor = 0; -#endif - delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; delete QApplicationPrivate::sys_pal; @@ -1731,14 +1522,6 @@ QFont QApplication::font(const QWidget *widget) { FontHash *hash = app_fonts(); -#ifdef Q_WS_MAC - // short circuit for small and mini controls - if (widget->testAttribute(Qt::WA_MacSmallSize)) { - return hash->value("QSmallFont"); - } else if (widget->testAttribute(Qt::WA_MacMiniSize)) { - return hash->value("QMiniFont"); - } -#endif if (widget && hash && hash->size()) { QHash::ConstIterator it = hash->constFind(widget->metaObject()->className()); @@ -1877,11 +1660,6 @@ void QApplication::setWindowIcon(const QIcon &icon) QApplicationPrivate::app_icon = new QIcon(); *QApplicationPrivate::app_icon = icon; if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { -#ifdef Q_WS_MAC - void qt_mac_set_app_icon(const QPixmap &); //qapplication_mac.cpp - QSize size = QApplicationPrivate::app_icon->actualSize(QSize(128, 128)); - qt_mac_set_app_icon(QApplicationPrivate::app_icon->pixmap(size)); -#endif QEvent e(QEvent::ApplicationWindowIconChange); QWidgetList all = QApplication::allWidgets(); for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { @@ -2094,13 +1872,7 @@ void QApplication::closeAllWindows() void QApplication::aboutQt() { #ifndef QT_NO_MESSAGEBOX - QMessageBox::aboutQt( -#ifdef Q_WS_MAC - 0 -#else - activeWindow() -#endif // Q_WS_MAC - ); + QMessageBox::aboutQt(activeWindow()); #endif // QT_NO_MESSAGEBOX } @@ -2184,9 +1956,6 @@ bool QApplication::event(QEvent *e) } if(e->type() == QEvent::LanguageChange) { -#ifdef Q_WS_MAC - qt_mac_post_retranslateAppMenu(); -#endif QWidgetList list = topLevelWidgets(); for (int i = 0; i < list.size(); ++i) { QWidget *w = list.at(i); @@ -2198,13 +1967,14 @@ bool QApplication::event(QEvent *e) return QGuiApplication::event(e); } -#if !defined(Q_WS_X11) - -// The doc and X implementation of this function is in qapplication_x11.cpp - -void QApplication::syncX() {} // do nothing - -#endif +/*! + Was used to synchronize with the X server in 4.x, here for source compatibility. + \internal + \obsolete +*/ +void QApplication::syncX() +{ +} void QApplicationPrivate::notifyLayoutDirectionChange() { @@ -2298,13 +2068,6 @@ void QApplication::setActiveWindow(QWidget* act) sendSpontaneousEvent(w, &activationChange); } -#ifdef Q_WS_MAC - // In case the user clicked on a child window, we need to - // reestablish the stacking order of the window so - // it pops in front of other child windows in cocoa: - qt_cocoaStackChildWindowOnTopOfOtherChildren(window); -#endif - for(int i = 0; i < toBeDeactivated.size(); ++i) { QWidget *w = toBeDeactivated.at(i); sendSpontaneousEvent(w, &windowDeactivate); @@ -2455,10 +2218,6 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { for (int i = 0; i < leaveList.size(); ++i) { w = leaveList.at(i); if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) - if (leaveAfterRelease == w) - leaveAfterRelease = 0; -#endif QApplication::sendEvent(w, &leaveEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { @@ -2511,9 +2270,6 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { if (!parentOfLeavingCursor->window()->graphicsProxyWidget()) #endif { -#if defined(Q_WS_X11) - qt_x11_enforce_cursor(parentOfLeavingCursor,true); -#endif if (enter == QApplication::desktop()) { qt_qpa_set_cursor(enter, true); } else { @@ -2535,13 +2291,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { } else #endif { -#if defined(Q_WS_WIN) - qt_win_set_cursor(cursorWidget, true); -#elif defined(Q_WS_X11) - qt_x11_enforce_cursor(cursorWidget, true); -#else qt_qpa_set_cursor(cursorWidget, true); -#endif } } #endif @@ -2575,12 +2325,6 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) return false; w = w->parentWidget(); } -#ifdef Q_WS_WIN - if ((widget->testAttribute(Qt::WA_WState_Created) || widget->data->winid) - && (modalWidget->testAttribute(Qt::WA_WState_Created) || modalWidget->data->winid) - && IsChild(modalWidget->data->winid, widget->data->winid)) - return false; -#endif } Qt::WindowModality windowModality = modalWidget->windowModality(); @@ -2708,12 +2452,6 @@ bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop) if (QApplication::activePopupWidget()) return true; -#if defined(Q_WS_MAC) - top = QApplicationPrivate::tryModalHelper_sys(top); - if (rettop) - *rettop = top; -#endif - return !isBlockedByModal(widget->window()); } @@ -3726,16 +3464,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) case QEvent::DragEnter: { QWidget* w = static_cast(receiver); QDragEnterEvent *dragEvent = static_cast(e); -#ifdef Q_WS_MAC - // HIView has a slight difference in how it delivers events to children and parents - // It will not give a leave to a child's parent when it enters a child. - QWidget *currentTarget = QDragManager::self()->currentTarget(); - if (currentTarget) { - // Assume currentTarget did not get a leave - QDragLeaveEvent event; - QApplication::sendEvent(currentTarget, &event); - } -#endif #ifndef QT_NO_GRAPHICSVIEW // QGraphicsProxyWidget handles its own propagation, // and we must not change QDragManagers currentTarget. @@ -3774,20 +3502,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) w = qobject_cast(QDragManager::self()->currentTarget()); if (!w) { -#ifdef Q_WS_MAC - // HIView has a slight difference in how it delivers events to children and parents - // It will not give an enter to a child's parent when it leaves the child. - if (e->type() == QEvent::DragLeave) - break; - // Assume that w did not get an enter. - QDropEvent *dropEvent = static_cast(e); - QDragEnterEvent dragEnterEvent(dropEvent->pos(), dropEvent->possibleActions(), - dropEvent->mimeData(), dropEvent->mouseButtons(), - dropEvent->keyboardModifiers()); - QApplication::sendEvent(receiver, &dragEnterEvent); - w = QDragManager::self()->currentTarget(); - if (!w) -#endif break; } if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) { @@ -3951,24 +3665,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) break; } #endif // QT_NO_GESTURES -#ifdef Q_WS_MAC - case QEvent::Enter: - if (receiver->isWidgetType()) { - QWidget *w = static_cast(receiver); - if (w->testAttribute(Qt::WA_AcceptTouchEvents)) - qt_widget_private(w)->registerTouchWindow(true); - } - res = d->notify_helper(receiver, e); - break; - case QEvent::Leave: - if (receiver->isWidgetType()) { - QWidget *w = static_cast(receiver); - if (w->testAttribute(Qt::WA_AcceptTouchEvents)) - qt_widget_private(w)->registerTouchWindow(false); - } - res = d->notify_helper(receiver, e); - break; -#endif default: res = d->notify_helper(receiver, e); break; @@ -4304,168 +4000,6 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) \sa isPhase2() */ -/***************************************************************************** - Stubbed session management support - *****************************************************************************/ -#ifndef QT_NO_SESSIONMANAGER -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_QWS) - -#if defined(Q_OS_WINCE) -HRESULT qt_CoCreateGuid(GUID* guid) -{ - // We will use the following information to create the GUID - // 1. absolute path to application - wchar_t tempFilename[MAX_PATH]; - if (!GetModuleFileName(0, tempFilename, MAX_PATH)) - return S_FALSE; - unsigned int hash = qHash(QString::fromWCharArray(tempFilename)); - guid->Data1 = hash; - // 2. creation time of file - QFileInfo info(QString::fromWCharArray(tempFilename)); - guid->Data2 = qHash(info.created().toTime_t()); - // 3. current system time - guid->Data3 = qHash(QDateTime::currentDateTime().toTime_t()); - return S_OK; -} -#if !defined(OLE32_MCOMGUID) || defined(QT_WINCE_FORCE_CREATE_GUID) -#define CoCreateGuid qt_CoCreateGuid -#endif - -#endif - -class QSessionManagerPrivate : public QObjectPrivate -{ -public: - QStringList restartCommand; - QStringList discardCommand; - QString sessionId; - QString sessionKey; - QSessionManager::RestartHint restartHint; -}; - -QSessionManager* qt_session_manager_self = 0; -QSessionManager::QSessionManager(QApplication * app, QString &id, QString &key) - : QObject(*new QSessionManagerPrivate, app) -{ - Q_D(QSessionManager); - setObjectName(QLatin1String("qt_sessionmanager")); - qt_session_manager_self = this; -#if defined(Q_WS_WIN) - wchar_t guidstr[40]; - GUID guid; - CoCreateGuid(&guid); - StringFromGUID2(guid, guidstr, 40); - id = QString::fromWCharArray(guidstr); - CoCreateGuid(&guid); - StringFromGUID2(guid, guidstr, 40); - key = QString::fromWCharArray(guidstr); -#endif - d->sessionId = id; - d->sessionKey = key; - d->restartHint = RestartIfRunning; -} - -QSessionManager::~QSessionManager() -{ - qt_session_manager_self = 0; -} - -QString QSessionManager::sessionId() const -{ - Q_D(const QSessionManager); - return d->sessionId; -} - -QString QSessionManager::sessionKey() const -{ - Q_D(const QSessionManager); - return d->sessionKey; -} - - -#if defined(Q_WS_X11) || defined(Q_WS_MAC) -void* QSessionManager::handle() const -{ - return 0; -} -#endif - -#if !defined(Q_WS_WIN) -bool QSessionManager::allowsInteraction() -{ - return true; -} - -bool QSessionManager::allowsErrorInteraction() -{ - return true; -} -void QSessionManager::release() -{ -} - -void QSessionManager::cancel() -{ -} -#endif - - -void QSessionManager::setRestartHint(QSessionManager::RestartHint hint) -{ - Q_D(QSessionManager); - d->restartHint = hint; -} - -QSessionManager::RestartHint QSessionManager::restartHint() const -{ - Q_D(const QSessionManager); - return d->restartHint; -} - -void QSessionManager::setRestartCommand(const QStringList& command) -{ - Q_D(QSessionManager); - d->restartCommand = command; -} - -QStringList QSessionManager::restartCommand() const -{ - Q_D(const QSessionManager); - return d->restartCommand; -} - -void QSessionManager::setDiscardCommand(const QStringList& command) -{ - Q_D(QSessionManager); - d->discardCommand = command; -} - -QStringList QSessionManager::discardCommand() const -{ - Q_D(const QSessionManager); - return d->discardCommand; -} - -void QSessionManager::setManagerProperty(const QString&, const QString&) -{ -} - -void QSessionManager::setManagerProperty(const QString&, const QStringList&) -{ -} - -bool QSessionManager::isPhase2() const -{ - return false; -} - -void QSessionManager::requestPhase2() -{ -} - -#endif -#endif // QT_NO_SESSIONMANAGER - /*! \typedef QApplication::ColorMode \compat @@ -4895,120 +4429,6 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) return true; } -/*! \fn QDecoration &QApplication::qwsDecoration() - Return the QWSDecoration used for decorating windows. - - \warning This method is non-portable. It is only available in - Qt for Embedded Linux. - - \sa QDecoration -*/ - -/*! - \fn void QApplication::qwsSetDecoration(QDecoration *decoration) - - Sets the QDecoration derived class to use for decorating the - windows used by Qt for Embedded Linux to the \a decoration - specified. - - This method is non-portable. It is only available in Qt for Embedded Linux. - - \sa QDecoration -*/ - -/*! \fn QDecoration* QApplication::qwsSetDecoration(const QString &decoration) - \overload - - Requests a QDecoration object for \a decoration from the - QDecorationFactory. - - The string must be one of the QDecorationFactory::keys(). Keys are case - insensitive. - - A later call to the QApplication constructor will override the requested - style when a "-style" option is passed in as a commandline parameter. - - Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object - returned is set as the application's GUI style. -*/ - -/*! - \fn bool QApplication::qwsEventFilter(QWSEvent *event) - - This virtual function is only implemented under Qt for Embedded Linux. - - If you create an application that inherits QApplication and - reimplement this function, you get direct access to all QWS (Q - Window System) events that the are received from the QWS master - process. The events are passed in the \a event parameter. - - Return true if you want to stop the event from being processed. - Return false for normal event dispatching. The default - implementation returns false. -*/ - -/*! \fn void QApplication::qwsSetCustomColors(QRgb *colorTable, int start, int numColors) - Set Qt for Embedded Linux custom color table. - - Qt for Embedded Linux on 8-bpp displays allocates a standard 216 color cube. - The remaining 40 colors may be used by setting a custom color - table in the QWS master process before any clients connect. - - \a colorTable is an array of up to 40 custom colors. \a start is - the starting index (0-39) and \a numColors is the number of colors - to be set (1-40). - - This method is non-portable. It is available \e only in - Qt for Embedded Linux. - - \note The custom colors will not be used by the default screen - driver. To make use of the new colors, implement a custom screen - driver, or use QDirectPainter. -*/ - -/*! \fn int QApplication::qwsProcessEvent(QWSEvent* event) - \internal -*/ - -/*! \fn int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only) - \internal -*/ - -/*! \fn int QApplication::x11ProcessEvent(XEvent* event) - This function does the core processing of individual X - \a{event}s, normally by dispatching Qt events to the right - destination. - - It returns 1 if the event was consumed by special handling, 0 if - the \a event was consumed by normal handling, and -1 if the \a - event was for an unrecognized widget. - - \sa x11EventFilter() -*/ - -/*! - \fn bool QApplication::x11EventFilter(XEvent *event) - - \warning This virtual function is only implemented under X11. - - If you create an application that inherits QApplication and - reimplement this function, you get direct access to all X events - that the are received from the X server. The events are passed in - the \a event parameter. - - Return true if you want to stop the event from being processed. - Return false for normal event dispatching. The default - implementation returns false. - - It is only the directly addressed messages that are filtered. - You must install an event filter directly on the event - dispatcher, which is returned by - QAbstractEventDispatcher::instance(), to handle system wide - messages. - - \sa x11ProcessEvent() -*/ - /*! \fn void QApplication::winFocus(QWidget *widget, bool gotFocus) \internal \since 4.1 @@ -5021,11 +4441,6 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) \internal */ -/*! \fn void QApplication::syncX() - Synchronizes with the X server in the X11 implementation. - This normally takes some time. Does nothing on other platforms. -*/ - void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent) { for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 503b36aec6..060765969f 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -98,12 +98,8 @@ public: #ifndef qdoc QApplication(int &argc, char **argv, int = ApplicationFlags); - QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); + QT_DEPRECATED QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); QApplication(int &argc, char **argv, Type, int = ApplicationFlags); -#if defined(Q_WS_X11) - QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = ApplicationFlags); - QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = ApplicationFlags); -#endif #endif virtual ~QApplication(); @@ -150,7 +146,7 @@ public: static QWidget *topLevelAt(const QPoint &p); static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); } - static void syncX(); + QT_DEPRECATED static void syncX(); static void beep(); static void alert(QWidget *widget, int duration = 0); @@ -182,31 +178,8 @@ public: static bool isEffectEnabled(Qt::UIEffect); static void setEffectEnabled(Qt::UIEffect, bool enable = true); -#if defined(Q_WS_MAC) - virtual bool macEventFilter(EventHandlerCallRef, EventRef); -#endif -#if defined(Q_WS_X11) - virtual bool x11EventFilter(XEvent *); - virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only); - int x11ProcessEvent(XEvent*); -#endif -#if defined(Q_WS_QWS) - virtual bool qwsEventFilter(QWSEvent *); - int qwsProcessEvent(QWSEvent*); - void qwsSetCustomColors(QRgb *colortable, int start, int numColors); -#ifndef QT_NO_QWS_MANAGER - static QDecoration &qwsDecoration(); - static void qwsSetDecoration(QDecoration *); - static QDecoration *qwsSetDecoration(const QString &decoration); -#endif -#endif - static QPlatformNativeInterface *platformNativeInterface(); -#if defined(Q_WS_WIN) - void winFocus(QWidget *, bool); - static void winMouseButtonUp(); -#endif #ifndef QT_NO_SESSIONMANAGER // session management bool isSessionRestored() const; @@ -252,21 +225,14 @@ public Q_SLOTS: static void aboutQt(); protected: -#if defined(Q_WS_QWS) - void setArgs(int, char **); -#endif bool event(QEvent *); bool compressEvent(QEvent *, QObject *receiver, QPostEventList *); #if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc) QApplication(int &argc, char **argv); - QApplication(int &argc, char **argv, bool GUIenabled); + QT_DEPRECATED QApplication(int &argc, char **argv, bool GUIenabled); QApplication(int &argc, char **argv, Type); -#if defined(Q_WS_X11) - QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); - QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); -#endif #endif private: @@ -291,21 +257,9 @@ private: #endif friend class QAction; -#if defined(Q_WS_QWS) - friend class QWSDirectPainterSurface; - friend class QDirectPainter; - friend class QDirectPainterPrivate; -#endif #ifndef QT_NO_GESTURES friend class QGestureManager; #endif - -#if defined(Q_WS_MAC) || defined(Q_WS_X11) - Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut()) -#endif -#if defined(QT_RX71_MULTITOUCH) - Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents()) -#endif }; QT_END_NAMESPACE diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 978e989a00..b331356e66 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -220,8 +220,6 @@ void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePa if (pe) pe->setSystemClip(QRegion()); - QApplication::syncX(); - #if defined(Q_OS_UNIX) ::usleep(1000 * msec); #endif diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index aba0ca58c6..5380fb798c 100644 --- a/src/widgets/widgets/qwidgetresizehandler.cpp +++ b/src/widgets/widgets/qwidgetresizehandler.cpp @@ -326,8 +326,6 @@ void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e) else widget->setGeometry(geom); } - - QApplication::syncX(); } void QWidgetResizeHandler::setMouseCursor(MousePosition m) From 186692f81f2612c3cf3a4090cbf949f2fb1558f8 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 30 Jan 2012 14:23:22 +0200 Subject: [PATCH 006/166] Remove custom text codec for C strings. This setting is extremely harmful, as code cannot know whether or not to expect it. It also made the behaviour of QString::fromAscii and ::toAscii unintuitive, and caused a lot of people to make mistakes with it. Change-Id: I2f429fa7ef93bd75bb93a7f64c56db15b7283388 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- dist/changes-5.0.0 | 4 + src/corelib/codecs/qtextcodec.cpp | 30 +------- src/corelib/codecs/qtextcodec.h | 5 -- src/corelib/kernel/qvariant.cpp | 6 +- src/corelib/tools/qchar.cpp | 63 ++++----------- src/corelib/tools/qchar.h | 13 ++-- src/corelib/tools/qstring.cpp | 76 +++---------------- src/corelib/tools/qstring.h | 9 --- src/corelib/tools/qstringbuilder.cpp | 16 ---- src/corelib/tools/qstringbuilder.h | 14 +--- .../corelib/tools/qstring/tst_qstring.cpp | 18 +---- .../qstringbuilder1/stringbuilder.cpp | 16 +++- .../other/collections/tst_collections.cpp | 7 +- 13 files changed, 61 insertions(+), 216 deletions(-) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 292f5ffba0..8d928208de 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -295,6 +295,10 @@ QtCore * The QDate::addDays() and QDateTime::addDays() methods now take a qint64 * The QDate::daysTo() and QDateTime::daysTo() methods now return a qint64 +* QTextCodec::codecForCStrings() and QTextCodec::setCodecForCStrings() have both + been removed. This was removed due to issues with breaking other code from + libraries, creating uncertainty/bugs in using QString easily, and (to a lesser + extent) performance issues. * QIntValidator and QDoubleValidator no longer fall back to using the C locale if the requested locale fails to validate the input. diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 82e5c9a1c3..68866b9000 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -1495,35 +1495,7 @@ QString QTextDecoder::toUnicode(const QByteArray &ba) files to be loaded. For details of internationalization, see \l{Internationalization with Qt}. - \sa codecForTr(), setCodecForCStrings() -*/ - - -/*! - \fn QTextCodec* QTextCodec::codecForCStrings() - - Returns the codec used by QString to convert to and from \c{const - char *} and QByteArrays. If this function returns 0 (the default), - QString assumes Latin-1. - - \sa setCodecForCStrings() -*/ - -/*! - \fn void QTextCodec::setCodecForCStrings(QTextCodec *codec) - \nonreentrant - - Sets the codec used by QString to convert to and from \c{const - char *} and QByteArrays. If the \a codec is 0 (the default), - QString assumes Latin-1. - - \warning Some codecs do not preserve the characters in the ASCII - range (0x00 to 0x7F). For example, the Japanese Shift-JIS - encoding maps the backslash character (0x5A) to the Yen - character. To avoid undesirable side-effects, we recommend - avoiding such codecs with setCodecsForCString(). - - \sa codecForCStrings(), setCodecForTr() + \sa codecForTr() */ /*! diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h index 9e46863964..ad37005e92 100644 --- a/src/corelib/codecs/qtextcodec.h +++ b/src/corelib/codecs/qtextcodec.h @@ -75,9 +75,6 @@ public: static QTextCodec* codecForTr(); static void setCodecForTr(QTextCodec *c); - static QTextCodec* codecForCStrings(); - static void setCodecForCStrings(QTextCodec *c); - static QTextCodec *codecForHtml(const QByteArray &ba); static QTextCodec *codecForHtml(const QByteArray &ba, QTextCodec *defaultCodec); @@ -139,8 +136,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QTextCodec::ConversionFlags) inline QTextCodec* QTextCodec::codecForTr() { return validCodecs() ? cftr : 0; } inline void QTextCodec::setCodecForTr(QTextCodec *c) { cftr = c; } -inline QTextCodec* QTextCodec::codecForCStrings() { return validCodecs() ? QString::codecForCStrings : 0; } -inline void QTextCodec::setCodecForCStrings(QTextCodec *c) { QString::codecForCStrings = c; } class Q_CORE_EXPORT QTextEncoder { Q_DISABLE_COPY(QTextEncoder) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 4e7fd94141..9f57cd018c 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1162,8 +1162,8 @@ QVariant::QVariant(QDataStream &s) \fn QVariant::QVariant(const char *val) Constructs a new variant with a string value of \a val. - The variant creates a deep copy of \a val, using the encoding - set by QTextCodec::setCodecForCStrings(). + The variant creates a deep copy of \a val into a QString assuming + UTF-8 encoding on the input \a val. Note that \a val is converted to a QString for storing in the variant and QVariant::type() will return QMetaType::QString for @@ -1171,8 +1171,6 @@ QVariant::QVariant(QDataStream &s) You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. - - \sa QTextCodec::setCodecForCStrings() */ #ifndef QT_NO_CAST_FROM_ASCII diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 01241dce6b..0261843a3a 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -413,33 +413,16 @@ QT_BEGIN_NAMESPACE */ /*! + \fn QChar::QChar(char ch) + Constructs a QChar corresponding to ASCII/Latin-1 character \a ch. */ -QChar::QChar(char ch) -{ -#ifndef QT_NO_CODEC_FOR_C_STRINGS - if (QTextCodec::codecForCStrings()) - // ##### - ucs = QTextCodec::codecForCStrings()->toUnicode(&ch, 1).at(0).unicode(); - else -#endif - ucs = uchar(ch); -} /*! + \fn QChar::QChar(uchar ch) + Constructs a QChar corresponding to ASCII/Latin-1 character \a ch. */ -QChar::QChar(uchar ch) -{ -#ifndef QT_NO_CODEC_FOR_C_STRINGS - if (QTextCodec::codecForCStrings()) { - // ##### - char c = char(ch); - ucs = QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode(); - } else -#endif - ucs = ch; -} /*! \fn QChar::QChar(uchar cell, uchar row) @@ -1256,49 +1239,35 @@ ushort QChar::toCaseFolded(ushort ucs2) Returns the Latin-1 character equivalent to the QChar, or 0. This is mainly useful for non-internationalized software. - \sa toAscii(), unicode(), QTextCodec::codecForCStrings() + \sa toAscii(), unicode() */ /*! - Returns the character value of the QChar obtained using the current - codec used to read C strings, or 0 if the character is not representable - using this codec. The default codec handles Latin-1 encoded text, - but this can be changed to assist developers writing source code using - other encodings. + \fn char QChar::toAscii() const + + Returns the Latin-1 character value of the QChar, or 0 if the character is not + representable. The main purpose of this function is to preserve ASCII characters used in C strings. This is mainly useful for developers of non-internationalized software. - \sa toLatin1(), unicode(), QTextCodec::codecForCStrings() + \note It is not possible to distinguish a non-Latin 1 character from an ASCII 0 + (NUL) character. Prefer to use unicode(), which does not have this ambiguity. + + \sa toLatin1(), unicode() */ -char QChar::toAscii() const -{ -#ifndef QT_NO_CODEC_FOR_C_STRINGS - if (QTextCodec::codecForCStrings()) - // ##### - return QTextCodec::codecForCStrings()->fromUnicode(QString(*this)).at(0); -#endif - return ucs > 0xff ? 0 : char(ucs); -} /*! + \fn QChar QChar::fromAscii(char) + Converts the ASCII character \a c to it's equivalent QChar. This is mainly useful for non-internationalized software. An alternative is to use QLatin1Char. - \sa fromLatin1(), unicode(), QTextCodec::codecForCStrings() + \sa fromLatin1(), unicode() */ -QChar QChar::fromAscii(char c) -{ -#ifndef QT_NO_CODEC_FOR_C_STRINGS - if (QTextCodec::codecForCStrings()) - // ##### - return QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode(); -#endif - return QChar(ushort((uchar)c)); -} #ifndef QT_NO_DATASTREAM /*! diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index df3d7eac33..d55fcdba89 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -86,9 +86,8 @@ public: Q_DECL_CONSTEXPR QChar(QLatin1Char ch) : ucs(ch.unicode()) {} // implicit #ifndef QT_NO_CAST_FROM_ASCII - // these two constructors are NOT inline const_expr! - QT_ASCII_CAST_WARN_CONSTRUCTOR explicit QChar(char c); - QT_ASCII_CAST_WARN_CONSTRUCTOR explicit QChar(uchar c); + QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTEXPR explicit QChar(char c) : ucs(uchar(c)) { } + QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTEXPR explicit QChar(uchar c) : ucs(c) { } #endif // Unicode information @@ -222,13 +221,13 @@ public: UnicodeVersion unicodeVersion() const; - char toAscii() const; + inline char toAscii() const; inline char toLatin1() const; inline ushort unicode() const { return ucs; } inline ushort &unicode() { return ucs; } - static QChar fromAscii(char c); - static QChar fromLatin1(char c); + static inline QChar fromAscii(char c); + static inline QChar fromLatin1(char c); inline bool isNull() const { return ucs == 0; } bool isPrint() const; @@ -344,8 +343,10 @@ private: Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE); +inline char QChar::toAscii() const { return ucs > 0xff ? 0 : char(ucs); } inline char QChar::toLatin1() const { return ucs > 0xff ? '\0' : char(ucs); } inline QChar QChar::fromLatin1(char c) { return QChar(ushort(uchar(c))); } +inline QChar QChar::fromAscii(char c) { return QChar(ushort(uchar(c))); } inline void QChar::setCell(uchar acell) { ucs = ushort((ucs & 0xff00) + acell); } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 704545667c..bf50159de2 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -96,10 +96,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_TEXTCODEC -QTextCodec *QString::codecForCStrings; -#endif - #ifdef QT_USE_ICU // qlocale_icu.cpp extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result); @@ -471,9 +467,8 @@ const QString::Null QString::null = { }; \snippet doc/src/snippets/qstring/main.cpp 0 QString converts the \c{const char *} data into Unicode using the - fromAscii() function. By default, fromAscii() treats character - above 128 as Latin-1 characters, but this can be changed by - calling QTextCodec::setCodecForCStrings(). + fromAscii() function. fromAscii() treats ordinals above 128 as Latin-1 + characters. In all of the QString functions that take \c{const char *} parameters, the \c{const char *} is interpreted as a classic @@ -611,9 +606,7 @@ const QString::Null QString::null = { }; toLatin1(), toUtf8(), and toLocal8Bit(). \list - \o toAscii() returns an 8-bit string encoded using the codec - specified by QTextCodec::codecForCStrings (by default, that is - Latin 1). + \o toAscii() returns a Latin-1 (ISO 8859-1) encoded 8-bit string. \o toLatin1() returns a Latin-1 (ISO 8859-1) encoded 8-bit string. \o toUtf8() returns a UTF-8 encoded 8-bit string. UTF-8 is a superset of US-ASCII (ANSI X3.4-1986) that supports the entire @@ -721,11 +714,11 @@ const QString::Null QString::null = { }; \section1 More Efficient String Construction Many strings are known at compile time. But the trivial - constructor QString("Hello"), will convert the string literal - to a QString using the codecForCStrings(). To avoid this one - can use the QStringLiteral macro to directly create the required - data at compile time. Constructing a QString out of the literal - does then not cause any overhead at runtime. + constructor QString("Hello"), will copy the contents of the string, + treating the contents as Latin-1. To avoid this one can use the + QStringLiteral macro to directly create the required data at compile + time. Constructing a QString out of the literal does then not cause + any overhead at runtime. A slightly less efficient way is to use QLatin1String. This class wraps a C string literal, precalculates it length at compile time and can @@ -3652,9 +3645,7 @@ QByteArray QString::toLatin1() const /*! Returns an 8-bit representation of the string as a QByteArray. - If a codec has been set using QTextCodec::setCodecForCStrings(), - it is used to convert Unicode to 8-bit char; otherwise this - function does the same as toLatin1(). + This function does the same as toLatin1(). Note that, despite the name, this function does not necessarily return an US-ASCII (ANSI X3.4-1986) string and its result may not be US-ASCII compatible. @@ -3663,10 +3654,6 @@ QByteArray QString::toLatin1() const */ QByteArray QString::toAscii() const { -#ifndef QT_NO_TEXTCODEC - if (codecForCStrings) - return codecForCStrings->fromUnicode(*this); -#endif // QT_NO_TEXTCODEC return toLatin1(); } @@ -3800,23 +3787,6 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size) QString::Data *QString::fromAscii_helper(const char *str, int size) { -#ifndef QT_NO_TEXTCODEC - if (codecForCStrings) { - Data *d; - if (!str) { - d = const_cast(&shared_null.str); - } else if (size == 0 || (!*str && size < 0)) { - d = const_cast(&shared_empty.str); - } else { - if (size < 0) - size = qstrlen(str); - QString s = codecForCStrings->toUnicode(str, size); - d = s.d; - d->ref.ref(); - } - return d; - } -#endif return fromLatin1_helper(str, size); } @@ -3865,11 +3835,7 @@ QString QString::fromLocal8Bit_helper(const char *str, int size) If \a size is -1 (default), it is taken to be strlen(\a str). - Note that, despite the name, this function actually uses the codec - defined by QTextCodec::setCodecForCStrings() to convert \a str to - Unicode. Depending on the codec, it may not accept valid US-ASCII (ANSI - X3.4-1986) input. If no codec has been set, this function does the same - as fromLatin1(). + This function does the same as fromLatin1(). \sa toAscii(), fromLatin1(), fromUtf8(), fromLocal8Bit() */ @@ -5138,19 +5104,8 @@ QString &QString::vsprintf(const char* cformat, va_list ap) const char *c = cformat; for (;;) { // Copy non-escape chars to result -#ifndef QT_NO_TEXTCODEC - int i = 0; - while (*(c + i) != '\0' && *(c + i) != '%') - ++i; - if (codecForCStrings) - result.append(codecForCStrings->toUnicode(c, i)); - else - result.append(fromLatin1(c, i)); - c += i; -#else while (*c != '\0' && *c != '%') result.append(QLatin1Char(*c++)); -#endif if (*c == '\0') break; @@ -7062,8 +7017,7 @@ bool QString::isRightToLeft() const This operator is mostly useful to pass a QString to a function that accepts a std::string object. - If the QString contains Unicode characters that the - QTextCodec::codecForCStrings() codec cannot handle, using this operator + If the QString contains non-Latin1 Unicode characters, using this can lead to loss of information. This operator is only available if Qt is configured with STL @@ -8736,9 +8690,7 @@ QByteArray QStringRef::toLatin1() const Returns an 8-bit representation of the string as a QByteArray. - If a codec has been set using QTextCodec::setCodecForCStrings(), - it is used to convert Unicode to 8-bit char; otherwise this - function does the same as toLatin1(). + This function does the same as toLatin1(). Note that, despite the name, this function does not necessarily return an US-ASCII (ANSI X3.4-1986) string and its result may not be US-ASCII compatible. @@ -8747,10 +8699,6 @@ QByteArray QStringRef::toLatin1() const */ QByteArray QStringRef::toAscii() const { -#ifndef QT_NO_TEXTCODEC - if (QString::codecForCStrings) - return QString::codecForCStrings->fromUnicode(unicode(), length()); -#endif // QT_NO_TEXTCODEC return toLatin1(); } diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index f1bad5c028..f49d989e9d 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -605,9 +605,6 @@ private: Data *d; inline QString(Data *dd, int /*dummy*/) : d(dd) {} -#ifndef QT_NO_TEXTCODEC - static QTextCodec *codecForCStrings; -#endif static int grow(int); static void free(Data *); void realloc(); @@ -927,9 +924,6 @@ inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); } #ifndef QT_NO_CAST_FROM_ASCII inline bool qStringComparisonHelper(const QString &s1, const char *s2) { -# ifndef QT_NO_TEXTCODEC - if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2, s2 ? int(strlen(s2)) : -1)); -# endif return (s1 == QLatin1String(s2)); } inline bool QString::operator==(const char *s) const @@ -1216,9 +1210,6 @@ inline bool operator>=(const QStringRef &s1, const QStringRef &s2) inline bool qStringComparisonHelper(const QStringRef &s1, const char *s2) { -# ifndef QT_NO_TEXTCODEC - if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2, s2 ? int(strlen(s2)) : -1)); -# endif return (s1 == QLatin1String(s2)); } diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 3d6b0eb709..30c4399cc9 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -105,14 +105,6 @@ QT_BEGIN_NAMESPACE */ void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out) { -#ifndef QT_NO_TEXTCODEC - if (QString::codecForCStrings && len) { - QString tmp = QString::fromAscii(a, len > 0 ? len : -1); - memcpy(out, reinterpret_cast(tmp.constData()), sizeof(QChar) * tmp.size()); - out += tmp.length(); - return; - } -#endif if (len == -1) { if (!a) return; @@ -127,14 +119,6 @@ void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out /*! \internal */ void QAbstractConcatenable::convertToAscii(const QChar* a, int len, char*& out) { -#ifndef QT_NO_TEXTCODEC - if (QString::codecForCStrings) { - QByteArray tmp = QString::codecForCStrings->fromUnicode(a, len); - memcpy(out, tmp.constData(), tmp.size()); - out += tmp.length(); - return; - } -#endif if (len == -1) { while (a->unicode()) convertToLatin1(*a++, out); diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 5a4c27d22a..ebaaaa35c2 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -65,22 +65,12 @@ protected: static void convertToAscii(const QChar *a, int len, char *&out); static inline void convertFromAscii(char a, QChar *&out) { -#ifndef QT_NO_TEXTCODEC - if (QString::codecForCStrings) - *out++ = QChar::fromAscii(a); - else -#endif - *out++ = QLatin1Char(a); + *out++ = QLatin1Char(a); } static inline void convertToAscii(QChar a, char *&out) { -#ifndef QT_NO_TEXTCODEC - if (QString::codecForCStrings) - *out++ = a.toAscii(); //### - else -#endif - convertToLatin1(a, out); + convertToLatin1(a, out); } static inline void convertToLatin1(QChar a, char *&out) diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 3fb253c646..7e4f591f47 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -808,10 +808,7 @@ void tst_QString::constructorQByteArray() QCOMPARE(str1.length(), expected.length()); QCOMPARE( str1, expected ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 QString strBA(src); - QTextCodec::setCodecForCStrings( 0 ); - QCOMPARE( strBA, expected ); } @@ -928,12 +925,7 @@ void tst_QString::sprintf() QCOMPARE(a.sprintf("%-5.5s", "Hello" ),(QString)"Hello"); // Check utf8 conversion for %s - QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString("\366\344\374\326\304\334\370\346\345\330\306\305")); - - // Check codecForCStrings is used to read non-modifier sequences in the format string - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); - QCOMPARE(a.sprintf("\303\251\303\250\303\240 %s", "\303\251\303\250\303\240"), QString("\303\251\303\250\303\240 \303\251\303\250\303\240")); - QTextCodec::setCodecForCStrings(0); + QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305")); int n1; a.sprintf("%s%n%s", "hello", &n1, "goodbye"); @@ -1871,9 +1863,7 @@ void tst_QString::append_bytearray() QFETCH( QString, str ); QFETCH( QByteArray, ba ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 str.append( ba ); - QTextCodec::setCodecForCStrings( 0 ); QTEST( str, "res" ); } @@ -1898,9 +1888,7 @@ void tst_QString::operator_pluseq_bytearray() QFETCH( QString, str ); QFETCH( QByteArray, ba ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 str += ba; - QTextCodec::setCodecForCStrings( 0 ); QTEST( str, "res" ); } @@ -1960,9 +1948,7 @@ void tst_QString::prepend_bytearray() QFETCH( QString, str ); QFETCH( QByteArray, ba ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 str.prepend( ba ); - QTextCodec::setCodecForCStrings( 0 ); QTEST( str, "res" ); } @@ -3211,7 +3197,7 @@ void tst_QString::utf8() QFETCH( QByteArray, utf8 ); QFETCH( QString, res ); - QCOMPARE( utf8, QByteArray(res.toUtf8()) ); + QCOMPARE(res.toUtf8(), utf8); } void tst_QString::stringRef_utf8_data() diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp index 95e24b22fb..afc16078b8 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -66,10 +66,8 @@ void runScenario() { - // set codec for C strings to 0, enforcing Latin1 - QTextCodec::setCodecForCStrings(0); - QVERIFY(!QTextCodec::codecForCStrings()); - + // this code is latin1. TODO: replace it with the utf8 block below, once + // strings default to utf8. QLatin1Literal l1literal(LITERAL); QLatin1String l1string(LITERAL); QString string(l1string); @@ -130,7 +128,10 @@ void runScenario() r = string P ba; QCOMPARE(r, r2); +#if 0 // now test with codec for C strings set + // TODO: to be re-enabled once strings default to utf8, in place of the + // latin1 code above. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QVERIFY(QTextCodec::codecForCStrings()); QCOMPARE(QTextCodec::codecForCStrings()->name(), QByteArray("UTF-8")); @@ -153,6 +154,7 @@ void runScenario() QCOMPARE(r, r3); r = string P ba; QCOMPARE(r, r3); +#endif ba = QByteArray(); // empty r = ba P string; @@ -212,8 +214,11 @@ void runScenario() str += QLatin1String(LITERAL) P str; QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL)); #ifndef QT_NO_CAST_FROM_ASCII +#if 0 + // TODO: this relies on strings defaulting to utf8, so disable this for now. str = (QString::fromUtf8(UTF8_LITERAL) += QLatin1String(LITERAL) P UTF8_LITERAL); QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL)); +#endif #endif } @@ -229,10 +234,13 @@ void runScenario() ba2 += ba2 P withZero; QCOMPARE(ba2, QByteArray(withZero + withZero + withZero)); #ifndef QT_NO_CAST_TO_ASCII +#if 0 + // TODO: this relies on strings defaulting to utf8, so disable this for now. ba = UTF8_LITERAL; ba2 = (ba += QLatin1String(LITERAL) + QString::fromUtf8(UTF8_LITERAL)); QCOMPARE(ba2, ba); QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL)); +#endif #endif } diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/other/collections/tst_collections.cpp index 9bfed15fc4..dc6d7f4b55 100644 --- a/tests/auto/other/collections/tst_collections.cpp +++ b/tests/auto/other/collections/tst_collections.cpp @@ -2124,11 +2124,10 @@ void tst_Collections::qstring() QVERIFY(s.toAscii().isNull()); s = "ascii"; - s += (uchar) 0xb0; + s += QChar((uchar) 0xb0); QVERIFY(s.toUtf8() != s.toLatin1()); - QString sa = s.toLatin1().constData(); - QVERIFY(sa[sa.length()-1] == (ushort) 0xb0); - QVERIFY(sa.left(sa.length()-1) == "ascii"); + QCOMPARE(s[s.length()-1].unicode(), (ushort)0xb0); + QVERIFY(s.left(s.length()-1) == "ascii"); QVERIFY(s == QString::fromUtf8(s.toUtf8().constData())); From 7d79e997683930f4f7b3ce1db314683d6e82ea31 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 21 Feb 2012 17:27:39 +0100 Subject: [PATCH 007/166] Fail with #error early if the compiler does not support bool or explicit. The fail mode for bool is moved from later in qglobal.h, and explicit is used unguarded throughout Qt, so the macro is already useless. Change-Id: Iff26892b025ba155e360a1f2dc93a67a6622dbc1 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 33 ++++++++----------------- src/corelib/global/qglobal.h | 5 ---- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 5ab79092d2..8adbdbe453 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -76,7 +76,7 @@ # define Q_CC_SYM /* "explicit" semantics implemented in 8.1e but keyword recognized since 7.5 */ # if defined(__SC__) && __SC__ < 0x750 -# define Q_NO_EXPLICIT_KEYWORD +# error "Compiler not supported" # endif # define Q_NO_USING_KEYWORD @@ -114,8 +114,7 @@ # define Q_CC_BOR # define Q_INLINE_TEMPLATE # if __BORLANDC__ < 0x502 -# define Q_NO_BOOL_TYPE -# define Q_NO_EXPLICIT_KEYWORD +# error "Compiler not supported" # endif # define Q_NO_USING_KEYWORD @@ -251,12 +250,7 @@ # define Q_CC_XLC # define Q_FULL_TEMPLATE_INSTANTIATION # if __xlC__ < 0x400 -# define Q_NO_BOOL_TYPE -# define Q_NO_EXPLICIT_KEYWORD -# define Q_NO_USING_KEYWORD -# define Q_OUTOFLINE_TEMPLATE inline -# define Q_BROKEN_TEMPLATE_SPECIALIZATION -# define Q_CANNOT_DELETE_CONSTANT +# error "Compiler not supported" # elif __xlC__ >= 0x0600 # define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) @@ -280,7 +274,7 @@ - observed on Compaq C++ V6.3-002. In any case versions prior to Compaq C++ V6.0-005 do not have bool. */ # if !defined(_BOOL_EXISTS) -# define Q_NO_BOOL_TYPE +# error "Compiler not supported" # endif /* Spurious (?) error messages observed on Compaq C++ V6.5-014. */ # define Q_NO_USING_KEYWORD @@ -315,7 +309,7 @@ __BOOL_DEFINED Defined in Microsoft C++ mode when bool is a keyword. */ # if !defined(_BOOL) && !defined(__BOOL_DEFINED) -# define Q_NO_BOOL_TYPE +# error "Compiler not supported" # endif /* The Comeau compiler is based on EDG and does define __EDG__ */ @@ -341,9 +335,8 @@ # elif defined(__DCC__) # define Q_CC_DIAB -# undef Q_NO_BOOL_TYPE # if !defined(__bool) -# define Q_NO_BOOL_TYPE +# error "Compiler not supported" # endif /* The UnixWare 7 UDK compiler is based on EDG and does define __EDG__ */ @@ -407,7 +400,7 @@ # define Q_NO_TEMPLATE_FRIENDS # endif # if !defined(_BOOL) -# define Q_NO_BOOL_TYPE +# error "Compiler not supported" # endif # if defined(__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT <= 4) # define Q_NO_USING_KEYWORD @@ -415,9 +408,7 @@ # define Q_C_CALLBACKS /* 4.2 compiler or older */ # else -# define Q_NO_BOOL_TYPE -# define Q_NO_EXPLICIT_KEYWORD -# define Q_NO_USING_KEYWORD +# error "Compiler not supported" # endif /* CDS++ does not seem to define __EDG__ or __EDG according to Reliant @@ -426,7 +417,7 @@ # define Q_CC_EDG # define Q_CC_CDS # if !defined(_BOOL) -# define Q_NO_BOOL_TYPE +# error "Compiler not supported" # endif # define Q_BROKEN_TEMPLATE_SPECIALIZATION @@ -449,11 +440,7 @@ # define Q_DECL_IMPORT Q_DECL_EXPORT # endif # else -# define Q_CC_HP -# define Q_NO_BOOL_TYPE -# define Q_FULL_TEMPLATE_INSTANTIATION -# define Q_BROKEN_TEMPLATE_SPECIALIZATION -# define Q_NO_EXPLICIT_KEYWORD +# error "Compiler not supported" # endif # define Q_NO_USING_KEYWORD /* ### check "using" status */ diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1fb5778f14..58bdf06fb5 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -275,11 +275,6 @@ typedef unsigned int uint; typedef unsigned long ulong; QT_END_INCLUDE_NAMESPACE -#if defined(Q_NO_BOOL_TYPE) -#error "Compiler doesn't support the bool type" -#endif - - /* Constant bool values */ From 53bb87d1d274a80b94595f6cd31bfa7a8ae81dc3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2012 15:29:05 +0100 Subject: [PATCH 008/166] QEasingCurve: fix a missing */ Change-Id: I344342e950158c9dc832f1cd181d92899ddb1651 Reviewed-by: Thiago Macieira --- src/corelib/tools/qeasingcurve.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 1ca9a55d72..81778f908f 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -1110,6 +1110,7 @@ QEasingCurve::~QEasingCurve() Swaps curve \a other with this curve. This operation is very fast and never fails. +*/ /*! Compare this easing curve with \a other and returns true if they are From 541949aed23ea14a71a7d4391bac244b623add0a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Feb 2012 15:36:01 +0100 Subject: [PATCH 009/166] Add further theme hints to QPlatformTheme. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add hints for QDialog/QDialogButtonBox. - Add hint for available popup-menu area. - Add keyboard scheme hint replacing QGuiApplicationPrivate::currentKeyPlatform() Reviewed-by: Samuel Rødal Reviewed-by: Morten Johan Sørvig Task-number: QTBUG-24204 Task-number: QTBUG-24315 Change-Id: I6653786b0dcb49a6fc264d3b9891dbfee502bd3e Reviewed-by: Friedemann Kleint --- src/gui/kernel/qevent.cpp | 2 +- src/gui/kernel/qguiapplication.cpp | 21 -- src/gui/kernel/qguiapplication_p.h | 13 - src/gui/kernel/qkeysequence.cpp | 316 ++++++++++-------- src/gui/kernel/qkeysequence_p.h | 1 + src/gui/kernel/qplatformtheme_qpa.cpp | 24 ++ src/gui/kernel/qplatformtheme_qpa.h | 17 +- .../themes/genericunix/qgenericunixthemes.cpp | 19 +- src/plugins/platforms/cocoa/qcocoatheme.mm | 13 +- .../platforms/windows/qwindowstheme.cpp | 13 +- src/widgets/dialogs/qdialog.cpp | 10 +- src/widgets/kernel/qicon.cpp | 5 - src/widgets/styles/qcommonstyle.cpp | 19 +- .../gui/kernel/qkeysequence/qkeysequence.pro | 2 +- .../kernel/qkeysequence/tst_qkeysequence.cpp | 59 ++-- .../other/languagechange/languagechange.pro | 2 +- .../languagechange/tst_languagechange.cpp | 14 +- .../dialogs/qmessagebox/qmessagebox.pro | 2 +- .../dialogs/qmessagebox/tst_qmessagebox.cpp | 15 +- tests/auto/widgets/kernel/qaction/qaction.pro | 2 +- .../widgets/kernel/qaction/tst_qaction.cpp | 29 +- 21 files changed, 336 insertions(+), 262 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index c3a6be692b..ce4594c7ab 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -833,7 +833,7 @@ Qt::KeyboardModifiers QKeyEvent::modifiers() const bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const { uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference - uint platform = QGuiApplicationPrivate::currentKeyPlatform(); + const uint platform = QKeySequencePrivate::currentKeyPlatforms(); uint N = QKeySequencePrivate::numberOfKeyBindings; diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 17208643ef..4b309096c9 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1911,27 +1911,6 @@ QInputPanel *QGuiApplication::inputPanel() const return inputMethod(); } - -// Returns the current platform used by keyBindings -uint QGuiApplicationPrivate::currentKeyPlatform() -{ - uint platform = KB_Win; -#ifdef Q_OS_MAC - platform = KB_Mac; -#elif defined Q_WS_X11 // ## TODO: detect these - platform = KB_X11; -#if 0 - if (X11->desktopEnvironment == DE_KDE) - platform |= KB_KDE; - if (X11->desktopEnvironment == DE_GNOME) - platform |= KB_Gnome; - if (X11->desktopEnvironment == DE_CDE) - platform |= KB_CDE; -#endif -#endif - return platform; -} - /*! \since 4.5 \fn void QGuiApplication::fontDatabaseChanged() diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 7e6e0aa8c7..66670e8e25 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -89,19 +89,6 @@ public: static QPlatformTheme *platformTheme() { return platform_theme; } - - enum KeyPlatform { - KB_Win = 1, - KB_Mac = 2, - KB_X11 = 4, - KB_KDE = 8, - KB_Gnome = 16, - KB_CDE = 32, - KB_All = 0xffff - }; - - static uint currentKeyPlatform(); - static QAbstractEventDispatcher *qt_qpa_core_dispatcher() { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; } diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 021135b6fe..bd0f220ae8 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -41,6 +41,7 @@ #include "qkeysequence.h" #include "qkeysequence_p.h" +#include "qplatformtheme_qpa.h" #include "private/qguiapplication_p.h" #ifndef QT_NO_SHORTCUT @@ -640,153 +641,163 @@ static const struct { //Table of key bindings. It must be sorted on key sequence. //A priority of 1 indicates that this is the primary key binding when multiple are defined. +enum KeyPlatform { + KB_Win = (1 << QPlatformTheme::WindowsKeyboardScheme), + KB_Mac = (1 << QPlatformTheme::MacKeyboardScheme), + KB_X11 = (1 << QPlatformTheme::X11KeyboardScheme), + KB_KDE = (1 << QPlatformTheme::KdeKeyboardScheme), + KB_Gnome = (1 << QPlatformTheme::GnomeKeyboardScheme), + KB_CDE = (1 << QPlatformTheme::CdeKeyboardScheme), + KB_All = 0xffff +}; + const QKeyBinding QKeySequencePrivate::keyBindings[] = { // StandardKey Priority Key Sequence Platforms - {QKeySequence::Back, 0, Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, QGuiApplicationPrivate::KB_All}, - {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Delete, 1, Qt::Key_Delete, QGuiApplicationPrivate::KB_All}, - {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, QGuiApplicationPrivate::KB_All}, - {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, QGuiApplicationPrivate::KB_All}, - {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, QGuiApplicationPrivate::KB_All}, - {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, QGuiApplicationPrivate::KB_All}, - {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, QGuiApplicationPrivate::KB_All}, - {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, QGuiApplicationPrivate::KB_All}, - {QKeySequence::HelpContents, 0, Qt::Key_F1, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::FindNext, 0, Qt::Key_F3, QGuiApplicationPrivate::KB_X11}, - {QKeySequence::FindNext, 1, Qt::Key_F3, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::Refresh, 0, Qt::Key_F5, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::Undo, 0, Qt::Key_F14, QGuiApplicationPrivate::KB_X11}, //Undo on sun keyboards - {QKeySequence::Copy, 0, Qt::Key_F16, QGuiApplicationPrivate::KB_X11}, //Copy on sun keyboards - {QKeySequence::Paste, 0, Qt::Key_F18, QGuiApplicationPrivate::KB_X11}, //Paste on sun keyboards - {QKeySequence::Cut, 0, Qt::Key_F20, QGuiApplicationPrivate::KB_X11}, //Cut on sun keyboards - {QKeySequence::PreviousChild, 0, Qt::Key_Back, QGuiApplicationPrivate::KB_All}, - {QKeySequence::NextChild, 0, Qt::Key_Forward, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, QGuiApplicationPrivate::KB_All}, - {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, //## Check if this should work on mac - {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_All}, - {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_All}, - {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_All}, - {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_All}, - {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, QGuiApplicationPrivate::KB_All}, - {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, QGuiApplicationPrivate::KB_All}, - {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, QGuiApplicationPrivate::KB_All}, - {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, QGuiApplicationPrivate::KB_X11}, - {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, QGuiApplicationPrivate::KB_All}, - {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, QGuiApplicationPrivate::KB_KDE}, - {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, QGuiApplicationPrivate::KB_All}, - {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, QGuiApplicationPrivate::KB_KDE}, - {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, QGuiApplicationPrivate::KB_X11}, //emacs (line edit only) - {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, QGuiApplicationPrivate::KB_All}, - {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QGuiApplicationPrivate::KB_Gnome}, - {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, QGuiApplicationPrivate::KB_All}, - {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, QGuiApplicationPrivate::KB_X11}, //emacs (line edit only) - {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_KDE | QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, QGuiApplicationPrivate::KB_KDE}, - {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, QGuiApplicationPrivate::KB_All}, - {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, QGuiApplicationPrivate::KB_All}, - {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, QGuiApplicationPrivate::KB_Mac}, //different priority from above - {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win}, - {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win}, - {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win}, - {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac }, - {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac }, - {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, QGuiApplicationPrivate::KB_KDE}, - {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QGuiApplicationPrivate::KB_Mac },//different priority from above - {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QGuiApplicationPrivate::KB_X11}, - {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac }, - {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac }, - {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win}, - {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, //mac only - {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, - {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, //mac only - {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, QGuiApplicationPrivate::KB_Mac }, - {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, QGuiApplicationPrivate::KB_Mac }, - {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,QGuiApplicationPrivate::KB_Win}, - {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, //mac only - {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, //mac only - {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac}, - {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac} + {QKeySequence::Back, 0, Qt::Key_Backspace, KB_Win}, + {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, KB_All}, + {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, KB_All}, + {QKeySequence::Delete, 1, Qt::Key_Delete, KB_All}, + {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, KB_Win | KB_X11}, + {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, KB_Mac}, + {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, KB_Win | KB_X11}, + {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, KB_Mac}, + {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, KB_All}, + {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, KB_All}, + {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, KB_All}, + {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, KB_All}, + {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, KB_All}, + {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, KB_All}, + {QKeySequence::HelpContents, 0, Qt::Key_F1, KB_Win | KB_X11}, + {QKeySequence::FindNext, 0, Qt::Key_F3, KB_X11}, + {QKeySequence::FindNext, 1, Qt::Key_F3, KB_Win}, + {QKeySequence::Refresh, 0, Qt::Key_F5, KB_Win | KB_X11}, + {QKeySequence::Undo, 0, Qt::Key_F14, KB_X11}, //Undo on sun keyboards + {QKeySequence::Copy, 0, Qt::Key_F16, KB_X11}, //Copy on sun keyboards + {QKeySequence::Paste, 0, Qt::Key_F18, KB_X11}, //Paste on sun keyboards + {QKeySequence::Cut, 0, Qt::Key_F20, KB_X11}, //Cut on sun keyboards + {QKeySequence::PreviousChild, 0, Qt::Key_Back, KB_All}, + {QKeySequence::NextChild, 0, Qt::Key_Forward, KB_All}, + {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, KB_Win}, + {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, KB_All}, + {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, KB_All}, + {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, KB_Win | KB_X11}, + {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, KB_Win | KB_X11}, //## Check if this should work on mac + {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11}, + {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, KB_Mac}, + {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11}, + {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, KB_Mac}, + {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, KB_All}, + {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, KB_All}, + {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, KB_All}, + {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, KB_All}, + {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, KB_All}, + {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, KB_All}, + {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, KB_All}, + {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, KB_X11}, + {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, KB_Win}, + {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, KB_All}, + {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, KB_KDE}, + {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, KB_Mac}, + {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, KB_All}, + {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, KB_KDE}, + {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, KB_Mac}, + {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, KB_All}, + {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, KB_All}, + {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, KB_All}, + {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, KB_X11}, //emacs (line edit only) + {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, KB_All}, + {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, KB_Gnome | KB_Mac}, + {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, KB_Win}, + {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Win}, + {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Gnome}, + {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, KB_All}, + {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, KB_X11}, //emacs (line edit only) + {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, KB_All}, + {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, KB_All}, + {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, KB_All}, + {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, KB_Gnome | KB_KDE | KB_Mac}, + {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, KB_Gnome | KB_Mac}, + {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, KB_KDE}, + {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, KB_All}, + {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, KB_All}, + {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, KB_All}, + {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, KB_All}, + {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, KB_Win | KB_X11}, + {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, KB_Mac}, + {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, KB_All}, + {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, KB_Win}, + {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, KB_All}, + {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, KB_Mac}, + {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, KB_Mac}, + {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, KB_Mac}, + {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, KB_Mac}, + {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, KB_Win | KB_X11}, + {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, KB_Mac}, //different priority from above + {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, KB_X11 | KB_Win}, + {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, KB_X11 | KB_Win}, + {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, KB_X11 | KB_Win}, + {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, KB_Win | KB_X11}, + {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, KB_Win | KB_X11}, + {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, KB_Mac}, + {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, KB_Win | KB_X11}, + {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, KB_Mac }, + {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, KB_Mac}, + {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, KB_Mac}, + {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, KB_Mac }, + {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, KB_Win | KB_X11}, + {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, KB_Mac}, + {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, KB_Win}, + {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, KB_Mac}, + {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, KB_Win}, + {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Gnome | KB_Mac}, + {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Win}, + {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, KB_KDE}, + {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, KB_Gnome | KB_Mac}, + {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Win | KB_X11}, + {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Mac}, + {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Win | KB_X11}, + {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Mac },//different priority from above + {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, KB_X11}, + {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11}, + {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11}, + {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Win | KB_X11}, + {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Mac }, + {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, KB_Mac}, + {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Win | KB_X11}, + {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Mac }, + {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, KB_Mac}, + {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, KB_Win}, + {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, KB_Win}, + {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, KB_Mac}, + {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, KB_Mac}, + {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, KB_Win | KB_X11}, + {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, KB_Mac}, + {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, KB_Mac}, //mac only + {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, KB_Mac}, + {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, KB_Win | KB_X11}, + {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, KB_Mac}, //mac only + {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, KB_Mac }, + {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, KB_Mac }, + {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,KB_Win}, + {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, KB_Mac}, + {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, KB_Mac}, //mac only + {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, KB_Mac}, + {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, KB_Mac}, //mac only + {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, KB_Mac}, + {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, KB_Mac}, + {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, KB_Mac}, + {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, KB_Mac}, + {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, KB_Mac}, + {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, KB_Mac}, + {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, KB_Mac}, + {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, KB_Mac}, + {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, KB_Mac}, + {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, KB_Mac}, + {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, KB_Mac}, + {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, KB_Mac}, + {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, KB_Mac}, + {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, KB_Mac}, + {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, KB_Mac} }; const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate::keyBindings)/(sizeof(QKeyBinding)); @@ -991,7 +1002,7 @@ static inline int maybeSwapShortcut(int shortcut) */ QList QKeySequence::keyBindings(StandardKey key) { - uint platform = QGuiApplicationPrivate::currentKeyPlatform(); + const uint platform = QKeySequencePrivate::currentKeyPlatforms(); QList list; for (uint i = 0; i < QKeySequencePrivate::numberOfKeyBindings ; ++i) { QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i]; @@ -1330,6 +1341,19 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence return ret; } +unsigned QKeySequencePrivate::currentKeyPlatforms() +{ + int keyboardScheme = QPlatformTheme::WindowsKeyboardScheme; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); + unsigned result = 1u << keyboardScheme; + if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme + || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme + || keyboardScheme == QPlatformTheme::CdeKeyboardScheme) + result |= KB_X11; + return result; +} + /*! Creates a shortcut string for \a key. For example, Qt::CTRL+Qt::Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h index 68cbb8778b..4481557121 100644 --- a/src/gui/kernel/qkeysequence_p.h +++ b/src/gui/kernel/qkeysequence_p.h @@ -88,6 +88,7 @@ public: static const QKeyBinding keyBindings[]; static const uint numberOfKeyBindings; + static unsigned currentKeyPlatforms(); }; #endif // QT_NO_SHORTCUT diff --git a/src/gui/kernel/qplatformtheme_qpa.cpp b/src/gui/kernel/qplatformtheme_qpa.cpp index aec465f0ff..3f6b69b902 100644 --- a/src/gui/kernel/qplatformtheme_qpa.cpp +++ b/src/gui/kernel/qplatformtheme_qpa.cpp @@ -84,6 +84,20 @@ QT_BEGIN_NAMESPACE \value StyleNames (QStringList) A list of preferred style names. + \value WindowAutoPlacement (bool) A boolean value indicating whether Windows + (particularly dialogs) are placed by the system + (see _NET_WM_FULL_PLACEMENT in X11). + + \value DialogButtonBoxLayout (int) An integer representing a + QDialogButtonBox::ButtonLayout value. + + \value DialogButtonBoxButtonsHaveIcons (bool) A boolean value indicating whether + the buttons of a QDialogButtonBox should have icons. + + \value UseFullScreenForPopupMenu (bool) Pop menus can cover the full screen including task bar. + + \value KeyboardScheme (int) An integer value (enum KeyboardSchemes) specifying the + keyboard scheme. \sa themeHint(), QStyle::pixelMetric() */ @@ -121,6 +135,14 @@ const QPalette *QPlatformTheme::palette(Palette type) const QVariant QPlatformTheme::themeHint(ThemeHint hint) const { switch (hint) { + case QPlatformTheme::UseFullScreenForPopupMenu: + return QVariant(false); + case QPlatformTheme::WindowAutoPlacement: + return QVariant(false); + case QPlatformTheme::DialogButtonBoxLayout: + return QVariant(int(0)); + case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: + return QVariant(false); case QPlatformTheme::ItemViewActivateItemOnSingleClick: return QVariant(false); case QPlatformTheme::ToolButtonStyle: @@ -140,6 +162,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const return QVariant(false); case MaximumScrollBarDragDistance: return QVariant(-1); + case KeyboardScheme: + return QVariant(int(WindowsKeyboardScheme)); } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme_qpa.h b/src/gui/kernel/qplatformtheme_qpa.h index 036432054e..31a52a9391 100644 --- a/src/gui/kernel/qplatformtheme_qpa.h +++ b/src/gui/kernel/qplatformtheme_qpa.h @@ -69,7 +69,12 @@ public: SystemIconThemeName, SystemIconFallbackThemeName, IconThemeSearchPaths, - StyleNames + StyleNames, + WindowAutoPlacement, + DialogButtonBoxLayout, + DialogButtonBoxButtonsHaveIcons, + UseFullScreenForPopupMenu, + KeyboardScheme }; enum DialogType { @@ -84,6 +89,16 @@ public: NPalettes }; + enum KeyboardSchemes + { + WindowsKeyboardScheme, + MacKeyboardScheme, + X11KeyboardScheme, + KdeKeyboardScheme, + GnomeKeyboardScheme, + CdeKeyboardScheme + }; + virtual QPlatformMenu *createPlatformMenu(QMenu *menu = 0) const; virtual QPlatformMenuBar *createPlatformMenuBar(QMenuBar *menuBar = 0) const; diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index a9f05f6084..257fe9156f 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -89,12 +89,15 @@ QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const return QVariant(QString(QStringLiteral("hicolor"))); case QPlatformTheme::IconThemeSearchPaths: return xdgIconThemePaths(); + case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: + return QVariant(true); case QPlatformTheme::StyleNames: { QStringList styleNames; styleNames << QStringLiteral("Plastique") << QStringLiteral("Windows"); return QVariant(styleNames); } - break; + case QPlatformTheme::KeyboardScheme: + return QVariant(int(X11KeyboardScheme)); default: break; } @@ -229,6 +232,12 @@ static QStringList kdeIconThemeSearchPaths(const QString &kdeHome) QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const { switch (hint) { + case QPlatformTheme::UseFullScreenForPopupMenu: + return QVariant(true); + case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: + return QVariant(true); + case QPlatformTheme::DialogButtonBoxLayout: + return QVariant(2); // QDialogButtonBox::KdeLayout case QPlatformTheme::ToolButtonStyle: return QVariant(m_toolButtonStyle); case QPlatformTheme::ToolBarIconSize: @@ -241,6 +250,8 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const return QVariant(kdeIconThemeSearchPaths(m_kdeHome)); case QPlatformTheme::StyleNames: return QVariant(m_styleNames); + case QPlatformTheme::KeyboardScheme: + return QVariant(int(KdeKeyboardScheme)); default: break; } @@ -282,6 +293,10 @@ QPlatformTheme *QKdeTheme::createKdeTheme() QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const { switch (hint) { + case QPlatformTheme::DialogButtonBoxButtonsHaveIcons: + return QVariant(true); + case QPlatformTheme::DialogButtonBoxLayout: + return QVariant(3); // QDialogButtonBox::GnomeLayout case QPlatformTheme::SystemIconThemeName: case QPlatformTheme::SystemIconFallbackThemeName: return QVariant(QString(QStringLiteral("gnome"))); @@ -292,6 +307,8 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const styleNames << QStringLiteral("GTK+") << QStringLiteral("cleanlooks") << QStringLiteral("windows"); return QVariant(styleNames); } + case QPlatformTheme::KeyboardScheme: + return QVariant(int(GnomeKeyboardScheme)); default: break; } diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index ad20c2fb27..0fef3234b4 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -105,13 +105,16 @@ QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialo QVariant QCocoaTheme::themeHint(ThemeHint hint) const { switch (hint) { - case QPlatformTheme::StyleNames: - return QStringList() << QLatin1Literal("macintosh"); - break; - default: - return QPlatformTheme::themeHint(hint); + case QPlatformTheme::StyleNames: + return QStringList(QStringLiteral("macintosh")); + case QPlatformTheme::DialogButtonBoxLayout: + return QVariant(1); // QDialogButtonBox::MacLayout + case KeyboardScheme: + return QVariant(int(MacKeyboardScheme)); + default: break; } + return QPlatformTheme::themeHint(hint); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index a59b74cef3..7276db4bb6 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -220,11 +220,12 @@ static inline QStringList styleNames() QVariant QWindowsTheme::themeHint(ThemeHint hint) const { switch (hint) { - case SystemIconThemeName: - break; + case UseFullScreenForPopupMenu: + return QVariant(true); + case DialogButtonBoxLayout: + return QVariant(int(0)); // QDialogButtonBox::WinLayout case IconThemeSearchPaths: return QVariant(iconThemeSearchPaths()); - break; case StyleNames: return QVariant(styleNames()); case TextCursorWidth: @@ -233,8 +234,12 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const return QVariant(booleanSystemParametersInfo(SPI_GETDROPSHADOW, false)); case MaximumScrollBarDragDistance: return QVariant(qRound(qreal(QWindowsContext::instance()->defaultDPI()) * 1.375)); + case KeyboardScheme: + return QVariant(int(WindowsKeyboardScheme)); + default: + break; } - return QVariant(); + return QPlatformTheme::themeHint(hint); } void QWindowsTheme::refresh() diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 49b4dd3a23..5ffb5466d6 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -55,6 +55,7 @@ #include "qplatformtheme_qpa.h" #include "private/qdialog_p.h" #include "private/qguiapplication_p.h" +#include "qplatformtheme_qpa.h" #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif @@ -790,11 +791,10 @@ void QDialog::showEvent(QShowEvent *event) /*! \internal */ void QDialog::adjustPosition(QWidget* w) { -#ifdef Q_WS_X11 - // if the WM advertises that it will place the windows properly for us, let it do it :) - if (X11->isSupportedByWM(ATOM(_NET_WM_FULL_PLACEMENT))) - return; -#endif + + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + if (theme->themeHint(QPlatformTheme::WindowAutoPlacement).toBool()) + return; QPoint p(0, 0); int extraw = 0, extrah = 0, scrn = 0; if (w) diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp index e579fac4f4..eebd57f97e 100644 --- a/src/widgets/kernel/qicon.cpp +++ b/src/widgets/kernel/qicon.cpp @@ -60,11 +60,6 @@ #include #endif -#ifdef Q_WS_X11 -#include "private/qt_x11_p.h" -#include "private/qkde_p.h" -#endif - #include "private/qhexstring_p.h" #ifndef QT_NO_ICON diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 75476faeeb..174e94e63d 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -83,12 +83,6 @@ # include "private/qtextengine_p.h" #endif -#ifdef Q_WS_X11 -# include -#elif defined(Q_WS_MAC) -# include -#endif - #include QT_BEGIN_NAMESPACE @@ -4920,12 +4914,8 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget break; case SH_DialogButtonLayout: ret = QDialogButtonBox::WinLayout; -#ifdef Q_WS_X11 - if (X11->desktopEnvironment == DE_KDE) - ret = QDialogButtonBox::KdeLayout; - else if (X11->desktopEnvironment == DE_GNOME) - ret = QDialogButtonBox::GnomeLayout; -#endif + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + ret = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt(); break; case SH_ComboBox_PopupFrameStyle: ret = QFrame::StyledPanel | QFrame::Plain; @@ -4934,10 +4924,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = Qt::LinksAccessibleByMouse; break; case SH_DialogButtonBox_ButtonsHaveIcons: -#ifdef Q_WS_X11 - return true; -#endif ret = 0; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + ret = theme->themeHint(QPlatformTheme::DialogButtonBoxButtonsHaveIcons).toBool() ? 1 : 0; break; case SH_SpellCheckUnderlineStyle: ret = QTextCharFormat::WaveUnderline; diff --git a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro index 1e0baafd09..cf4337b156 100644 --- a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro +++ b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qkeysequence -QT += widgets widgets-private testlib +QT += widgets testlib QT += core-private gui-private SOURCES += tst_qkeysequence.cpp diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index 29588e2ee9..861ad3835d 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -41,9 +41,10 @@ #include -#include #include +#include #include +#include #include #include @@ -142,6 +143,7 @@ private slots: void initTestCase(); private: + int m_keyboardScheme; QTranslator *ourTranslator; QTranslator *qtTranslator; #ifdef Q_OS_MAC @@ -161,8 +163,10 @@ const QString tst_QKeySequence::MacAlt = QString(QChar(0x2325)); const QString tst_QKeySequence::MacShift = QString(QChar(0x21E7)); #endif -tst_QKeySequence::tst_QKeySequence() +tst_QKeySequence::tst_QKeySequence() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme) { + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); } tst_QKeySequence::~tst_QKeySequence() @@ -297,8 +301,7 @@ void tst_QKeySequence::checkMultipleCodes() */ void tst_QKeySequence::ensureSorted() { -//### accessing static members from private classes does not work on msvc at the moment -#if defined(QT_BUILD_INTERNAL) && !defined(Q_WS_WIN) +#if defined(QT_BUILD_INTERNAL) uint N = QKeySequencePrivate::numberOfKeyBindings; uint val = QKeySequencePrivate::keyBindings[0].shortcut; for ( uint i = 1 ; i < N ; ++i) { @@ -322,13 +325,13 @@ void tst_QKeySequence::standardKeys_data() QTest::newRow("delete") << (int)QKeySequence::Delete<< QString("DEL"); QTest::newRow("open") << (int)QKeySequence::Open << QString("CTRL+O"); QTest::newRow("find") << (int)QKeySequence::Find<< QString("CTRL+F"); -#ifdef Q_WS_WIN - QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T"); - QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3"); - QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3"); - QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4"); - QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); -#endif + if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) { + QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T"); + QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3"); + QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3"); + QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4"); + QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); + } QTest::newRow("bold") << (int)QKeySequence::Bold << QString("CTRL+B"); QTest::newRow("italic") << (int)QKeySequence::Italic << QString("CTRL+I"); QTest::newRow("underline") << (int)QKeySequence::Underline << QString("CTRL+U"); @@ -362,23 +365,33 @@ void tst_QKeySequence::standardKeys() { QFETCH(int, standardKey); QFETCH(QString, expected); - QKeySequence ks((QKeySequence::StandardKey)standardKey); - QKeySequence ks2(expected); - QVERIFY(ks == ks2); + QKeySequence actualKeySequence((QKeySequence::StandardKey)standardKey); + QKeySequence expectedKeySequence(expected); + QVERIFY2(actualKeySequence == expectedKeySequence, + qPrintable(QString::fromLatin1("Key mismatch, expected '%1', got '%2' for standard key %3"). + arg(expected, actualKeySequence.toString()).arg(standardKey))); } void tst_QKeySequence::keyBindings() { - QList bindings = QKeySequence::keyBindings(QKeySequence::Copy); + const QList bindings = + QKeySequence::keyBindings(QKeySequence::Copy); + QList expected; -#if defined(Q_OS_MAC) - expected << QKeySequence("CTRL+C"); -#elif defined Q_WS_X11 - expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT"); -#else - expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT"); -#endif - QVERIFY(bindings == expected); + const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); + const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT")); + switch (m_keyboardScheme) { + case QPlatformTheme::MacKeyboardScheme: + expected << ctrlC; + break; + case QPlatformTheme::WindowsKeyboardScheme: + expected << ctrlC << ctrlInsert; + break; + default: // X11 + expected << ctrlC << QKeySequence(QStringLiteral("F16")) << ctrlInsert; + break; + } + QCOMPARE(bindings, expected); } void tst_QKeySequence::mnemonic_data() diff --git a/tests/auto/other/languagechange/languagechange.pro b/tests/auto/other/languagechange/languagechange.pro index efbc524556..b115c01641 100644 --- a/tests/auto/other/languagechange/languagechange.pro +++ b/tests/auto/other/languagechange/languagechange.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_languagechange -QT += widgets core-private testlib +QT += widgets core-private gui-private testlib SOURCES += tst_languagechange.cpp diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp index b4bd766df7..663f2ef798 100644 --- a/tests/auto/other/languagechange/tst_languagechange.cpp +++ b/tests/auto/other/languagechange/tst_languagechange.cpp @@ -43,13 +43,16 @@ #include #include +#include #include #include #include #include #include +#include #include #include +#include #include #include @@ -66,12 +69,16 @@ private slots: void retranslatability_data(); void retranslatability(); +private: + QDialogButtonBox::ButtonLayout m_layout; }; -tst_languageChange::tst_languageChange() - +tst_languageChange::tst_languageChange() : + m_layout(QDialogButtonBox::WinLayout) { + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_layout = static_cast(theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt()); } void tst_languageChange::initTestCase() @@ -240,6 +247,9 @@ void tst_languageChange::retranslatability() QFETCH( int, dialogType); QFETCH( TranslationSet, expected); + if (m_layout == QDialogButtonBox::GnomeLayout) + QSKIP("The input data are not suitable for this layout (QDialogButtonBox::GnomeLayout)"); + // This will always be queried for when a language changes expected.insert("QCoreApplication::QT_LAYOUT_DIRECTION::Translate this string to the string 'LTR' in left-to-right " "languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to " diff --git a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro index f25ed650c3..5b8f796485 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro +++ b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro @@ -1,7 +1,7 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qmessagebox -QT += widgets testlib +QT += gui-private core-private widgets testlib DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index 7fc752488d..1d391a1c09 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -48,6 +48,8 @@ #include #include #include +#include +#include #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) #include #endif @@ -407,15 +409,12 @@ void tst_QMessageBox::staticSourceCompat() sendKeySoon(); ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes, QMessageBox::No); int expectedButton = int(QMessageBox::Yes); -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) - if (qobject_cast(qApp->style())) - expectedButton = int(QMessageBox::No); -#elif !defined(QT_NO_STYLE_CLEANLOOKS) - if (qobject_cast(qApp->style())) { - QEXPECT_FAIL("", "Special handling of QMessageBox::information buttons for Cleanlooks not implemented yet, QTBUG-24315", Continue); - expectedButton = int(QMessageBox::No); + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + const int dialogButtonBoxLayout = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt(); + if (dialogButtonBoxLayout == QDialogButtonBox::MacLayout + || dialogButtonBoxLayout == QDialogButtonBox::GnomeLayout) + expectedButton = int(QMessageBox::No); } -#endif QCOMPARE(ret, expectedButton); QCOMPARE(keyToSend, -1); diff --git a/tests/auto/widgets/kernel/qaction/qaction.pro b/tests/auto/widgets/kernel/qaction/qaction.pro index e6f0735394..c57107b1b0 100644 --- a/tests/auto/widgets/kernel/qaction/qaction.pro +++ b/tests/auto/widgets/kernel/qaction/qaction.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qaction -QT += widgets testlib +QT += gui-private core-private widgets testlib SOURCES += tst_qaction.cpp diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 47aad21074..51123af953 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -46,6 +46,8 @@ #include #include #include +#include +#include class tst_QAction : public QObject { @@ -77,6 +79,7 @@ private slots: private: int m_lastEventType; + int m_keyboardScheme; QAction *m_lastAction; QWidget *m_tstWidget; }; @@ -121,8 +124,10 @@ private: tst_QAction *tst; }; -tst_QAction::tst_QAction() +tst_QAction::tst_QAction() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme) { + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); } tst_QAction::~tst_QAction() @@ -237,13 +242,21 @@ void tst_QAction::setStandardKeys() QVERIFY(act.shortcut() == act.shortcuts().first()); QList expected; -#if defined(Q_OS_MAC) - expected << QKeySequence("CTRL+C"); -#else - expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT"); -#endif -// Qt/Embedded on Windows: expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT"); - QVERIFY(act.shortcuts() == expected); + const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); + const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT")); + switch (m_keyboardScheme) { + case QPlatformTheme::MacKeyboardScheme: + expected << ctrlC; + break; + case QPlatformTheme::WindowsKeyboardScheme: + expected << ctrlC << ctrlInsert; + break; + default: // X11 + expected << ctrlC << QKeySequence(QStringLiteral("F16")) << ctrlInsert; + break; + } + + QCOMPARE(act.shortcuts(), expected); } From 194898bab9a02c442627714af569c8fa4d981df2 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Tue, 21 Feb 2012 22:44:08 +0000 Subject: [PATCH 010/166] Fix breakage in dead code Change-Id: Ibcddfb711a3f47bf957a4b010330e8a775f1a2e8 Reviewed-by: Rohan McGovern --- tests/auto/xml/dom/qdom/tst_qdom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index d79044157a..1533e6a139 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -1845,7 +1845,7 @@ void tst_QDom::checkIntOverflow() const QVERIFY(doc.setContent(xmlMessage)); const QDomNodeList nl(doc.elementsByTagName(QLatin1String("test"))); - QCOMPARE(nl.length(), uint(1)); + QCOMPARE(nl.length(), 1); } } From 4d0d49a92cca46555a5e3ed482b7d7f50ea3655a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 21 Feb 2012 19:45:05 +0100 Subject: [PATCH 011/166] Use QMAKE_SUBSTITUTIONS conditionals Instead of generating CMake conditionals. Change-Id: I3d987cc08666270e618222be9292558e73bc961e Reviewed-by: Oswald Buddenhagen --- mkspecs/cmake/Qt5BasicConfig.cmake.in | 76 ++++++++++++------------ src/corelib/Qt5CoreConfigExtras.cmake.in | 14 ++--- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/mkspecs/cmake/Qt5BasicConfig.cmake.in b/mkspecs/cmake/Qt5BasicConfig.cmake.in index b3d33d62d1..ebdad09bf9 100644 --- a/mkspecs/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/cmake/Qt5BasicConfig.cmake.in @@ -32,46 +32,46 @@ endif() if (NOT _Qt5$${CMAKE_MODULE_NAME}_target) set(_Qt5$${CMAKE_MODULE_NAME}_target 1) - if (\"$${CMAKE_STATIC_TYPE}\" STREQUAL \"\") - add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED) - else() - add_library(Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED) - endif() - if (NOT \"$${CMAKE_BUILD_IS_FRAMEWORK}\" STREQUAL \"\") - set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1) - endif() +!!IF !isEmpty(CMAKE_STATIC_TYPE) + add_library(Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED) +!!ELSE + add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED) +!!ENDIF +!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK) + set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1) +!!ENDIF endif() -if (NOT \"$${debug_type}\" STREQUAL \"\") - set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES - IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG \"$${CMAKE_QT5_MODULE_DEPS}\" - IMPORTED_LOCATION_DEBUG \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" - ) - if (NOT \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" STREQUAL \"\") - set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES - IMPORTED_IMPLIB_DEBUG \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" - ) - endif() -endif() +!!IF !isEmpty(debug_type) +set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES + IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG \"$${CMAKE_QT5_MODULE_DEPS}\" + IMPORTED_LOCATION_DEBUG \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" +) +!!IF !isEmpty(CMAKE_IMPLIB_FILE_LOCATION_DEBUG) +set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES + IMPORTED_IMPLIB_DEBUG \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" +) +!!ENDIF +!!ENDIF -if (NOT \"$${release_type}\" STREQUAL \"\") - set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES - IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE \"$${CMAKE_QT5_MODULE_DEPS}\" - IMPORTED_LOCATION_RELEASE \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" - ) - if (NOT \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" STREQUAL \"\") - set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES - IMPORTED_IMPLIB_RELEASE \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" - ) - endif() -endif() +!!IF !isEmpty(release_type) +set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE \"$${CMAKE_QT5_MODULE_DEPS}\" + IMPORTED_LOCATION_RELEASE \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" +) +!!IF !isEmpty(CMAKE_IMPLIB_FILE_LOCATION_RELEASE) +set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES + IMPORTED_IMPLIB_RELEASE \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" +) +!!ENDIF +!!ENDIF -if (NOT \"$${CMAKE_MODULE_EXTRAS}\" STREQUAL \"\") - include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake\") -endif() +!!IF !isEmpty(CMAKE_MODULE_EXTRAS) +include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}ConfigExtras.cmake\") +!!ENDIF -if (NOT \"$${CMAKE_MODULE_MACROS}\" STREQUAL \"\") - include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}Macros.cmake\") -endif() +!!IF !isEmpty(CMAKE_MODULE_MACROS) +include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}Macros.cmake\") +!!ENDIF diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 37af42d6bd..41dbf2c2a2 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -8,11 +8,11 @@ set(QT_RCC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/rcc$$CMAK list(APPEND Qt5Core_INCLUDE_DIRS \"${_qt5_corelib_install_prefix}/mkspecs/default\") -if (NOT \"$${CMAKE_ADD_FPIE_FLAGS}\" STREQUAL \"\") - set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "-fPIE") -endif() +!!IF !isEmpty(CMAKE_ADD_FPIE_FLAGS) +set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "-fPIE") +!!ENDIF -if (NOT \"$$QT_NAMESPACE\" STREQUAL \"\") - list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE) - list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) -endif() +!!IF !isEmpty(QT_NAMESPACE) +list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE) +list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) +!!ENDIF From f783ec5347ac9962d011b2ff470082e083216367 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 21 Feb 2012 22:18:26 +0100 Subject: [PATCH 012/166] Remove use of Q_BROKEN_DEBUG_STREAM. No supported compiler defines it, and it was not used consistently so it didn't work anyway. Change-Id: Icc9e911e22daaedaee3d9316c15d19be26cd2e72 Reviewed-by: Thiago Macieira --- src/corelib/itemmodels/qabstractitemmodel.cpp | 6 ----- .../itemmodels/qitemselectionmodel.cpp | 6 ----- src/corelib/kernel/qobject.cpp | 6 ----- src/corelib/kernel/qvariant.cpp | 24 +++++-------------- src/corelib/kernel/qvariant_p.h | 2 +- src/gui/kernel/qevent.cpp | 6 ----- src/gui/kernel/qguivariant.cpp | 4 ++-- src/gui/kernel/qkeysequence.cpp | 6 ----- src/gui/painting/qbrush.cpp | 6 ----- src/gui/painting/qcolor.cpp | 6 ----- src/gui/painting/qpen.cpp | 6 ----- src/gui/painting/qpolygon.cpp | 12 ---------- src/sql/kernel/qsqlfield.cpp | 6 ----- src/widgets/kernel/qwidgetsvariant.cpp | 4 ++-- 14 files changed, 11 insertions(+), 89 deletions(-) diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 1d6610af05..a8c3921f45 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -431,15 +431,9 @@ bool QPersistentModelIndex::isValid() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QModelIndex &idx) { -#ifndef Q_BROKEN_DEBUG_STREAM dbg.nospace() << "QModelIndex(" << idx.row() << ',' << idx.column() << ',' << idx.internalPointer() << ',' << idx.model() << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QModelIndex to QDebug"); - return dbg; - Q_UNUSED(idx); -#endif } QDebug operator<<(QDebug dbg, const QPersistentModelIndex &idx) diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 7f31128770..c6c1f6f3cf 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -1622,15 +1622,9 @@ void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelectio #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QItemSelectionRange &range) { -#ifndef Q_BROKEN_DEBUG_STREAM dbg.nospace() << "QItemSelectionRange(" << range.topLeft() << ',' << range.bottomRight() << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QItemSelectionRange to QDebug"); - return dbg; - Q_UNUSED(range); -#endif } #endif diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 252a713872..8fa5dcdcff 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3617,7 +3617,6 @@ QObjectUserData* QObject::userData(uint id) const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QObject *o) { -#ifndef Q_BROKEN_DEBUG_STREAM if (!o) return dbg << "QObject(0x0) "; dbg.nospace() << o->metaObject()->className() << '(' << (void *)o; @@ -3625,11 +3624,6 @@ QDebug operator<<(QDebug dbg, const QObject *o) { dbg << ", name = " << o->objectName(); dbg << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QObject to QDebug"); - return dbg; - Q_UNUSED(o); -#endif } #endif diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 9f57cd018c..0b7866c3eb 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -732,7 +732,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, return true; } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) static void streamDebug(QDebug dbg, const QVariant &v) { QVariant::Private *d = const_cast(&v.data_ptr()); @@ -752,7 +752,7 @@ const QVariant::Handler qt_kernel_variant_handler = { compare, convert, 0, -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) streamDebug #else 0 @@ -764,7 +764,7 @@ static void dummyClear(QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Try static bool dummyIsNull(const QVariant::Private *d) { Q_ASSERT_X(false, "QVariant::isNull", "Trying to call isNull on an unknown type"); return d->is_null; } static bool dummyCompare(const QVariant::Private *, const QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to compare an unknown types"); return false; } static bool dummyConvert(const QVariant::Private *, QVariant::Type , void *, bool *) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); return false; } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) static void dummyStreamDebug(QDebug, const QVariant &) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); } #endif const QVariant::Handler qt_dummy_variant_handler = { @@ -778,7 +778,7 @@ const QVariant::Handler qt_dummy_variant_handler = { dummyCompare, dummyConvert, 0, -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) dummyStreamDebug #else 0 @@ -847,7 +847,7 @@ static bool customConvert(const QVariant::Private *, QVariant::Type, void *, boo return false; } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) static void customStreamDebug(QDebug, const QVariant &) {} #endif @@ -862,7 +862,7 @@ const QVariant::Handler qt_custom_variant_handler = { customCompare, customConvert, 0, -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) customStreamDebug #else 0 @@ -2644,28 +2644,16 @@ bool QVariant::isNull() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QVariant &v) { -#ifndef Q_BROKEN_DEBUG_STREAM dbg.nospace() << "QVariant(" << QMetaType::typeName(v.userType()) << ", "; handlerManager[v.d.type]->debugStream(dbg, v); dbg.nospace() << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QVariant to QDebug"); - return dbg; - Q_UNUSED(v); -#endif } QDebug operator<<(QDebug dbg, const QVariant::Type p) { -#ifndef Q_BROKEN_DEBUG_STREAM dbg.nospace() << "QVariant::" << QMetaType::typeName(p); return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QVariant::Type to QDebug"); - return dbg; - Q_UNUSED(p); -#endif } #endif diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index cdae8997a7..c428d81bb4 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -410,7 +410,7 @@ Q_CORE_EXPORT void registerHandler(const int /* Modules::Names */ name, const QV Q_CORE_EXPORT void unregisterHandler(const int /* Modules::Names */ name); } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) template class QVariantDebugStream { diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ce4594c7ab..f99f3ddec3 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2887,7 +2887,6 @@ QShortcutEvent::~QShortcutEvent() #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QEvent *e) { -#ifndef Q_BROKEN_DEBUG_STREAM // More useful event output could be added here if (!e) return dbg << "QEvent(this = 0x0)"; @@ -3168,11 +3167,6 @@ QDebug operator<<(QDebug dbg, const QEvent *e) { dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QEvent to QDebug"); - return dbg; - Q_UNUSED(e); -#endif } #endif diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index 8378650dcb..2ebfb32bc3 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -342,7 +342,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, return qcoreVariantHandler()->convert(d, t, result, ok); } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) static void streamDebug(QDebug dbg, const QVariant &v) { QVariant::Private *d = const_cast(&v.data_ptr()); @@ -362,7 +362,7 @@ const QVariant::Handler qt_gui_variant_handler = { compare, convert, 0, -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) streamDebug #else 0 diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index bd0f220ae8..7053f01196 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1735,14 +1735,8 @@ QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence) #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QKeySequence &p) { -#ifndef Q_BROKEN_DEBUG_STREAM dbg.nospace() << "QKeySequence(" << p.toString() << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QKeySequence to QDebug"); - return dbg; - Q_UNUSED(p); -#endif } #endif diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index c8dc370a8b..6850eac59e 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -957,7 +957,6 @@ bool QBrush::operator==(const QBrush &b) const */ QDebug operator<<(QDebug dbg, const QBrush &b) { -#ifndef Q_BROKEN_DEBUG_STREAM static const char *BRUSH_STYLES[] = { "NoBrush", "SolidPattern", @@ -983,11 +982,6 @@ QDebug operator<<(QDebug dbg, const QBrush &b) dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QBrush to QDebug"); - return dbg; - Q_UNUSED(b); -#endif } #endif diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 2c95434843..96491918cd 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -2399,7 +2399,6 @@ void QColor::invalidate() #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QColor &c) { -#ifndef Q_BROKEN_DEBUG_STREAM if (!c.isValid()) dbg.nospace() << "QColor(Invalid)"; else if (c.spec() == QColor::Rgb) @@ -2413,11 +2412,6 @@ QDebug operator<<(QDebug dbg, const QColor &c) dbg.nospace() << "QColor(AHSL " << c.alphaF() << ", " << c.hslHueF() << ", " << c.hslSaturationF() << ", " << c.lightnessF() << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QColor to QDebug"); - return dbg; - Q_UNUSED(c); -#endif } #endif diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index b6966b12c3..8d05eb56ff 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -985,7 +985,6 @@ QDataStream &operator>>(QDataStream &s, QPen &p) #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QPen &p) { -#ifndef Q_BROKEN_DEBUG_STREAM const char *PEN_STYLES[] = { "NoPen", "SolidLine", @@ -1002,11 +1001,6 @@ QDebug operator<<(QDebug dbg, const QPen &p) << ',' << p.dashOffset() << ',' << p.miterLimit() << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QPen to QDebug"); - return dbg; - Q_UNUSED(p); -#endif } #endif diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp index 3a4860a559..ee1f7967cb 100644 --- a/src/gui/painting/qpolygon.cpp +++ b/src/gui/painting/qpolygon.cpp @@ -468,17 +468,11 @@ QRect QPolygon::boundingRect() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QPolygon &a) { -#ifndef Q_BROKEN_DEBUG_STREAM dbg.nospace() << "QPolygon("; for (int i = 0; i < a.count(); ++i) dbg.nospace() << a.at(i); dbg.nospace() << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QPolygon to QDebug"); - return dbg; - Q_UNUSED(a); -#endif } #endif @@ -814,17 +808,11 @@ QDataStream &operator>>(QDataStream &s, QPolygonF &a) #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QPolygonF &a) { -#ifndef Q_BROKEN_DEBUG_STREAM dbg.nospace() << "QPolygonF("; for (int i = 0; i < a.count(); ++i) dbg.nospace() << a.at(i); dbg.nospace() << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QPolygonF to QDebug"); - return dbg; - Q_UNUSED(a); -#endif } #endif diff --git a/src/sql/kernel/qsqlfield.cpp b/src/sql/kernel/qsqlfield.cpp index 5d01df1b8e..3160d25ef5 100644 --- a/src/sql/kernel/qsqlfield.cpp +++ b/src/sql/kernel/qsqlfield.cpp @@ -504,7 +504,6 @@ bool QSqlField::isValid() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QSqlField &f) { -#ifndef Q_BROKEN_DEBUG_STREAM dbg.nospace() << "QSqlField(" << f.name() << ", " << QVariant::typeToName(f.type()); if (f.length() >= 0) dbg.nospace() << ", length: " << f.length(); @@ -520,11 +519,6 @@ QDebug operator<<(QDebug dbg, const QSqlField &f) dbg.nospace() << ", auto-value: \"" << f.defaultValue() << '\"'; dbg.nospace() << ')'; return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QSqlField to QDebug"); - return dbg; - Q_UNUSED(f); -#endif } #endif diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index 72080d9e6b..cf85cbf063 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -127,7 +127,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type type, void *resul return false; } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) static void streamDebug(QDebug dbg, const QVariant &v) { QVariant::Private *d = const_cast(&v.data_ptr()); @@ -157,7 +157,7 @@ static const QVariant::Handler widgets_handler = { compare, convert, 0, -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) streamDebug #else 0 From 58cd93efe6545ea74e9d3ba2003bcd5478e6c582 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 21 Feb 2012 17:26:45 +0100 Subject: [PATCH 013/166] Remove detection of GCC versions which are not supported anywhere. Change-Id: If254af51880e20be486b14f5237e6e1d4e4d6af3 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 39 +++++-------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 8adbdbe453..fa5c424772 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -139,45 +139,22 @@ # define Q_CC_MINGW # endif # if defined(__INTEL_COMPILER) -/* Intel C++ also masquerades as GCC 3.2.0 */ +/* Intel C++ also masquerades as GCC */ # define Q_CC_INTEL # endif # if defined(__clang__) -/* Clang also masquerades as GCC 4.2.1 */ +/* Clang also masquerades as GCC */ # define Q_CC_CLANG # endif # ifdef __APPLE__ # define Q_NO_DEPRECATED_CONSTRUCTORS # endif -# if __GNUC__ == 2 && __GNUC_MINOR__ <= 7 -# define Q_FULL_TEMPLATE_INSTANTIATION -# endif -/* GCC 2.95 knows "using" but does not support it correctly */ -# if __GNUC__ == 2 && __GNUC_MINOR__ <= 95 -# define Q_NO_USING_KEYWORD -# endif -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) -# define Q_ALIGNOF(type) __alignof__(type) -# define Q_TYPEOF(expr) __typeof__(expr) -# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) -# endif -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -# define Q_LIKELY(expr) __builtin_expect(!!(expr), true) -# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false) -# endif -/* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */ -# if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1 -# define Q_WRONG_SB_CTYPE_MACROS -# endif -/* GCC <= 3.3 cannot handle template friends */ -# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3) -# define Q_NO_TEMPLATE_FRIENDS -# endif -/* Apple's GCC 3.1 chokes on our streaming qDebug() */ -# if defined(Q_OS_DARWIN) && __GNUC__ == 3 && (__GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 3) -# define Q_BROKEN_DEBUG_STREAM -# endif -# if (defined(Q_CC_GNU) || defined(Q_CC_INTEL)) && !defined(QT_MOC_CPP) +# define Q_ALIGNOF(type) __alignof__(type) +# define Q_TYPEOF(expr) __typeof__(expr) +# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) +# define Q_LIKELY(expr) __builtin_expect(!!(expr), true) +# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false) +# if !defined(QT_MOC_CPP) # define Q_PACKED __attribute__ ((__packed__)) # define Q_NO_PACKED_REFERENCE # ifndef __ARM_EABI__ From 26cf615c9601cf4dbe4450aa95ad6e2020639513 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 21 Feb 2012 23:00:57 +0100 Subject: [PATCH 014/166] Add the QT_LIBINFIX to the CMake config files. Change-Id: If7bec54eca2d28cba314ce94a1ab1831c024ad31 Reviewed-by: Alexander Neundorf Reviewed-by: Stephen Kelly --- src/corelib/Qt5CoreConfigExtras.cmake.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 41dbf2c2a2..4b5ac73bce 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -16,3 +16,7 @@ set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "-fPIE") list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE) list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) !!ENDIF + +!!IF !isEmpty(QT_LIBINFIX) +set(QT_LIBINFIX \"$${QT_LIBINFIX}\") +!!ENDIF From 126eaa7cddbf27d73d14394dfd8b0776376a6460 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 21 Feb 2012 17:25:28 +0100 Subject: [PATCH 015/166] Remove unused Q_CANNOT_DELETE_CONSTANT Change-Id: I697f3f786d84fa766b3bc48d93fc265deee5fdcf Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index fa5c424772..f76dfbaaa5 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -83,7 +83,6 @@ #elif defined(_MSC_VER) # define Q_CC_MSVC # define Q_CC_MSVC_NET -# define Q_CANNOT_DELETE_CONSTANT # define Q_OUTOFLINE_TEMPLATE inline # define Q_NO_TEMPLATE_FRIENDS # define Q_ALIGNOF(type) __alignof(type) @@ -259,7 +258,6 @@ DEC C++ V5.5-004. */ # if __DECCXX_VER < 60060000 # define Q_BROKEN_TEMPLATE_SPECIALIZATION -# define Q_CANNOT_DELETE_CONSTANT # endif /* avoid undefined symbol problems with out-of-line template members */ # define Q_OUTOFLINE_TEMPLATE inline From 13c7de63a15c2b47e07516650ba4f1b70f94680e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 22 Feb 2012 18:17:53 +0100 Subject: [PATCH 016/166] Don't do macro self-expansion for moc anymore. Change-Id: Ia34cc244a160c6c4abe6dacd7a2ce29bc4fc7bfb Reviewed-by: Olivier Goffart --- src/corelib/global/qglobal.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 58bdf06fb5..485f08bfce 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -310,9 +310,7 @@ QT_END_INCLUDE_NAMESPACE /* Warnings and errors when using deprecated methods */ -#if defined(Q_MOC_RUN) -# define Q_DECL_DEPRECATED Q_DECL_DEPRECATED -#elif (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT) +#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT) # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__)) #elif defined(Q_CC_MSVC) # define Q_DECL_DEPRECATED __declspec(deprecated) @@ -327,9 +325,7 @@ QT_END_INCLUDE_NAMESPACE # define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED #endif #ifndef Q_DECL_CONSTRUCTOR_DEPRECATED -# if defined(Q_MOC_RUN) -# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_CONSTRUCTOR_DEPRECATED -# elif defined(Q_NO_DEPRECATED_CONSTRUCTORS) +# if defined(Q_NO_DEPRECATED_CONSTRUCTORS) # define Q_DECL_CONSTRUCTOR_DEPRECATED # else # define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_DEPRECATED From 949127264d16050113aff0932d2e0197921952d2 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 13 Feb 2012 17:27:36 +0200 Subject: [PATCH 017/166] Remove unneeded code to convert to ASCII/Latin1. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This isn't used, and isn't wanted with the upcoming utf8 switch. Change-Id: Ibec0fa7f36549df6a1c240353ffcd44beb2976f0 Reviewed-by: João Abecasis Reviewed-by: Thiago Macieira --- src/corelib/tools/qstringbuilder.cpp | 13 ----------- src/corelib/tools/qstringbuilder.h | 32 ---------------------------- 2 files changed, 45 deletions(-) diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 30c4399cc9..6999972172 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -116,17 +116,4 @@ void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out } } -/*! \internal */ -void QAbstractConcatenable::convertToAscii(const QChar* a, int len, char*& out) -{ - if (len == -1) { - while (a->unicode()) - convertToLatin1(*a++, out); - } else { - for (int i = 0; i < len; ++i) - convertToLatin1(a[i], out); - } -} - - QT_END_NAMESPACE diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index ebaaaa35c2..4c963185ad 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -62,21 +62,10 @@ struct Q_CORE_EXPORT QAbstractConcatenable { protected: static void convertFromAscii(const char *a, int len, QChar *&out); - static void convertToAscii(const QChar *a, int len, char *&out); static inline void convertFromAscii(char a, QChar *&out) { *out++ = QLatin1Char(a); } - - static inline void convertToAscii(QChar a, char *&out) - { - convertToLatin1(a, out); - } - - static inline void convertToLatin1(QChar a, char *&out) - { - *out++ = a.unicode() > 0xff ? '?' : char(a.unicode()); - } }; template struct QConcatenable {}; @@ -182,10 +171,6 @@ template <> struct QConcatenable : private QAbstractConcatenable static int size(const QChar) { return 1; } static inline void appendTo(const QChar c, QChar *&out) { *out++ = c; } -#ifndef QT_NO_CAST_TO_ASCII - static inline QT_ASCII_CAST_WARN void appendTo(const QChar c, char *&out) - { convertToAscii(c, out); } -#endif }; template <> struct QConcatenable : private QAbstractConcatenable @@ -196,10 +181,6 @@ template <> struct QConcatenable : private QAbstractConcatenable static int size(const QCharRef &) { return 1; } static inline void appendTo(const QCharRef &c, QChar *&out) { *out++ = QChar(c); } -#ifndef QT_NO_CAST_TO_ASCII - static inline QT_ASCII_CAST_WARN void appendTo(const QCharRef &c, char *&out) - { convertToAscii(c, out); } -#endif }; template <> struct QConcatenable @@ -232,10 +213,6 @@ template <> struct QConcatenable : private QAbstractConcatenable memcpy(out, reinterpret_cast(a.constData()), sizeof(QChar) * n); out += n; } -#ifndef QT_NO_CAST_TO_ASCII - static inline QT_ASCII_CAST_WARN void appendTo(const QString &a, char *&out) - { convertToAscii(a.constData(), a.length(), out); } -#endif }; template struct QConcatenable > : private QAbstractConcatenable @@ -249,10 +226,6 @@ template struct QConcatenable > : private QAbstra memcpy(out, reinterpret_cast(a.ptr->data), sizeof(QChar) * N); out += N; } -#ifndef QT_NO_CAST_TO_ASCII - static inline QT_ASCII_CAST_WARN void appendTo(const type &a, char *&out) - { convertToAscii(a.ptr->data, N, out); } -#endif }; template <> struct QConcatenable : private QAbstractConcatenable @@ -267,11 +240,6 @@ template <> struct QConcatenable : private QAbstractConcatenable memcpy(out, reinterpret_cast(a.constData()), sizeof(QChar) * n); out += n; } -#ifndef QT_NO_CAST_TO_ASCII - static inline QT_ASCII_CAST_WARN void appendTo(const QStringRef &a, char *&out) - { convertToAscii(a.constData(), a.length(), out); } -#endif - }; template struct QConcatenable : private QAbstractConcatenable From eec25d44e43e80d200f4bfaa7b78e094e6a01df6 Mon Sep 17 00:00:00 2001 From: Rick Stockton Date: Thu, 16 Feb 2012 19:20:35 -0800 Subject: [PATCH 018/166] Suppport up to 27 mouse buttons from DirectFB Plugin. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous to this update, our plugin accepts only 3 moue buttons (from DirectFB, to be translated into Qt::MouseButton values.) This update changes our Plugin, so that it will successfully translate up to 27 mouse button numbers. It is unclear, to the author, which configurations of DirectFB on Linux might be capable of actually sending high-numbered mouse button Events to Qt. But, if/when a DirectFB configuration does so, this change makes Qt ready to recognize and work with the button event. Task-number: QTBUG-24335 Change-Id: I8839ed386eb3d261a187355a244e80d511399ea8 Reviewed-by: Samuel Rødal --- .../directfb/qdirectfbconvenience.cpp | 62 +++++++++++++++++-- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp index 7b253b7220..e41a2e0440 100644 --- a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp +++ b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp @@ -128,13 +128,65 @@ IDirectFBSurface *QDirectFbConvenience::dfbSurfaceForPlatformPixmap(QPlatformPix Qt::MouseButton QDirectFbConvenience::mouseButton(DFBInputDeviceButtonIdentifier identifier) { - switch (identifier){ - case DIBI_LEFT: + // The Enum contains values for DIBI_FIRST (= DIBI_LEFT), DIBI_LAST (= 0x1f,) and + // just 3 enumerated Mouse Buttons. To convert into *ALL* possible Qt::MoueButton values, + // the parameter is cast as integer. + + switch (int(identifier)) { + case DIBI_LEFT: // value is 0x00 return Qt::LeftButton; - case DIBI_MIDDLE: - return Qt::MidButton; - case DIBI_RIGHT: + case DIBI_RIGHT: // value is 0x01 return Qt::RightButton; + case DIBI_MIDDLE: // value is 0x02 + return Qt::MidButton; + case 0x03: + return Qt::BackButton; + case 0x04: + return Qt::ForwardButton; + case 0x05: + return Qt::ExtraButton3; + case 0x06: + return Qt::ExtraButton4; + case 0x07: + return Qt::ExtraButton5; + case 0x08: + return Qt::ExtraButton6; + case 0x09: + return Qt::ExtraButton7; + case 0x0a: + return Qt::ExtraButton8; + case 0x0b: + return Qt::ExtraButton9; + case 0x0c: + return Qt::ExtraButton10; + case 0x0d: + return Qt::ExtraButton11; + case 0x0e: + return Qt::ExtraButton12; + case 0x0f: + return Qt::ExtraButton13; + case 0x10: + return Qt::ExtraButton14; + case 0x11: + return Qt::ExtraButton15; + case 0x12: + return Qt::ExtraButton16; + case 0x13: + return Qt::ExtraButton17; + case 0x14: + return Qt::ExtraButton18; + case 0x15: + return Qt::ExtraButton19; + case 0x16: + return Qt::ExtraButton20; + case 0x17: + return Qt::ExtraButton21; + case 0x18: + return Qt::ExtraButton22; + case 0x19: + return Qt::ExtraButton23; + case 0x1a: + return Qt::ExtraButton24; default: return Qt::NoButton; } From 5942556d65924f07750c4e1e96a7a9e908e77d11 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 01:05:46 +0100 Subject: [PATCH 019/166] Use the CMake definition of Windows for CMake macros. Change-Id: I599ddaaf9176f76f2e144c893e607757957dfef2 Reviewed-by: Clinton Stimpson Reviewed-by: Stephen Kelly --- src/corelib/Qt5CoreMacros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index abfe49ec84..4a10fad9eb 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -83,7 +83,7 @@ macro(QT5_GET_MOC_FLAGS _moc_flags) set(${_moc_flags} ${${_moc_flags}} "-D${_current}") endforeach() - if(Q_WS_WIN) + if(WIN32) set(${_moc_flags} ${${_moc_flags}} -DWIN32) endif() endmacro() From 1f80ce8135addad822fed71f3b3c2afaceadbfef Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Mon, 20 Feb 2012 10:23:26 +1000 Subject: [PATCH 020/166] Report failure to open deprecated header file If a deprecated header file is not writable, report the error message. The existing error message statement is not processed due to an operator precedence issue. Change-Id: Ifb2d4e234c64e560d05c021c621966bce19ce215 Reviewed-by: Rohan McGovern --- bin/syncqt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/syncqt b/bin/syncqt index 9129de053a..581233a162 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -351,7 +351,7 @@ sub syncHeader { #write it my $iheader_out = fixPaths($iheader, $header_dir); - open HEADER, ">$header" || die "Could not open $header for writing!\n"; + open(HEADER, ">$header") || die "Could not open $header for writing: $!\n"; print HEADER "#include \"$iheader_out\"\n"; close HEADER; if(defined($ts)) { @@ -1133,7 +1133,7 @@ foreach my $lib (@modules_to_sync) { my $header_dir = dirname($header_path); make_path($header_dir, $lib, $verbose_level); - open HEADER, ">$header_path" || die "Could not open $header_path for writing!\n"; + open(HEADER, ">$header_path") || die "Could not open $header_path for writing: $!\n"; print HEADER "#ifndef $guard\n"; print HEADER "#define $guard\n"; my $warning = "Header <$lib/"; From 8bf009e2162ec1a8fd7a6756c10f85e1236cfc15 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 22 Feb 2012 13:28:44 +0100 Subject: [PATCH 021/166] Silence coverity warning about sizeof(Node*) vs sizeof(Node) in QList Coverity was complaining about QList::node_copy using sizeof(Node *) instead of sizeof(Node). The complete message from Coverity is: "Passing argument "from" of type "struct QList::Node *" and argument "(to - from) * sizeof (struct QList::Node *) /*4*/" to function "memcpy" is suspicious. Did you intend to use "sizeof(struct QList::Node)" instead of "sizeof (struct QList::Node *)" ? In this particular case sizeof(struct QList::Node *) happens to be equal to sizeof(struct QList::Node), but this is not a portable assumption." Task-number: QTBUG-24443 Change-Id: I583887a8b4177a224664065e14f8780a9586c9a3 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 8f36e5c2ae..bf6933732c 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -402,7 +402,7 @@ Q_INLINE_TEMPLATE void QList::node_copy(Node *from, Node *to, Node *src) } } else { if (src != from && to - from > 0) - memcpy(from, src, (to - from) * sizeof(Node *)); + memcpy(from, src, (to - from) * sizeof(Node)); } } From 2b4e20ff17b56b1c590e9cc25393fa751d7fbce4 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 23 Feb 2012 08:17:22 +0100 Subject: [PATCH 022/166] Add src/concurrent/qtconcurrentversion.h to .gitignore Change-Id: I521d9809b5e7a67db1370dd178d3795beee2a388 Reviewed-by: Friedemann Kleint Reviewed-by: Robin Burchell --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3aeefbafe9..33387c5bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -122,6 +122,7 @@ translations/*.qm translations/*_untranslated.ts qrc_*.cpp +src/concurrent/qtconcurrentversion.h src/corelib/qtcoreversion.h src/dbus/qtdbusversion.h src/gui/qtguiversion.h From 4a7be92f06d81b93264e998d5f98480cf5bc58ba Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 08:53:04 +0100 Subject: [PATCH 023/166] Fixed tst_qobject signalbug silently not compiled in -fast builds. When configuring with -fast on Windows, a directory which contains two .pro files, one SUBDIRS and one not, will have the SUBDIRS Makefile silently clobbered by the non-SUBDIRS Makefile. In practice, this may cause various subdirectories to be silently excluded from the build. Rearrange .pro files for this test to avoid triggering this bug. See also e9015b3bc8827a8276f58bdd41adcac1bcbf2137. Task-number: QTBUG-21168 Change-Id: I18fac1ac636fdc6b2aaee1b4cdfee9c4bc2a77ff Reviewed-by: Rohan McGovern --- tests/auto/corelib/kernel/qobject/qobject.pro | 8 +++++--- .../kernel/qobject/{tst_qobject.pro => test/test.pro} | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) rename tests/auto/corelib/kernel/qobject/{tst_qobject.pro => test/test.pro} (79%) diff --git a/tests/auto/corelib/kernel/qobject/qobject.pro b/tests/auto/corelib/kernel/qobject/qobject.pro index 0f86408fc9..6a7cf07f51 100644 --- a/tests/auto/corelib/kernel/qobject/qobject.pro +++ b/tests/auto/corelib/kernel/qobject/qobject.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs -SUBDIRS = signalbug -tst_qobject.pro.depends = $$SUBDIRS -SUBDIRS += tst_qobject.pro +CONFIG += ordered + +SUBDIRS += \ + signalbug \ + test diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.pro b/tests/auto/corelib/kernel/qobject/test/test.pro similarity index 79% rename from tests/auto/corelib/kernel/qobject/tst_qobject.pro rename to tests/auto/corelib/kernel/qobject/test/test.pro index 30fd810a2e..9443b2e2c7 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.pro +++ b/tests/auto/corelib/kernel/qobject/test/test.pro @@ -1,11 +1,11 @@ CONFIG += testcase console -TARGET = tst_qobject +TARGET = ../tst_qobject QT = core-private network testlib -SOURCES = tst_qobject.cpp +SOURCES = ../tst_qobject.cpp # this is here for a reason, moc_oldnormalizedobject.cpp is not auto-generated, it was generated by # moc from Qt 4.6, and should *not* be generated by the current moc -SOURCES += moc_oldnormalizeobject.cpp +SOURCES += ../moc_oldnormalizeobject.cpp load(testcase) # for target.path and installTestHelperApp() installTestHelperApp("signalbug/signalbug",signalbug,signalbug) From 034ac599f6d5b3149b3fe4983c8f539a4d0ffe05 Mon Sep 17 00:00:00 2001 From: Marko Kenttala Date: Tue, 31 Jan 2012 13:19:02 +0200 Subject: [PATCH 024/166] Fix height of some Thai characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some Thai characters with two above glyphs were higher than fonts ascent. This caused them to be clipped in for example qtcomponents buttons. Added checking for this and calculation of new lower offset between glyphs if needed. Task-Number: ou1cimx1#898104 Reviewed-by: Lars Knoll Reviewed-by: Sami Merilä Reviewed-by: Pasi Pentikäinen (cherry picked from commit d7c7bf721c93fe7629f725c181b52ad9ca645a7a) Change-Id: Ie4ac69de75f50b68b2ba87353d83098846f319f4 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp index 0734442fe0..af0ee52e9a 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp @@ -265,6 +265,34 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom, int glast) //qreal offsetBase = (size - 4) / 4 + qMin(size, 4) + 1; // qDebug("offset = %f", offsetBase); + // To fix some Thai character heights check for two above glyphs + if (nmarks == 2 && (attributes[gfrom+1].combiningClass == HB_Combining_AboveRight || + attributes[gfrom+1].combiningClass == HB_Combining_AboveLeft || + attributes[gfrom+1].combiningClass == HB_Combining_Above)) + if (attributes[gfrom+2].combiningClass == 23 || + attributes[gfrom+2].combiningClass == 24 || + attributes[gfrom+2].combiningClass == 25 || + attributes[gfrom+2].combiningClass == 27 || + attributes[gfrom+2].combiningClass == 28 || + attributes[gfrom+2].combiningClass == 30 || + attributes[gfrom+2].combiningClass == 31 || + attributes[gfrom+2].combiningClass == 33 || + attributes[gfrom+2].combiningClass == 34 || + attributes[gfrom+2].combiningClass == 35 || + attributes[gfrom+2].combiningClass == 36 || + attributes[gfrom+2].combiningClass == 107 || + attributes[gfrom+2].combiningClass == 122) { + // Two above glyphs, check total height + int markTotalHeight = baseMetrics.height; + HB_GlyphMetrics markMetrics; + item->font->klass->getGlyphMetrics(item->font, glyphs[gfrom+1], &markMetrics); + markTotalHeight += markMetrics.height; + item->font->klass->getGlyphMetrics(item->font, glyphs[gfrom+2], &markMetrics); + markTotalHeight += markMetrics.height; + if ((markTotalHeight + 2 * offsetBase) > (size * 10)) + offsetBase = ((size * 10) - markTotalHeight) / 2; // Use offset that just fits + } + bool rightToLeft = item->item.bidiLevel % 2; int i; From 5b4a44f83d6d3571731fd1029061b1deea27d7b1 Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Wed, 8 Feb 2012 10:12:03 +0000 Subject: [PATCH 025/166] Harfbuzz-thai - fix to_tis620 function for latin characters This was an obvious typo - a missing "else" in a group of if statements. Reviewed-by: Jiang Jiang Reviewed-by: Adrian Yanes Reviewed-by: Lars Knoll (cherry picked from commit a784bdcabe895ab927cbc28118d427c6e932b9fc) Change-Id: Icbd458034e42cf7f2af33c1ecc9b0e4f1aa8724a Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/3rdparty/harfbuzz/src/harfbuzz-thai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c index deff61be7e..59f5f7d448 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c @@ -74,7 +74,7 @@ static void to_tis620(const HB_UChar16 *string, hb_uint32 len, const char *cstr) for (i = 0; i < len; ++i) { if (string[i] <= 0xa0) result[i] = (unsigned char)string[i]; - if (string[i] >= 0xe01 && string[i] <= 0xe5b) + else if (string[i] >= 0xe01 && string[i] <= 0xe5b) result[i] = (unsigned char)(string[i] - 0xe00 + 0xa0); else result[i] = '?'; From c065ac562af6b13d6e103b0378c44e39a6c715aa Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Wed, 8 Feb 2012 10:12:08 +0000 Subject: [PATCH 026/166] Harfbuzz-thai - When calling HB_OpenTypePosition we must set doLogClusters to true for thai This bug resulted in word wrapping not working correctly for thai. Reviewed-by: Adrian Yanes Reviewed-by: Lars Knoll (cherry picked from commit 7495f2c7c55917a98c903547858be923028b7827) Change-Id: Iedb26a10078c6cc4e90d090176ab63499293d69d Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/3rdparty/harfbuzz/src/harfbuzz-thai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c index 59f5f7d448..386fd5c252 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c @@ -353,7 +353,7 @@ HB_Bool HB_ThaiShape (HB_ShaperItem *shaper_item) const int availableGlyphs = shaper_item->num_glyphs; if ( HB_SelectScript (shaper_item, thai_features) ) { HB_OpenTypeShape (shaper_item, /*properties*/0); - return HB_OpenTypePosition (shaper_item, availableGlyphs, /*doLogClusters*/false); + return HB_OpenTypePosition (shaper_item, availableGlyphs, /*doLogClusters*/true); } #endif From 1501f1ddd499320c264dc3ab16d4ce8b408991bb Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Wed, 22 Feb 2012 18:29:51 -0800 Subject: [PATCH 027/166] QMenuBar: Clean up Q_WS_WIN - Replace Q_WS_WIN with Q_OS_WIN - Remove useless #ifdef Q_OS_WINCE which located in another #ifdef Q_OS_WINCE Change-Id: I6279b6d74902ab3ca6bdb7292c2936a76e3e6952 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qmenubar.cpp | 6 +----- tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp | 4 ---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index d797a4e315..16e486e77f 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1075,7 +1075,7 @@ void QMenuBar::mousePressEvent(QMouseEvent *e) d->activeMenu = 0; menu->hide(); } -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN if((d->closePopupMode = style()->styleHint(QStyle::SH_MenuBar_DismissOnSecondClick))) update(d->actionRect(action)); #endif @@ -1845,15 +1845,12 @@ void QMenuBar::setDefaultAction(QAction *act) Q_D(QMenuBar); if (d->defaultAction == act) return; -#ifdef Q_OS_WINCE if (qt_wince_is_mobile()) if (d->defaultAction) { disconnect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction())); disconnect(d->defaultAction, SIGNAL(destroyed()), this, SLOT(_q_updateDefaultAction())); } -#endif d->defaultAction = act; -#ifdef Q_OS_WINCE if (qt_wince_is_mobile()) if (d->defaultAction) { connect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction())); @@ -1862,7 +1859,6 @@ void QMenuBar::setDefaultAction(QAction *act) if (d->wce_menubar) { d->wce_menubar->rebuild(); } -#endif } /*! diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 9989e5e7aa..6a1f418739 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -50,10 +50,6 @@ #include #include -#ifdef Q_WS_WIN -#include -#endif - #include QT_FORWARD_DECLARE_CLASS(QMainWindow) From ef9a86db5615a438c72a78745a8e558e687bf829 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 23 Feb 2012 15:02:23 +1000 Subject: [PATCH 028/166] Fix rounding error in QInputMethod::cursorRectangle(). Use QRectF consistently to avoid the rounding done in the conversion to QRect. Task-number: QTBUG-24463 Change-Id: If9ea858ebabf8c449ea058b9d379d4a57cb6c82d Reviewed-by: Joona Petrell --- src/gui/kernel/qinputmethod.cpp | 4 ++-- tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp index de00396e40..9e724446ff 100644 --- a/src/gui/kernel/qinputmethod.cpp +++ b/src/gui/kernel/qinputmethod.cpp @@ -154,9 +154,9 @@ QRectF QInputMethod::cursorRectangle() const QInputMethodQueryEvent query(Qt::ImCursorRectangle); QGuiApplication::sendEvent(d->inputItem.data(), &query); - QRect r = query.value(Qt::ImCursorRectangle).toRect(); + QRectF r = query.value(Qt::ImCursorRectangle).toRectF(); if (!r.isValid()) - return QRect(); + return QRectF(); return d->inputItemTransform.mapRect(r); } diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index 2ca921b557..c906ebaabe 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -50,7 +50,7 @@ class InputItem : public QObject { Q_OBJECT public: - InputItem() : m_enabled(true) {} + InputItem() : cursorRectangle(1, 2, 3, 4), m_enabled(true) {} bool event(QEvent *event) { @@ -59,7 +59,7 @@ public: if (query->queries() & Qt::ImEnabled) query->setValue(Qt::ImEnabled, m_enabled); if (query->queries() & Qt::ImCursorRectangle) - query->setValue(Qt::ImCursorRectangle, QRectF(1, 2, 3, 4)); + query->setValue(Qt::ImCursorRectangle, cursorRectangle); if (query->queries() & Qt::ImPreferredLanguage) query->setValue(Qt::ImPreferredLanguage, QString("English")); m_lastQueries = query->queries(); @@ -76,6 +76,7 @@ public: } } + QRectF cursorRectangle; Qt::InputMethodQueries m_lastQueries; bool m_enabled; }; @@ -226,7 +227,11 @@ void tst_qinputmethod::cursorRectangle() QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4))); + m_inputItem.cursorRectangle = QRectF(1.5, 2, 1, 8); + QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1.5, 2, 1, 8))); + // reset + m_inputItem.cursorRectangle = QRectF(1, 2, 3, 4); qApp->inputMethod()->setInputItemTransform(QTransform()); } From d2f65aa470fe30849a01380e4a50e8a4ebbce07e Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Sun, 25 Dec 2011 00:47:41 +0800 Subject: [PATCH 029/166] Fix conflict between QMainWindow::restoreState() and QWidget::setStylesheet() If QMainWindow::restoreState() then QWidget::setStylesheet() were called before the QMainWindow is shown, the size of QDockWidget can not be restored. QWidget::setStylesheet() will generate QEvent::StyleChange event, which will cause the function QDockAreaLayout::fitLayout() to be called before the layout of MainWindow is activated. Although the state info has been stored in a QMainWindowLayoutState variable by QMainWindow::restoreState(), but QMainWindowLayout::setGeometry() still isn't called at present. So QDockAreaLayout::fitLayout() will force the size of dockwidgets and centralwidget to be calculated using the wrong geometry, which will break the state restored by QMainWindow::restoreState(). This is a side effect of 692e9103ebb85b90e79377206d5d03b704d43d42. Task-number: QTBUG-15080 Change-Id: I8cda6a529d178f7467a59b780db80df0a44d4769 Reviewed-by: Olivier Goffart --- src/widgets/widgets/qdockarealayout.cpp | 3 +- .../widgets/qmainwindow/tst_qmainwindow.cpp | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index df083ccbfe..a07ab73ad0 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -3321,7 +3321,8 @@ void QDockAreaLayout::keepSize(QDockWidget *w) void QDockAreaLayout::styleChangedEvent() { sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow); - fitLayout(); + if (isValid()) + fitLayout(); } QT_END_NAMESPACE diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 13540355c7..0f07546559 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -101,6 +101,7 @@ private slots: void centralWidgetSize(); void dockWidgetSize(); void QTBUG2774_stylechange(); + void QTBUG15080_restoreState(); void toggleUnifiedTitleAndToolBarOnMac(); }; @@ -1705,6 +1706,41 @@ void tst_QMainWindow::QTBUG2774_stylechange() } } +void tst_QMainWindow::QTBUG15080_restoreState() +{ + QByteArray state; + + //save state + { + QMainWindow mw1; + QDockWidget * dw1 = new QDockWidget(); + dw1->setObjectName("Left DockWidget"); + mw1.addDockWidget(Qt::LeftDockWidgetArea, dw1); + mw1.setCentralWidget(new QTextEdit()); + mw1.show(); + QApplication::processEvents(); + dw1->setFixedWidth(101); + QApplication::processEvents(); + + state = mw1.saveState(); + } + + //restore state + + QMainWindow mw2; + QDockWidget * dw2 = new QDockWidget(); + dw2->setObjectName("Left DockWidget"); + mw2.addDockWidget(Qt::LeftDockWidgetArea, dw2); + mw2.setCentralWidget(new QTextEdit()); + mw2.restoreState(state); + //QTBUG15080 caused by setStyleSheet + mw2.setStyleSheet("color:red"); + mw2.show(); + QApplication::processEvents(); + + QCOMPARE(dw2->width(), 101); +} + void tst_QMainWindow::toggleUnifiedTitleAndToolBarOnMac() { #ifdef Q_OS_MAC From a6e20e4874d3f46f311625e471f1b7fbc64964b2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Feb 2012 14:45:07 +0100 Subject: [PATCH 030/166] Handle theme change in QApplication/QGuiApplication. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-initialize palette and fonts. Change-Id: Ib312747886a31e8370f8d99536d52cbcf8afe8a4 Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qguiapplication.cpp | 70 +++++++++++++++---- src/gui/kernel/qguiapplication_p.h | 3 + .../platforms/windows/qwindowstheme.cpp | 5 +- src/widgets/kernel/qapplication.cpp | 33 +++++++-- src/widgets/kernel/qapplication_p.h | 4 +- 5 files changed, 93 insertions(+), 22 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 4b309096c9..2e7441d62c 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -99,6 +99,14 @@ QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; QList QGuiApplicationPrivate::generic_plugin_list; +enum ApplicationResourceFlags +{ + ApplicationPaletteExplicitlySet = 0x1, + ApplicationFontExplicitlySet = 0x2 +}; + +static unsigned applicationResourceFlags = 0; + bool QGuiApplicationPrivate::app_do_modal = false; QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette @@ -144,6 +152,33 @@ static bool qt_detectRTLLanguage() " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); } +static void initPalette() +{ + if (!QGuiApplicationPrivate::app_pal) + if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) + QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); + if (!QGuiApplicationPrivate::app_pal) + QGuiApplicationPrivate::app_pal = new QPalette(Qt::black); +} + +static inline void clearPalette() +{ + delete QGuiApplicationPrivate::app_pal; + QGuiApplicationPrivate::app_pal = 0; +} + +static void initFontUnlocked() +{ + if (!QGuiApplicationPrivate::app_font) + QGuiApplicationPrivate::app_font = + new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont()); +} + +static inline void clearFontUnlocked() +{ + delete QGuiApplicationPrivate::app_font; + QGuiApplicationPrivate::app_font = 0; +} /*! \class QGuiApplication @@ -312,8 +347,7 @@ QGuiApplication::~QGuiApplication() delete QGuiApplicationPrivate::qt_clipboard; QGuiApplicationPrivate::qt_clipboard = 0; - delete QGuiApplicationPrivate::app_pal; - QGuiApplicationPrivate::app_pal = 0; + clearPalette(); qUnregisterGuiVariant(); @@ -671,8 +705,8 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() delete generic_plugin_list.at(i); generic_plugin_list.clear(); - delete app_font; - app_font = 0; + clearFontUnlocked(); + QFont::cleanup(); #ifndef QT_NO_CURSOR @@ -1090,6 +1124,8 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce) { + if (self) + self->notifyThemeChanged(); if (QWindow *window = tce->window.data()) { QEvent e(QEvent::ThemeChange); QGuiApplication::sendSpontaneousEvent(window, &e); @@ -1579,13 +1615,10 @@ QClipboard * QGuiApplication::clipboard() \sa setPalette() */ + QPalette QGuiApplication::palette() { - if (!QGuiApplicationPrivate::app_pal) - if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) - QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); - if (!QGuiApplicationPrivate::app_pal) - QGuiApplicationPrivate::app_pal = new QPalette(Qt::black); + initPalette(); return *QGuiApplicationPrivate::app_pal; } @@ -1602,6 +1635,7 @@ void QGuiApplication::setPalette(const QPalette &pal) QGuiApplicationPrivate::app_pal = new QPalette(pal); else *QGuiApplicationPrivate::app_pal = pal; + applicationResourceFlags |= ApplicationPaletteExplicitlySet; } /*! @@ -1612,9 +1646,7 @@ void QGuiApplication::setPalette(const QPalette &pal) QFont QGuiApplication::font() { QMutexLocker locker(&applicationFontMutex); - if (!QGuiApplicationPrivate::app_font) - QGuiApplicationPrivate::app_font = - new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont()); + initFontUnlocked(); return *QGuiApplicationPrivate::app_font; } @@ -1630,6 +1662,7 @@ void QGuiApplication::setFont(const QFont &font) QGuiApplicationPrivate::app_font = new QFont(font); else *QGuiApplicationPrivate::app_font = font; + applicationResourceFlags |= ApplicationFontExplicitlySet; } /*! @@ -2034,4 +2067,17 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) return QPixmap(); } +void QGuiApplicationPrivate::notifyThemeChanged() +{ + if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet)) { + clearPalette(); + initPalette(); + } + if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { + QMutexLocker locker(&applicationFontMutex); + clearFontUnlocked(); + initFontUnlocked(); + } +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 66670e8e25..68546ce0cf 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -200,6 +200,9 @@ public: }; QHash synthesizedMousePoints; +protected: + virtual void notifyThemeChanged(); + private: void init(); diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 7276db4bb6..5350b3ca3f 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -52,6 +52,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -265,10 +266,10 @@ QPlatformDialogHelper *QWindowsTheme::createPlatformDialogHelper(DialogType type return QWindowsDialogs::createHelper(type); } -void QWindowsTheme::windowsThemeChanged(QWindow * /* window */) +void QWindowsTheme::windowsThemeChanged(QWindow * window) { refresh(); - // QWindowSystemInterface::handleThemeChange(window); + QWindowSystemInterface::handleThemeChange(window); } QT_END_NAMESPACE diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 134b1809bb..650d4af38b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -128,6 +128,21 @@ Q_CORE_EXPORT void qt_call_post_routines(); QApplicationPrivate *QApplicationPrivate::self = 0; +static void initSystemPalette() +{ + if (!QApplicationPrivate::sys_pal) + if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) + QApplicationPrivate::setSystemPalette(*themePalette); + if (!QApplicationPrivate::sys_pal && QApplicationPrivate::app_style) + QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); +} + +static void clearSystemPalette() +{ + delete QApplicationPrivate::sys_pal; + QApplicationPrivate::sys_pal = 0; +} + #ifdef Q_OS_WINCE int QApplicationPrivate::autoMaximizeThreshold = -1; bool QApplicationPrivate::autoSipEnabled = false; @@ -365,6 +380,7 @@ QString QApplicationPrivate::styleSheet; // default application styles QPointer QApplicationPrivate::leaveAfterRelease = 0; int QApplicationPrivate::app_cspec = QApplication::NormalColor; + QPalette *QApplicationPrivate::sys_pal = 0; // default system palette QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer @@ -783,8 +799,7 @@ QApplication::~QApplication() delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; - delete QApplicationPrivate::sys_pal; - QApplicationPrivate::sys_pal = 0; + clearSystemPalette(); delete QApplicationPrivate::set_pal; QApplicationPrivate::set_pal = 0; app_palettes()->clear(); @@ -1084,11 +1099,8 @@ QStyle *QApplication::style() // take ownership of the style QApplicationPrivate::app_style->setParent(qApp); - if (!QApplicationPrivate::sys_pal) - if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) - QApplicationPrivate::setSystemPalette(*themePalette); - if (!QApplicationPrivate::sys_pal) - QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); + initSystemPalette(); + if (QApplicationPrivate::set_pal) // repolish set palette with the new style QApplication::setPalette(*QApplicationPrivate::set_pal); @@ -4631,6 +4643,13 @@ void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong times } } +void QApplicationPrivate::notifyThemeChanged() +{ + QGuiApplicationPrivate::notifyThemeChanged(); + clearSystemPalette(); + initSystemPalette(); +} + #ifndef QT_NO_GESTURES QGestureManager* QGestureManager::instance() { diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index e728868182..7a880986bf 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -260,7 +260,9 @@ public: static QPalette *sys_pal; static QPalette *set_pal; -private: +protected: + void notifyThemeChanged(); + public: static QFont *sys_font; static QFont *set_font; From 660af10dee503729025952ed2374b8a081f941a2 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 23 Feb 2012 10:13:41 +0100 Subject: [PATCH 031/166] Update tst_QTextEdit::fullWidthSelection Since we would add 1 to the height of script lines in the layout before and there was no compensation for this in the box font engine, which is used by this test, the selection rect in the test images was one pixel too high. Now that the +1 has been removed from the height, the images have to be updated. Change-Id: Ic9ea0ace6b61be496846c7f757ae309756cd9f5f Reviewed-by: Bradley T. Hughes --- .../centered-fully-selected.png | Bin 1232 -> 1247 bytes .../centered-partly-selected.png | Bin 1231 -> 1246 bytes .../fullWidthSelection/last-char-on-line.png | Bin 1226 -> 1241 bytes .../fullWidthSelection/last-char-on-parag.png | Bin 1223 -> 1238 bytes .../multiple-full-width-lines.png | Bin 1236 -> 1250 bytes .../fullWidthSelection/nowrap_long.png | Bin 1199 -> 1214 bytes .../single-full-width-line.png | Bin 1225 -> 1240 bytes 7 files changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png index ced6eb6e5bbe9e2440e74a7f26c640c90051d27c..b9df19eeb329ee8df1bfa76bb84ab135265d94aa 100644 GIT binary patch delta 124 zcmcb>d7pEFiXwBdlV=DA2gmJ){tp-!7&r?&B8wRq_>O=u<5X=v>4|1qOfK^#CRy^X z{TsgQzlF=a^N9~5awa}hVB5CGl~H&0=8a5AjFSVIv^n=PznfXYW1$Zc;$)ia!00P> ZgS|9Hj5T9h+-#uX44$rjF6*2UngB#ODlY&4 delta 112 zcmcc5d4Y3+iV$akM`SSr1D`Jt&tbgxZBF<^S1qO^vnCc=3Umr2W$#!2)1Te&cYcY5 z*zC!PjLK}MSNmMp#JTw*Q!V3UdnRojrIs7-yOPvona`b8+uX=x#3Xiuog+$&)$LpK QWCkGcboFyt=akR{00}K97ytkO diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png index 481b99c7fc8779a314281b757449593ce2e156d8..792593ff123110622d510314fb9ff8eafe81fbd9 100644 GIT binary patch delta 255 zcmX@ld5?2~NO=u<5X=vX$A(CMo$;Vkcv5P z?`{-4WFWxc*jdPU#UW6{Gw_N7yOP0`0_I!3bLxsdpR6{y9>x43<`rW?xx4LwcX8*d zZJB1ieruTHbfQxrNvUN9hoYKO2MSXJB5Za(e&)Z&JwI&PTkj_cPj+OKXWRHvmn-Au zW<%yAMiXnh`<9mt6TGu|XA2ZzH3x2bE&q<|UdJ11K{`7aCnqqT7rpm_RgCrSX2T^w P|1o&F`njxgN@xNA2=84q delta 191 zcmV;w06_oV3C{_TBv=V>NLh0L01iz601li1-u9eV000DmNklsdA=w7kGuTmopksuHj^O%BL=2lnV@A8vylRQ0S%7NIcGWsY-z1w6GBdtfdL>2 t?E8vht#l07mrb+r0@wkQZ~O=u<5X=vX$A(C8c!F;kcv5P zZ*Al~K5gl|ekRA^c?f^Q;>m%G?m`>) z%6$m$|NZr}{v7@7^K}~er%z5~l9-&w#KFFH=1TJe3wLfl$YjSj*_%n5b8r2Fd7kM9 j3PD0&7$-L{CX3E{VlKeh$11uS=q?6NS3j3^P6$Hqzh5Kml4L=Q-sXu+CQKqXYXmqKtUDsb00f?{elF{r5}E+I>Nk!6 diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png index 69b72ede09e880f1dac9e098ffc3b9aa40328eff..5ef32d2d19e108cce7700092b8ec454b19885b5b 100644 GIT binary patch delta 170 zcmV;b09F6T3DyaaBvu1+LP=Bz2ngHZPv8Im010qNS#tmY4#WTe4#WYKD-Ig~00enS zL_t(|obB4N5dtv`0Kqr&1yBP;Q6xoC109G2THuE9ZsJf%Zj^Y<%mH*R^#ZUvv4N}s zlQ;q^3ikcLJ(I2h`*I1B@dEpk5CdiscK&SA>v{j#Ecgr8+v9KvAt#do1hA7J0YVmg Y12r5F3B*5f4gdfE07*qoM6N<$g2rk+WdHyG delta 125 zcmV-@0D}M43C9VLBpwNHNLh0L01iz601li1-u9eV000DeNklZ^A(JKoD-0$=h<$%i%%p3;zFd>x0^5_|0-_Sw`Lju{=ly51;4fTnkHaN|oRg6P fAd~9@lNNgeEO=u<5X=vX$A(CR!%Y^4o%|**WRYWk+;BV8FeGPkBBKJ=x83qP?$76Cjt6r$%Q7l4 za?b59zkk^a@;OQASJ><0ItYr?$C*1QS;I-J4N L)z4*}Q$iB}Pw`L* literal 1236 zcmeAS@N?(olHy`uVBq!ia0y~yVAKKPHV!7Bh~EtDRX~cfz$3Dlfq~B#i03fg`!*+> zfq|vX)5S5QV$R#U8wC#;2rxL#UdWKOK%;AkM%IF6^#dv*2MibAb$O|7KHuY;ow4)< z%d5->Ub%1>3Of0;2nZ`4!NYtL!@pt9^T%QR2lnrXc|Y5i!;+AujgLiJSN{#z$f>C2 z)X^!Bq|`El0|)cl?)tzz_PhCOh*7-lypJuj&RI3w#u2n{L@JouUwr?vVS=YIQIU6E wyK80%PsDUzqEZLJ zfq^B_)5S5QV$R#!8#xac@Gu4x@=+ cz>% diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png index 937494ac3ca1716a7a52f050571b090dc2dd49ba..55d060af1fd8eed50edf0f8e808a9df8a6c07b97 100644 GIT binary patch literal 1240 zcmeAS@N?(olHy`uVBq!ia0y~yVAKKPHV!7Bh~EtDRX~cl*vT`5gM;JtL;nXrE@y#9 zWHAE+-w_aIoT|+y&A`A??djqeQZeW4-Hp7590Xh)<%<}vI0TA#23~Ps_hyn+u~>gW_mQfisOG0LPxIF!}h+j>cI!_t|DRa@rZ599m%JJNwl^{3Oq h9i#C)(i8a&>GekiIQLaE2Lj6`22WQ%mvv4FO#pr0dI zfq|vk)5S5QV$R#U8+i{o2)H`R7cpLO2o&)QyyC#_%_OT}+d11)@9)XWZqu%xk#Tq) z#NTkYQy@vHWd?_$no|cJ=8Z`H8|PkEu2=ul`TA|3{}0~jL})u5KXbuTAt#>}0b#`> zE*yq}qfB~-!@2Xj!>pLMnH2A6nLscSe%HAgPCnOAyK^+cMpG+^xwe{lueAW@r+0}T QfMpYdr>mdKI;Vst0F0nR8~^|S From 04652b9856f70c5d38eefd4907a02bd929059705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 21 Feb 2012 13:40:57 +0100 Subject: [PATCH 032/166] Added documentation for QSurfaceFormat. Change-Id: I3b42b09e6e42092c098e4fc20c5ba7dd7e354116 Reviewed-by: Gunnar Sletta --- src/gui/kernel/qsurfaceformat.cpp | 151 +++++++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index b97852dc1d..9021d82e20 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -106,10 +106,86 @@ public: int minor; }; +/*! + \class QSurfaceFormat + \brief The QSurfaceFormat class represents the format of a QSurface. + + The format includes the size of the color buffers, red, green, and blue; + the size of the alpha buffer; the size of the depth and stencil buffers; + and number of samples per pixel for multisampling. In addition, the format + contains surface configuration parameters such as OpenGL profile and + version for rendering, whether or not enable stereo buffers, and swap + behaviour. +*/ + +/*! + \enum QSurfaceFormat::FormatOption + + This enum contains format options for use with QSurfaceFormat. + + \value StereoBuffers Used to request stereo buffers in the surface format. + \value DebugContext Used to request a debug context with extra debugging information. + This requires OpenGL version 3.0 or higher. + \value DeprecatedFunctions Used to request that deprecated functions be included + in the OpenGL context profile. If not specified, you should get a forward compatible context + without support functionality marked as deprecated. This requires OpenGL version 3.0 or higher. +*/ + +/*! + \enum QSurfaceFormat::SwapBehavior + + This enum is used by QSurfaceFormat to specify the swap behaviour of a surface. The swap behaviour + is mostly transparent to the application, but it affects factors such as rendering latency and + throughput. + + \value DefaultSwapBehavior The default, unspecified swap behaviour of the platform. + \value SingleBuffer Used to request single buffering, which might result in flickering + when OpenGL rendering is done directly to screen without an intermediate offscreen + buffer. + \value DoubleBuffer This is typically the default swap behaviour on desktop platforms, + consisting of one back buffer and one front buffer. Rendering is done to the back + buffer, and then the back buffer and front buffer are swapped, or the contents of + the back buffer are copied to the front buffer, depending on the implementation. + \value TripleBuffer This swap behaviour is sometimes used in order to decrease the + risk of skipping a frame when the rendering rate is just barely keeping up with + the screen refresh rate. Depending on the platform it might also lead to slightly + more efficient use of the GPU due to improved pipelining behaviour. Triple buffering + comes at the cost of an extra frame of memory usage and latency, and might not be + supported depending on the underlying platform. +*/ + +/*! + \enum QSurfaceFormat::OpenGLContextProfile + + This enum is used to specify the OpenGL context profile, in + conjunction with QSurfaceFormat::setMajorVersion() and + QSurfaceFormat::setMinorVersion(). + + Profiles are exposed in OpenGL 3.2 and above, and are used + to choose between a restricted core profile, and a compatibility + profile which might contain deprecated support functionality. + + Note that the core profile might still contain functionality that + is deprecated and scheduled for removal in a higher version. To + get access to the deprecated functionality for the core profile + in the set OpenGL version you can use the QSurfaceFormat format option + QSurfaceFormat::DeprecatedFunctions. + + \value NoProfile OpenGL version is lower than 3.2. + \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available. + \value CompatibilityProfile Functionality from earlier OpenGL versions is available. +*/ + +/*! + Constructs a default initialized QSurfaceFormat. +*/ QSurfaceFormat::QSurfaceFormat() : d(new QSurfaceFormatPrivate) { } +/*! + Constructs a QSurfaceFormat with the given format \a options. +*/ QSurfaceFormat::QSurfaceFormat(QSurfaceFormat::FormatOptions options) : d(new QSurfaceFormatPrivate(options)) { @@ -131,7 +207,6 @@ void QSurfaceFormat::detach() /*! Constructs a copy of \a other. */ - QSurfaceFormat::QSurfaceFormat(const QSurfaceFormat &other) { d = other.d; @@ -141,7 +216,6 @@ QSurfaceFormat::QSurfaceFormat(const QSurfaceFormat &other) /*! Assigns \a other to this object. */ - QSurfaceFormat &QSurfaceFormat::operator=(const QSurfaceFormat &other) { if (d != other.d) { @@ -182,7 +256,6 @@ QSurfaceFormat::~QSurfaceFormat() \sa stereo() */ - void QSurfaceFormat::setStereo(bool enable) { QSurfaceFormat::FormatOptions newOptions = d->opts; @@ -199,8 +272,7 @@ void QSurfaceFormat::setStereo(bool enable) /*! Returns the number of samples per pixel when multisampling is - enabled. By default, the highest number of samples that is - available is used. + enabled. By default, multisampling is disabled. \sa setSampleBuffers(), sampleBuffers(), setSamples() */ @@ -211,8 +283,7 @@ int QSurfaceFormat::samples() const /*! Set the preferred number of samples per pixel when multisampling - is enabled to \a numSamples. By default, the highest number of - samples available is used. + is enabled to \a numSamples. By default, multisampling is disabled. \sa setSampleBuffers(), sampleBuffers(), samples() */ @@ -229,7 +300,6 @@ void QSurfaceFormat::setSamples(int numSamples) \sa testOption() */ - void QSurfaceFormat::setOption(QSurfaceFormat::FormatOptions opt) { const QSurfaceFormat::FormatOptions newOptions = d->opts | opt; @@ -244,7 +314,6 @@ void QSurfaceFormat::setOption(QSurfaceFormat::FormatOptions opt) \sa setOption() */ - bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOptions opt) const { return d->opts & opt; @@ -273,6 +342,13 @@ int QSurfaceFormat::depthBufferSize() const return d->depthSize; } +/*! + Set the swap behaviour of the surface. + + The swap behaviour specifies whether single, double, or triple + buffering is desired. The default, SwapBehavior::DefaultSwapBehavior, + gives the default swap behavior of the platform. +*/ void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior) { if (d->swapBehavior != behavior) { @@ -281,19 +357,29 @@ void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior) } } +/*! + Returns the configured swap behaviour. + \sa setSwapBehavior() +*/ QSurfaceFormat::SwapBehavior QSurfaceFormat::swapBehavior() const { return d->swapBehavior; } +/*! + Returns true if the alpha buffer size is greater than zero. + + This means that the surface might be used with per pixel + translucency effects. +*/ bool QSurfaceFormat::hasAlpha() const { return d->alphaBufferSize > 0; } /*! - Set the preferred stencil buffer size to \a size. + Set the preferred stencil buffer size to \a size bits. \sa stencilBufferSize(), setStencil(), stencil() */ @@ -306,7 +392,7 @@ void QSurfaceFormat::setStencilBufferSize(int size) } /*! - Returns the stencil buffer size. + Returns the stencil buffer size in bits. \sa stencil(), setStencil(), setStencilBufferSize() */ @@ -315,26 +401,41 @@ int QSurfaceFormat::stencilBufferSize() const return d->stencilSize; } +/*! + Get the size in bits of the red channel of the color buffer. +*/ int QSurfaceFormat::redBufferSize() const { return d->redBufferSize; } +/*! + Get the size in bits of the green channel of the color buffer. +*/ int QSurfaceFormat::greenBufferSize() const { return d->greenBufferSize; } +/*! + Get the size in bits of the blue channel of the color buffer. +*/ int QSurfaceFormat::blueBufferSize() const { return d->blueBufferSize; } +/*! + Get the size in bits of the alpha channel of the color buffer. +*/ int QSurfaceFormat::alphaBufferSize() const { return d->alphaBufferSize; } +/*! + Set the desired size in bits of the red channel of the color buffer. +*/ void QSurfaceFormat::setRedBufferSize(int size) { if (d->redBufferSize != size) { @@ -343,6 +444,9 @@ void QSurfaceFormat::setRedBufferSize(int size) } } +/*! + Set the desired size in bits of the green channel of the color buffer. +*/ void QSurfaceFormat::setGreenBufferSize(int size) { if (d->greenBufferSize != size) { @@ -351,6 +455,9 @@ void QSurfaceFormat::setGreenBufferSize(int size) } } +/*! + Set the desired size in bits of the blue channel of the color buffer. +*/ void QSurfaceFormat::setBlueBufferSize(int size) { if (d->blueBufferSize != size) { @@ -359,6 +466,9 @@ void QSurfaceFormat::setBlueBufferSize(int size) } } +/*! + Set the desired size in bits of the alpha channel of the color buffer. +*/ void QSurfaceFormat::setAlphaBufferSize(int size) { if (d->alphaBufferSize != size) { @@ -368,10 +478,10 @@ void QSurfaceFormat::setAlphaBufferSize(int size) } /*! - Sets the desired OpenGL context profile. + Sets the desired OpenGL context profile. - This setting is ignored if the requested OpenGL version is - less than 3.2. + This setting is ignored if the requested OpenGL version is + less than 3.2. */ void QSurfaceFormat::setProfile(OpenGLContextProfile profile) { @@ -381,6 +491,12 @@ void QSurfaceFormat::setProfile(OpenGLContextProfile profile) } } +/*! + Get the configured OpenGL context profile. + + This setting is ignored if the requested OpenGL version is + less than 3.2. +*/ QSurfaceFormat::OpenGLContextProfile QSurfaceFormat::profile() const { return d->profile; @@ -428,6 +544,12 @@ int QSurfaceFormat::minorVersion() const return d->minor; } +/*! + Returns true if all the options of the two QSurfaceFormat objects + are equal. + + \relates QSurfaceFormat +*/ bool operator==(const QSurfaceFormat& a, const QSurfaceFormat& b) { return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts @@ -450,7 +572,6 @@ bool operator==(const QSurfaceFormat& a, const QSurfaceFormat& b) \relates QSurfaceFormat */ - bool operator!=(const QSurfaceFormat& a, const QSurfaceFormat& b) { return !(a == b); From 88b69ab0c482183afa4e1575d666185bbd631890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 21 Feb 2012 10:44:33 +0100 Subject: [PATCH 033/166] Fleshed out the QWindow documentation to be less sparse. Change-Id: Ia3873687a2c3e0dd85c56e4f9e34d2e194e2ff50 Reviewed-by: Gunnar Sletta --- src/gui/kernel/qwindow.cpp | 594 +++++++++++++++++++++++++++++++++---- 1 file changed, 541 insertions(+), 53 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 9c6b6c4bf7..77731f776b 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -63,15 +63,17 @@ QT_BEGIN_NAMESPACE /*! \class QWindow - \brief The QWindow class encapsulates an independent window in a Windowing System. + \brief The QWindow class represents a window in the underlying windowing system. - A window that is supplied a parent become a native child window of + A window that is supplied a parent becomes a native child window of their parent window. + \section1 Resource management + Windows can potentially use a lot of memory. A usual measurement is - width * height * depth. A window might also include multiple buffers - to support double and triple buffering. To release a windows memory - resources, the destroy() function. + width times height times color depth. A window might also include multiple + buffers to support double and triple buffering, as well as depth and stencil + buffers. To release a window's memory resources, the destroy() function. \section1 Window and content orientation @@ -90,6 +92,29 @@ QT_BEGIN_NAMESPACE the contents instead, especially when doing rotation animations between different orientations. The windowing system might use this value to determine the layout of system popups or dialogs. + + \section1 Visibility and Windowing system exposure. + + By default, the window is not visible, and you must call setVisible(true), + or show() or similar to make it visible. To make a window hidden again, + call setVisible(false) or hide(). The visible property describes the state + the application wants the window to be in. Depending on the underlying + system, a visible window might still not be shown on the screen. It could, + for instance, be covered by other opaque windows or moved outside the + physical area of the screen. On windowing systems that have exposure + notifications, the isExposed() accessor describes whether the window should + be treated as directly visible on screen. The exposeEvent() function is + called whenever the windows exposure in the windowing system changes. On + windowing systems that do not make this information visible to the + application, isExposed() will simply return the same value as isVisible(). +*/ + +/*! + Creates a window as a top level on the given screen. + + The window is not shown until setVisible(true), show(), or similar is called. + + \sa setScreen() */ QWindow::QWindow(QScreen *targetScreen) : QObject(*new QWindowPrivate(), 0) @@ -108,6 +133,15 @@ QWindow::QWindow(QScreen *targetScreen) QGuiApplicationPrivate::window_list.prepend(this); } +/*! + Creates a window as a child of the given \a parent window. + + The window will be embedded inside the parent window, its coordinates relative to the parent. + + The screen is inherited from the parent. + + \sa setParent() +*/ QWindow::QWindow(QWindow *parent) : QObject(*new QWindowPrivate(), parent) , QSurface(QSurface::Window) @@ -134,6 +168,9 @@ QWindow::QWindow(QWindowPrivate &dd, QWindow *parent) QGuiApplicationPrivate::window_list.prepend(this); } +/*! + Destroys the window. +*/ QWindow::~QWindow() { if (QGuiApplicationPrivate::focus_window == this) @@ -146,18 +183,43 @@ QSurface::~QSurface() { } +/*! + Set the \a surfaceType of the window. + + Specifies whether the window is meant for raster rendering with + QBackingStore, or OpenGL rendering with QOpenGLContext. + + \sa QBackingStore, QOpenGLContext +*/ void QWindow::setSurfaceType(SurfaceType surfaceType) { Q_D(QWindow); d->surfaceType = surfaceType; } +/*! + Returns the surface type of the window. + + \sa setSurfaceType() +*/ QWindow::SurfaceType QWindow::surfaceType() const { Q_D(const QWindow); return d->surfaceType; } +/*! + \property QWindow::visible + \brief whether the window is visible or not + \since 5.0 + + This property controls the visibility of the window in the windowing system. + + By default, the window is not visible, you must call setVisible(true), or + show() or similar to make it visible. + + \sa show() +*/ void QWindow::setVisible(bool visible) { Q_D(QWindow); @@ -186,7 +248,10 @@ void QWindow::setVisible(bool visible) } } - +/*! + Returns true if the window is set to visible. + \obsolete +*/ bool QWindow::visible() const { return isVisible(); @@ -199,6 +264,20 @@ bool QWindow::isVisible() const return d->visible; } +/*! + Allocates the platform resources associated with the window. + + It is at this point that the surface format set using setFormat() gets resolved + into an actual native surface. However, the window remains hidden until setVisible() is called. + + Note that it is not usually necessary to call this function directly, as it will be implicitly + called by show(), setVisible(), and other functions that require access to the platform + resources. + + Call destroy() to free the platform resources if necessary. + + \sa destroy() +*/ void QWindow::create() { Q_D(QWindow); @@ -216,6 +295,14 @@ void QWindow::create() } } +/*! + Returns the window's platform id. + + For platforms where this id might be useful, the value returned + will uniquely represent the window inside the corresponding screen. + + \sa screen() +*/ WId QWindow::winId() const { Q_D(const QWindow); @@ -228,16 +315,22 @@ WId QWindow::winId() const return id; } +/*! + Returns the parent window, if any. + + A window without a parent is known as a top level window. +*/ QWindow *QWindow::parent() const { Q_D(const QWindow); return d->parentWindow; } -/** - Sets the parent Window. This will lead to the windowing system managing the clip of the window, so it will be clipped to the parent window. - Setting parent to be 0(NULL) means map it as a top level window. If the parent window has grabbed its window system resources, then the current window will also grab its window system resources. - **/ +/*! + Sets the parent Window. This will lead to the windowing system managing the clip of the window, so it will be clipped to the parent window. + + Setting parent to be 0 will make the window become a top level window. +*/ void QWindow::setParent(QWindow *parent) { @@ -257,46 +350,66 @@ void QWindow::setParent(QWindow *parent) } /*! - Returns whether the window is top level, i.e. has no parent window. - */ + Returns whether the window is top level, i.e. has no parent window. +*/ bool QWindow::isTopLevel() const { Q_D(const QWindow); return d->parentWindow == 0; } +/*! + Returns whether the window is modal. + + A modal window prevents other windows from getting any input. +*/ bool QWindow::isModal() const { Q_D(const QWindow); return d->modality != Qt::NonModal; } +/*! + Returns the window's modality. + + \sa setWindowModality() +*/ Qt::WindowModality QWindow::windowModality() const { Q_D(const QWindow); return d->modality; } +/*! + Sets the window's modality to \a windowModality. +*/ void QWindow::setWindowModality(Qt::WindowModality windowModality) { Q_D(QWindow); d->modality = windowModality; } +/*! + Sets the window's surface \a format. + + The format determines properties such as color depth, alpha, + depth and stencil buffer size, etc. +*/ void QWindow::setFormat(const QSurfaceFormat &format) { Q_D(QWindow); d->requestedFormat = format; } - /*! Returns the requested surfaceformat of this window. If the requested format was not supported by the platform implementation, the requestedFormat will differ from the actual window format. - \sa format. + This is the value set with setFormat(). + + \sa setFormat(), format() */ QSurfaceFormat QWindow::requestedFormat() const { @@ -304,6 +417,15 @@ QSurfaceFormat QWindow::requestedFormat() const return d->requestedFormat; } +/*! + Returns the actual format of this window. + + After the window has been created, this function will return the actual surface format + of the window. It might differ from the requested format if the requested format could + not be fulfilled by the platform. + + \sa create(), requestedFormat() +*/ QSurfaceFormat QWindow::format() const { Q_D(const QWindow); @@ -312,6 +434,15 @@ QSurfaceFormat QWindow::format() const return d->requestedFormat; } +/*! + Sets the window flags of the window to \a flags. + + The window flags control the window's appearance in the windowing system, + whether it's a dialog, popup, or a regular window, and whether it should + have a title bar, etc. + + \sa windowFlags() +*/ void QWindow::setWindowFlags(Qt::WindowFlags flags) { Q_D(QWindow); @@ -321,18 +452,46 @@ void QWindow::setWindowFlags(Qt::WindowFlags flags) d->windowFlags = flags; } +/*! + Returns the window flags of the window. + + This might differ from the flags set with setWindowFlags() if the + requested flags could not be fulfilled. + + \sa setWindowFlags() +*/ Qt::WindowFlags QWindow::windowFlags() const { Q_D(const QWindow); return d->windowFlags; } +/*! + Returns the type of the window. + + This returns the part of the window flags that represents + whether the window is a dialog, tooltip, popup, regular window, etc. + + \sa windowFlags(), setWindowFlags() +*/ Qt::WindowType QWindow::windowType() const { Q_D(const QWindow); return static_cast(int(d->windowFlags & Qt::WindowType_Mask)); } +/*! + \property QWindow::windowTitle + \brief the window's title in the windowing system + \since 5.0 + + The window title might appear in the title area of the window decorations, + depending on the windowing system and the window flags. It might also + be used by the windowing system to identify the window in other contexts, + such as in the task switcher. + + \sa windowFlags() +*/ void QWindow::setWindowTitle(const QString &title) { Q_D(QWindow); @@ -348,6 +507,11 @@ QString QWindow::windowTitle() const return d->windowTitle; } +/*! + Raise the window in the windowing system. + + Requests that the window be raised to appear above other windows. +*/ void QWindow::raise() { Q_D(QWindow); @@ -356,6 +520,11 @@ void QWindow::raise() } } +/*! + Lower the window in the windowing system. + + Requests that the window be lowered to appear below other windows. +*/ void QWindow::lower() { Q_D(QWindow); @@ -364,6 +533,16 @@ void QWindow::lower() } } +/*! + Sets the window's opacity in the windowing system to \a level. + + If the windowing system supports window opacity, this can be used to fade the + window in and out, or to make it semitransparent. + + A value of 1.0 or above is treated as fully opaque, whereas a value of 0.0 or below + is treated as fully transparent. Values inbetween represent varying levels of + translucency between the two extremes. +*/ void QWindow::setOpacity(qreal level) { Q_D(QWindow); @@ -372,6 +551,11 @@ void QWindow::setOpacity(qreal level) } } +/*! + Requests the window to be activated, i.e. receive keyboard focus. + + \sa isActive(), QGuiApplication::focusWindow() +*/ void QWindow::requestActivateWindow() { Q_D(QWindow); @@ -379,7 +563,6 @@ void QWindow::requestActivateWindow() d->platformWindow->requestActivateWindow(); } - /*! Returns if this window is exposed in the windowing system. @@ -388,8 +571,9 @@ void QWindow::requestActivateWindow() should minimize rendering and other graphical activities. An exposeEvent() is sent every time this value changes. - */ + \sa exposeEvent() +*/ bool QWindow::isExposed() const { Q_D(const QWindow); @@ -424,22 +608,26 @@ bool QWindow::isActive() const } /*! - Reports that the orientation of the window's contents have changed. + \property QWindow::contentOrientation + \since 5.0 + \brief the orientation of the window's contents - This is a hint to the window manager in case it needs to display - additional content like popups, dialogs, status bars, or similar - in relation to the window. + This is a hint to the window manager in case it needs to display + additional content like popups, dialogs, status bars, or similar + in relation to the window. - The recommended orientation is QScreen::orientation() but - an application doesn't have to support all possible orientations, - and thus can opt to ignore the current screen orientation. + The recommended orientation is QScreen::orientation() but + an application doesn't have to support all possible orientations, + and thus can opt to ignore the current screen orientation. - The difference between the window and the content orientation - determines how much to rotate the content by. QScreen::angleBetween(), - QScreen::transformBetween(), and QScreen::mapBetween() can be used - to compute the necessary transform. + The difference between the window and the content orientation + determines how much to rotate the content by. QScreen::angleBetween(), + QScreen::transformBetween(), and QScreen::mapBetween() can be used + to compute the necessary transform. - \sa requestWindowOrientation(), QScreen::orientation() + The default value is Qt::PrimaryOrientation + + \sa requestWindowOrientation(), QScreen::orientation() */ void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation) { @@ -454,12 +642,6 @@ void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation) emit contentOrientationChanged(orientation); } -/*! - Returns the actual content orientation. - - This is the last value set with reportContentOrientationChange(). It defaults - to Qt::PrimaryOrientation. -*/ Qt::ScreenOrientation QWindow::contentOrientation() const { Q_D(const QWindow); @@ -506,12 +688,27 @@ Qt::ScreenOrientation QWindow::windowOrientation() const return d->windowOrientation; } +/*! + Returns the window state. + + \sa setWindowState() +*/ Qt::WindowState QWindow::windowState() const { Q_D(const QWindow); return d->windowState; } +/*! + Sets the desired window \a state. + + The window state represents whether the window appears in the + windowing system as maximized, minimized, fullscreen, or normal. + + The enum value Qt::WindowActive is not an accepted parameter. + + \sa windowState(), showNormal(), showFullScreen(), showMinimized(), showMaximized() +*/ void QWindow::setWindowState(Qt::WindowState state) { if (state == Qt::WindowActive) { @@ -527,7 +724,11 @@ void QWindow::setWindowState(Qt::WindowState state) } /*! - Sets the transient parent, which is a hint to the window manager that this window is a dialog or pop-up on behalf of the given window. + Sets the transient parent + + This is a hint to the window manager that this window is a dialog or pop-up on behalf of the given window. + + \sa transientParent(), parent() */ void QWindow::setTransientParent(QWindow *parent) { @@ -538,6 +739,11 @@ void QWindow::setTransientParent(QWindow *parent) d->transientParent = parent; } +/*! + Returns the transient parent of the window. + + \sa setTransientParent(), parent() +*/ QWindow *QWindow::transientParent() const { Q_D(const QWindow); @@ -555,8 +761,8 @@ QWindow *QWindow::transientParent() const */ /*! - Returns true if the window is an ancestor of the given child. If mode is - IncludeTransients transient parents are also considered ancestors. + Returns true if the window is an ancestor of the given child. If mode is + IncludeTransients transient parents are also considered ancestors. */ bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode) const { @@ -567,30 +773,57 @@ bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode) const || (mode == IncludeTransients && child->transientParent() && isAncestorOf(child->transientParent(), mode)); } +/*! + Returns the minimum size of the window. + + \sa setMinimumSize() +*/ QSize QWindow::minimumSize() const { Q_D(const QWindow); return d->minimumSize; } +/*! + Returns the maximum size of the window. + + \sa setMaximumSize() +*/ QSize QWindow::maximumSize() const { Q_D(const QWindow); return d->maximumSize; } +/*! + Returns the base size of the window. + + \sa setBaseSize() +*/ QSize QWindow::baseSize() const { Q_D(const QWindow); return d->baseSize; } +/*! + Returns the size increment of the window. + + \sa setSizeIncrement() +*/ QSize QWindow::sizeIncrement() const { Q_D(const QWindow); return d->sizeIncrement; } +/*! + Sets the minimum size of the window. + + This is a hint to the window manager to prevent resizing below the specified \a size. + + \sa setMaximumSize(), minimumSize() +*/ void QWindow::setMinimumSize(const QSize &size) { Q_D(QWindow); @@ -602,6 +835,13 @@ void QWindow::setMinimumSize(const QSize &size) d->platformWindow->propagateSizeHints(); } +/*! + Sets the maximum size of the window. + + This is a hint to the window manager to prevent resizing above the specified \a size. + + \sa setMinimumSize(), maximumSize() +*/ void QWindow::setMaximumSize(const QSize &size) { Q_D(QWindow); @@ -613,6 +853,14 @@ void QWindow::setMaximumSize(const QSize &size) d->platformWindow->propagateSizeHints(); } +/*! + Sets the base size of the window. + + The base size is used to calculate a proper window size if the + window defines sizeIncrement(). + + \sa setMinimumSize(), setMaximumSize(), setSizeIncrement(), baseSize() +*/ void QWindow::setBaseSize(const QSize &size) { Q_D(QWindow); @@ -623,6 +871,20 @@ void QWindow::setBaseSize(const QSize &size) d->platformWindow->propagateSizeHints(); } +/*! + Sets the size increment of the window. + + When the user resizes the window, the size will move in steps of + sizeIncrement().width() pixels horizontally and + sizeIncrement().height() pixels vertically, with baseSize() as the + basis. + + By default, this property contains a size with zero width and height. + + The windowing system might not support size increments. + + \sa setBaseSize(), setMinimumSize(), setMaximumSize() +*/ void QWindow::setSizeIncrement(const QSize &size) { Q_D(QWindow); @@ -634,7 +896,12 @@ void QWindow::setSizeIncrement(const QSize &size) } /*! - Sets the geometry of the window excluding its window frame. + Sets the geometry of the window, excluding its window frame, to \a rect. + + To make sure the window is visible, make sure the geometry is within + the virtual geometry of its screen. + + \sa geometry(), screen(), QScreen::virtualGeometry() */ void QWindow::setGeometry(const QRect &rect) { @@ -661,7 +928,33 @@ void QWindow::setGeometry(const QRect &rect) } /*! - Returns the geometry of the window excluding its window frame. + \property QWindow::x + \since 5.0 + \brief the x position of the window's geometry +*/ + +/*! + \property QWindow::y + \since 5.0 + \brief the y position of the window's geometry +*/ + +/*! + \property QWindow::width + \since 5.0 + \brief the width of the window's geometry +*/ + +/*! + \property QWindow::height + \since 5.0 + \brief the height of the window's geometry +*/ + +/*! + Returns the geometry of the window, excluding its window frame. + + \sa frameMargins(), frameGeometry() */ QRect QWindow::geometry() const { @@ -673,6 +966,8 @@ QRect QWindow::geometry() const /*! Returns the window frame margins surrounding the window. + + \sa geometry(), frameGeometry() */ QMargins QWindow::frameMargins() const { @@ -683,7 +978,9 @@ QMargins QWindow::frameMargins() const } /*! - Returns the geometry of the window including its window frame. + Returns the geometry of the window, including its window frame. + + \sa geometry(), frameMargins() */ QRect QWindow::frameGeometry() const { @@ -696,7 +993,11 @@ QRect QWindow::frameGeometry() const } /*! - Returns the top left position of the window including its window frame. + Returns the top left position of the window, including its window frame. + + This returns the same value as frameGeometry().topLeft(). + + \sa geometry(), frameGeometry() */ QPoint QWindow::framePos() const { @@ -710,6 +1011,8 @@ QPoint QWindow::framePos() const /*! Sets the upper left position of the window including its window frame. + + \sa setGeometry(), frameGeometry() */ void QWindow::setFramePos(const QPoint &point) { @@ -722,6 +1025,11 @@ void QWindow::setFramePos(const QPoint &point) } } +/*! + Sets the size of the window to be \a newSize. + + \sa setGeometry() +*/ void QWindow::resize(const QSize &newSize) { Q_D(QWindow); @@ -732,18 +1040,23 @@ void QWindow::resize(const QSize &newSize) } } +/*! + Sets the window icon to the given \a icon image. + + The window icon might be used by the windowing system for example to decorate the window, + or in the task switcher. +*/ void QWindow::setWindowIcon(const QImage &icon) const { Q_UNUSED(icon); qDebug() << "unimplemented:" << __FILE__ << __LINE__; } - - /*! Releases the native platform resources associated with this window. - */ + \sa create() +*/ void QWindow::destroy() { Q_D(QWindow); @@ -761,18 +1074,37 @@ void QWindow::destroy() d->platformWindow = 0; } +/*! + Returns the platform window corresponding to the window. + + \internal +*/ QPlatformWindow *QWindow::handle() const { Q_D(const QWindow); return d->platformWindow; } +/*! + Returns the platform surface corresponding to the window. + + \internal +*/ QPlatformSurface *QWindow::surfaceHandle() const { Q_D(const QWindow); return d->platformWindow; } +/*! + Set whether keyboard grab should be enabled or not. + + If the return value is true, the window receives all key events until setKeyboardGrabEnabled(false) is + called; other windows get no key events at all. Mouse events are not affected. + Use setMouseGrabEnabled() if you want to grab that. + + \sa setMouseGrabEnabled() +*/ bool QWindow::setKeyboardGrabEnabled(bool grab) { Q_D(QWindow); @@ -781,6 +1113,15 @@ bool QWindow::setKeyboardGrabEnabled(bool grab) return false; } +/*! + Sets whether mouse grab should be enabled or not. + + If the return value is true, the window receives all mouse events until setMouseGrabEnabled(false) is + called; other windows get no mouse events at all. Keyboard events are not affected. + Use setKeyboardGrabEnabled() if you want to grab that. + + \sa setKeyboardGrabEnabled() +*/ bool QWindow::setMouseGrabEnabled(bool grab) { Q_D(QWindow); @@ -789,12 +1130,30 @@ bool QWindow::setMouseGrabEnabled(bool grab) return false; } +/*! + Returns the screen on which the window is shown. + + The value returned will not change when the window is moved + between virtual screens (as returned by QScreen::virtualSiblings()). + + \sa setScreen(), QScreen::virtualSiblings() +*/ QScreen *QWindow::screen() const { Q_D(const QWindow); return d->screen; } +/*! + Sets the screen on which the window should be shown. + + If the window has been created, it will be recreated on the new screen. + + Note that if the screen is part of a virtual desktop of multiple screens, + the window can appear on any of the screens returned by QScreen::virtualSiblings(). + + \sa screen(), QScreen::virtualSiblings() +*/ void QWindow::setScreen(QScreen *newScreen) { Q_D(QWindow); @@ -849,14 +1208,22 @@ QAccessibleInterface *QWindow::accessibleRoot() const */ /*! - Returns the QObject that will be the final receiver of events tied focus, such - as key events. + Returns the QObject that will be the final receiver of events tied focus, such + as key events. */ QObject *QWindow::focusObject() const { return const_cast(this); } +/*! + Shows the window. + + This equivalent to calling showFullScreen() or showNormal(), depending + on whether the platform defaults to windows being fullscreen or not. + + \sa showFullScreen(), showNormal(), hide(), QStyleHints::showIsFullScreen() +*/ void QWindow::show() { if (qApp->styleHints()->showIsFullScreen()) @@ -865,23 +1232,54 @@ void QWindow::show() showNormal(); } +/*! + Hides the window. + + Equivalent to calling setVisible(false). + + \sa show(), setVisible() +*/ void QWindow::hide() { setVisible(false); } +/*! + Shows the window as minimized. + + Equivalent to calling setWindowState(Qt::WindowMinimized) and then + setVisible(true). + + \sa setWindowState(), setVisible() +*/ void QWindow::showMinimized() { setWindowState(Qt::WindowMinimized); setVisible(true); } +/*! + Shows the window as maximized. + + Equivalent to calling setWindowState(Qt::WindowMaximized) and then + setVisible(true). + + \sa setWindowState(), setVisible() +*/ void QWindow::showMaximized() { setWindowState(Qt::WindowMaximized); setVisible(true); } +/*! + Shows the window as fullscreen. + + Equivalent to calling setWindowState(Qt::WindowFullScreen) and then + setVisible(true). + + \sa setWindowState(), setVisible() +*/ void QWindow::showFullScreen() { setWindowState(Qt::WindowFullScreen); @@ -889,12 +1287,28 @@ void QWindow::showFullScreen() requestActivateWindow(); } +/*! + Shows the window as normal, i.e. neither maximized, minimized, nor fullscreen. + + Equivalent to calling setWindowState(Qt::WindowNoState) and then + setVisible(true). + + \sa setWindowState(), setVisible() +*/ void QWindow::showNormal() { setWindowState(Qt::WindowNoState); setVisible(true); } +/*! + Close the window. + + This closes the window, effectively calling destroy(), and + potentially quitting the application + + \sa destroy(), QGuiApplication::quitOnLastWindowClosed() +*/ bool QWindow::close() { Q_D(QWindow); @@ -912,8 +1326,6 @@ bool QWindow::close() return true; } - - /*! The expose event is sent by the window system whenever the window's exposure on screen changes. @@ -923,33 +1335,60 @@ bool QWindow::close() value of isExposed() might change to false. When this happens, an application should stop its rendering as it is no longer visible to the user. - */ + \sa isExposed() +*/ void QWindow::exposeEvent(QExposeEvent *ev) { ev->ignore(); } +/*! + Override this to handle mouse events. +*/ void QWindow::moveEvent(QMoveEvent *ev) { ev->ignore(); } +/*! + Override this to handle resize events. + + The resize event is called whenever the window is resized in the windowing system, + either directly through the windowing system acknowledging a setGeometry() or resize() request, + or indirectly through the user resizing the window manually. +*/ void QWindow::resizeEvent(QResizeEvent *ev) { ev->ignore(); } +/*! + Override this to handle show events. + + The show event is called when the window becomes visible in the windowing system. +*/ void QWindow::showEvent(QShowEvent *ev) { ev->ignore(); } +/*! + Override this to handle show events. + + The show event is called when the window becomes hidden in the windowing system. +*/ void QWindow::hideEvent(QHideEvent *ev) { ev->ignore(); } +/*! + Override this to handle any event sent to the window. + + Remembet to call the base class version if you wish for mouse events, + key events, resize events, etc to be dispatched as usual. +*/ bool QWindow::event(QEvent *ev) { switch (ev->type()) { @@ -1032,58 +1471,111 @@ bool QWindow::event(QEvent *ev) return true; } +/*! + Override this to handle key press events. + + \sa keyReleaseEvent +*/ void QWindow::keyPressEvent(QKeyEvent *ev) { ev->ignore(); } +/*! + Override this to handle key release events. + + \sa keyPressEvent +*/ void QWindow::keyReleaseEvent(QKeyEvent *ev) { ev->ignore(); } +/*! + Override this to handle focus in events. + + Focus in events are sent when the window receives keyboard focus. + + \sa focusOutEvent +*/ void QWindow::focusInEvent(QFocusEvent *ev) { ev->ignore(); } +/*! + Override this to handle focus out events. + + Focus out events are sent when the window loses keyboard focus. + + \sa focusInEvent +*/ void QWindow::focusOutEvent(QFocusEvent *ev) { ev->ignore(); } +/*! + Override this to handle mouse press events. + + \sa mouseReleaseEvent() +*/ void QWindow::mousePressEvent(QMouseEvent *ev) { ev->ignore(); } +/*! + Override this to handle mouse release events. + + \sa mousePressEvent() +*/ void QWindow::mouseReleaseEvent(QMouseEvent *ev) { ev->ignore(); } +/*! + Override this to handle mouse double click events. + + \sa mousePressEvent(), QStyleHints::mouseDoubleClickInterval() +*/ void QWindow::mouseDoubleClickEvent(QMouseEvent *ev) { ev->ignore(); } +/*! + Override this to handle mouse move events. +*/ void QWindow::mouseMoveEvent(QMouseEvent *ev) { ev->ignore(); } #ifndef QT_NO_WHEELEVENT +/*! + Override this to handle mouse wheel or other wheel events. +*/ void QWindow::wheelEvent(QWheelEvent *ev) { ev->ignore(); } #endif //QT_NO_WHEELEVENT +/*! + Override this to handle touch events. +*/ void QWindow::touchEvent(QTouchEvent *ev) { ev->ignore(); } +/*! + Override this to handle platform dependent events. + + This might make your application non-portable. +*/ bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) { Q_UNUSED(eventType); @@ -1101,14 +1593,12 @@ bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *resu \sa mapFromGlobal() */ - QPoint QWindow::mapToGlobal(const QPoint &pos) const { return pos + d_func()->globalPosition(); } - /*! \fn QPoint QWindow::mapFromGlobal(const QPoint &pos) const @@ -1117,14 +1607,12 @@ QPoint QWindow::mapToGlobal(const QPoint &pos) const \sa mapToGlobal() */ - QPoint QWindow::mapFromGlobal(const QPoint &pos) const { return pos - d_func()->globalPosition(); } - Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window) { return window->d_func(); From 8d10d9a444cbb3ad4535444272870c4c71279dba Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 12:23:25 +0100 Subject: [PATCH 034/166] compile fix: missing #include s Change-Id: I3bd34f67033fb921c49da97419c107811d8da6ff Reviewed-by: David Faure --- .../auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 5 +++++ tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 1 + 2 files changed, 6 insertions(+) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 671d03cf84..c214b5fc57 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -79,6 +79,11 @@ #ifdef QT_BUILD_INTERNAL #include #endif + +#ifdef Q_OS_UNIX +# include +# include // for getuid() +#endif #include #include "../../../network-settings.h" diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 70da67455e..2715bfc5dc 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -50,6 +50,7 @@ #include #include #include +#include // for unlink() #endif Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError) From 422b6ba9ecf0595da5772afec8c5a0a00983d95d Mon Sep 17 00:00:00 2001 From: Jan Arne Petersen Date: Fri, 2 Dec 2011 15:20:04 +0100 Subject: [PATCH 035/166] Add WindowDoesNotAcceptFocus flag and use it in xcb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add window flag to support windows which should not get the input focus. Sets the input field in the WM_HINTS structure of the window to false if the WindowDoesNotAcceptFocus flag is set on a window in xcb. Change-Id: Ifbc10695b83484c17dca0eb13ea826d74f174833 Reviewed-by: Samuel Rødal --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 3 +++ src/plugins/platforms/xcb/qxcbwindow.cpp | 24 ++++++++++++++++++++++++ src/plugins/platforms/xcb/qxcbwindow.h | 1 + 4 files changed, 29 insertions(+) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 2087d763de..4ea62c77a6 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -293,6 +293,7 @@ public: WindowStaysOnTopHint = 0x00040000, WindowTransparentForInput = 0x00080000, WindowOverridesSystemGestures = 0x00100000, + WindowDoesNotAcceptFocus = 0x00200000, CustomizeWindowHint = 0x02000000, WindowStaysOnBottomHint = 0x04000000, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index d50960f68b..895feb7f53 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2112,6 +2112,9 @@ implements its own set of gestures and that system level gestures, like for instance three-finger desktop switching, should be disabled. + \value WindowDoesNotAcceptFocus Informs the window system that this window should + not receive the input focus. + \value WindowType_Mask A mask for extracting the window type part of the window flags. diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 43e4a6b7d9..067cb775c8 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -77,6 +77,7 @@ #define xcb_size_hints_set_win_gravity xcb_icccm_size_hints_set_win_gravity #define xcb_wm_hints_set_iconic xcb_icccm_wm_hints_set_iconic #define xcb_wm_hints_set_normal xcb_icccm_wm_hints_set_normal +#define xcb_wm_hints_set_input xcb_icccm_wm_hints_set_input #define xcb_wm_hints_t xcb_icccm_wm_hints_t #define XCB_WM_STATE_ICONIC XCB_ICCCM_WM_STATE_ICONIC #define XCB_WM_STATE_WITHDRAWN XCB_ICCCM_WM_STATE_WITHDRAWN @@ -322,6 +323,8 @@ void QXcbWindow::create() memset(&hints, 0, sizeof(hints)); xcb_wm_hints_set_normal(&hints); + xcb_wm_hints_set_input(&hints, !(window()->windowFlags() & Qt::WindowDoesNotAcceptFocus)); + xcb_set_wm_hints(xcb_connection(), m_window, &hints); xcb_window_t leader = m_screen->clientLeader(); @@ -509,6 +512,8 @@ void QXcbWindow::show() else xcb_wm_hints_set_normal(&hints); + xcb_wm_hints_set_input(&hints, !(window()->windowFlags() & Qt::WindowDoesNotAcceptFocus)); + xcb_set_wm_hints(xcb_connection(), m_window, &hints); // update WM_NORMAL_HINTS @@ -730,6 +735,7 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags) setMotifWindowFlags(flags); setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput); + updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus); return flags; } @@ -1062,6 +1068,24 @@ void QXcbWindow::setTransparentForMouseEvents(bool transparent) m_transparent = transparent; } +void QXcbWindow::updateDoesNotAcceptFocus(bool doesNotAcceptFocus) +{ + xcb_get_property_cookie_t cookie = xcb_get_wm_hints(xcb_connection(), m_window); + + xcb_generic_error_t *error; + + xcb_wm_hints_t hints; + xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, &error); + + if (error) { + connection()->handleXcbError(error); + free(error); + return; + } + + xcb_wm_hints_set_input(&hints, !doesNotAcceptFocus); + xcb_set_wm_hints(xcb_connection(), m_window, &hints); +} WId QXcbWindow::winId() const { diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 365c8b0549..6ae55e77e6 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -132,6 +132,7 @@ private: void updateNetWmStateBeforeMap(); void setTransparentForMouseEvents(bool transparent); + void updateDoesNotAcceptFocus(bool doesNotAcceptFocus); void create(); void destroy(); From b067f6cfe30a5a687316130d04678ac406837d09 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 8 Feb 2012 15:55:29 +0100 Subject: [PATCH 036/166] Add the quitlock feature to QThread. Change-Id: Ib44ee9739499ba4c5f0fecbef3976251ea22836d Reviewed-by: Bradley T. Hughes Reviewed-by: Thiago Macieira --- src/corelib/kernel/qeventloop.cpp | 19 ++++++- src/corelib/kernel/qeventloop.h | 1 + src/corelib/thread/qthread.cpp | 9 ++++ src/corelib/thread/qthread.h | 2 + src/corelib/thread/qthread_p.h | 17 +++++++ .../corelib/thread/qthread/tst_qthread.cpp | 49 +++++++++++++++++++ 6 files changed, 95 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index 8b0ec85679..2fb351797c 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -322,13 +322,19 @@ class QEventLoopLockerPrivate { public: explicit QEventLoopLockerPrivate(QEventLoopPrivate *loop) - : loop(loop), app(0) + : loop(loop), thread(0), app(0) { loop->ref(); } + explicit QEventLoopLockerPrivate(QThreadPrivate *thread) + : loop(0), thread(thread), app(0) + { + thread->ref(); + } + explicit QEventLoopLockerPrivate(QCoreApplicationPrivate *app) - : loop(0), app(app) + : loop(0), thread(0), app(app) { app->ref(); } @@ -337,12 +343,15 @@ public: { if (loop) loop->deref(); + else if (thread) + thread->deref(); else app->deref(); } private: QEventLoopPrivate *loop; + QThreadPrivate *thread; QCoreApplicationPrivate *app; }; @@ -390,6 +399,12 @@ QEventLoopLocker::QEventLoopLocker(QEventLoop *loop) } +QEventLoopLocker::QEventLoopLocker(QThread *thread) + : d_ptr(new QEventLoopLockerPrivate(static_cast(QObjectPrivate::get(thread)))) +{ + +} + /*! Destroys this event loop locker object */ diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h index 0e7195d6a7..ba082d7d9d 100644 --- a/src/corelib/kernel/qeventloop.h +++ b/src/corelib/kernel/qeventloop.h @@ -96,6 +96,7 @@ class Q_CORE_EXPORT QEventLoopLocker public: QEventLoopLocker(); explicit QEventLoopLocker(QEventLoop *loop); + explicit QEventLoopLocker(QThread *thread); ~QEventLoopLocker(); private: diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index be0a98d3b5..a071463178 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -763,5 +763,14 @@ void QThread::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) } } +bool QThread::event(QEvent *event) +{ + if (event->type() == QEvent::Quit) { + quit(); + return true; + } else { + return QObject::event(event); + } +} QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 719f4afbbb..ba119afb5d 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -95,6 +95,8 @@ public: QAbstractEventDispatcher *eventDispatcher() const; void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher); + bool event(QEvent *event); + public Q_SLOTS: void start(Priority = InheritPriority); void terminate(); diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index d8374e9805..6597b56893 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -60,6 +60,7 @@ #include "QtCore/qstack.h" #include "QtCore/qwaitcondition.h" #include "QtCore/qmap.h" +#include "QtCore/qcoreapplication.h" #include "private/qobject_p.h" @@ -144,6 +145,7 @@ public: ~QThreadPrivate(); mutable QMutex mutex; + QAtomicInt quitLockRef; bool running; bool finished; @@ -179,6 +181,18 @@ public: QThreadData *data; static void createEventDispatcher(QThreadData *data); + + void ref() + { + quitLockRef.ref(); + } + + void deref() + { + if (!quitLockRef.deref() && running) { + QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit)); + } + } }; #else // QT_NO_THREAD @@ -195,6 +209,9 @@ public: static QThread *threadForId(int) { return QThread::currentThread(); } static void createEventDispatcher(QThreadData *data); + void ref() {} + void deref() {} + Q_DECLARE_PUBLIC(QThread) }; diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 25e1a0587c..8eccd17376 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -107,6 +107,8 @@ private slots: void customEventDispatcher(); void stressTest(); + + void quitLock(); }; enum { one_minute = 60 * 1000, five_minutes = 5 * one_minute }; @@ -1285,5 +1287,52 @@ void tst_QThread::customEventDispatcher() QVERIFY(weak_ed.isNull()); } +class Job : public QObject +{ + Q_OBJECT +public: + Job(QThread *thread, int deleteDelay, QObject *parent = 0) + : QObject(parent), quitLocker(thread), exitThreadCalled(false) + { + moveToThread(thread); + QTimer::singleShot(deleteDelay, this, SLOT(deleteLater())); + QTimer::singleShot(1000, this, SLOT(exitThread())); + } + +private slots: + void exitThread() + { + exitThreadCalled = true; + thread()->exit(1); + } + +private: + QEventLoopLocker quitLocker; +public: + bool exitThreadCalled; +}; + +void tst_QThread::quitLock() +{ + QThread thread; + + QEventLoop loop; + connect(&thread, SIGNAL(finished()), &loop, SLOT(quit())); + + Job *job; + + thread.start(); + job = new Job(&thread, 500); + QCOMPARE(job->thread(), &thread); + loop.exec(); + QVERIFY(!job->exitThreadCalled); + + thread.start(); + job = new Job(&thread, 2500); + QCOMPARE(job->thread(), &thread); + loop.exec(); + QVERIFY(job->exitThreadCalled); +} + QTEST_MAIN(tst_QThread) #include "tst_qthread.moc" From cc6f28e2d653473d92ace43334e448604b7c23f2 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Thu, 23 Feb 2012 11:41:47 +0000 Subject: [PATCH 037/166] Fix fontconfig.pri file to allow QPA plugins to build Change-Id: I5ebcffb7153f4216d69921d4818051e6b3d14d8a Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/platformsupport/fontdatabases/fontconfig/fontconfig.pri | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri b/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri index 2c896ef2cc..af9bd0a01c 100644 --- a/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri +++ b/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri @@ -1,5 +1,5 @@ HEADERS += $$PWD/qfontconfigdatabase_p.h \ - fontdatabases/fontconfig/qfontenginemultifontconfig_p.h + $$PWD/qfontenginemultifontconfig_p.h SOURCES += $$PWD/qfontconfigdatabase.cpp \ - fontdatabases/fontconfig/qfontenginemultifontconfig.cpp + $$PWD/qfontenginemultifontconfig.cpp DEFINES -= QT_NO_FONTCONFIG From 729a73dfada8269c698e83a9bbd91a62dab77737 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Thu, 23 Feb 2012 12:42:17 +0000 Subject: [PATCH 038/166] Use -fPIE on QNX Change-Id: Iec065f528f5edd848be580807a607488dc2e401f Reviewed-by: Thiago Macieira --- mkspecs/common/qcc-base.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkspecs/common/qcc-base.conf b/mkspecs/common/qcc-base.conf index da006f52d7..5aa09cf21d 100644 --- a/mkspecs/common/qcc-base.conf +++ b/mkspecs/common/qcc-base.conf @@ -15,6 +15,7 @@ QMAKE_CFLAGS_RELEASE += -O2 QMAKE_CFLAGS_DEBUG += -g QMAKE_CFLAGS_SHLIB += -fPIC QMAKE_CFLAGS_STATIC_LIB += -fPIC +QMAKE_CFLAGS_APP += -fPIE QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden @@ -26,6 +27,7 @@ QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB +QMAKE_CXXFLAGS_APP += $$QMAKE_CFLAGS_APP QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden From 60c6ed0e042fa18d76d4961d394b8f99226e9892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Mon, 13 Feb 2012 13:06:40 +0100 Subject: [PATCH 039/166] Rename QMetaTypeSwitcher::UnknownType to NotBuiltinType. UnknownType suggest that a type is unknown to QMetaType, but QMetaTypeSwitcher is not checking for custom types. Change-Id: I6b8b692e0f20bed286c713672b35fb15757d389e Reviewed-by: Olivier Goffart --- src/corelib/kernel/qmetatype.cpp | 12 ++++++------ src/corelib/kernel/qmetatypeswitcher_p.h | 4 ++-- src/corelib/kernel/qvariant_p.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index a1baf28f10..0021c0ced2 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1318,7 +1318,7 @@ public: template void delegate(const T *where) { DestroyerImpl::Destroy(m_type, const_cast(where)); } void delegate(const void *) {} - void delegate(const QMetaTypeSwitcher::UnknownType *where) { customTypeDestroyer(m_type, (void*)where); } + void delegate(const QMetaTypeSwitcher::NotBuiltinType *where) { customTypeDestroyer(m_type, (void*)where); } private: static void customTypeDestroyer(const int type, void *where) @@ -1380,7 +1380,7 @@ public: template void *delegate(const T *copy) { return ConstructorImpl::Construct(m_type, m_where, copy); } void *delegate(const void *) { return m_where; } - void *delegate(const QMetaTypeSwitcher::UnknownType *copy) { return customTypeConstructor(m_type, m_where, copy); } + void *delegate(const QMetaTypeSwitcher::NotBuiltinType *copy) { return customTypeConstructor(m_type, m_where, copy); } private: static void *customTypeConstructor(const int type, void *where, const void *copy) @@ -1468,7 +1468,7 @@ public: template void delegate(const T *where) { DestructorImpl::Destruct(m_type, const_cast(where)); } void delegate(const void *) {} - void delegate(const QMetaTypeSwitcher::UnknownType *where) { customTypeDestructor(m_type, (void*)where); } + void delegate(const QMetaTypeSwitcher::NotBuiltinType *where) { customTypeDestructor(m_type, (void*)where); } private: static void customTypeDestructor(const int type, void *where) @@ -1536,7 +1536,7 @@ public: template int delegate(const T*) { return SizeOfImpl::Size(m_type); } - int delegate(const QMetaTypeSwitcher::UnknownType*) { return customTypeSizeOf(m_type); } + int delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return customTypeSizeOf(m_type); } private: static int customTypeSizeOf(const int type) { @@ -1606,7 +1606,7 @@ public: template quint32 delegate(const T*) { return FlagsImpl::Flags(m_type); } quint32 delegate(const void*) { return 0; } - quint32 delegate(const QMetaTypeSwitcher::UnknownType*) { return customTypeFlags(m_type); } + quint32 delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return customTypeFlags(m_type); } private: const int m_type; static quint32 customTypeFlags(const int type) @@ -1793,7 +1793,7 @@ public: template void delegate(const T*) { TypeInfoImpl(m_type, info); } void delegate(const void*) {} - void delegate(const QMetaTypeSwitcher::UnknownType*) { customTypeInfo(m_type); } + void delegate(const QMetaTypeSwitcher::NotBuiltinType*) { customTypeInfo(m_type); } private: void customTypeInfo(const uint type) { diff --git a/src/corelib/kernel/qmetatypeswitcher_p.h b/src/corelib/kernel/qmetatypeswitcher_p.h index c1cccfca63..05db2cb4c7 100644 --- a/src/corelib/kernel/qmetatypeswitcher_p.h +++ b/src/corelib/kernel/qmetatypeswitcher_p.h @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE class QMetaTypeSwitcher { public: - typedef void *UnknownType; + typedef void *NotBuiltinType; template static ReturnType switcher(DelegateObject &logic, int type, const void *data); }; @@ -91,7 +91,7 @@ ReturnType QMetaTypeSwitcher::switcher(DelegateObject &logic, int type, const vo QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_METATYPE_SWICHER_CASE_QCLASS) default: - return logic.delegate(static_cast(data)); + return logic.delegate(static_cast(data)); } } diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index c428d81bb4..708a427860 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -345,7 +345,7 @@ public: FilteredConstructor(*this); } - void delegate(const QMetaTypeSwitcher::UnknownType*) + void delegate(const QMetaTypeSwitcher::NotBuiltinType*) { qWarning("Trying to construct an instance of an invalid type, type id: %i", m_x->type); m_x->type = QVariant::Invalid; @@ -395,7 +395,7 @@ public: FilteredDestructor cleaner(m_d); } - void delegate(const QMetaTypeSwitcher::UnknownType*) + void delegate(const QMetaTypeSwitcher::NotBuiltinType*) { qWarning("Trying to destruct an instance of an invalid type, type id: %i", m_d->type); } @@ -441,7 +441,7 @@ public: Filtered streamIt(m_debugStream, m_d); } - void delegate(const QMetaTypeSwitcher::UnknownType*) + void delegate(const QMetaTypeSwitcher::NotBuiltinType*) { qWarning("Trying to stream an instance of an invalid type, type id: %i", m_d->type); } From 52c253fa33162c1db2d0cb0916e0de188b9a0aae Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 00:22:59 +0100 Subject: [PATCH 040/166] Remove QT_ASCII_CAST_WARN_CONSTRUCTOR GCC version < 3 which it was created for is not supported anymore. Change-Id: I0b4df4c99600cacbaafbf0bc4270cd4978600956 Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 7 ------- src/corelib/kernel/qvariant.h | 2 +- src/corelib/tools/qchar.h | 4 ++-- src/corelib/tools/qstring.h | 4 ++-- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 485f08bfce..e7a6b59f2e 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -385,15 +385,8 @@ QT_END_INCLUDE_NAMESPACE #ifdef QT_ASCII_CAST_WARNINGS # define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED -# if defined(Q_CC_GNU) && __GNUC__ < 4 - /* gcc < 4 doesn't like Q_DECL_DEPRECATED in front of constructors */ -# define QT_ASCII_CAST_WARN_CONSTRUCTOR -# else -# define QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED -# endif #else # define QT_ASCII_CAST_WARN -# define QT_ASCII_CAST_WARN_CONSTRUCTOR #endif #if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 5fcfe3e696..20d3946ea1 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -210,7 +210,7 @@ class Q_CORE_EXPORT QVariant QVariant(double d); QVariant(float f) { d.is_null = false; d.type = QMetaType::Float; d.data.f = f; } #ifndef QT_NO_CAST_FROM_ASCII - QT_ASCII_CAST_WARN_CONSTRUCTOR QVariant(const char *str); + QT_ASCII_CAST_WARN QVariant(const char *str); #endif QVariant(const QByteArray &bytearray); diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index d55fcdba89..3209ffb0f2 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -86,8 +86,8 @@ public: Q_DECL_CONSTEXPR QChar(QLatin1Char ch) : ucs(ch.unicode()) {} // implicit #ifndef QT_NO_CAST_FROM_ASCII - QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTEXPR explicit QChar(char c) : ucs(uchar(c)) { } - QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTEXPR explicit QChar(uchar c) : ucs(c) { } + QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) : ucs(uchar(c)) { } + QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(uchar c) : ucs(c) { } #endif // Unicode information diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index f49d989e9d..b1ade85a30 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -498,10 +498,10 @@ public: // ASCII compatibility #ifndef QT_NO_CAST_FROM_ASCII - inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const char *ch) + inline QT_ASCII_CAST_WARN QString(const char *ch) : d(fromAscii_helper(ch, ch ? int(strlen(ch)) : -1)) {} - inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const QByteArray &a) + inline QT_ASCII_CAST_WARN QString(const QByteArray &a) : d(fromAscii_helper(a.constData(), qstrnlen(a.constData(), a.size()))) {} inline QT_ASCII_CAST_WARN QString &operator=(const char *ch) From cf2ca62dcd2494155b9c07d6a14df7c453226c1e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 22 Feb 2012 14:25:33 +0100 Subject: [PATCH 041/166] Require compiler support for deprecated constructors. Change-Id: I1d4cdcbbddb7895e6529e4f6b5295312e9a3a0e6 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 3 --- src/corelib/global/qglobal.h | 7 ------- 2 files changed, 10 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index f76dfbaaa5..b3787261be 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -145,9 +145,6 @@ /* Clang also masquerades as GCC */ # define Q_CC_CLANG # endif -# ifdef __APPLE__ -# define Q_NO_DEPRECATED_CONSTRUCTORS -# endif # define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e7a6b59f2e..acafde595d 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -324,13 +324,6 @@ QT_END_INCLUDE_NAMESPACE #ifndef Q_DECL_VARIABLE_DEPRECATED # define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED #endif -#ifndef Q_DECL_CONSTRUCTOR_DEPRECATED -# if defined(Q_NO_DEPRECATED_CONSTRUCTORS) -# define Q_DECL_CONSTRUCTOR_DEPRECATED -# else -# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_DEPRECATED -# endif -#endif #if defined(QT_NO_DEPRECATED) # undef QT_DEPRECATED From 785e95ef0a95ca8fb39ef57678cd4876ee657c43 Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Wed, 8 Feb 2012 10:12:13 +0000 Subject: [PATCH 042/166] Harfbuzz-thai: Hide ZWJ and ZWNJ characters and show Inherited characters Thai is not supposed to have ZWJ and ZWNJ characters or any other of the Inherited Unicode Scripts (http://www.verisigninc.com/assets/idn-inherited-unicode-script.pdf) - they don't have a mapping to the thai encoding tis620 which libthai requires. However it is an unfortunate fact that there are many websites etc that liberally place these ZWJ and ZWNJ characters throughout thai text to force word boundaries, so we must also deal with them. We deal with all Inherited characters by mapping them to the invalid code ~0 in tis620 encoding, following what libthai does internally in its own tis620 encoding functions, and then replacing this character with the original unicode and setting dontPrint to true to hide the ZWJ and ZWNJ characters. Includes a unit test to check the behaviour. Change-Id: I1ee8388b650cb5fc61bcb265efb9843c73f327ac Reviewed-by: Adrian Yanes Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/3rdparty/harfbuzz/src/harfbuzz-thai.c | 11 +++-- .../tst_qtextscriptengine.cpp | 42 +++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c index 386fd5c252..bf6c35b19c 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c @@ -77,7 +77,7 @@ static void to_tis620(const HB_UChar16 *string, hb_uint32 len, const char *cstr) else if (string[i] >= 0xe01 && string[i] <= 0xe5b) result[i] = (unsigned char)(string[i] - 0xe00 + 0xa0); else - result[i] = '?'; + result[i] = (unsigned char)~0; // Same encoding as libthai uses for invalid chars } result[len] = 0; @@ -259,8 +259,13 @@ static HB_Bool HB_ThaiConvertStringToGlyphIndices (HB_ShaperItem *item) for (int lgi = 0; lgi < lgn; lgi++) { if ( rglyphs[lgi] == 0xdd/*TH_BLANK_BASE_GLYPH*/ ) { glyphString[slen++] = C_DOTTED_CIRCLE; - } - else { + } else if (cstr[i] == (signed char)~0) { + // The only glyphs that should be passed to this function that cannot be mapped to + // tis620 are the ones of type Inherited class. Pass these glyphs untouched. + glyphString[slen++] = string[i]; + if (string[i] == 0x200D || string[i] == 0x200C) + item->attributes[slen-1].dontPrint = true; // Hide ZWJ and ZWNJ characters + } else { glyphString[slen++] = (HB_UChar16) thai_get_glyph_index (font_type, rglyphs[lgi]); } } diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index cf02d1af50..7db12ed2b4 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -104,6 +104,7 @@ private slots: void mirroredChars(); void thaiIsolatedSaraAm(); + void thaiWithZWJ(); private: bool haveTestFonts; @@ -1280,5 +1281,46 @@ void tst_QTextScriptEngine::thaiIsolatedSaraAm() QSKIP("Cannot find Waree."); } +void tst_QTextScriptEngine::thaiWithZWJ() +{ + QString s(QString::fromUtf8("ร‍ร‌ร“ร…ร”ร\xA0ร本ร") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); + QTextLayout layout(s); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QTextEngine *e = layout.engine(); + e->width(0, s.length()); //force itemize and shape + + // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. + // The current implementation hides them, so we test for that. + // But make sure that we don't hide anything else + QCOMPARE(e->layoutData->items.size(), 11); + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(5)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script + QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a seperate item + QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[3].num_glyphs, ushort(1)); // Common: Ellipsis + QCOMPARE(e->layoutData->items[4].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[5].num_glyphs, ushort(1)); // Common: Smart quote + QCOMPARE(e->layoutData->items[6].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[7].num_glyphs, ushort(1)); // Common: \xA0 = non-breaking space. Could be useful to have in thai, but not currently implemented + QCOMPARE(e->layoutData->items[8].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[9].num_glyphs, ushort(1)); // Japanese: Kanji for tree + QCOMPARE(e->layoutData->items[10].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type + + //A quick sanity check - check all the characters are individual clusters + unsigned short *logClusters = e->layoutData->logClustersPtr; + for (int i = 0; i < 5; i++) + QCOMPARE(logClusters[i], ushort(i)); + for (int i = 0; i < 10; i++) + QCOMPARE(logClusters[i+5], ushort(0)); + QCOMPARE(logClusters[15], ushort(1)); + + // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 + // and 3. + for (int i = 0; i < 16; i++) + QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3)); +} + QTEST_MAIN(tst_QTextScriptEngine) #include "tst_qtextscriptengine.moc" From 2b23d7214f1bb90369ee418a30958fcc5d96cd8f Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Wed, 8 Feb 2012 10:12:16 +0000 Subject: [PATCH 043/166] QTextEngine - treat a fullstop (0x2E) as the same script as the preceeding text when dividing up strings Many languages use a fullstop to indicate an abbreviation, making the fullstop part of the word. For languages like thai, it is required to pass the fullstop along for correct word breaking. Change-Id: I5ad0ddbc66ea96e08913446dad8fd3c5d5dd0905 Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine.cpp | 15 ++++++++++++++- .../qtextscriptengine/tst_qtextscriptengine.cpp | 12 ++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index bc7f4f7ad6..30170759a0 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -115,7 +115,20 @@ private: return; const int end = start + length; for (int i = start + 1; i < end; ++i) { - if ((m_analysis[i] == m_analysis[start]) + // According to the unicode spec we should be treating characters in the Common script + // (punctuation, spaces, etc) as being the same script as the surrounding text for the + // purpose of splitting up text. This is important because, for example, a fullstop + // (0x2E) can be used to indicate an abbreviation and so must be treated as part of a + // word. Thus it must be passed along with the word in languages that have to calculate + // word breaks. For example the thai word "ครม." has no word breaks but the word "ครม" + // does. + // Unfortuntely because we split up the strings for both wordwrapping and for setting + // the font and because Japanese and Chinese are also aliases of the script "Common", + // doing this would break too many things. So instead we only pass the full stop + // along, and nothing else. + if (m_analysis[i].bidiLevel == m_analysis[start].bidiLevel + && m_analysis[i].flags == m_analysis[start].flags + && (m_analysis[i].script == m_analysis[start].script || m_string[i] == QLatin1Char('.')) && m_analysis[i].flags < QScriptAnalysis::SpaceTabOrObject && i - start < MaxItemLength) continue; diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 7db12ed2b4..7c9a83eaa4 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1283,7 +1283,7 @@ void tst_QTextScriptEngine::thaiIsolatedSaraAm() void tst_QTextScriptEngine::thaiWithZWJ() { - QString s(QString::fromUtf8("ร‍ร‌ร“ร…ร”ร\xA0ร本ร") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); + QString s(QString::fromUtf8("ร‍ร‌.ร.“ร…ร”ร\xA0ร本ร") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); QTextLayout layout(s); layout.beginLayout(); layout.createLine(); @@ -1296,7 +1296,7 @@ void tst_QTextScriptEngine::thaiWithZWJ() // The current implementation hides them, so we test for that. // But make sure that we don't hide anything else QCOMPARE(e->layoutData->items.size(), 11); - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(5)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(7)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a seperate item QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character QCOMPARE(e->layoutData->items[3].num_glyphs, ushort(1)); // Common: Ellipsis @@ -1310,15 +1310,15 @@ void tst_QTextScriptEngine::thaiWithZWJ() //A quick sanity check - check all the characters are individual clusters unsigned short *logClusters = e->layoutData->logClustersPtr; - for (int i = 0; i < 5; i++) + for (int i = 0; i < 7; i++) QCOMPARE(logClusters[i], ushort(i)); for (int i = 0; i < 10; i++) - QCOMPARE(logClusters[i+5], ushort(0)); - QCOMPARE(logClusters[15], ushort(1)); + QCOMPARE(logClusters[i+7], ushort(0)); + QCOMPARE(logClusters[17], ushort(1)); // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 // and 3. - for (int i = 0; i < 16; i++) + for (int i = 0; i < 18; i++) QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3)); } From 031389e62eef062d0bc93539d9144265996fa86f Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Thu, 23 Feb 2012 13:18:47 +0100 Subject: [PATCH 044/166] QWindowsPipeWriter could terminate the process to early When the QWindowsPipeWriter is deleted it will wait for the thread to exit. This wait was set to 100 ms which will not always be enough time for the thread to exit, in that case the thread will be terminated. This will increase the timeout to 30 seconds that should be more then enough time for the thread to exit by itself. Task-number: QTBUG-4425 Change-Id: I9b1910c0213376c622c091be050df2a1c4c6b190 Reviewed-by: Joerg Bornemann Reviewed-by: Bradley T. Hughes --- src/corelib/io/qwindowspipewriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index e31337d0fd..aa3745237b 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -67,7 +67,7 @@ QWindowsPipeWriter::~QWindowsPipeWriter() quitNow = true; waitCondition.wakeOne(); lock.unlock(); - if (!wait(100)) + if (!wait(30000)) terminate(); #if !defined(Q_OS_WINCE) || (_WIN32_WCE >= 0x600) CloseHandle(writePipe); From 19a562a92318f417bb4dca0cae2b97f28a98a7e2 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Tue, 21 Feb 2012 15:28:18 +0100 Subject: [PATCH 045/166] QSslSocket::verify certificates when on-demand loading is used Task-number: QTBUG-24350 Change-Id: I5a328efe6606f5d438bb4787a5c02a425ce42aca Reviewed-by: Richard J. Moore --- src/network/ssl/qsslsocket_openssl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index f62f3c1229..20ad82407c 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1384,6 +1384,10 @@ QList QSslSocketBackendPrivate::verify(QList certifi return errors; } + if (s_loadRootCertsOnDemand) { + setDefaultCaCertificates(defaultCaCertificates() + systemCaCertificates()); + } + QList expiredCerts; foreach (const QSslCertificate &caCertificate, QSslSocket::defaultCaCertificates()) { From 5e7a4d6bed8ab6c87ce530680e31aff2f7fdd408 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 13:51:12 +0100 Subject: [PATCH 046/166] Use new plugin system in plugin autotest. Fix up test use QFINDTESTDATA for shadow builds. Change-Id: I64731baa44f446ce360631ed6a638cea098d78a0 Reviewed-by: Lars Knoll --- .../auto/corelib/plugin/qplugin/debugplugin/main.cpp | 11 ++++++++++- .../corelib/plugin/qplugin/releaseplugin/main.cpp | 11 ++++++++++- tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp | 10 +++++++++- .../qpluginloader/almostplugin/almostplugin.cpp | 2 -- .../plugin/qpluginloader/almostplugin/almostplugin.h | 2 ++ tests/auto/corelib/plugin/qpluginloader/empty.json | 1 + .../plugin/qpluginloader/theplugin/plugininterface.h | 8 +++++++- .../plugin/qpluginloader/theplugin/theplugin.cpp | 3 --- .../plugin/qpluginloader/theplugin/theplugin.h | 2 ++ 9 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 tests/auto/corelib/plugin/qpluginloader/empty.json diff --git a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp index 057db69174..e27085c293 100644 --- a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp @@ -39,5 +39,14 @@ ** ****************************************************************************/ #include +#include -Q_EXPORT_PLUGIN2(DebugPlugin, QObject) +class DebugPlugin : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "SomeIID") +public: + DebugPlugin() {} +}; + +#include "main.moc" diff --git a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp index 9542695112..d0875d2902 100644 --- a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp @@ -39,5 +39,14 @@ ** ****************************************************************************/ #include +#include -Q_EXPORT_PLUGIN2(ReleasePlugin, QObject) +class ReleasePlugin : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "SomeIID") +public: + ReleasePlugin() {} +}; + +#include "main.moc" diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp index e6a83cf3d7..af76fcc4a2 100644 --- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp +++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp @@ -55,15 +55,23 @@ public: tst_QPlugin(); private slots: + void initTestCase(); void loadDebugPlugin(); void loadReleasePlugin(); }; tst_QPlugin::tst_QPlugin() - : dir("plugins") + : dir(QFINDTESTDATA("plugins")) { } +void tst_QPlugin::initTestCase() +{ + QVERIFY2(dir.exists(), + qPrintable(QString::fromLatin1("Cannot find the 'plugins' directory starting from '%1'"). + arg(QDir::toNativeSeparators(QDir::currentPath())))); +} + void tst_QPlugin::loadDebugPlugin() { foreach (QString fileName, dir.entryList(QStringList() << "*debug*", QDir::Files)) { diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp index 4b2057087a..eaad3ceff5 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp @@ -47,5 +47,3 @@ QString AlmostPlugin::pluginName() const unresolvedSymbol(); return QLatin1String("Plugin ok"); } - -Q_EXPORT_PLUGIN2(almostplugin, AlmostPlugin) diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h index 6658a5be8d..d64f5985ec 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h @@ -42,11 +42,13 @@ #define ALMOSTPLUGIN_H #include +#include #include "../theplugin/plugininterface.h" class AlmostPlugin : public QObject, public PluginInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../empty.json") Q_INTERFACES(PluginInterface) public: diff --git a/tests/auto/corelib/plugin/qpluginloader/empty.json b/tests/auto/corelib/plugin/qpluginloader/empty.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/tests/auto/corelib/plugin/qpluginloader/empty.json @@ -0,0 +1 @@ +{} diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h index a568dd118d..fe0892c0fe 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h @@ -41,13 +41,19 @@ #ifndef PLUGININTERFACE_H #define PLUGININTERFACE_H +#include + struct PluginInterface { virtual ~PluginInterface() {} virtual QString pluginName() const = 0; }; QT_BEGIN_NAMESPACE -Q_DECLARE_INTERFACE(PluginInterface, "com.trolltect.autotests.plugininterface/1.0") + +#define PluginInterface_iid "org.qt-project.Qt.autotests.plugininterface" + +Q_DECLARE_INTERFACE(PluginInterface, PluginInterface_iid) + QT_END_NAMESPACE #endif // PLUGININTERFACE_H diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp index b064901a4d..8c97956a5f 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp @@ -46,6 +46,3 @@ QString ThePlugin::pluginName() const { return QLatin1String("Plugin ok"); } - -Q_EXPORT_PLUGIN2(theplugin, ThePlugin) - diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h index b769aa6eed..3b8f12140e 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h @@ -42,11 +42,13 @@ #define THEPLUGIN_H #include +#include #include "plugininterface.h" class ThePlugin : public QObject, public PluginInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../empty.json") Q_INTERFACES(PluginInterface) public: From 553ffa01188d3c14bec02e5f4b8d72291677b8ef Mon Sep 17 00:00:00 2001 From: Andreas Hartmetz Date: Thu, 23 Feb 2012 15:05:39 +0100 Subject: [PATCH 047/166] Revert "Escape project file name in makefile rebuild rules." It was the result of miscoordination between Andreas Holzammer and me, duplicating the functional change of commit ea2c9f764fed654a57972223449f41e208e05863. This reverts commit 8b7a9b4898c85e81d87cf642ec59ce85e917ee35. Change-Id: I9a47746c1c12ca00b2dc5c5d50e99f9bf990e3f7 Reviewed-by: Oswald Buddenhagen --- qmake/generators/makefile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index dd098596e9..7a00e0b48d 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2508,10 +2508,10 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QListtarget << "-qmake_all: "; if(project->isEmpty("QMAKE_NOFORCE")) @@ -2520,10 +2520,10 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList Date: Thu, 23 Feb 2012 13:52:16 +0100 Subject: [PATCH 048/166] Bump the moc output revision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit aee1f6cc413f56bf4962324799ee3887c3dd037f changed the values of some built-in meta-type ids. Since the ids of built-in types are directly encoded -- not as the symbolic QMetaType::Type name, but as a raw integer -- in the flags for meta-properties, the moc output prior to that change is incompatible with the current output. Change-Id: I970484825137a4f19c80726cfe2024e741e3e879 Reviewed-by: Jędrzej Nowacki Reviewed-by: Roberto Raggi Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart --- src/corelib/kernel/qobjectdefs.h | 2 +- src/tools/moc/outputrevision.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 0b1fa8839f..ec51251531 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -54,7 +54,7 @@ class QByteArray; class QString; #ifndef Q_MOC_OUTPUT_REVISION -#define Q_MOC_OUTPUT_REVISION 63 +#define Q_MOC_OUTPUT_REVISION 64 #endif // The following macros are our "extensions" to C++ diff --git a/src/tools/moc/outputrevision.h b/src/tools/moc/outputrevision.h index 15661a43aa..2ce5b9b765 100644 --- a/src/tools/moc/outputrevision.h +++ b/src/tools/moc/outputrevision.h @@ -43,6 +43,6 @@ #define OUTPUTREVISION_H // if the output revision changes, you MUST change it in qobjectdefs.h too -enum { mocOutputRevision = 63 }; // moc format output revision +enum { mocOutputRevision = 64 }; // moc format output revision #endif // OUTPUTREVISION_H From 804e93462e939ecae671570f3a6ed943ebf3270a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 21 Feb 2012 12:46:44 +0100 Subject: [PATCH 049/166] Added documentation for QOpenGLContext and QOpenGLContextGroup. Change-Id: I00e3e3b3fd37b27b31d4705de3c8c34be9211707 Reviewed-by: Casper van Donderen Reviewed-by: Gunnar Sletta --- src/gui/kernel/qopenglcontext.cpp | 276 +++++++++++++++++++++++++----- 1 file changed, 233 insertions(+), 43 deletions(-) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index ba51653fcf..c263a2a84e 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -74,6 +74,76 @@ QHash QOpenGLContextPrivate::makeCurrentTracker; QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex; #endif +/*! + \class QOpenGLContext + \brief The QOpenGLContext represents a native OpenGL context, enabling + OpenGL rendering on a QSurface. + + QOpenGLContext represents the OpenGL state of an underlying OpenGL context. + To set up a context, set its screen and format such that they match those + of the surface or surfaces with which the context is meant to be used, if + necessary make it share resources with other contexts with + setShareContext(), and finally call create(). Use isValid() to check if the + context was successfully initialized. + + A context can be made current against a given surface by calling + makeCurrent(). When OpenGL rendering is done, call swapBuffers() to swap + the front and back buffers of the surface, so that the newly rendered + content becomes visible. To be able to support certain platforms, + QOpenGLContext requires that you call makeCurrent() again before starting + rendering a new frame, after calling swapBuffers(). + + If the context is temporarily not needed, such as when the application is + not rendering, it can be useful to call destroy() to free resources. + However, if you do so you will need to call create() again before the + context can be used, and you might need to recreate any OpenGL resources + and reinitialize the OpenGL state. You can connect to the + aboutToBeDestroyed() signal to clean up any resources that have been + allocated with different ownership from the QOpenGLContext itself. + + Once a QOpenGLContext has been made current, you can render to it in a + platform independent way by using Qt's OpenGL enablers such as + QOpenGLFunctions, QOpenGLBuffer, QOpenGLShaderProgram, and + QOpenGLFramebufferObject. It is also possible to use the platform's OpenGL + API directly, without using the Qt enablers, although potentially at the + cost of portability. The latter is necessary when wanting to use OpenGL 1.x + or OpenGL ES 1.x. + + For more information about the OpenGL API, refer to the official + \l{OpenGL documentation}. + + \section1 Thread affinity + + QOpenGLContext can be moved to a different thread with moveToThread(). Do + not call makeCurrent() from a different thread than the one to which the + QOpenGLContext object belongs. A context can only be current in one thread + and against one surface at a time, and a thread only has one context + current at a time. + + \section1 Context resource sharing + + Resources, such as framebuffer objects, textures, and vertex buffer objects + can be shared between contexts. Use setShareContext() before calling + create() to specify that the contexts should share these resources. + QOpenGLContext internally keeps track of a QOpenGLContextGroup object which + can be accessed with shareGroup(), and which can be used to find all the + contexts in a given share group. A share group consists of all contexts that + have been succesfully initialized and are sharing with an existing context in + the share group. A non-sharing context has a share group consisting of a + single context. + + \section1 Default framebuffer + + On certain platforms, a framebuffer other than 0 might be the default frame + buffer depending on the current surface. Instead of calling + glBindFramebuffer(0), it is recommended that you use + glBindFramebuffer(ctx->defaultFramebufferObject()), to ensure that your + application is portable between different platforms. However, if you use + QOpenGLFunctions::glBindFramebuffer(), this is done automatically for you. + + \sa QOpenGLFunctions, QOpenGLBuffer, QOpenGLShaderProgram, QOpenGLFramebufferObject +*/ + void QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context) { QGuiGLThreadContext *threadContext = qwindow_context_storage.localData(); @@ -89,7 +159,8 @@ void QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context) } /*! - Returns the last context which called makeCurrent. This function is thread aware. + Returns the last context which called makeCurrent in the current thread, + or 0, if no context is current. */ QOpenGLContext* QOpenGLContext::currentContext() { @@ -100,17 +171,31 @@ QOpenGLContext* QOpenGLContext::currentContext() return 0; } +/*! + Returns true if the two contexts are sharing OpenGL resources. +*/ bool QOpenGLContext::areSharing(QOpenGLContext *first, QOpenGLContext *second) { return first->shareGroup() == second->shareGroup(); } +/*! + Returns the underlying platform context. + + \internal +*/ QPlatformOpenGLContext *QOpenGLContext::handle() const { Q_D(const QOpenGLContext); return d->platformGLContext; } +/*! + Returns the underlying platform context with which this context is sharing. + + \internal +*/ + QPlatformOpenGLContext *QOpenGLContext::shareHandle() const { Q_D(const QOpenGLContext); @@ -120,7 +205,11 @@ QPlatformOpenGLContext *QOpenGLContext::shareHandle() const } /*! - Creates a new GL context instance, you need to call create() before it can be used. + Creates a new OpenGL context instance. + + Before it can be used you need to set the proper format and call create(). + + \sa create(), makeCurrent() */ QOpenGLContext::QOpenGLContext(QObject *parent) : QObject(*new QOpenGLContextPrivate(), parent) @@ -130,7 +219,8 @@ QOpenGLContext::QOpenGLContext(QObject *parent) } /*! - Sets the format the GL context should be compatible with. You need to call create() before it takes effect. + Sets the \a format the OpenGL context should be compatible with. You need + to call create() before it takes effect. */ void QOpenGLContext::setFormat(const QSurfaceFormat &format) { @@ -139,7 +229,8 @@ void QOpenGLContext::setFormat(const QSurfaceFormat &format) } /*! - Sets the context to share textures, shaders, and other GL resources with. You need to call create() before it takes effect. + Sets the context to share textures, shaders, and other OpenGL resources + with. You need to call create() before it takes effect. */ void QOpenGLContext::setShareContext(QOpenGLContext *shareContext) { @@ -148,7 +239,8 @@ void QOpenGLContext::setShareContext(QOpenGLContext *shareContext) } /*! - Sets the screen the GL context should be valid for. You need to call create() before it takes effect. + Sets the \a screen the GL context should be valid for. You need to call + create() before it takes effect. */ void QOpenGLContext::setScreen(QScreen *screen) { @@ -159,9 +251,15 @@ void QOpenGLContext::setScreen(QScreen *screen) } /*! - Attempts to create the GL context with the desired parameters. + Attempts to create the OpenGL context with the current configuration. - Returns true if the native context was successfully created and is ready to be used. + The current configuration includes the format, the share context, and the + screen. + + Returns true if the native context was successfully created and is ready to + be used with makeCurrent(), swapBuffers(), etc. + + \sa makeCurrent(), destroy() */ bool QOpenGLContext::create() { @@ -179,6 +277,22 @@ bool QOpenGLContext::create() return d->platformGLContext; } +/*! + Destroy the underlying platform context associated with this context. + + If any other context is directly or indirectly sharing resources with this + context, the shared resources, which includes vertex buffer objects, shader + objects, textures, and framebuffer objects, are not freed. However, + destroying the underlying platform context frees any state associated with + the context. + + After destroy() has been called, you must call create() if you wish to + use the context again. + + \note This implicitly calls doneCurrent() if the context is current. + + \sa create() +*/ void QOpenGLContext::destroy() { Q_D(QOpenGLContext); @@ -199,15 +313,20 @@ void QOpenGLContext::destroy() \fn void QOpenGLContext::aboutToBeDestroyed() This signal is emitted before the underlying native OpenGL context is - destroyed, such that users may clean up OpenGL resources that might otherwise - be left dangling in the case of shared OpenGL contexts. + destroyed, such that users may clean up OpenGL resources that might + otherwise be left dangling in the case of shared OpenGL contexts. - If you wish to make the context current in order to do clean-up, make sure to - only connect to the signal using a direct connection. + If you wish to make the context current in order to do clean-up, make sure + to only connect to the signal using a direct connection. */ /*! - If this is the current context for the thread, doneCurrent is called + Destroys the QOpenGLContext object. + + This implicitly calls destroy(), so if this is the current context for the + thread, doneCurrent() is also called. + + \sa destroy() */ QOpenGLContext::~QOpenGLContext() { @@ -219,7 +338,9 @@ QOpenGLContext::~QOpenGLContext() } /*! - Returns if this context is valid, i.e. has been successfully created. + Returns if this context is valid, i.e. has been successfully created. + + \sa create() */ bool QOpenGLContext::isValid() const { @@ -228,11 +349,13 @@ bool QOpenGLContext::isValid() const } /*! - Get the QOpenGLFunctions instance for this context. + Get the QOpenGLFunctions instance for this context. - The context or a sharing context must be current. + QOpenGLContext offers this as a convenient way to access QOpenGLFunctions + without having to manage it manually. + + The context or a sharing context must be current. */ - QOpenGLFunctions *QOpenGLContext::functions() const { Q_D(const QOpenGLContext); @@ -242,15 +365,17 @@ QOpenGLFunctions *QOpenGLContext::functions() const } /*! - Call this to get the default framebuffer object for the current surface. + Call this to get the default framebuffer object for the current surface. - On some platforms the default framebuffer object depends on the surface being rendered to, - and might be different from 0. Thus, instead of calling glBindFramebuffer(0), you should - call glBindFramebuffer(ctx->defaultFramebufferObject()) if you want your application to - work across different Qt platforms. + On some platforms the default framebuffer object depends on the surface + being rendered to, and might be different from 0. Thus, instead of calling + glBindFramebuffer(0), you should call + glBindFramebuffer(ctx->defaultFramebufferObject()) if you want your + application to work across different Qt platforms. - If you use the glBindFramebuffer() in QOpenGLFunctions you do not have to worry about this, - as it automatically binds the current context's defaultFramebufferObject() when 0 is passed. + If you use the glBindFramebuffer() in QOpenGLFunctions you do not have to + worry about this, as it automatically binds the current context's + defaultFramebufferObject() when 0 is passed. */ GLuint QOpenGLContext::defaultFramebufferObject() const { @@ -265,12 +390,18 @@ GLuint QOpenGLContext::defaultFramebufferObject() const } /*! - If surface is 0 this is equivalent to calling doneCurrent(). + Makes the context current in the current thread, against the given + \a surface. - Do not call this function from a different thread than the one the QOpenGLContext instance lives in. If - you wish to use QOpenGLContext from a different thread you should first call make sure it's not current - in the current thread, by calling doneCurrent() if necessary. Then call moveToThread(otherThread) - before using it in the other thread. + If \a surface is 0 this is equivalent to calling doneCurrent(). + + Do not call this function from a different thread than the one the + QOpenGLContext instance lives in. If you wish to use QOpenGLContext from a + different thread you should first call make sure it's not current in the + current thread, by calling doneCurrent() if necessary. Then call + moveToThread(otherThread) before using it in the other thread. + + \sa functions(), doneCurrent() */ bool QOpenGLContext::makeCurrent(QSurface *surface) { @@ -313,6 +444,10 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) /*! Convenience function for calling makeCurrent with a 0 surface. + + This results in no context being current in the current thread. + + \sa makeCurrent(), currentContext() */ void QOpenGLContext::doneCurrent() { @@ -330,7 +465,9 @@ void QOpenGLContext::doneCurrent() } /*! - Returns the surface the context is current for. + Returns the surface the context has been made current with. + + This is the surface passed as an argument to makeCurrent(). */ QSurface *QOpenGLContext::surface() const { @@ -391,6 +528,11 @@ void QOpenGLContext::swapBuffers(QSurface *surface) d->platformGLContext->swapBuffers(surfaceHandle); } +/*! + Resolves the function pointer to an OpenGL extension function, identified by \a procName + + Returns 0 if no such function can be found. +*/ QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName) { Q_D(QOpenGLContext); @@ -399,6 +541,11 @@ QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName) return d->platformGLContext->getProcAddress(procName); } +/*! + Returns the format of the underlying platform context, if create() has been called. + + Otherwise, returns the requested format. +*/ QSurfaceFormat QOpenGLContext::format() const { Q_D(const QOpenGLContext); @@ -407,27 +554,41 @@ QSurfaceFormat QOpenGLContext::format() const return d->platformGLContext->format(); } +/*! + Returns the share group this context belongs to. +*/ QOpenGLContextGroup *QOpenGLContext::shareGroup() const { Q_D(const QOpenGLContext); return d->shareGroup; } +/*! + Returns the share context this context was created with. + + If the underlying platform was not able to support the requested + sharing, this will return 0. +*/ QOpenGLContext *QOpenGLContext::shareContext() const { Q_D(const QOpenGLContext); return d->shareContext; } +/*! + Returns the screen the context was created for. +*/ QScreen *QOpenGLContext::screen() const { Q_D(const QOpenGLContext); return d->screen; } -/* - internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant - have any type information. +/*! + internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant + have any type information. + + \internal */ void *QOpenGLContext::qGLContextHandle() const { @@ -435,6 +596,9 @@ void *QOpenGLContext::qGLContextHandle() const return d->qGLContextHandle; } +/*! + \internal +*/ void QOpenGLContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *)) { Q_D(QOpenGLContext); @@ -442,6 +606,9 @@ void QOpenGLContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFun d->qGLContextDeleteFunction = qGLContextDeleteFunction; } +/*! + \internal +*/ void QOpenGLContext::deleteQGLContext() { Q_D(QOpenGLContext); @@ -452,23 +619,45 @@ void QOpenGLContext::deleteQGLContext() } } +/*! + \class QOpenGLContextGroup + \brief The QOpenGLContextGroup represents a group of contexts sharing + OpenGL resources. + + QOpenGLContextGroup is automatically created and managed by QOpenGLContext + instances. Its purpose is to identify all the contexts that are sharing + resources. + + \sa QOpenGLContext::shareGroup() +*/ QOpenGLContextGroup::QOpenGLContextGroup() : QObject(*new QOpenGLContextGroupPrivate()) { } +/*! + \internal +*/ QOpenGLContextGroup::~QOpenGLContextGroup() { Q_D(QOpenGLContextGroup); d->cleanup(); } +/*! + Returns all the QOpenGLContext objects in this share group. +*/ QList QOpenGLContextGroup::shares() const { Q_D(const QOpenGLContextGroup); return d->m_shares; } +/*! + Returns the QOpenGLContextGroup corresponding to the current context. + + \sa QOpenGLContext::currentContext() +*/ QOpenGLContextGroup *QOpenGLContextGroup::currentContextGroup() { QOpenGLContext *current = QOpenGLContext::currentContext(); @@ -544,9 +733,10 @@ void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx) \class QOpenGLSharedResource \internal \since 5.0 - \brief The QOpenGLSharedResource class is used to keep track of resources that - are shared between OpenGL contexts (like textures, framebuffer objects, shader - programs, etc), and clean them up in a safe way when they're no longer needed. + \brief The QOpenGLSharedResource class is used to keep track of resources + that are shared between OpenGL contexts (like textures, framebuffer + objects, shader programs, etc), and clean them up in a safe way when + they're no longer needed. The QOpenGLSharedResource instance should never be deleted, instead free() should be called when it's no longer needed. Thus it will be put on a queue @@ -556,11 +746,11 @@ void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx) The sub-class needs to implement two pure virtual functions. The first, freeResource() must be implemented to actually do the freeing, for example call glDeleteTextures() on a texture id. Qt makes sure a valid context in - the resource's share group is current at the time. The other, invalidateResource(), - is called by Qt in the circumstance when the last context in the share group is - destroyed before free() has been called. The implementation of invalidateResource() - should set any identifiers to 0 or set a flag to prevent them from being used - later on. + the resource's share group is current at the time. The other, + invalidateResource(), is called by Qt in the circumstance when the last + context in the share group is destroyed before free() has been called. The + implementation of invalidateResource() should set any identifiers to 0 or + set a flag to prevent them from being used later on. */ QOpenGLSharedResource::QOpenGLSharedResource(QOpenGLContextGroup *group) : m_group(group) @@ -616,9 +806,9 @@ void QOpenGLSharedResourceGuard::freeResource(QOpenGLContext *context) \since 5.0 \brief The QOpenGLMultiGroupSharedResource keeps track of a shared resource that might be needed from multiple contexts, like a glyph cache or gradient - cache. One instance of the object is created for each group when - necessary. The shared resource instance should have a constructor that - takes a QOpenGLContext *. To get an instance for a given context one calls + cache. One instance of the object is created for each group when necessary. + The shared resource instance should have a constructor that takes a + QOpenGLContext *. To get an instance for a given context one calls T *QOpenGLMultiGroupSharedResource::value(context), where T is a sub-class of QOpenGLSharedResource. From 8583bc914aaf2a0301e5e2655c68fcac79f5fb34 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 23 Feb 2012 10:43:25 +1000 Subject: [PATCH 050/166] Fixed resolution of QMAKESPEC on Windows. base_vars["QMAKESPEC_ORIGINAL"] is not guaranteed to be set the first time resolveSpec is called, since an include() can wipe it out. Change it so that resolveSpec is called repeatedly until some QMAKESPEC_ORIGINAL is set. The code which attempted to remove all of the path up to the last / was incorrect and must have been dead code (or its wrongness didn't matter) until now. Change-Id: I2b31ae10fc284ac7293c3cd95e5a2fd503ca7ab0 Reviewed-by: Marius Storm-Olsen --- qmake/project.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index 2029e068ec..a8620334d8 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1528,12 +1528,15 @@ QMakeProject::resolveSpec(QString *spec, const QString &qmakespec) // We can't resolve symlinks as they do on Unix, so configure.exe puts the source of the // qmake.conf at the end of the default/qmake.conf in the QMAKESPEC_ORG variable. const QStringList &spec_org = base_vars["QMAKESPEC_ORIGINAL"]; - if (!spec_org.isEmpty()) { + if (spec_org.isEmpty()) { + // try again the next time around + *spec = QString(); + } else { *spec = spec_org.at(0); #endif int lastSlash = spec->lastIndexOf(QLatin1Char('/')); if (lastSlash != -1) - spec->remove(lastSlash + 1); + spec->remove(0, lastSlash + 1); } } } From b2c37a81382219b0e1479d30ad4fb57deddd52bf Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Mon, 20 Feb 2012 22:17:11 +0100 Subject: [PATCH 051/166] improve documentation language style Change-Id: Ic7daa90fff764578bd8122986a73c2ea6280e784 Reviewed-by: Robin Burchell --- src/sql/models/qsqltablemodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 932bbbfd6b..5c84dda1d9 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -659,7 +659,7 @@ bool QSqlTableModel::deleteRowFromTable(int row) Note: In OnManualSubmit mode, already submitted changes won't be cleared from the cache when submitAll() fails. This allows - transactions to be rolled back and resubmitted again without + transactions to be rolled back and resubmitted without losing data. \sa revertAll(), lastError() From 083af1b8cf9e9c805ec41c675728d644d6890578 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Thu, 16 Feb 2012 14:21:07 +0100 Subject: [PATCH 052/166] QSqlTableModel: document edit strategy behavior Change-Id: Ib674288e950837aa343cf1206ed081386b1fff0d Reviewed-by: Robin Burchell --- src/sql/models/qsqltablemodel.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 5c84dda1d9..309c01d7ee 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -1050,6 +1050,8 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent) Returns false if the parameters are out of bounds; otherwise returns true. + Does not submit rows, regardless of edit strategy, not even OnFieldChange. + \sa primeInsert(), insertRecord() */ bool QSqlTableModel::insertRows(int row, int count, const QModelIndex &parent) @@ -1097,7 +1099,11 @@ bool QSqlTableModel::insertRows(int row, int count, const QModelIndex &parent) Returns true if the record could be inserted, otherwise false. - \sa insertRows(), removeRows() + Changes are submitted immediately for OnFieldChange and + OnRowChange. Note the contrast with setRecord() in respect to + OnRowChange. + + \sa insertRows(), removeRows(), setRecord() */ bool QSqlTableModel::insertRecord(int row, const QSqlRecord &record) { @@ -1210,7 +1216,13 @@ Qt::ItemFlags QSqlTableModel::flags(const QModelIndex &index) const Returns true if all the values could be set; otherwise returns false. - \sa record() + The edit strategy affects automatic submitting. + With OnFieldChange, setRecord() commits its changed row. + With OnRowChange, setRecord() does not commit its changed row, + but making a change to another row causes previous changes to + be submitted. + + \sa record(), editStrategy() */ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record) { From 5d516234bef7bf9d86cb1dbb1cddeb7e4c8fc8ec Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Wed, 15 Feb 2012 15:05:28 +0100 Subject: [PATCH 053/166] fix style Change-Id: I8ad0b4d15484662be7b38daa797a688727377c88 Reviewed-by: Robin Burchell --- src/sql/models/qsqltablemodel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 309c01d7ee..f30352e2fe 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -513,10 +513,9 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in QSqlTableModelPrivate::ModifiedRow &row = d->cache[index.row()]; - if (row.op() == QSqlTableModelPrivate::None) { + if (row.op() == QSqlTableModelPrivate::None) row = QSqlTableModelPrivate::ModifiedRow(QSqlTableModelPrivate::Update, d->rec); - } row.setValue(index.column(), value); emit dataChanged(index, index); From 3a863280dc7f1845bf3daa74fe235b1df9bc26ae Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Wed, 15 Feb 2012 10:22:15 +0100 Subject: [PATCH 054/166] QSqlTableModel: avoid extra QMap lookup The consensus on #qt-labs seems to be that there is little or no point in checking with contains() before using value(), even if the map does not contain the key in most cases. Change-Id: I34740a91d5c3af65e20937a5ae3b4bab32406440 Reviewed-by: Robin Burchell --- src/sql/models/qsqltablemodel.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index f30352e2fe..0cb7c3921b 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -439,13 +439,11 @@ QVariant QSqlTableModel::headerData(int section, Qt::Orientation orientation, in { Q_D(const QSqlTableModel); if (orientation == Qt::Vertical && role == Qt::DisplayRole) { - if (d->cache.contains(section)) { - const QSqlTableModelPrivate::Op op = d->cache.value(section).op(); - if (op == QSqlTableModelPrivate::Insert) - return QLatin1String("*"); - else if (op == QSqlTableModelPrivate::Delete) - return QLatin1String("!"); - } + const QSqlTableModelPrivate::Op op = d->cache.value(section).op(); + if (op == QSqlTableModelPrivate::Insert) + return QLatin1String("*"); + else if (op == QSqlTableModelPrivate::Delete) + return QLatin1String("!"); } return QSqlQueryModel::headerData(section, orientation, role); } From 3d763dc83adce6fc270c17933fd66ae5c539517c Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Wed, 15 Feb 2012 01:31:07 +0100 Subject: [PATCH 055/166] QSqlTableModel: rename parameter to avoid name clash with method Change-Id: Ib8fa6b0ca71ffdd9f1f8416c448b5c830988ed08 Reviewed-by: Robin Burchell --- src/sql/models/qsqltablemodel.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 0cb7c3921b..c895c39212 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -1221,7 +1221,7 @@ Qt::ItemFlags QSqlTableModel::flags(const QModelIndex &index) const \sa record(), editStrategy() */ -bool QSqlTableModel::setRecord(int row, const QSqlRecord &record) +bool QSqlTableModel::setRecord(int row, const QSqlRecord &values) { Q_D(QSqlTableModel); Q_ASSERT_X(row >= 0, "QSqlTableModel::setRecord()", "Cannot set a record to a row less than 0"); @@ -1239,9 +1239,9 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record) // Check field names and remember mapping typedef QMap Map; Map map; - for (int i = 0; i < record.count(); ++i) { - if (record.isGenerated(i)) { - int idx = d->nameToIndex(record.fieldName(i)); + for (int i = 0; i < values.count(); ++i) { + if (values.isGenerated(i)) { + int idx = d->nameToIndex(values.fieldName(i)); if (idx == -1) return false; map[i] = idx; @@ -1256,7 +1256,7 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record) Map::const_iterator i = map.constBegin(); const Map::const_iterator e = map.constEnd(); for ( ; i != e; ++i) - mrow.setValue(i.value(), record.value(i.key())); + mrow.setValue(i.value(), values.value(i.key())); if (columnCount()) emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1)); From bd5096d012327d4acb44449464cb00c488450cc5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 17:05:41 +0100 Subject: [PATCH 056/166] Add the QtMain windows library to the CMake files. Change-Id: Iff8b9bdd4b069721103e1cd5854e56b6116d7549 Reviewed-by: Andreas Holzammer Reviewed-by: Oswald Buddenhagen Reviewed-by: Alexander Neundorf Reviewed-by: Stephen Kelly --- mkspecs/features/create_cmake.prf | 9 ++++ src/corelib/Qt5CoreConfigExtras.cmake.in | 23 ++++++++++ tests/manual/cmake/CMakeLists.txt | 1 + tests/manual/cmake/pass8/CMakeLists.txt | 20 +++++++++ tests/manual/cmake/pass8/myobject.cpp | 54 ++++++++++++++++++++++ tests/manual/cmake/pass8/myobject.h | 57 ++++++++++++++++++++++++ 6 files changed, 164 insertions(+) create mode 100644 tests/manual/cmake/pass8/CMakeLists.txt create mode 100644 tests/manual/cmake/pass8/myobject.cpp create mode 100644 tests/manual/cmake/pass8/myobject.h diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 3ae4ddc83b..1f9eded772 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -58,6 +58,15 @@ macx { CMAKE_IMPLIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}$$eval(QT.$${MODULE}.MAJOR_VERSION).lib } CMAKE_BIN_SUFFIX = ".exe" + + CMAKE_WINDOWS_BUILD = "true" + win32-g++ { + CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}d.a + CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqtmain$${QT_LIBINFIX}.a + } else { + CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}d.lib + CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qtmain$${QT_LIBINFIX}.lib + } } else { !isEmpty(CMAKE_STATIC_TYPE) { CMAKE_LIB_FILE_LOCATION_DEBUG = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.a diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 4b5ac73bce..4873391f52 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -20,3 +20,26 @@ list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) !!IF !isEmpty(QT_LIBINFIX) set(QT_LIBINFIX \"$${QT_LIBINFIX}\") !!ENDIF + +!!IF !isEmpty(CMAKE_WINDOWS_BUILD) +set(Qt5Core_QTMAIN_LIBRARIES Qt5::WinMain) + +if (NOT _Qt5WinMain_target) + set(_Qt5WinMain_target 1) + add_library(Qt5::WinMain STATIC IMPORTED) +endif() + +!!IF !isEmpty(debug_type) +set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(Qt5::WinMain PROPERTIES + IMPORTED_LOCATION_DEBUG "${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}" +) +!!ENDIF + +!!IF !isEmpty(release_type) +set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Qt5::WinMain PROPERTIES + IMPORTED_LOCATION_RELEASE \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\" +) +!!ENDIF +!!ENDIF diff --git a/tests/manual/cmake/CMakeLists.txt b/tests/manual/cmake/CMakeLists.txt index 930936a7b5..2d0164a47b 100644 --- a/tests/manual/cmake/CMakeLists.txt +++ b/tests/manual/cmake/CMakeLists.txt @@ -88,3 +88,4 @@ expect_fail(fail4) expect_fail(fail5) expect_pass("pass(needsquoting)6") expect_pass(pass7) +expect_pass(pass8) diff --git a/tests/manual/cmake/pass8/CMakeLists.txt b/tests/manual/cmake/pass8/CMakeLists.txt new file mode 100644 index 0000000000..735b1bd26e --- /dev/null +++ b/tests/manual/cmake/pass8/CMakeLists.txt @@ -0,0 +1,20 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass8) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) + +add_definitions(${Qt5Core_DEFINITIONS}) + +qt5_wrap_cpp(moc_files myobject.h) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +# On non-windows, the WIN32 is harmless, and Qt5Core_QTMAIN_LIBRARIES is empty. +# We test that it is harmless on those, and test that it builds on Windows. +# It wouldn't build if WIN32 is used and Qt5Core_QTMAIN_LIBRARIES is empty. +add_executable(myobject WIN32 myobject.cpp ${moc_files} ) +target_link_libraries(myobject ${Qt5Core_LIBRARIES} ${Qt5Core_QTMAIN_LIBRARIES}) diff --git a/tests/manual/cmake/pass8/myobject.cpp b/tests/manual/cmake/pass8/myobject.cpp new file mode 100644 index 0000000000..b6287b2540 --- /dev/null +++ b/tests/manual/cmake/pass8/myobject.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "myobject.h" + +MyObject::MyObject(QObject *parent) + : QObject(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyObject myObject; + return 0; +} diff --git a/tests/manual/cmake/pass8/myobject.h b/tests/manual/cmake/pass8/myobject.h new file mode 100644 index 0000000000..71a65ee801 --- /dev/null +++ b/tests/manual/cmake/pass8/myobject.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif From 194899df2443c72ff38aaed9b1b26fc3a192a6f0 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Thu, 23 Feb 2012 15:49:11 +0200 Subject: [PATCH 057/166] Reverted part of "Refactor input context tests" This commit reverts partly 7401832a7d45de99562b94340375393a39267f41 There is something wrong with DummyWindow/XCB/Metacity, Metacity crashes quite often when QWindow is activated. Change-Id: I611af2678814f41c941cb697054135f561a77878 Reviewed-by: Joona Petrell --- .../kernel/qinputmethod/tst_qinputmethod.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index c906ebaabe..bc364e37f1 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -212,18 +212,12 @@ void tst_qinputmethod::cursorRectangle() { QCOMPARE(qApp->inputMethod()->cursorRectangle(), QRectF()); - DummyWindow window; - window.show(); - QTest::qWaitForWindowShown(&window); - window.requestActivateWindow(); - QTRY_COMPARE(qApp->focusWindow(), &window); - window.setFocusObject(&m_inputItem); - QTransform transform; transform.translate(10, 10); transform.scale(2, 2); transform.shear(2, 2); qApp->inputMethod()->setInputItemTransform(transform); + qApp->inputMethod()->setInputItem(&m_inputItem); QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4))); @@ -232,6 +226,7 @@ void tst_qinputmethod::cursorRectangle() // reset m_inputItem.cursorRectangle = QRectF(1, 2, 3, 4); + qApp->inputMethod()->setInputItem(0); qApp->inputMethod()->setInputItemTransform(QTransform()); } @@ -269,13 +264,6 @@ void tst_qinputmethod::commit() void tst_qinputmethod::update() { - DummyWindow window; - window.show(); - QTest::qWaitForWindowShown(&window); - window.requestActivateWindow(); - QTRY_COMPARE(qApp->focusWindow(), &window); - window.setFocusObject(&m_inputItem); - QCOMPARE(m_platformInputContext.m_updateCallCount, 0); QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImhNone)); @@ -288,6 +276,9 @@ void tst_qinputmethod::update() QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImQueryAll)); QCOMPARE(qApp->inputMethod()->keyboardRectangle(), QRectF(10, 20, 30, 40)); + + // reset + qApp->inputMethod()->setInputItem(0); } void tst_qinputmethod::query() From d91cf1e53b450483d92c50965fd3c33ab1da4300 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 21 Feb 2012 16:09:30 +0100 Subject: [PATCH 058/166] clean up qmake-generated projects remove "header" and assignmets which are defaults or bogus, reorder some assignments. Change-Id: I67403872168c890ca3b696753ceb01c605d19be7 Reviewed-by: Rohan McGovern --- examples/dbus/complexpingpong/complexping.pro | 5 ----- examples/dbus/complexpingpong/complexpong.pro | 5 ----- examples/dbus/dbus-chat/dbus-chat.pro | 6 +----- examples/dbus/listnames/listnames.pro | 5 ----- examples/dbus/pingpong/ping.pro | 6 ------ examples/dbus/pingpong/pong.pro | 6 ------ examples/dbus/remotecontrolledcar/car/car.pro | 10 +--------- .../controller/controller.pro | 10 +--------- examples/embedded/styleexample/styleexample.pro | 5 +---- examples/graphicsview/boxes/boxes.pro | 12 +----------- examples/graphicsview/flowlayout/flowlayout.pro | 6 +----- .../weatheranchorlayout/weatheranchorlayout.pro | 6 +----- examples/itemviews/spreadsheet/spreadsheet.pro | 12 ------------ examples/network/download/download.pro | 9 --------- .../network/downloadmanager/downloadmanager.pro | 10 +--------- examples/opengl/hellogl_es/hellogl_es.pro | 7 +------ examples/opengl/hellogl_es2/hellogl_es2.pro | 11 +---------- examples/opengl/hellowindow/hellowindow.pro | 9 +-------- examples/opengl/paintedwindow/paintedwindow.pro | 10 ---------- examples/opengl/pbuffers2/pbuffers2.pro | 10 ---------- examples/qpa/windows/windows.pro | 14 ++------------ .../qtconcurrent/imagescaling/imagescaling.pro | 9 +-------- examples/qtconcurrent/map/map.pro | 8 ++------ .../progressdialog/progressdialog.pro | 12 +++--------- .../qtconcurrent/runfunction/runfunction.pro | 12 +++--------- examples/qtconcurrent/wordcount/wordcount.pro | 12 +++--------- .../threads/waitconditions/waitconditions.pro | 11 +---------- examples/widgets/validators/validators.pro | 12 +----------- src/testlib/testlib.pro | 1 - src/tools/moc/util/generate_keywords.pro | 8 -------- .../kernel/qobject/signalbug/signalbug.pro | 5 +---- .../auto/gui/kernel/qclipboard/copier/copier.pro | 7 +------ .../auto/gui/kernel/qclipboard/paster/paster.pro | 8 +------- .../qpainter/utils/createImages/createImages.pro | 8 -------- .../text/qtextscriptengine/generate/generate.pro | 9 --------- .../qlocalsocket/example/client/client.pro | 6 ------ .../qlocalsocket/example/server/server.pro | 8 -------- tests/auto/other/atwrapper/atWrapper.pro | 4 ---- tests/auto/other/macgui/macgui.pro | 4 ---- .../other/macnativeevents/macnativeevents.pro | 4 ---- tests/auto/other/macplist/app/app.pro | 13 ++----------- .../testdata/bundle-spaces/bundle-spaces.pro | 6 ------ .../tools/qmake/testdata/findDeps/findDeps.pro | 5 ----- .../tools/qmake/testdata/findMocs/findMocs.pro | 5 ----- .../dialogs/qerrormessage/qerrormessage.pro | 3 --- .../widgets/dialogs/qmessagebox/qmessagebox.pro | 5 +---- .../desktopsettingsaware.pro | 15 +++------------ .../widgets/styles/qstyleoption/qstyleoption.pro | 11 +++-------- .../styles/qstylesheetstyle/qstylesheetstyle.pro | 6 +++--- .../auto/widgets/util/qcompleter/qcompleter.pro | 3 --- .../xml/sax/qxmlsimplereader/parser/parser.pro | 15 ++------------- .../sax/qxmlsimplereader/qxmlsimplereader.pro | 1 - tests/benchmarks/corelib/io/qdir/10000/10000.pro | 3 --- tests/benchmarks/corelib/io/qdir/tree/tree.pro | 3 --- .../corelib/io/qfileinfo/qfileinfo.pro | 4 ---- .../corelib/io/qiodevice/qiodevice.pro | 3 --- .../corelib/io/qtemporaryfile/qtemporaryfile.pro | 3 --- .../benchmarks/corelib/kernel/events/events.pro | 7 +++---- .../kernel/qcoreapplication/qcoreapplication.pro | 3 --- .../corelib/kernel/qobject/qobject.pro | 3 --- .../containers-associative.pro | 6 ++---- .../containers-sequential.pro | 6 ++---- .../corelib/tools/qbytearray/qbytearray.pro | 4 ---- tests/benchmarks/corelib/tools/qrect/qrect.pro | 4 ---- .../benchmarks/corelib/tools/qregexp/qregexp.pro | 6 +----- .../qgraphicswidget/qgraphicswidget.pro | 3 +-- .../gui/image/blendbench/blendbench.pro | 4 +--- .../gui/image/qpixmapcache/qpixmapcache.pro | 2 +- .../gui/kernel/qapplication/qapplication.pro | 3 --- .../benchmarks/gui/painting/qregion/qregion.pro | 3 --- .../styles/qstylesheetstyle/qstylesheetstyle.pro | 4 ---- .../qfile_vs_qnetworkaccessmanager.pro | 3 --- .../qnetworkdiskcache/qnetworkdiskcache.pro | 5 ----- .../access/qnetworkreply/qnetworkreply.pro | 3 --- .../network/kernel/qhostinfo/qhostinfo.pro | 3 --- .../network/socket/qtcpserver/qtcpserver.pro | 3 --- .../network/ssl/qsslsocket/qsslsocket.pro | 3 --- tests/benchmarks/opengl/opengl.pro | 3 --- .../plugins/imageformats/jpeg/jpeg.pro | 3 --- .../gestures/graphicsview/graphicsview.pro | 9 --------- tests/manual/lance/lance.pro | 1 - tests/manual/qgraphicslayout/flicker/flicker.pro | 6 ------ .../qhttpnetworkconnection.pro | 3 --- tests/manual/qimagereader/qimagereader.pro | 7 ------- tests/manual/qlocale/qlocale.pro | 6 ------ tests/manual/qnetworkaccessmanager/qget/qget.pro | 1 - .../qnetworkconfigurationmanager.pro | 3 --- tests/manual/qnetworkreply/qnetworkreply.pro | 3 --- .../device_information/qtabletevent.pro | 16 ++++------------ .../event_compression/event_compression.pro | 2 -- tests/manual/qwidget_zorder/qwidget_zorder.pro | 5 ----- tests/manual/repaint/mainwindow/mainwindow.pro | 13 ------------- tests/manual/repaint/scrollarea/scrollarea.pro | 13 ------------- tests/manual/repaint/splitter/splitter.pro | 13 ------------- tests/manual/repaint/tableview/tableview.pro | 6 ------ tests/manual/repaint/task141091/task141091.pro | 11 +---------- tests/manual/repaint/toplevel/toplevel.pro | 12 ------------ tests/manual/repaint/widget/widget.pro | 13 ------------- tests/manual/socketengine/socketengine.pro | 3 --- .../qurl-generateTLDs/qurl-generateTLDs.pro | 6 ------ util/unicode/codecs/big5/big5.pro | 2 -- 101 files changed, 60 insertions(+), 604 deletions(-) diff --git a/examples/dbus/complexpingpong/complexping.pro b/examples/dbus/complexpingpong/complexping.pro index bc45e99c7b..303f6eb2d7 100644 --- a/examples/dbus/complexpingpong/complexping.pro +++ b/examples/dbus/complexpingpong/complexping.pro @@ -1,14 +1,9 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . QT -= gui CONFIG += qdbus -# Input HEADERS += complexping.h ping-common.h SOURCES += complexping.cpp -# install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/complexpingpong sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/complexpingpong diff --git a/examples/dbus/complexpingpong/complexpong.pro b/examples/dbus/complexpingpong/complexpong.pro index 0934740185..fcb833e596 100644 --- a/examples/dbus/complexpingpong/complexpong.pro +++ b/examples/dbus/complexpingpong/complexpong.pro @@ -1,14 +1,9 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . QT -= gui CONFIG += qdbus -# Input HEADERS += complexpong.h SOURCES += complexpong.cpp -# install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/complexpingpong sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/complexpingpong diff --git a/examples/dbus/dbus-chat/dbus-chat.pro b/examples/dbus/dbus-chat/dbus-chat.pro index e1a3539cf3..29b1f56826 100644 --- a/examples/dbus/dbus-chat/dbus-chat.pro +++ b/examples/dbus/dbus-chat/dbus-chat.pro @@ -1,9 +1,6 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . CONFIG += qdbus +QT += widgets -# Input HEADERS += chat.h chat_adaptor.h chat_interface.h SOURCES += chat.cpp chat_adaptor.cpp chat_interface.cpp FORMS += chatmainwindow.ui chatsetnickname.ui @@ -17,5 +14,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.xml sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/chat INSTALLS += target sources -QT += widgets simulator: warning(This example does not work on Simulator platform) diff --git a/examples/dbus/listnames/listnames.pro b/examples/dbus/listnames/listnames.pro index a863bbc83d..27805e5f6b 100644 --- a/examples/dbus/listnames/listnames.pro +++ b/examples/dbus/listnames/listnames.pro @@ -1,14 +1,9 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . QT -= gui CONFIG += qdbus win32:CONFIG += console -# Input SOURCES += listnames.cpp -# install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/listnames sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/listnames diff --git a/examples/dbus/pingpong/ping.pro b/examples/dbus/pingpong/ping.pro index 533371c2ce..2ba1ad2c9c 100644 --- a/examples/dbus/pingpong/ping.pro +++ b/examples/dbus/pingpong/ping.pro @@ -1,15 +1,9 @@ -TEMPLATE = app -TARGET = ping -DEPENDPATH += . -INCLUDEPATH += . QT -= gui CONFIG += qdbus -# Input HEADERS += ping-common.h SOURCES += ping.cpp -# install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/pingpong sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/pingpong diff --git a/examples/dbus/pingpong/pong.pro b/examples/dbus/pingpong/pong.pro index 37a5a5c404..5c7cb85c43 100644 --- a/examples/dbus/pingpong/pong.pro +++ b/examples/dbus/pingpong/pong.pro @@ -1,15 +1,9 @@ -TEMPLATE = app -TARGET = pong -DEPENDPATH += . -INCLUDEPATH += . QT -= gui CONFIG += qdbus -# Input HEADERS += ping-common.h pong.h SOURCES += pong.cpp -# install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/pingpong sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/pingpong diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro index 761181a782..ea49a7a6d3 100644 --- a/examples/dbus/remotecontrolledcar/car/car.pro +++ b/examples/dbus/remotecontrolledcar/car/car.pro @@ -1,13 +1,6 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Mon Aug 28 19:50:14 2006 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . +QT += widgets CONFIG += qdbus -# Input # DBUS_ADAPTORS += car.xml HEADERS += car.h car_adaptor.h SOURCES += car.cpp main.cpp car_adaptor.cpp @@ -18,5 +11,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.xml sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/remotecontrolledcar/car INSTALLS += target sources -QT += widgets simulator: warning(This example does not work on Simulator platform) diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro index 36983e0c54..07fd169519 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.pro +++ b/examples/dbus/remotecontrolledcar/controller/controller.pro @@ -1,13 +1,6 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue Aug 29 12:28:05 2006 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . +QT += widgets CONFIG += qdbus -# Input # DBUS_INTERFACES += car.xml FORMS += controller.ui HEADERS += car_interface.h controller.h @@ -19,5 +12,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.xml sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/remotecontrolledcar/controller INSTALLS += target sources -QT += widgets simulator: warning(This example does not work on Simulator platform) diff --git a/examples/embedded/styleexample/styleexample.pro b/examples/embedded/styleexample/styleexample.pro index 3cd4d0a3c0..a0fd001cf9 100644 --- a/examples/embedded/styleexample/styleexample.pro +++ b/examples/embedded/styleexample/styleexample.pro @@ -1,6 +1,5 @@ -TEMPLATE = app +QT += widgets -# Input HEADERS += stylewidget.h FORMS += stylewidget.ui SOURCES += main.cpp stylewidget.cpp @@ -10,5 +9,3 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/embedded/styleexample sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.html sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/embedded/styleexample INSTALLS += target sources - -QT += widgets widgets diff --git a/examples/graphicsview/boxes/boxes.pro b/examples/graphicsview/boxes/boxes.pro index 176bc3a1cf..0564ae0ba6 100644 --- a/examples/graphicsview/boxes/boxes.pro +++ b/examples/graphicsview/boxes/boxes.pro @@ -1,13 +1,5 @@ -###################################################################### -# Automatically generated by qmake (2.01a) ma 3. nov 17:33:30 2008 -###################################################################### +QT += opengl widgets -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += 3rdparty/fbm.h \ glbuffers.h \ glextensions.h \ @@ -27,8 +19,6 @@ SOURCES += 3rdparty/fbm.c \ RESOURCES += boxes.qrc -QT += opengl widgets - # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/boxes sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html *.jpg *.png *.fsh *.vsh *.par diff --git a/examples/graphicsview/flowlayout/flowlayout.pro b/examples/graphicsview/flowlayout/flowlayout.pro index 8d1f7b85ff..4a4b22bcf7 100644 --- a/examples/graphicsview/flowlayout/flowlayout.pro +++ b/examples/graphicsview/flowlayout/flowlayout.pro @@ -1,12 +1,8 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . +QT += widgets QMAKE_PROJECT_NAME = flowlayout_graphicsview -# Input HEADERS += flowlayout.h window.h SOURCES += flowlayout.cpp main.cpp window.cpp -QT += widgets simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro b/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro index 4c2fdc60de..b6eb292a12 100644 --- a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro +++ b/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro @@ -1,8 +1,5 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue May 12 15:22:25 2009 -###################################################################### +QT += widgets -# Input SOURCES += main.cpp RESOURCES += weatheranchorlayout.qrc @@ -12,5 +9,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES weatheranchorlayout.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/weatheranchorlayout INSTALLS += target sources -QT += widgets simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/itemviews/spreadsheet/spreadsheet.pro b/examples/itemviews/spreadsheet/spreadsheet.pro index f00dfb4c81..93fc5e95c6 100644 --- a/examples/itemviews/spreadsheet/spreadsheet.pro +++ b/examples/itemviews/spreadsheet/spreadsheet.pro @@ -1,17 +1,6 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Thu Mar 5 14:39:33 2009 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - QT += widgets printsupport -CONFIG += qt warn_on #unix:contains(QT_CONFIG, dbus):QT += dbus widgets -# Input HEADERS += printview.h spreadsheet.h spreadsheetdelegate.h spreadsheetitem.h SOURCES += main.cpp \ printview.cpp \ @@ -20,7 +9,6 @@ SOURCES += main.cpp \ spreadsheetitem.cpp RESOURCES += spreadsheet.qrc - build_all:!build_pass { CONFIG -= build_all CONFIG += release diff --git a/examples/network/download/download.pro b/examples/network/download/download.pro index 7c53044f69..3eabedd375 100644 --- a/examples/network/download/download.pro +++ b/examples/network/download/download.pro @@ -1,14 +1,6 @@ -###################################################################### -# Automatically generated by qmake (2.01a) fr. nov. 16 13:18:20 2007 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . QT = core network CONFIG += console -# Input SOURCES += main.cpp # install @@ -17,5 +9,4 @@ sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/network/download INSTALLS += target sources - simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/network/downloadmanager/downloadmanager.pro b/examples/network/downloadmanager/downloadmanager.pro index 6b7e4f8757..04a6c4c4ea 100644 --- a/examples/network/downloadmanager/downloadmanager.pro +++ b/examples/network/downloadmanager/downloadmanager.pro @@ -1,14 +1,6 @@ -###################################################################### -# Automatically generated by qmake (2.01a) fr. nov. 16 14:11:36 2007 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . QT = core network CONFIG += console -# Input HEADERS += downloadmanager.h textprogressbar.h SOURCES += downloadmanager.cpp main.cpp textprogressbar.cpp @@ -18,7 +10,6 @@ sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/network/downloadmanager INSTALLS += target sources - OTHER_FILES += \ debian/changelog \ debian/compat \ @@ -26,4 +17,5 @@ OTHER_FILES += \ debian/copyright \ debian/README \ debian/rules + simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/opengl/hellogl_es/hellogl_es.pro b/examples/opengl/hellogl_es/hellogl_es.pro index 6932b77831..ca0a4bf4cd 100644 --- a/examples/opengl/hellogl_es/hellogl_es.pro +++ b/examples/opengl/hellogl_es/hellogl_es.pro @@ -1,17 +1,12 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . +QT += gui -# Input SOURCES += main.cpp SOURCES += glwindow.cpp HEADERS += glwindow.h RESOURCES += texture.qrc -QT += gui -# install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellogl_es.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es diff --git a/examples/opengl/hellogl_es2/hellogl_es2.pro b/examples/opengl/hellogl_es2/hellogl_es2.pro index d5bc7ba0a5..5a3d170df8 100644 --- a/examples/opengl/hellogl_es2/hellogl_es2.pro +++ b/examples/opengl/hellogl_es2/hellogl_es2.pro @@ -1,12 +1,5 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Thu Oct 4 19:01:12 2007 -###################################################################### +QT += opengl widgets -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp SOURCES += glwidget.cpp SOURCES += mainwindow.cpp @@ -17,7 +10,6 @@ HEADERS += mainwindow.h HEADERS += bubble.h RESOURCES += texture.qrc -QT += opengl widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es2 @@ -25,7 +17,6 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellogl_es2.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es2 INSTALLS += target sources - maemo5 { # Debian package name may not contain numbers or special characters # such as '_', lets change this in Maemo. diff --git a/examples/opengl/hellowindow/hellowindow.pro b/examples/opengl/hellowindow/hellowindow.pro index dc724421f5..b5ede1b83f 100644 --- a/examples/opengl/hellowindow/hellowindow.pro +++ b/examples/opengl/hellowindow/hellowindow.pro @@ -1,12 +1,5 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 27 16:40:46 2011 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . QT += gui-private core-private -# Input + HEADERS += hellowindow.h SOURCES += hellowindow.cpp main.cpp diff --git a/examples/opengl/paintedwindow/paintedwindow.pro b/examples/opengl/paintedwindow/paintedwindow.pro index a3ae3bace5..098329ac4d 100644 --- a/examples/opengl/paintedwindow/paintedwindow.pro +++ b/examples/opengl/paintedwindow/paintedwindow.pro @@ -1,12 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 27 16:40:46 2011 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += paintedwindow.h SOURCES += paintedwindow.cpp main.cpp @@ -15,4 +6,3 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/paintedwindow sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS paintedwindow.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/paintedwindow INSTALLS += target sources - diff --git a/examples/opengl/pbuffers2/pbuffers2.pro b/examples/opengl/pbuffers2/pbuffers2.pro index bc3b7bb692..ba3a039da2 100644 --- a/examples/opengl/pbuffers2/pbuffers2.pro +++ b/examples/opengl/pbuffers2/pbuffers2.pro @@ -1,14 +1,5 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Fri May 12 17:15:46 2006 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . - QT += opengl svg widgets -# Input HEADERS += glwidget.h SOURCES += glwidget.cpp main.cpp RESOURCES += pbuffers2.qrc @@ -19,5 +10,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES pbuffers2.pro *.png *.svg sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/pbuffers2 INSTALLS += target sources - simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/qpa/windows/windows.pro b/examples/qpa/windows/windows.pro index ab59f28a3e..40280b718a 100644 --- a/examples/qpa/windows/windows.pro +++ b/examples/qpa/windows/windows.pro @@ -1,15 +1,5 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 27 16:40:46 2011 -###################################################################### +CONFIG += console +QT += gui-private core-private -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . -CONFIG+=console -QT += gui-private -QT += core-private - -# Input HEADERS += window.h SOURCES += window.cpp main.cpp diff --git a/examples/qtconcurrent/imagescaling/imagescaling.pro b/examples/qtconcurrent/imagescaling/imagescaling.pro index b268aa75f2..b959915a55 100644 --- a/examples/qtconcurrent/imagescaling/imagescaling.pro +++ b/examples/qtconcurrent/imagescaling/imagescaling.pro @@ -1,20 +1,13 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . -QT += concurrent +QT += concurrent widgets -# Input SOURCES += main.cpp imagescaling.cpp HEADERS += imagescaling.h -# install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/imagescaling sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/imagescaling INSTALLS += target sources - wince*: DEPLOYMENT_PLUGIN += qgif qjpeg -QT += widgets simulator: warning(This example does not work on Simulator platform) diff --git a/examples/qtconcurrent/map/map.pro b/examples/qtconcurrent/map/map.pro index 72f770755f..994c266e9b 100644 --- a/examples/qtconcurrent/map/map.pro +++ b/examples/qtconcurrent/map/map.pro @@ -1,14 +1,10 @@ TEMPLATE = app TARGET = mapdemo -DEPENDPATH += . -INCLUDEPATH += . QT += concurrent widgets - -# Input -SOURCES += main.cpp CONFIG += console -# install +SOURCES += main.cpp + target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/map sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/map diff --git a/examples/qtconcurrent/progressdialog/progressdialog.pro b/examples/qtconcurrent/progressdialog/progressdialog.pro index 75a3aba0ae..3ec3243b6a 100644 --- a/examples/qtconcurrent/progressdialog/progressdialog.pro +++ b/examples/qtconcurrent/progressdialog/progressdialog.pro @@ -1,17 +1,11 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp +QT += concurrent widgets CONFIG += console -# install +SOURCES += main.cpp + target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/progressdialog sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/progressdialog INSTALLS += target sources -QT += concurrent widgets - simulator: warning(This example does not work on Simulator platform) diff --git a/examples/qtconcurrent/runfunction/runfunction.pro b/examples/qtconcurrent/runfunction/runfunction.pro index f047577c9f..1ac02f6fa2 100644 --- a/examples/qtconcurrent/runfunction/runfunction.pro +++ b/examples/qtconcurrent/runfunction/runfunction.pro @@ -1,17 +1,11 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp +QT += concurrent widgets CONFIG += console -# install +SOURCES += main.cpp + target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/runfunction sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/runfunction INSTALLS += target sources -QT += concurrent widgets - simulator: warning(This example does not work on Simulator platform) diff --git a/examples/qtconcurrent/wordcount/wordcount.pro b/examples/qtconcurrent/wordcount/wordcount.pro index 3bddf1a862..8b6bf8104a 100644 --- a/examples/qtconcurrent/wordcount/wordcount.pro +++ b/examples/qtconcurrent/wordcount/wordcount.pro @@ -1,17 +1,11 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp +QT += concurrent widgets CONFIG += console -# install +SOURCES += main.cpp + target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/wordcount sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/wordcount INSTALLS += target sources -QT += concurrent widgets - simulator: warning(This example does not work on Simulator platform) diff --git a/examples/threads/waitconditions/waitconditions.pro b/examples/threads/waitconditions/waitconditions.pro index 6a3d63b641..29ef9b8334 100644 --- a/examples/threads/waitconditions/waitconditions.pro +++ b/examples/threads/waitconditions/waitconditions.pro @@ -1,16 +1,8 @@ -###################################################################### -# Automatically generated by qmake (1.08a) Fri Jan 7 15:25:07 2005 -###################################################################### - -TEMPLATE = app QT = core gui CONFIG -= moc app_bundle -DEPENDPATH += . -INCLUDEPATH += . +CONFIG += console -# Input SOURCES += waitconditions.cpp -CONFIG += qt warn_on create_prl link_prl console # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/threads/waitconditions @@ -18,5 +10,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS waitconditions.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/threads/waitconditions INSTALLS += target sources - simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/widgets/validators/validators.pro b/examples/widgets/validators/validators.pro index f4cab8edac..7970f961cd 100644 --- a/examples/widgets/validators/validators.pro +++ b/examples/widgets/validators/validators.pro @@ -1,16 +1,8 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue Nov 28 13:20:04 2006 -###################################################################### - -TEMPLATE = app -TARGET = validators -DEPENDPATH += . -INCLUDEPATH += . +QT += widgets FORMS += validators.ui RESOURCES += validators.qrc -# Input SOURCES += main.cpp ledwidget.cpp localeselector.cpp HEADERS += ledwidget.h localeselector.h @@ -20,6 +12,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/validators INSTALLS += target sources -QT += widgets - simulator: warning(This example might not fully work on Simulator platform) diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 26769f95db..2f5b3229e4 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -13,7 +13,6 @@ unix:!embedded:QMAKE_PKGCONFIG_DESCRIPTION = Qt \ Testing \ Library -# Input HEADERS = qbenchmark.h \ qsignalspy.h \ qtestaccessible.h \ diff --git a/src/tools/moc/util/generate_keywords.pro b/src/tools/moc/util/generate_keywords.pro index eb04409922..88e5553f54 100644 --- a/src/tools/moc/util/generate_keywords.pro +++ b/src/tools/moc/util/generate_keywords.pro @@ -1,12 +1,4 @@ -###################################################################### -# Automatically generated by qmake (1.08a) Mon Feb 23 13:08:28 2004 -###################################################################### - -TEMPLATE = app CONFIG -= moc mac:CONFIG -= app_bundle -INCLUDEPATH += . -# Input SOURCES += generate_keywords.cpp -CONFIG += qt create_prl link_prl diff --git a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro index 19d36a63a1..799ef34559 100644 --- a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro +++ b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro @@ -1,6 +1,3 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . CONFIG -= app_bundle debug_and_release CONFIG += console DESTDIR = ./ @@ -8,7 +5,7 @@ QT -= gui wince*: { LIBS += coredll.lib } -# Input + HEADERS += signalbug.h SOURCES += signalbug.cpp diff --git a/tests/auto/gui/kernel/qclipboard/copier/copier.pro b/tests/auto/gui/kernel/qclipboard/copier/copier.pro index 1c188ca7de..def50b6476 100644 --- a/tests/auto/gui/kernel/qclipboard/copier/copier.pro +++ b/tests/auto/gui/kernel/qclipboard/copier/copier.pro @@ -1,9 +1,4 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . CONFIG -= app_bundle win32: DESTDIR = ../copier -# Input -SOURCES += main.cpp +SOURCES += main.cpp diff --git a/tests/auto/gui/kernel/qclipboard/paster/paster.pro b/tests/auto/gui/kernel/qclipboard/paster/paster.pro index 2f50eefb1e..ef91e77b6e 100644 --- a/tests/auto/gui/kernel/qclipboard/paster/paster.pro +++ b/tests/auto/gui/kernel/qclipboard/paster/paster.pro @@ -1,10 +1,4 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . win32: DESTDIR = ../paster CONFIG -= app_bundle -# Input + SOURCES += main.cpp - - diff --git a/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro b/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro index ce2d341e92..36661c7d63 100644 --- a/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro +++ b/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro @@ -1,11 +1,3 @@ -###################################################################### -# Automatically generated by qmake (1.02a) Thu Apr 18 18:56:53 2002 -###################################################################### - -TEMPLATE = app CONFIG -= moc -# Input SOURCES += main.cpp - - diff --git a/tests/auto/gui/text/qtextscriptengine/generate/generate.pro b/tests/auto/gui/text/qtextscriptengine/generate/generate.pro index 354e0e5cdf..101b7451de 100644 --- a/tests/auto/gui/text/qtextscriptengine/generate/generate.pro +++ b/tests/auto/gui/text/qtextscriptengine/generate/generate.pro @@ -1,14 +1,5 @@ -###################################################################### -# Automatically generated by qmake (1.07a) Fri Sep 30 15:20:45 2005 -###################################################################### - -TEMPLATE = app CONFIG -= moc INCLUDEPATH += . /usr/include/freetype2 INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src -# Input SOURCES += main.cpp -CONFIG += qt warn_on debug thread create_prl link_prl - - diff --git a/tests/auto/network/socket/qlocalsocket/example/client/client.pro b/tests/auto/network/socket/qlocalsocket/example/client/client.pro index 84f20d6ec0..4b6585ff10 100644 --- a/tests/auto/network/socket/qlocalsocket/example/client/client.pro +++ b/tests/auto/network/socket/qlocalsocket/example/client/client.pro @@ -1,10 +1,4 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . CONFIG += console QT = core network SOURCES += main.cpp - - diff --git a/tests/auto/network/socket/qlocalsocket/example/server/server.pro b/tests/auto/network/socket/qlocalsocket/example/server/server.pro index bfd14d2bb7..b78e63d0a7 100644 --- a/tests/auto/network/socket/qlocalsocket/example/server/server.pro +++ b/tests/auto/network/socket/qlocalsocket/example/server/server.pro @@ -1,13 +1,5 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - CONFIG += console QT = core network -# Input SOURCES += main.cpp - - diff --git a/tests/auto/other/atwrapper/atWrapper.pro b/tests/auto/other/atwrapper/atWrapper.pro index 5dcbdb98ce..9de320b364 100644 --- a/tests/auto/other/atwrapper/atWrapper.pro +++ b/tests/auto/other/atwrapper/atWrapper.pro @@ -1,9 +1,6 @@ -# -*- Mode: makefile -*- - ARTHUR=$$QT_SOURCE_TREE/tests/arthur COMMON_FOLDER = $$ARTHUR/common include($$ARTHUR/arthurtester.pri) -TEMPLATE = app INCLUDEPATH += $$ARTHUR DEFINES += SRCDIR=\\\"$$PWD\\\" @@ -15,7 +12,6 @@ include($$ARTHUR/datagenerator/datagenerator.pri) CONFIG += testcase -# Input HEADERS += atWrapper.h SOURCES += atWrapperAutotest.cpp atWrapper.cpp diff --git a/tests/auto/other/macgui/macgui.pro b/tests/auto/other/macgui/macgui.pro index 5632450a3a..b7adbb470e 100644 --- a/tests/auto/other/macgui/macgui.pro +++ b/tests/auto/other/macgui/macgui.pro @@ -1,10 +1,6 @@ CONFIG += testcase TARGET = tst_macgui -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . -# Input SOURCES += tst_macgui.cpp guitest.cpp HEADERS += guitest.h diff --git a/tests/auto/other/macnativeevents/macnativeevents.pro b/tests/auto/other/macnativeevents/macnativeevents.pro index efe091f9f0..6ec0942222 100644 --- a/tests/auto/other/macnativeevents/macnativeevents.pro +++ b/tests/auto/other/macnativeevents/macnativeevents.pro @@ -1,7 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Nov 29 22:24:47 2006 -###################################################################### - CONFIG += testcase TARGET = tst_macnativeevents TEMPLATE = app diff --git a/tests/auto/other/macplist/app/app.pro b/tests/auto/other/macplist/app/app.pro index b4b895197c..9ccac831d0 100644 --- a/tests/auto/other/macplist/app/app.pro +++ b/tests/auto/other/macplist/app/app.pro @@ -1,12 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Jan 7 13:01:11 2009 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp QT += widgets + +SOURCES += main.cpp diff --git a/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro b/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro index 644a817a8e..e4f81e6e1e 100644 --- a/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro +++ b/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro @@ -1,9 +1,3 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp QWERTY_BUNDLE.version = Bogus.78 diff --git a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro index 43577b5122..442c9c767f 100644 --- a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro +++ b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro @@ -1,10 +1,5 @@ -TEMPLATE = app -TARGET = findDeps -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input HEADERS += object1.h \ object2.h \ object3.h \ diff --git a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro index 1469b4c5c3..a4a7dc987d 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro +++ b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro @@ -1,9 +1,4 @@ -TEMPLATE = app -TARGET = findMocs -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input HEADERS += object1.h object2.h object3.h object4.h object5.h object6.h object7.h SOURCES += main.cpp diff --git a/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro b/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro index 730932d83d..b4cf05e347 100644 --- a/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro +++ b/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro @@ -1,10 +1,7 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qerrormessage -DEPENDPATH += . -INCLUDEPATH += . QT += widgets testlib -# Input SOURCES += tst_qerrormessage.cpp diff --git a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro index 5b8f796485..91848fee24 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro +++ b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro @@ -1,9 +1,6 @@ -CONFIG += testcase TEMPLATE = app TARGET = tst_qmessagebox QT += gui-private core-private widgets testlib -DEPENDPATH += . -INCLUDEPATH += . +CONFIG += testcase -# Input SOURCES += tst_qmessagebox.cpp diff --git a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro index 3b229e31cb..97768eac74 100644 --- a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro +++ b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro @@ -1,15 +1,6 @@ -###################################################################### -# Automatically generated by qmake (2.00a) Mon Jul 11 11:30:34 2005 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . -DESTDIR = ./ - -# Input QT += widgets -SOURCES += main.cpp -CONFIG += qt warn_on create_prl link_prl CONFIG -= app_bundle +DESTDIR = ./ + +SOURCES += main.cpp diff --git a/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro b/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro index cadc6d6ddc..bf12a6b30f 100644 --- a/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro +++ b/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro @@ -1,12 +1,7 @@ -###################################################################### -# Automatically generated by qmake (2.00a) ti 8. mar 16:20:21 2005 -###################################################################### +TEMPLATE = app +TARGET = tst_qstyleoption CONFIG += testcase -TARGET = tst_qstyleoption -TEMPLATE = app QT += widgets testlib -# Input + SOURCES += tst_qstyleoption.cpp - - diff --git a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro index f908c3ab7d..dd17183b30 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro @@ -1,10 +1,10 @@ CONFIG += testcase TARGET = tst_qstylesheetstyle -QT += widgets widgets-private testlib -QT += gui-private -# Input +QT += widgets widgets-private gui-private testlib + SOURCES += tst_qstylesheetstyle.cpp RESOURCES += resources.qrc + requires(contains(QT_CONFIG,private_tests)) win32:CONFIG += insignificant_test # QTBUG-24323 diff --git a/tests/auto/widgets/util/qcompleter/qcompleter.pro b/tests/auto/widgets/util/qcompleter/qcompleter.pro index 63b137eb7c..6a817a89ac 100644 --- a/tests/auto/widgets/util/qcompleter/qcompleter.pro +++ b/tests/auto/widgets/util/qcompleter/qcompleter.pro @@ -2,10 +2,7 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qcompleter QT += widgets testlib -DEPENDPATH += . -INCLUDEPATH += . .. -# Input SOURCES += tst_qcompleter.cpp CONFIG += insignificant_test # QTBUG-21424 diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro index 93167f81c8..f801200942 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro +++ b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro @@ -1,15 +1,4 @@ -###################################################################### -# Automatically generated by qmake (1.06a) Thu Jun 5 19:00:42 2003 -###################################################################### - -TEMPLATE = app -INCLUDEPATH += . - -# Input -HEADERS += parser.h -SOURCES += main.cpp parser.cpp - -CONFIG += qt warn_on debug QT += xml - +HEADERS += parser.h +SOURCES += main.cpp parser.cpp diff --git a/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro b/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro index cec33ded18..dc579ab742 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro +++ b/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro @@ -4,7 +4,6 @@ TEMPLATE = app DEPENDPATH += parser INCLUDEPATH += . parser -# Input HEADERS += parser/parser.h SOURCES += tst_qxmlsimplereader.cpp parser/parser.cpp diff --git a/tests/benchmarks/corelib/io/qdir/10000/10000.pro b/tests/benchmarks/corelib/io/qdir/10000/10000.pro index 0319f2c195..196b3b5b30 100644 --- a/tests/benchmarks/corelib/io/qdir/10000/10000.pro +++ b/tests/benchmarks/corelib/io/qdir/10000/10000.pro @@ -1,9 +1,6 @@ TEMPLATE = app TARGET = bench_qdir_10000 -DEPENDPATH += . -INCLUDEPATH += . -# Input SOURCES += bench_qdir_10000.cpp QT = core testlib diff --git a/tests/benchmarks/corelib/io/qdir/tree/tree.pro b/tests/benchmarks/corelib/io/qdir/tree/tree.pro index 415580cc46..2998a13b57 100644 --- a/tests/benchmarks/corelib/io/qdir/tree/tree.pro +++ b/tests/benchmarks/corelib/io/qdir/tree/tree.pro @@ -1,9 +1,6 @@ TEMPLATE = app TARGET = bench_qdir_tree -DEPENDPATH += . -INCLUDEPATH += . -# Input SOURCES += bench_qdir_tree.cpp RESOURCES += bench_qdir_tree.qrc diff --git a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro index 0dca21c1a8..42e8708b02 100644 --- a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro @@ -1,13 +1,9 @@ TEMPLATE = app TARGET = tst_bench_qfileinfo -DEPENDPATH += . -INCLUDEPATH += . QT -= gui - QT += core-private testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro b/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro index 0dff0ce86e..20b02d190a 100644 --- a/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro +++ b/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro @@ -1,12 +1,9 @@ TEMPLATE = app TARGET = tst_bench_qiodevice TARGET.EPOCHEAPSIZE = 0x100000 0x2000000 -DEPENDPATH += . -INCLUDEPATH += . QT = core testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro b/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro index 6ebee8a659..758930c139 100644 --- a/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro +++ b/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro @@ -1,11 +1,8 @@ TEMPLATE = app TARGET = tst_bench_qtemporaryfile -DEPENDPATH += . -INCLUDEPATH += . QT = core testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/kernel/events/events.pro b/tests/benchmarks/corelib/kernel/events/events.pro index fb50116495..798a880e5b 100644 --- a/tests/benchmarks/corelib/kernel/events/events.pro +++ b/tests/benchmarks/corelib/kernel/events/events.pro @@ -1,7 +1,6 @@ TEMPLATE = app TARGET = tst_bench_events -DEPENDPATH += . -INCLUDEPATH += . -# Input -SOURCES += main.cpp + QT = core testlib + +SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/benchmarks/corelib/kernel/qcoreapplication/qcoreapplication.pro index 2c29fafca4..6896b3ff55 100644 --- a/tests/benchmarks/corelib/kernel/qcoreapplication/qcoreapplication.pro +++ b/tests/benchmarks/corelib/kernel/qcoreapplication/qcoreapplication.pro @@ -2,8 +2,5 @@ QT += testlib TEMPLATE = app TARGET = tst_bench_qcoreapplication -DEPENDPATH += . -INCLUDEPATH += . -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/kernel/qobject/qobject.pro b/tests/benchmarks/corelib/kernel/qobject/qobject.pro index 8edd038b0d..e611eff0a2 100644 --- a/tests/benchmarks/corelib/kernel/qobject/qobject.pro +++ b/tests/benchmarks/corelib/kernel/qobject/qobject.pro @@ -2,9 +2,6 @@ QT += widgets testlib TEMPLATE = app TARGET = tst_bench_qobject -DEPENDPATH += . -INCLUDEPATH += . -# Input HEADERS += object.h SOURCES += main.cpp object.cpp diff --git a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro index 940973d8db..49edcbee70 100644 --- a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro +++ b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro @@ -1,8 +1,6 @@ TEMPLATE = app TARGET = tst_bench_containers-associative -DEPENDPATH += . -INCLUDEPATH += . -# Input -SOURCES += main.cpp QT = core testlib + +SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro index 0ae83d70f7..6f731cb6d8 100644 --- a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro +++ b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro @@ -1,8 +1,6 @@ TEMPLATE = app TARGET = tst_bench_containers-sequential -DEPENDPATH += . -INCLUDEPATH += . -# Input -SOURCES += main.cpp QT = core testlib + +SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro b/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro index 10fdc7261e..23d8dae18f 100644 --- a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro +++ b/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro @@ -1,11 +1,7 @@ TEMPLATE = app TARGET = tst_bench_qbytearray -DEPENDPATH += . -INCLUDEPATH += . QT = core testlib - CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qrect/qrect.pro b/tests/benchmarks/corelib/tools/qrect/qrect.pro index b05483599e..42cfcd8924 100644 --- a/tests/benchmarks/corelib/tools/qrect/qrect.pro +++ b/tests/benchmarks/corelib/tools/qrect/qrect.pro @@ -1,11 +1,7 @@ TEMPLATE = app TARGET = tst_bench_qrect -DEPENDPATH += . -INCLUDEPATH += . QT = core testlib - CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro index b427150041..59e7d19244 100644 --- a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro +++ b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro @@ -1,14 +1,10 @@ TEMPLATE = app TARGET = tst_bench_qregexp -DEPENDPATH += . -INCLUDEPATH += . -RESOURCES+=qregexp.qrc QT = core testlib - CONFIG += release -# Input SOURCES += main.cpp +RESOURCES += qregexp.qrc !isEmpty(QT.webkit.sources):exists($${QT.webkit.sources}/../JavaScriptCore/JavaScriptCore.pri) { include( $${QT.webkit.sources}/../JavaScriptCore/JavaScriptCore.pri ) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro b/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro index 3c880eeb4d..00becec216 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro @@ -2,6 +2,5 @@ QT += widgets testlib TEMPLATE = app TARGET = tst_bench_qgraphicswidget -TEMPLATE = app -# Input + SOURCES += tst_qgraphicswidget.cpp diff --git a/tests/benchmarks/gui/image/blendbench/blendbench.pro b/tests/benchmarks/gui/image/blendbench/blendbench.pro index 74ba0a5920..17c18301bb 100644 --- a/tests/benchmarks/gui/image/blendbench/blendbench.pro +++ b/tests/benchmarks/gui/image/blendbench/blendbench.pro @@ -1,7 +1,5 @@ TEMPLATE = app TARGET = tst_bench_blendbench -DEPENDPATH += . -INCLUDEPATH += . QT += testlib -# Input + SOURCES += main.cpp diff --git a/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro b/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro index 7f5d829b26..074c764e50 100644 --- a/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro +++ b/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro @@ -1,5 +1,5 @@ TARGET = tst_bench_qpixmapcache TEMPLATE = app QT += testlib -# Input + SOURCES += tst_qpixmapcache.cpp diff --git a/tests/benchmarks/gui/kernel/qapplication/qapplication.pro b/tests/benchmarks/gui/kernel/qapplication/qapplication.pro index 19ca697102..86a016d42e 100644 --- a/tests/benchmarks/gui/kernel/qapplication/qapplication.pro +++ b/tests/benchmarks/gui/kernel/qapplication/qapplication.pro @@ -2,10 +2,7 @@ QT += widgets testlib TEMPLATE = app TARGET = tst_bench_qapplication -DEPENDPATH += . -INCLUDEPATH += . CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/gui/painting/qregion/qregion.pro b/tests/benchmarks/gui/painting/qregion/qregion.pro index 99bbd39043..1ff55080c5 100644 --- a/tests/benchmarks/gui/painting/qregion/qregion.pro +++ b/tests/benchmarks/gui/painting/qregion/qregion.pro @@ -1,9 +1,6 @@ TEMPLATE = app TARGET = tst_bench_qregion -DEPENDPATH += . -INCLUDEPATH += . QT += testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro b/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro index 82558e7ec9..5aef3520c0 100644 --- a/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro @@ -1,11 +1,7 @@ TEMPLATE = app QT += widgets testlib TARGET = tst_bench_qstylesheetstyle -DEPENDPATH += . -INCLUDEPATH += . - CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro index bee2adafa1..eccabd5d89 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro @@ -1,12 +1,9 @@ TEMPLATE = app TARGET = tst_bench_qfile_vs_qnetworkaccessmanager -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/network/access/qnetworkdiskcache/qnetworkdiskcache.pro b/tests/benchmarks/network/access/qnetworkdiskcache/qnetworkdiskcache.pro index fe2204bb16..9de05b5e65 100644 --- a/tests/benchmarks/network/access/qnetworkdiskcache/qnetworkdiskcache.pro +++ b/tests/benchmarks/network/access/qnetworkdiskcache/qnetworkdiskcache.pro @@ -1,14 +1,9 @@ TEMPLATE = app TARGET = tst_bench_qnetworkdiskcache -DEPENDPATH += . -INCLUDEPATH += . QT += gui # for QDesktopServices QT += network testlib CONFIG += release -# Input SOURCES += tst_qnetworkdiskcache.cpp - - diff --git a/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro index 36eeb23fd0..1618728295 100644 --- a/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro +++ b/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro @@ -1,12 +1,9 @@ TEMPLATE = app TARGET = tst_bench_qnetworkreply -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += tst_qnetworkreply.cpp diff --git a/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro b/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro index e26406fe74..41dae0051b 100644 --- a/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro +++ b/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro @@ -1,12 +1,9 @@ TEMPLATE = app TARGET = tst_bench_qhostinfo -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += core-private network network-private testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro b/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro index 1ea2f96d78..ebf1891433 100644 --- a/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro +++ b/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro @@ -1,12 +1,9 @@ TEMPLATE = app TARGET = tst_bench_qtcpserver -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += tst_qtcpserver.cpp diff --git a/tests/benchmarks/network/ssl/qsslsocket/qsslsocket.pro b/tests/benchmarks/network/ssl/qsslsocket/qsslsocket.pro index d71fd86316..a67c0d66df 100644 --- a/tests/benchmarks/network/ssl/qsslsocket/qsslsocket.pro +++ b/tests/benchmarks/network/ssl/qsslsocket/qsslsocket.pro @@ -1,12 +1,9 @@ TEMPLATE = app TARGET = tst_bench_qsslsocket -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += tst_qsslsocket.cpp diff --git a/tests/benchmarks/opengl/opengl.pro b/tests/benchmarks/opengl/opengl.pro index 2866dbc650..1a81571a3f 100644 --- a/tests/benchmarks/opengl/opengl.pro +++ b/tests/benchmarks/opengl/opengl.pro @@ -1,11 +1,8 @@ TEMPLATE = app TARGET = tst_bench_opengl -DEPENDPATH += . -INCLUDEPATH += . QT += core-private gui-private opengl opengl-private testlib -# Input SOURCES += main.cpp include(../trusted-benchmarks.pri) diff --git a/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro index 1db78e332d..d278e9e721 100644 --- a/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro +++ b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro @@ -1,7 +1,5 @@ TEMPLATE = app TARGET = jpeg -DEPENDPATH += . -INCLUDEPATH += . QT += testlib CONFIG += release @@ -11,5 +9,4 @@ wince*: { DEFINES += SRCDIR=\\\"$$PWD/\\\" } -# Input SOURCES += jpeg.cpp diff --git a/tests/manual/gestures/graphicsview/graphicsview.pro b/tests/manual/gestures/graphicsview/graphicsview.pro index a40c323eb3..c5f6fe0764 100644 --- a/tests/manual/gestures/graphicsview/graphicsview.pro +++ b/tests/manual/gestures/graphicsview/graphicsview.pro @@ -1,12 +1,3 @@ -# ##################################################################### -# Automatically generated by qmake (2.01a) Mon Sep 7 13:26:43 2009 -# ##################################################################### -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp \ imageitem.cpp \ gestures.cpp \ diff --git a/tests/manual/lance/lance.pro b/tests/manual/lance/lance.pro index 7eee7ec2de..e24d3f2fa3 100644 --- a/tests/manual/lance/lance.pro +++ b/tests/manual/lance/lance.pro @@ -4,7 +4,6 @@ TEMPLATE = app INCLUDEPATH += . $$LANCELOT_DIR QT += core-private gui-private -# Input HEADERS += widgets.h \ interactivewidget.h \ $$LANCELOT_DIR/paintcommands.h diff --git a/tests/manual/qgraphicslayout/flicker/flicker.pro b/tests/manual/qgraphicslayout/flicker/flicker.pro index 323a30f7bf..2e09826022 100644 --- a/tests/manual/qgraphicslayout/flicker/flicker.pro +++ b/tests/manual/qgraphicslayout/flicker/flicker.pro @@ -1,8 +1,2 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += window.h SOURCES += main.cpp window.cpp diff --git a/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro index d73124c8f9..fd21007793 100644 --- a/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -1,13 +1,10 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qhttpnetworkconnection -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/manual/qimagereader/qimagereader.pro b/tests/manual/qimagereader/qimagereader.pro index b8293b9552..28dcadcbfa 100644 --- a/tests/manual/qimagereader/qimagereader.pro +++ b/tests/manual/qimagereader/qimagereader.pro @@ -1,8 +1 @@ - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp diff --git a/tests/manual/qlocale/qlocale.pro b/tests/manual/qlocale/qlocale.pro index e9f17f4f9f..4eaddedcf0 100644 --- a/tests/manual/qlocale/qlocale.pro +++ b/tests/manual/qlocale/qlocale.pro @@ -1,8 +1,2 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += currency.h calendar.h dateformats.h numberformats.h languages.h window.h miscellaneous.h info.h SOURCES += currency.cpp main.cpp calendar.cpp dateformats.cpp numberformats.cpp languages.cpp window.cpp miscellaneous.cpp info.cpp diff --git a/tests/manual/qnetworkaccessmanager/qget/qget.pro b/tests/manual/qnetworkaccessmanager/qget/qget.pro index 341f772b51..1f2b497171 100644 --- a/tests/manual/qnetworkaccessmanager/qget/qget.pro +++ b/tests/manual/qnetworkaccessmanager/qget/qget.pro @@ -2,6 +2,5 @@ TEMPLATE = app QT = core network CONFIG += console -# Input SOURCES += qget.cpp HEADERS += qget.h diff --git a/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro b/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro index 613fcd85e4..7ad271ce46 100644 --- a/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro +++ b/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro @@ -1,13 +1,10 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qnetworkconfigurationmanager -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/manual/qnetworkreply/qnetworkreply.pro b/tests/manual/qnetworkreply/qnetworkreply.pro index 479a1e63bc..17f48c6544 100644 --- a/tests/manual/qnetworkreply/qnetworkreply.pro +++ b/tests/manual/qnetworkreply/qnetworkreply.pro @@ -1,13 +1,10 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qnetworkreply -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/tests/manual/qtabletevent/device_information/qtabletevent.pro b/tests/manual/qtabletevent/device_information/qtabletevent.pro index e0ed549004..8251d73094 100644 --- a/tests/manual/qtabletevent/device_information/qtabletevent.pro +++ b/tests/manual/qtabletevent/device_information/qtabletevent.pro @@ -1,13 +1,5 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Mon Aug 10 17:02:09 2009 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp\ +SOURCES += \ + main.cpp \ tabletwidget.cpp -HEADERS += tabletwidget.h +HEADERS += \ + tabletwidget.h diff --git a/tests/manual/qtabletevent/event_compression/event_compression.pro b/tests/manual/qtabletevent/event_compression/event_compression.pro index 273fd6c1b0..fd2521e44f 100644 --- a/tests/manual/qtabletevent/event_compression/event_compression.pro +++ b/tests/manual/qtabletevent/event_compression/event_compression.pro @@ -1,7 +1,5 @@ -TEMPLATE = app QT += testlib -# Input SOURCES += main.cpp \ mousestatwidget.cpp HEADERS += mousestatwidget.h diff --git a/tests/manual/qwidget_zorder/qwidget_zorder.pro b/tests/manual/qwidget_zorder/qwidget_zorder.pro index 5526f9161f..28dcadcbfa 100644 --- a/tests/manual/qwidget_zorder/qwidget_zorder.pro +++ b/tests/manual/qwidget_zorder/qwidget_zorder.pro @@ -1,6 +1 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp diff --git a/tests/manual/repaint/mainwindow/mainwindow.pro b/tests/manual/repaint/mainwindow/mainwindow.pro index c269d57eff..db6b2d280c 100644 --- a/tests/manual/repaint/mainwindow/mainwindow.pro +++ b/tests/manual/repaint/mainwindow/mainwindow.pro @@ -1,15 +1,2 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Nov 8 15:46:28 2006 -###################################################################### - -TEMPLATE = app -TARGET = mainwindow -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/scrollarea/scrollarea.pro b/tests/manual/repaint/scrollarea/scrollarea.pro index e1a40ad6ad..db6b2d280c 100644 --- a/tests/manual/repaint/scrollarea/scrollarea.pro +++ b/tests/manual/repaint/scrollarea/scrollarea.pro @@ -1,15 +1,2 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Nov 8 15:28:57 2006 -###################################################################### - -TEMPLATE = app -TARGET = scrollarea -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/splitter/splitter.pro b/tests/manual/repaint/splitter/splitter.pro index 0afc0630ba..db6b2d280c 100644 --- a/tests/manual/repaint/splitter/splitter.pro +++ b/tests/manual/repaint/splitter/splitter.pro @@ -1,15 +1,2 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Nov 8 15:39:53 2006 -###################################################################### - -TEMPLATE = app -TARGET = splitter -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/tableview/tableview.pro b/tests/manual/repaint/tableview/tableview.pro index 4fccf4abc9..4097c95739 100644 --- a/tests/manual/repaint/tableview/tableview.pro +++ b/tests/manual/repaint/tableview/tableview.pro @@ -1,8 +1,2 @@ HEADERS +=../shared/shared.h -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp diff --git a/tests/manual/repaint/task141091/task141091.pro b/tests/manual/repaint/task141091/task141091.pro index db89bd35b8..82ead4b6c2 100644 --- a/tests/manual/repaint/task141091/task141091.pro +++ b/tests/manual/repaint/task141091/task141091.pro @@ -1,12 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue Mar 6 13:44:00 2007 -###################################################################### +CONFIG += console -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . -CONFIG+=console - -# Input SOURCES += main.cpp diff --git a/tests/manual/repaint/toplevel/toplevel.pro b/tests/manual/repaint/toplevel/toplevel.pro index 568ea8e062..c2cc19f67d 100644 --- a/tests/manual/repaint/toplevel/toplevel.pro +++ b/tests/manual/repaint/toplevel/toplevel.pro @@ -1,16 +1,4 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue Nov 7 10:15:42 2006 -###################################################################### - -TEMPLATE = app -TARGET = toplevel -DEPENDPATH += . -INCLUDEPATH += . CONFIG += console -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/widget/widget.pro b/tests/manual/repaint/widget/widget.pro index c9d8f872e8..db6b2d280c 100644 --- a/tests/manual/repaint/widget/widget.pro +++ b/tests/manual/repaint/widget/widget.pro @@ -1,15 +1,2 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue Nov 7 11:16:05 2006 -###################################################################### - -TEMPLATE = app -TARGET = widget -DEPENDPATH += . -INCLUDEPATH += . - -# Input HEADERS += ../shared/shared.h SOURCES += main.cpp -CONFIG += qt warn_on debug create_prl link_prl -OBJECTS_DIR = .obj/debug-shared -MOC_DIR = .moc/debug-shared diff --git a/tests/manual/socketengine/socketengine.pro b/tests/manual/socketengine/socketengine.pro index 24523e9ca4..808502c22a 100644 --- a/tests/manual/socketengine/socketengine.pro +++ b/tests/manual/socketengine/socketengine.pro @@ -1,13 +1,10 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_socketengine -DEPENDPATH += . -INCLUDEPATH += . QT -= gui QT += network testlib CONFIG += release -# Input SOURCES += main.cpp diff --git a/util/corelib/qurl-generateTLDs/qurl-generateTLDs.pro b/util/corelib/qurl-generateTLDs/qurl-generateTLDs.pro index 9d5f1cf7f9..99723b7c0f 100644 --- a/util/corelib/qurl-generateTLDs/qurl-generateTLDs.pro +++ b/util/corelib/qurl-generateTLDs/qurl-generateTLDs.pro @@ -1,9 +1,3 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - QT = core -# Input SOURCES += main.cpp diff --git a/util/unicode/codecs/big5/big5.pro b/util/unicode/codecs/big5/big5.pro index 84cf33033c..a42176bb6b 100644 --- a/util/unicode/codecs/big5/big5.pro +++ b/util/unicode/codecs/big5/big5.pro @@ -1,6 +1,4 @@ -TEMPLATE = app CONFIG -= moc -# Input SOURCES += main.cpp RESOURCES += big5.qrc From 4ee14d6f87688492e64db77fd89b48c7fcc98a63 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 23 Feb 2012 10:41:50 +0100 Subject: [PATCH 059/166] CodeCoverage: Skip headersclean test. The code coverage tool adds #line when instrumenting the code using the gcc syntax. Since tst_headersclean now uses the -pedantic-errors flag (qtbase commit 7e970eb58c71dc089815), it causes a fatal error when the code is instrumented with the coverage tool. Change-Id: Icb1888d1c1f0a982c0c56aa168e70a76a246a18c Reviewed-by: Rohan McGovern --- tests/auto/other/other.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 69fe00dc19..9ec5ea8e34 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -26,6 +26,8 @@ SUBDIRS=\ qtokenautomaton \ windowsmobile \ +testcocoon: SUBDIRS -= headersclean + cross_compile: SUBDIRS -= \ atwrapper \ compiler \ From 4df6e058490b4202a5bb5ac0a34b7b2b18493250 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Wed, 22 Feb 2012 11:41:28 -0800 Subject: [PATCH 060/166] Clean up some Q_WS_WIN Q_WS_WIN does not exist any more. Change-Id: Icb7f542cfcd4d21e994f246ff665583cb6b57610 Reviewed-by: Oswald Buddenhagen Reviewed-by: Friedemann Kleint --- doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp | 2 +- src/sql/drivers/sqlite2/qsql_sqlite2.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp b/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp index 9fa9a23234..9de685a7b5 100644 --- a/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp +++ b/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp @@ -76,7 +76,7 @@ extern "C" MY_EXPORT int avg(int a, int b) //! [4] -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #define MY_EXPORT __declspec(dllexport) #else #define MY_EXPORT diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp index b42f82e800..2ffd88e8c5 100644 --- a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp +++ b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp @@ -53,7 +53,7 @@ #include #include -#if !defined Q_WS_WIN32 +#if !defined Q_OS_WIN # include #endif #include @@ -208,7 +208,7 @@ bool QSQLite2ResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int // keep trying while busy, wish I could implement this better. while ((res = sqlite_step(currentMachine, &colNum, &fvals, &cnames)) == SQLITE_BUSY) { // sleep instead requesting result again immidiately. -#if defined Q_WS_WIN32 +#if defined Q_OS_WIN Sleep(1000); #else sleep(1); From bb5c7b75a87ec87218d489313ffc5a2b9cb4e3d5 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 24 Feb 2012 18:30:40 +1000 Subject: [PATCH 061/166] XCB No longer lists ThreadedOpenGL capability Even with the more recent libxcb, it's a bit flaky. Just don't list having this capability until it is more stable. Change-Id: I1c2b39d757803fc23295944bc9a00e39ff4e1bbf Reviewed-by: Gunnar Sletta --- src/plugins/platforms/xcb/qxcbintegration.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index e7cdef4da9..98f69e9e16 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -204,12 +204,7 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const case ThreadedPixmaps: return true; case OpenGL: return true; - case ThreadedOpenGL: -#ifdef XCB_POLL_FOR_QUEUED_EVENT - return true; -#else - return false; -#endif + case ThreadedOpenGL: return false; default: return QPlatformIntegration::hasCapability(cap); } } From 9610458e0c460fc9a478678528fdb406b6d0f8e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 21 Feb 2012 13:24:39 +0100 Subject: [PATCH 062/166] Use "OpenGL" instead of just "GL" in documentation. Change-Id: I81a0beebc0241b9699ce321174e13a93e76e45e8 Reviewed-by: Gunnar Sletta --- src/gui/kernel/qopenglcontext.cpp | 2 +- src/gui/opengl/qopenglbuffer.cpp | 44 ++++++++++----------- src/gui/opengl/qopenglframebufferobject.cpp | 22 +++++------ src/gui/opengl/qopenglfunctions.cpp | 2 +- src/gui/opengl/qopenglpaintdevice.cpp | 6 +-- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index c263a2a84e..f9ebf8820c 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -239,7 +239,7 @@ void QOpenGLContext::setShareContext(QOpenGLContext *shareContext) } /*! - Sets the \a screen the GL context should be valid for. You need to call + Sets the \a screen the OpenGL context should be valid for. You need to call create() before it takes effect. */ void QOpenGLContext::setScreen(QScreen *screen) diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp index e6879a9e60..f47f71c121 100644 --- a/src/gui/opengl/qopenglbuffer.cpp +++ b/src/gui/opengl/qopenglbuffer.cpp @@ -49,16 +49,16 @@ QT_BEGIN_NAMESPACE /*! \class QOpenGLBuffer - \brief The QOpenGLBuffer class provides functions for creating and managing GL buffer objects. + \brief The QOpenGLBuffer class provides functions for creating and managing OpenGL buffer objects. \since 5.0 \ingroup painting-3D - Buffer objects are created in the GL server so that the + Buffer objects are created in the OpenGL server so that the client application can avoid uploading vertices, indices, texture image data, etc every time they are needed. QOpenGLBuffer objects can be copied around as a reference to the - underlying GL buffer object: + underlying OpenGL buffer object: \code QOpenGLBuffer buffer1(QOpenGLBuffer::IndexBuffer); @@ -74,16 +74,16 @@ QT_BEGIN_NAMESPACE /*! \enum QOpenGLBuffer::Type - This enum defines the type of GL buffer object to create with QOpenGLBuffer. + This enum defines the type of OpenGL buffer object to create with QOpenGLBuffer. \value VertexBuffer Vertex buffer object for use when specifying vertex arrays. \value IndexBuffer Index buffer object for use with \c{glDrawElements()}. \value PixelPackBuffer Pixel pack buffer object for reading pixel - data from the GL server (for example, with \c{glReadPixels()}). + data from the OpenGL server (for example, with \c{glReadPixels()}). Not supported under OpenGL/ES. \value PixelUnpackBuffer Pixel unpack buffer object for writing pixel - data to the GL server (for example, with \c{glTexImage2D()}). + data to the OpenGL server (for example, with \c{glTexImage2D()}). Not supported under OpenGL/ES. */ @@ -95,26 +95,26 @@ QT_BEGIN_NAMESPACE for drawing operations. Under OpenGL/ES 1.1 this is identical to StaticDraw. \value StreamRead The data will be set once and used a few times - for reading data back from the GL server. Not supported + for reading data back from the OpenGL server. Not supported under OpenGL/ES. \value StreamCopy The data will be set once and used a few times - for reading data back from the GL server for use in further + for reading data back from the OpenGL server for use in further drawing operations. Not supported under OpenGL/ES. \value StaticDraw The data will be set once and used many times for drawing operations. \value StaticRead The data will be set once and used many times - for reading data back from the GL server. Not supported + for reading data back from the OpenGL server. Not supported under OpenGL/ES. \value StaticCopy The data will be set once and used many times - for reading data back from the GL server for use in further + for reading data back from the OpenGL server for use in further drawing operations. Not supported under OpenGL/ES. \value DynamicDraw The data will be modified repeatedly and used many times for drawing operations. \value DynamicRead The data will be modified repeatedly and used - many times for reading data back from the GL server. + many times for reading data back from the OpenGL server. Not supported under OpenGL/ES. \value DynamicCopy The data will be modified repeatedly and used - many times for reading data back from the GL server for + many times for reading data back from the OpenGL server for use in further drawing operations. Not supported under OpenGL/ES. */ @@ -152,7 +152,7 @@ public: Constructs a new buffer object of type QOpenGLBuffer::VertexBuffer. Note: this constructor just creates the QOpenGLBuffer instance. The actual - buffer object in the GL server is not created until create() is called. + buffer object in the OpenGL server is not created until create() is called. \sa create() */ @@ -165,7 +165,7 @@ QOpenGLBuffer::QOpenGLBuffer() Constructs a new buffer object of \a type. Note: this constructor just creates the QOpenGLBuffer instance. The actual - buffer object in the GL server is not created until create() is called. + buffer object in the OpenGL server is not created until create() is called. \sa create() */ @@ -188,7 +188,7 @@ QOpenGLBuffer::QOpenGLBuffer(const QOpenGLBuffer &other) /*! Destroys this buffer object, including the storage being - used in the GL server. + used in the OpenGL server. */ QOpenGLBuffer::~QOpenGLBuffer() { @@ -256,14 +256,14 @@ namespace { } /*! - Creates the buffer object in the GL server. Returns true if + Creates the buffer object in the OpenGL server. Returns true if the object was created; false otherwise. This function must be called with a current QOpenGLContext. The buffer will be bound to and can only be used in that context (or any other context that is shared with it). - This function will return false if the GL implementation + This function will return false if the OpenGL implementation does not support buffers, or there is no current QOpenGLContext. \sa isCreated(), allocate(), write(), destroy() @@ -303,7 +303,7 @@ bool QOpenGLBuffer::isCreated() const /*! Destroys this buffer object, including the storage being - used in the GL server. All references to the buffer will + used in the OpenGL server. All references to the buffer will become invalid. */ void QOpenGLBuffer::destroy() @@ -398,8 +398,8 @@ void QOpenGLBuffer::allocate(const void *data, int count) /*! Binds the buffer associated with this object to the current - GL context. Returns false if binding was not possible, usually because - type() is not supported on this GL implementation. + OpenGL context. Returns false if binding was not possible, usually because + type() is not supported on this OpenGL implementation. The buffer must be bound to the same QOpenGLContext current when create() was called, or to another QOpenGLContext that is sharing with it. @@ -431,7 +431,7 @@ bool QOpenGLBuffer::bind() /*! Releases the buffer associated with this object from the - current GL context. + current OpenGL context. This function must be called with the same QOpenGLContext current as when bind() was called on the buffer. @@ -470,7 +470,7 @@ void QOpenGLBuffer::release(QOpenGLBuffer::Type type) } /*! - Returns the GL identifier associated with this buffer; zero if + Returns the OpenGL identifier associated with this buffer; zero if the buffer has not been created. \sa isCreated() diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 0eb264b2d9..a523cd2cf1 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE { \ GLenum err = glGetError(); \ if (err != GL_NO_ERROR) { \ - qDebug("[%s line %d] GL Error: %d", \ + qDebug("[%s line %d] OpenGL Error: %d", \ __FILE__, __LINE__, (int)err); \ } \ } @@ -649,13 +649,13 @@ void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpen The QOpenGLFramebufferObject class encapsulates an OpenGL framebuffer object, defined by the \c{GL_EXT_framebuffer_object} extension. In addition it provides a rendering surface that can be painted on - with a QPainter, rendered to using native GL calls, or both. This - surface can be bound and used as a regular texture in your own GL + with a QPainter, rendered to using native OpenGL calls, or both. This + surface can be bound and used as a regular texture in your own OpenGL drawing code. By default, the QOpenGLFramebufferObject class - generates a 2D GL texture (using the \c{GL_TEXTURE_2D} target), + generates a 2D OpenGL texture (using the \c{GL_TEXTURE_2D} target), which is used as the internal rendering target. - \bold{It is important to have a current GL context when creating a + \bold{It is important to have a current OpenGL context when creating a QOpenGLFramebufferObject, otherwise initialization will fail.} When using a QPainter to paint to a QOpenGLFramebufferObject you should take @@ -708,11 +708,11 @@ void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpen /*! \fn QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, GLenum target) - Constructs an OpenGL framebuffer object and binds a 2D GL texture + Constructs an OpenGL framebuffer object and binds a 2D OpenGL texture to the buffer of the size \a size. The texture is bound to the \c GL_COLOR_ATTACHMENT0 target in the framebuffer object. - The \a target parameter is used to specify the GL texture + The \a target parameter is used to specify the OpenGL texture target. The default target is \c GL_TEXTURE_2D. Keep in mind that \c GL_TEXTURE_2D textures must have a power of 2 width and height (e.g. 256x512), unless you are using OpenGL 2.0 or higher. @@ -723,7 +723,7 @@ void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpen The default internal texture format is \c GL_RGBA8 for desktop OpenGL, and \c GL_RGBA for OpenGL/ES. - It is important that you have a current GL context set when + It is important that you have a current OpenGL context set when creating the QOpenGLFramebufferObject, otherwise the initialization will fail. @@ -739,7 +739,7 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, GLenum tar /*! \overload - Constructs an OpenGL framebuffer object and binds a 2D GL texture + Constructs an OpenGL framebuffer object and binds a 2D OpenGL texture to the buffer of the given \a width and \a height. \sa size(), texture() @@ -931,7 +931,7 @@ bool QOpenGLFramebufferObject::release() Returns the texture id for the texture attached as the default rendering target in this framebuffer object. This texture id can - be bound as a normal texture in your own GL code. + be bound as a normal texture in your own OpenGL code. If a multisample framebuffer object is used then the value returned from this function will be invalid. @@ -1109,7 +1109,7 @@ bool QOpenGLFramebufferObject::hasOpenGLFramebufferObjects() /*! \fn GLuint QOpenGLFramebufferObject::handle() const - Returns the GL framebuffer object handle for this framebuffer + Returns the OpenGL framebuffer object handle for this framebuffer object (returned by the \c{glGenFrameBuffersEXT()} function). This handle can be used to attach new images or buffers to the framebuffer. The user is responsible for cleaning up and diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 13f91e2ad8..c2e177c162 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -421,7 +421,7 @@ bool QOpenGLExtensions::hasOpenGLExtension(QOpenGLExtensions::OpenGLExtension ex } /*! - Initializes GL function resolution for the current context. + Initializes OpenGL function resolution for the current context. After calling this function, the QOpenGLFunctions object can only be used with the current context and other contexts that share with it. diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index 118fe63122..32da27a078 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -63,10 +63,10 @@ QT_BEGIN_NAMESPACE \ingroup painting-3D When painting to a QOpenGLPaintDevice using QPainter, the state of - the current GL context will be altered by the paint engine to reflect - its needs. Applications should not rely upon the GL state being reset + the current OpenGL context will be altered by the paint engine to reflect + its needs. Applications should not rely upon the OpenGL state being reset to its original conditions, particularly the current shader program, - GL viewport, texture units, and drawing modes. + OpenGL viewport, texture units, and drawing modes. */ class QOpenGLPaintDevicePrivate From 7b4e718b849b20b4dc98fa2e14c7f541ee36fc15 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Tue, 14 Feb 2012 13:09:46 +0100 Subject: [PATCH 063/166] Add UDev helper class for evdev plugins Adopt evdevkeyboard plugin to use new UDev helper Change-Id: Ie914c77dde9a28a8cf7f7cd972acd963c13bc698 Reviewed-by: Laszlo Agocs --- src/platformsupport/udev/qudevhelper_p.h | 1 + src/platformsupport/udev/qudevicehelper.cpp | 235 ++++++++++++++++++ src/platformsupport/udev/qudevicehelper_p.h | 98 ++++++++ src/platformsupport/udev/udev.pri | 4 +- .../generic/evdevkeyboard/evdevkeyboard.pro | 2 +- .../evdevkeyboard/qevdevkeyboardmanager.cpp | 192 +++----------- .../evdevkeyboard/qevdevkeyboardmanager.h | 21 +- 7 files changed, 381 insertions(+), 172 deletions(-) create mode 100644 src/platformsupport/udev/qudevicehelper.cpp create mode 100644 src/platformsupport/udev/qudevicehelper_p.h diff --git a/src/platformsupport/udev/qudevhelper_p.h b/src/platformsupport/udev/qudevhelper_p.h index e6046ca085..3895da87b6 100644 --- a/src/platformsupport/udev/qudevhelper_p.h +++ b/src/platformsupport/udev/qudevhelper_p.h @@ -43,6 +43,7 @@ #define QUDEVHELPER_P_H #include +#include QT_BEGIN_NAMESPACE diff --git a/src/platformsupport/udev/qudevicehelper.cpp b/src/platformsupport/udev/qudevicehelper.cpp new file mode 100644 index 0000000000..bf3ce67b43 --- /dev/null +++ b/src/platformsupport/udev/qudevicehelper.cpp @@ -0,0 +1,235 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qudevicehelper_p.h" + +#include +#include +#include +#include +#include + +#include + +//#define QT_QPA_UDEVICE_HELPER_DEBUG + +#ifdef QT_QPA_UDEVICE_HELPER_DEBUG +#include +#endif + +QT_BEGIN_NAMESPACE + +QUDeviceHelper *QUDeviceHelper::createUDeviceHelper(QUDeviceTypes types, QObject *parent) +{ +#ifdef QT_QPA_UDEVICE_HELPER_DEBUG + qWarning() << "Try to create new UDeviceHelper"; +#endif + + QUDeviceHelper *helper = 0; + struct udev *udev; + + udev = udev_new(); + if (udev) { + helper = new QUDeviceHelper(types, udev, parent); + } else { + qWarning("Failed to get udev library context."); + } + + return helper; +} + +QUDeviceHelper::QUDeviceHelper(QUDeviceTypes types, struct udev *udev, QObject *parent) : + QObject(parent), + m_udev(udev), m_types(types), m_udevMonitor(0), m_udevMonitorFileDescriptor(-1), m_udevSocketNotifier(0) +{ +#ifdef QT_QPA_UDEVICE_HELPER_DEBUG + qWarning() << "New UDeviceHelper created for type" << types; +#endif + + if (!m_udev) + return; + + m_udevMonitor = udev_monitor_new_from_netlink(m_udev, "udev"); + if (!m_udevMonitor) { +#ifdef QT_QPA_UDEVICE_HELPER_DEBUG + qWarning("Unable to create an Udev monitor. No devices can be detected."); +#endif + return; + } + + udev_monitor_filter_add_match_subsystem_devtype(m_udevMonitor, "input", 0); + udev_monitor_enable_receiving(m_udevMonitor); + m_udevMonitorFileDescriptor = udev_monitor_get_fd(m_udevMonitor); + + m_udevSocketNotifier = new QSocketNotifier(m_udevMonitorFileDescriptor, QSocketNotifier::Read, this); + connect(m_udevSocketNotifier, SIGNAL(activated(int)), this, SLOT(handleUDevNotification())); +} + +QUDeviceHelper::~QUDeviceHelper() +{ + if (m_udevMonitor) + udev_monitor_unref(m_udevMonitor); + + if (m_udev) + udev_unref(m_udev); +} + +QStringList QUDeviceHelper::scanConnectedDevices() +{ + QStringList devices; + + if (!m_udev) + return devices; + + udev_enumerate *ue = udev_enumerate_new(m_udev); + udev_enumerate_add_match_subsystem(ue, "input"); + + if (m_types & UDev_Mouse) + udev_enumerate_add_match_property(ue, "ID_INPUT_MOUSE", "1"); + if (m_types & UDev_Touchpad) + udev_enumerate_add_match_property(ue, "ID_INPUT_TOUCHPAD", "1"); + if (m_types & UDev_Touchscreen) + udev_enumerate_add_match_property(ue, "ID_INPUT_TOUCHSCREEN", "1"); + if (m_types & UDev_Keyboard) + udev_enumerate_add_match_property(ue, "ID_INPUT_KEYBOARD", "1"); + + if (udev_enumerate_scan_devices(ue) != 0) { +#ifdef QT_QPA_UDEVICE_HELPER_DEBUG + qWarning() << "UDeviceHelper scan connected devices for enumeration failed"; +#endif + return devices; + } + + udev_list_entry *entry; + udev_list_entry_foreach (entry, udev_enumerate_get_list_entry(ue)) { + const char *syspath = udev_list_entry_get_name(entry); + udev_device *udevice = udev_device_new_from_syspath(m_udev, syspath); + QString candidate = QString::fromUtf8(udev_device_get_devnode(udevice)); + if (candidate.startsWith(QLatin1String("/dev/input/event"))) + devices << candidate; + + udev_device_unref(udevice); + } + udev_enumerate_unref(ue); + +#ifdef QT_QPA_UDEVICE_HELPER_DEBUG + qWarning() << "UDeviceHelper found matching devices" << devices; +#endif + + return devices; +} + +void QUDeviceHelper::handleUDevNotification() +{ + if (!m_udevMonitor) + return; + + struct udev_device *dev; + QString devNode; + QUDeviceTypes types = QFlag(UDev_Unknown); + + dev = udev_monitor_receive_device(m_udevMonitor); + if (!dev) + goto cleanup; + + const char *action; + action = udev_device_get_action(dev); + if (!action) + goto cleanup; + + const char *str; + str = udev_device_get_devnode(dev); + if (!str) + goto cleanup; + + devNode = QString::fromUtf8(str); + if (!devNode.startsWith(QLatin1String("/dev/input/event"))) + goto cleanup; + + // does not increase the refcount + dev = udev_device_get_parent_with_subsystem_devtype(dev, "input", 0); + if (!dev) + goto cleanup; + + types = checkDeviceType(dev); + + if (types && (qstrcmp(action, "add") == 0)) + emit deviceDetected(devNode, types); + + if (types && (qstrcmp(action, "remove") == 0)) + emit deviceRemoved(devNode, types); + +cleanup: + udev_device_unref(dev); +} + +QUDeviceHelper::QUDeviceTypes QUDeviceHelper::checkDeviceType(udev_device *dev) +{ + QUDeviceTypes types = QFlag(UDev_Unknown); + + if ((m_types & UDev_Keyboard) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 )) { + const char *capabilities_key = udev_device_get_sysattr_value(dev, "capabilities/key"); + QStringList val = QString::fromUtf8(capabilities_key).split(QString::fromUtf8(" "), QString::SkipEmptyParts); + if (!val.isEmpty()) { + bool ok; + unsigned long long keys = val.last().toULongLong(&ok, 16); + if (ok) { + // Tests if the letter Q is valid for the device. We may want to alter this test, but it seems mostly reliable. + bool test = (keys >> KEY_Q) & 1; + if (test) + types |= UDev_Keyboard; + } + } + } + + if ((m_types & UDev_Mouse) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_MOUSE"), "1") == 0)) + types |= UDev_Mouse; + + if ((m_types & UDev_Touchpad) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD"), "1") == 0)) + types |= UDev_Touchpad; + + if ((m_types & UDev_Touchscreen) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"), "1") == 0)) + types |= UDev_Touchscreen; + + return types; +} + +QT_END_NAMESPACE diff --git a/src/platformsupport/udev/qudevicehelper_p.h b/src/platformsupport/udev/qudevicehelper_p.h new file mode 100644 index 0000000000..b7544fa6c2 --- /dev/null +++ b/src/platformsupport/udev/qudevicehelper_p.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QUDEVICEHELPER_H +#define QUDEVICEHELPER_H + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QUDeviceHelper : public QObject +{ + Q_OBJECT + Q_ENUMS(QUDeviceType) + +public: + enum QUDeviceType { + UDev_Unknown = 0x00, + UDev_Mouse = 0x01, + UDev_Touchpad = 0x02, + UDev_Touchscreen = 0x04, + UDev_Keyboard = 0x08 + }; + Q_DECLARE_FLAGS(QUDeviceTypes, QUDeviceType) + + static QUDeviceHelper *createUDeviceHelper(QUDeviceTypes type, QObject *parent); + ~QUDeviceHelper(); + + QStringList scanConnectedDevices(); + +signals: + void deviceDetected(const QString &deviceNode, QUDeviceTypes types); + void deviceRemoved(const QString &deviceNode, QUDeviceTypes types); + +private slots: + void handleUDevNotification(); + +private: + QUDeviceHelper(QUDeviceTypes types, struct udev *udev, QObject *parent = 0); + + void startWatching(); + void stopWatching(); + + QUDeviceTypes checkDeviceType(struct udev_device *dev); + + struct udev *m_udev; + QUDeviceTypes m_types; + struct udev_monitor *m_udevMonitor; + int m_udevMonitorFileDescriptor; + QSocketNotifier *m_udevSocketNotifier; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QUDeviceHelper::QUDeviceTypes) + +QT_END_NAMESPACE + +#endif // QUDEVICEHELPER_H diff --git a/src/platformsupport/udev/udev.pri b/src/platformsupport/udev/udev.pri index ac3f7df40a..48ad9d36af 100644 --- a/src/platformsupport/udev/udev.pri +++ b/src/platformsupport/udev/udev.pri @@ -1,5 +1,5 @@ contains(QT_CONFIG, libudev) { - HEADERS += $$PWD/qudevhelper_p.h - SOURCES += $$PWD/qudevhelper.cpp + HEADERS += $$PWD/qudevhelper_p.h $$PWD/qudevicehelper_p.h + SOURCES += $$PWD/qudevhelper.cpp $$PWD/qudevicehelper.cpp LIBS += -ludev } diff --git a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro index 47608b7154..82edf170a8 100644 --- a/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro +++ b/src/plugins/generic/evdevkeyboard/evdevkeyboard.pro @@ -10,7 +10,7 @@ HEADERS = \ qevdevkeyboardhandler.h \ qevdevkeyboardmanager.h -QT += core-private +QT += core-private platformsupport-private LIBS += -ludev diff --git a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp index cb23d3a49c..0938fdc2e4 100644 --- a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -42,28 +42,27 @@ #include "qevdevkeyboardmanager.h" #include -#include #include -#include -#include - //#define QT_QPA_KEYMAP_DEBUG +#ifdef QT_QPA_KEYMAP_DEBUG +#include +#endif + QT_BEGIN_NAMESPACE QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &specification) - : m_udev(0), m_udevMonitor(0), m_udevMonitorFileDescriptor(-1), m_udevSocketNotifier(0) { Q_UNUSED(key); - bool useUDev = false; + bool useUDev = true; QStringList args = specification.split(QLatin1Char(':')); QStringList devices; foreach (const QString &arg, args) { - if (arg.startsWith("udev") && !arg.contains("no")) { - useUDev = true; + if (arg.startsWith("udev") && arg.contains("no")) { + useUDev = false; } else if (arg.startsWith("/dev/")) { // if device is specified try to use it devices.append(arg); @@ -71,182 +70,69 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString & } } + // build new specification without /dev/ elements m_spec = args.join(":"); // add all keyboards for devices specified in the argument list foreach (const QString &device, devices) addKeyboard(device); - // no udev and no devices specified, try a fallback - if (!useUDev && devices.isEmpty()) { - addKeyboard(); - return; - } + if (useUDev) { +#ifdef QT_QPA_KEYMAP_DEBUG + qWarning() << "Use UDev for device discovery"; +#endif - m_udev = udev_new(); - if (!m_udev) { - qWarning() << "Failed to read udev configuration. Try to open a keyboard without it"; - addKeyboard(); - } else { - // Look for already attached devices: - parseConnectedDevices(); - // Watch for device add/remove - startWatching(); + m_udeviceHelper = QUDeviceHelper::createUDeviceHelper(QUDeviceHelper::UDev_Keyboard, this); + if (m_udeviceHelper) { + // scan and add already connected keyboards + QStringList devices = m_udeviceHelper->scanConnectedDevices(); + foreach (QString device, devices) { + addKeyboard(device); + } + + connect(m_udeviceHelper, SIGNAL(deviceDetected(QString,QUDeviceTypes)), this, SLOT(addKeyboard(QString))); + connect(m_udeviceHelper, SIGNAL(deviceRemoved(QString,QUDeviceTypes)), this, SLOT(removeKeyboard(QString))); + } } } QEvdevKeyboardManager::~QEvdevKeyboardManager() { - // cleanup udev related resources - stopWatching(); - if (m_udev) - udev_unref(m_udev); - - // cleanup all resources of connected keyboards qDeleteAll(m_keyboards); m_keyboards.clear(); } -void QEvdevKeyboardManager::addKeyboard(const QString &devnode) +void QEvdevKeyboardManager::addKeyboard(const QString &deviceNode) { - QString specification = m_spec; - QString deviceString = devnode; - - if (!deviceString.isEmpty()) { - specification.append(":"); - specification.append(deviceString); - } else { - deviceString = "default"; - } - #ifdef QT_QPA_KEYMAP_DEBUG - qWarning() << "Adding keyboard at" << deviceString; + qWarning() << "Adding keyboard at" << deviceNode; #endif + QString specification = m_spec; + + if (!deviceNode.isEmpty()) { + specification.append(":"); + specification.append(deviceNode); + } + QEvdevKeyboardHandler *keyboard; keyboard = QEvdevKeyboardHandler::createLinuxInputKeyboardHandler("EvdevKeyboard", specification); if (keyboard) - m_keyboards.insert(deviceString, keyboard); + m_keyboards.insert(deviceNode, keyboard); else - qWarning() << "Failed to open keyboard"; + qWarning("Failed to open keyboard"); } -void QEvdevKeyboardManager::removeKeyboard(const QString &devnode) +void QEvdevKeyboardManager::removeKeyboard(const QString &deviceNode) { - if (m_keyboards.contains(devnode)) { + if (m_keyboards.contains(deviceNode)) { #ifdef QT_QPA_KEYMAP_DEBUG - qWarning() << "Removing keyboard at" << devnode; + qWarning() << "Removing keyboard at" << deviceNode; #endif - QEvdevKeyboardHandler *keyboard = m_keyboards.value(devnode); - m_keyboards.remove(devnode); + QEvdevKeyboardHandler *keyboard = m_keyboards.value(deviceNode); + m_keyboards.remove(deviceNode); delete keyboard; } } -void QEvdevKeyboardManager::startWatching() -{ - m_udevMonitor = udev_monitor_new_from_netlink(m_udev, "udev"); - if (!m_udevMonitor) { -#ifdef QT_QPA_KEYMAP_DEBUG - qWarning("Unable to create an Udev monitor. No devices can be detected."); -#endif - return; - } - - udev_monitor_filter_add_match_subsystem_devtype(m_udevMonitor, "input", NULL); - udev_monitor_enable_receiving(m_udevMonitor); - m_udevMonitorFileDescriptor = udev_monitor_get_fd(m_udevMonitor); - - m_udevSocketNotifier = new QSocketNotifier(m_udevMonitorFileDescriptor, QSocketNotifier::Read, this); - connect(m_udevSocketNotifier, SIGNAL(activated(int)), this, SLOT(deviceDetected())); -} - -void QEvdevKeyboardManager::stopWatching() -{ - if (m_udevSocketNotifier) - delete m_udevSocketNotifier; - - if (m_udevMonitor) - udev_monitor_unref(m_udevMonitor); - - m_udevSocketNotifier = 0; - m_udevMonitor = 0; - m_udevMonitorFileDescriptor = 0; -} - -void QEvdevKeyboardManager::deviceDetected() -{ - if (!m_udevMonitor) - return; - - struct udev_device *dev; - dev = udev_monitor_receive_device(m_udevMonitor); - if (!dev) - return; - - if (qstrcmp(udev_device_get_action(dev), "add") == 0) { - checkDevice(dev); - } else { - // We can't determine what the device was, so we handle false positives outside of this class - QString str = udev_device_get_devnode(dev); - if (!str.isEmpty()) - removeKeyboard(str); - } - - udev_device_unref(dev); -} - -void QEvdevKeyboardManager::parseConnectedDevices() -{ - struct udev_enumerate *enumerate; - struct udev_list_entry *devices; - struct udev_list_entry *dev_list_entry; - struct udev_device *dev; - const char *str; - - enumerate = udev_enumerate_new(m_udev); - udev_enumerate_add_match_subsystem(enumerate, "input"); - udev_enumerate_scan_devices(enumerate); - devices = udev_enumerate_get_list_entry(enumerate); - - udev_list_entry_foreach(dev_list_entry, devices) { - str = udev_list_entry_get_name(dev_list_entry); - dev = udev_device_new_from_syspath(m_udev, str); - checkDevice(dev); - } - - udev_enumerate_unref(enumerate); -} - -void QEvdevKeyboardManager::checkDevice(udev_device *dev) -{ - const char *str; - QString devnode; - - str = udev_device_get_devnode(dev); - if (!str) - return; - - devnode = str; - - dev = udev_device_get_parent_with_subsystem_devtype(dev, "input", NULL); - if (!dev) - return; - - str = udev_device_get_sysattr_value(dev, "capabilities/key"); - QStringList val = QString(str).split(' ', QString::SkipEmptyParts); - - bool ok; - unsigned long long keys = val.last().toULongLong(&ok, 16); - if (!ok) - return; - - // Tests if the letter Q is valid for the device. We may want to alter this test, but it seems mostly reliable. - bool test = (keys >> KEY_Q) & 1; - if (test) { - addKeyboard(devnode); - return; - } -} - QT_END_NAMESPACE diff --git a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h index 3caed6ff43..c776af2ec5 100644 --- a/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h +++ b/src/plugins/generic/evdevkeyboard/qevdevkeyboardmanager.h @@ -44,12 +44,12 @@ #include "qevdevkeyboardhandler.h" +#include + #include #include #include -#include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -62,24 +62,13 @@ public: ~QEvdevKeyboardManager(); private slots: - void deviceDetected(); + void addKeyboard(const QString &deviceNode = QString()); + void removeKeyboard(const QString &deviceNode); private: - void startWatching(); - void stopWatching(); - void parseConnectedDevices(); - void checkDevice(struct udev_device *dev); - - void addKeyboard(const QString &devnode = QString()); - void removeKeyboard(const QString &devnode); - QString m_spec; QHash m_keyboards; - - struct udev *m_udev; - struct udev_monitor *m_udevMonitor; - int m_udevMonitorFileDescriptor; - QSocketNotifier *m_udevSocketNotifier; + QUDeviceHelper *m_udeviceHelper; }; QT_END_HEADER From cbf8f03cf4f3b0aa49c9f35c9ae0e3304f142ac7 Mon Sep 17 00:00:00 2001 From: Hib Eris Date: Tue, 7 Feb 2012 15:28:55 +0100 Subject: [PATCH 064/166] Create target pkgconfig dir in qmake generated Windows Makefiles Change-Id: Icea70987ee3c6040ca3ba278a578849cb74156f4 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/winmakefile.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 5f0828383f..a26be16f78 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -844,6 +844,12 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t) QString dst_pc = pkgConfigFileName(false); if (!dst_pc.isEmpty()) { dst_pc = filePrefixRoot(root, targetdir + dst_pc); + const QString dst_pc_dir = fileInfo(dst_pc).path(); + if (!dst_pc_dir.isEmpty()) { + if (!ret.isEmpty()) + ret += "\n\t"; + ret += mkdir_p_asstring(dst_pc_dir, true); + } if(!ret.isEmpty()) ret += "\n\t"; ret += "-$(INSTALL_FILE) \"" + pkgConfigFileName(true) + "\" \"" + dst_pc + "\""; From e5d362f333ca74e4f63d8105b50044841e8fc8cd Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Fri, 24 Feb 2012 23:03:49 +1100 Subject: [PATCH 065/166] Fix Windows -no-freetype build The localizedName and getEnglishName functions were defined in qwindowsfontdatabase_ft.cpp but used in qwindowsfontdatabase.cpp. However if -no-freetype is specified during configure then qwindowsfontdatabase_ft.cpp is not compiled which results in an undefined reference. To resolve this, the functions are moved to qwindowsfontdatabase.cpp which is always compiled whether -no-freetype is specified or not. Change-Id: I085d84cecb29065ba5e6495b52eef7a678947bdc Reviewed-by: Jiang Jiang --- .../windows/qwindowsfontdatabase.cpp | 179 ++++++++++++++++- .../windows/qwindowsfontdatabase_ft.cpp | 181 +----------------- 2 files changed, 180 insertions(+), 180 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 1df985c8a7..fba7794a12 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -329,8 +329,183 @@ static inline QFontDatabase::WritingSystem writingSystemFromScript(const QString return QFontDatabase::Any; } -extern bool localizedName(const QString &name); -extern QString getEnglishName(const QString &familyName); +#ifdef MAKE_TAG +#undef MAKE_TAG +#endif +// GetFontData expects the tags in little endian ;( +#define MAKE_TAG(ch1, ch2, ch3, ch4) (\ + (((quint32)(ch4)) << 24) | \ + (((quint32)(ch3)) << 16) | \ + (((quint32)(ch2)) << 8) | \ + ((quint32)(ch1)) \ + ) + +bool localizedName(const QString &name) +{ + const QChar *c = name.unicode(); + for (int i = 0; i < name.length(); ++i) { + if (c[i].unicode() >= 0x100) + return true; + } + return false; +} + +static inline quint16 getUShort(const unsigned char *p) +{ + quint16 val; + val = *p++ << 8; + val |= *p; + + return val; +} + +static QString getEnglishName(const uchar *table, quint32 bytes) +{ + QString i18n_name; + enum { + NameRecordSize = 12, + FamilyId = 1, + MS_LangIdEnglish = 0x009 + }; + + // get the name table + quint16 count; + quint16 string_offset; + const unsigned char *names; + + int microsoft_id = -1; + int apple_id = -1; + int unicode_id = -1; + + if (getUShort(table) != 0) + goto error; + + count = getUShort(table+2); + string_offset = getUShort(table+4); + names = table + 6; + + if (string_offset >= bytes || 6 + count*NameRecordSize > string_offset) + goto error; + + for (int i = 0; i < count; ++i) { + // search for the correct name entry + + quint16 platform_id = getUShort(names + i*NameRecordSize); + quint16 encoding_id = getUShort(names + 2 + i*NameRecordSize); + quint16 language_id = getUShort(names + 4 + i*NameRecordSize); + quint16 name_id = getUShort(names + 6 + i*NameRecordSize); + + if (name_id != FamilyId) + continue; + + enum { + PlatformId_Unicode = 0, + PlatformId_Apple = 1, + PlatformId_Microsoft = 3 + }; + + quint16 length = getUShort(names + 8 + i*NameRecordSize); + quint16 offset = getUShort(names + 10 + i*NameRecordSize); + if (DWORD(string_offset + offset + length) >= bytes) + continue; + + if ((platform_id == PlatformId_Microsoft + && (encoding_id == 0 || encoding_id == 1)) + && (language_id & 0x3ff) == MS_LangIdEnglish + && microsoft_id == -1) + microsoft_id = i; + // not sure if encoding id 4 for Unicode is utf16 or ucs4... + else if (platform_id == PlatformId_Unicode && encoding_id < 4 && unicode_id == -1) + unicode_id = i; + else if (platform_id == PlatformId_Apple && encoding_id == 0 && language_id == 0) + apple_id = i; + } + { + bool unicode = false; + int id = -1; + if (microsoft_id != -1) { + id = microsoft_id; + unicode = true; + } else if (apple_id != -1) { + id = apple_id; + unicode = false; + } else if (unicode_id != -1) { + id = unicode_id; + unicode = true; + } + if (id != -1) { + quint16 length = getUShort(names + 8 + id*NameRecordSize); + quint16 offset = getUShort(names + 10 + id*NameRecordSize); + if (unicode) { + // utf16 + + length /= 2; + i18n_name.resize(length); + QChar *uc = (QChar *) i18n_name.unicode(); + const unsigned char *string = table + string_offset + offset; + for (int i = 0; i < length; ++i) + uc[i] = getUShort(string + 2*i); + } else { + // Apple Roman + + i18n_name.resize(length); + QChar *uc = (QChar *) i18n_name.unicode(); + const unsigned char *string = table + string_offset + offset; + for (int i = 0; i < length; ++i) + uc[i] = QLatin1Char(string[i]); + } + } + } +error: + //qDebug("got i18n name of '%s' for font '%s'", i18n_name.latin1(), familyName.toLocal8Bit().data()); + return i18n_name; +} + +QString getEnglishName(const QString &familyName) +{ + QString i18n_name; + + HDC hdc = GetDC( 0 ); + LOGFONT lf; + memset(&lf, 0, sizeof(LOGFONT)); + memcpy(lf.lfFaceName, familyName.utf16(), qMin(LF_FACESIZE, familyName.length()) * sizeof(wchar_t)); + lf.lfCharSet = DEFAULT_CHARSET; + HFONT hfont = CreateFontIndirect(&lf); + + if (!hfont) { + ReleaseDC(0, hdc); + return QString(); + } + + HGDIOBJ oldobj = SelectObject( hdc, hfont ); + + const DWORD name_tag = MAKE_TAG( 'n', 'a', 'm', 'e' ); + + // get the name table + unsigned char *table = 0; + + DWORD bytes = GetFontData( hdc, name_tag, 0, 0, 0 ); + if ( bytes == GDI_ERROR ) { + // ### Unused variable + // int err = GetLastError(); + goto error; + } + + table = new unsigned char[bytes]; + GetFontData(hdc, name_tag, 0, table, bytes); + if ( bytes == GDI_ERROR ) + goto error; + + i18n_name = getEnglishName(table, bytes); +error: + delete [] table; + SelectObject( hdc, oldobj ); + DeleteObject( hfont ); + ReleaseDC( 0, hdc ); + + //qDebug("got i18n name of '%s' for font '%s'", i18n_name.latin1(), familyName.toLocal8Bit().data()); + return i18n_name; +} Q_GUI_EXPORT void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias); diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index 031d6ad1a6..e972ae23ee 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -102,184 +102,6 @@ static inline QFont::Weight weightFromInteger(long weight) return QFont::Black; } -#ifdef MAKE_TAG -#undef MAKE_TAG -#endif -// GetFontData expects the tags in little endian ;( -#define MAKE_TAG(ch1, ch2, ch3, ch4) (\ - (((quint32)(ch4)) << 24) | \ - (((quint32)(ch3)) << 16) | \ - (((quint32)(ch2)) << 8) | \ - ((quint32)(ch1)) \ - ) - -bool localizedName(const QString &name) -{ - const QChar *c = name.unicode(); - for (int i = 0; i < name.length(); ++i) { - if (c[i].unicode() >= 0x100) - return true; - } - return false; -} - -static inline quint16 getUShort(const unsigned char *p) -{ - quint16 val; - val = *p++ << 8; - val |= *p; - - return val; -} - -static QString getEnglishName(const uchar *table, quint32 bytes) -{ - QString i18n_name; - enum { - NameRecordSize = 12, - FamilyId = 1, - MS_LangIdEnglish = 0x009 - }; - - // get the name table - quint16 count; - quint16 string_offset; - const unsigned char *names; - - int microsoft_id = -1; - int apple_id = -1; - int unicode_id = -1; - - if (getUShort(table) != 0) - goto error; - - count = getUShort(table+2); - string_offset = getUShort(table+4); - names = table + 6; - - if (string_offset >= bytes || 6 + count*NameRecordSize > string_offset) - goto error; - - for (int i = 0; i < count; ++i) { - // search for the correct name entry - - quint16 platform_id = getUShort(names + i*NameRecordSize); - quint16 encoding_id = getUShort(names + 2 + i*NameRecordSize); - quint16 language_id = getUShort(names + 4 + i*NameRecordSize); - quint16 name_id = getUShort(names + 6 + i*NameRecordSize); - - if (name_id != FamilyId) - continue; - - enum { - PlatformId_Unicode = 0, - PlatformId_Apple = 1, - PlatformId_Microsoft = 3 - }; - - quint16 length = getUShort(names + 8 + i*NameRecordSize); - quint16 offset = getUShort(names + 10 + i*NameRecordSize); - if (DWORD(string_offset + offset + length) >= bytes) - continue; - - if ((platform_id == PlatformId_Microsoft - && (encoding_id == 0 || encoding_id == 1)) - && (language_id & 0x3ff) == MS_LangIdEnglish - && microsoft_id == -1) - microsoft_id = i; - // not sure if encoding id 4 for Unicode is utf16 or ucs4... - else if (platform_id == PlatformId_Unicode && encoding_id < 4 && unicode_id == -1) - unicode_id = i; - else if (platform_id == PlatformId_Apple && encoding_id == 0 && language_id == 0) - apple_id = i; - } - { - bool unicode = false; - int id = -1; - if (microsoft_id != -1) { - id = microsoft_id; - unicode = true; - } else if (apple_id != -1) { - id = apple_id; - unicode = false; - } else if (unicode_id != -1) { - id = unicode_id; - unicode = true; - } - if (id != -1) { - quint16 length = getUShort(names + 8 + id*NameRecordSize); - quint16 offset = getUShort(names + 10 + id*NameRecordSize); - if (unicode) { - // utf16 - - length /= 2; - i18n_name.resize(length); - QChar *uc = (QChar *) i18n_name.unicode(); - const unsigned char *string = table + string_offset + offset; - for (int i = 0; i < length; ++i) - uc[i] = getUShort(string + 2*i); - } else { - // Apple Roman - - i18n_name.resize(length); - QChar *uc = (QChar *) i18n_name.unicode(); - const unsigned char *string = table + string_offset + offset; - for (int i = 0; i < length; ++i) - uc[i] = QLatin1Char(string[i]); - } - } - } -error: - //qDebug("got i18n name of '%s' for font '%s'", i18n_name.latin1(), familyName.toLocal8Bit().data()); - return i18n_name; -} - -QString getEnglishName(const QString &familyName) -{ - QString i18n_name; - - HDC hdc = GetDC( 0 ); - LOGFONT lf; - memset(&lf, 0, sizeof(LOGFONT)); - memcpy(lf.lfFaceName, familyName.utf16(), qMin(LF_FACESIZE, familyName.length()) * sizeof(wchar_t)); - lf.lfCharSet = DEFAULT_CHARSET; - HFONT hfont = CreateFontIndirect(&lf); - - if (!hfont) { - ReleaseDC(0, hdc); - return QString(); - } - - HGDIOBJ oldobj = SelectObject( hdc, hfont ); - - const DWORD name_tag = MAKE_TAG( 'n', 'a', 'm', 'e' ); - - // get the name table - unsigned char *table = 0; - - DWORD bytes = GetFontData( hdc, name_tag, 0, 0, 0 ); - if ( bytes == GDI_ERROR ) { - // ### Unused variable - // int err = GetLastError(); - goto error; - } - - table = new unsigned char[bytes]; - GetFontData(hdc, name_tag, 0, table, bytes); - if ( bytes == GDI_ERROR ) - goto error; - - i18n_name = getEnglishName(table, bytes); -error: - delete [] table; - SelectObject( hdc, oldobj ); - DeleteObject( hfont ); - ReleaseDC( 0, hdc ); - - //qDebug("got i18n name of '%s' for font '%s'", i18n_name.latin1(), familyName.toLocal8Bit().data()); - return i18n_name; -} - static FontFile * createFontFile(const QString &fileName, int index) { FontFile *fontFile = new FontFile; @@ -288,6 +110,9 @@ static FontFile * createFontFile(const QString &fileName, int index) return fontFile; } +extern bool localizedName(const QString &name); +extern QString getEnglishName(const QString &familyName); + Q_GUI_EXPORT void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias); static bool addFontToDatabase(QString familyName, const QString &scriptName, From c470999329ee576038c50573314699f972f48909 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 18:25:28 +0100 Subject: [PATCH 066/166] Fix the library names on MinGW. Change-Id: I6c2008a0e7a07ca0603b8aa9362d31fa4ef7310a Reviewed-by: Andreas Holzammer Reviewed-by: Stephen Kelly --- mkspecs/features/create_cmake.prf | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 1f9eded772..eb0cdf6991 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -48,24 +48,34 @@ macx { } } } else:win32 { - !isEmpty(CMAKE_STATIC_TYPE) { - CMAKE_IMPLIB_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d.lib - CMAKE_IMPLIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.lib - } else { - CMAKE_LIB_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d$$eval(QT.$${MODULE}.MAJOR_VERSION).dll - CMAKE_LIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}$$eval(QT.$${MODULE}.MAJOR_VERSION).dll - CMAKE_IMPLIB_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d$$eval(QT.$${MODULE}.MAJOR_VERSION).lib - CMAKE_IMPLIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}$$eval(QT.$${MODULE}.MAJOR_VERSION).lib - } + CMAKE_WINDOWS_BUILD = "true" CMAKE_BIN_SUFFIX = ".exe" - CMAKE_WINDOWS_BUILD = "true" + CMAKE_LIB_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d$$eval(QT.$${MODULE}.MAJOR_VERSION).dll + CMAKE_LIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}$$eval(QT.$${MODULE}.MAJOR_VERSION).dll + win32-g++ { CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}d.a CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqtmain$${QT_LIBINFIX}.a + + !isEmpty(CMAKE_STATIC_TYPE) { + CMAKE_IMPLIB_FILE_LOCATION_DEBUG = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d.a + CMAKE_IMPLIB_FILE_LOCATION_RELEASE = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.a + } else { + CMAKE_IMPLIB_FILE_LOCATION_DEBUG = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d$$eval(QT.$${MODULE}.MAJOR_VERSION).a + CMAKE_IMPLIB_FILE_LOCATION_RELEASE = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}$$eval(QT.$${MODULE}.MAJOR_VERSION).a + } } else { CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}d.lib CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qtmain$${QT_LIBINFIX}.lib + + !isEmpty(CMAKE_STATIC_TYPE) { + CMAKE_IMPLIB_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d.lib + CMAKE_IMPLIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.lib + } else { + CMAKE_IMPLIB_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d$$eval(QT.$${MODULE}.MAJOR_VERSION).lib + CMAKE_IMPLIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}$$eval(QT.$${MODULE}.MAJOR_VERSION).lib + } } } else { !isEmpty(CMAKE_STATIC_TYPE) { From de5ebd342f46567a04b58ed28a55ebae48041847 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 00:45:22 +0100 Subject: [PATCH 067/166] Remove unused define QT_NO_COP. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It used to relate to QCop and QWS, which are no more. Change-Id: Ie70c64a3a6ef60664009108b79eed7f33ea59f32 Reviewed-by: Jørgen Lind --- src/corelib/global/qglobal.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index acafde595d..ecd981614a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -489,10 +489,6 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max class QDataStream; -#if !defined(QT_NO_COP) -# define QT_NO_COP -#endif - #if defined(Q_OS_VXWORKS) # define QT_NO_CRASHHANDLER // no popen # define QT_NO_PROCESS // no exec*, no fork From 5a3496ce884dc6b2135ed9154b1da00aa0b64188 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 00:47:54 +0100 Subject: [PATCH 068/166] Remove QT_NO_QWS_MULTIPROCESS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1d6731dc5268919d0c36d5d27285321742be708f Reviewed-by: Jørgen Lind --- src/corelib/global/qglobal.h | 2 -- src/plugins/platforms/vnc/qvncserver.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index ecd981614a..382a05deea 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -495,7 +495,6 @@ class QDataStream; # define QT_NO_LPR # define QT_NO_SHAREDMEMORY // only POSIX, no SysV and in the end... # define QT_NO_SYSTEMSEMAPHORE // not needed at all in a flat address space -# define QT_NO_QWS_MULTIPROCESS // no processes #endif # include @@ -1452,7 +1451,6 @@ Q_CORE_EXPORT int qrand(); #ifdef Q_OS_QNX // QNX doesn't have SYSV style shared memory. Multiprocess QWS apps, // shared fonts and QSystemSemaphore + QSharedMemory are not available -# define QT_NO_QWS_MULTIPROCESS # define QT_NO_QWS_SHARE_FONTS # define QT_NO_SYSTEMSEMAPHORE # define QT_NO_SHAREDMEMORY diff --git a/src/plugins/platforms/vnc/qvncserver.h b/src/plugins/platforms/vnc/qvncserver.h index b0c53dde95..e8b093764f 100644 --- a/src/plugins/platforms/vnc/qvncserver.h +++ b/src/plugins/platforms/vnc/qvncserver.h @@ -262,7 +262,7 @@ public: int refreshRate; QVNCServer *vncServer; -#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY) +#if !defined(QT_NO_SHAREDMEMORY) QSharedMemory shm; #endif From 9c92df82ddd420867fc5b66616046695557fe7f6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 00:48:54 +0100 Subject: [PATCH 069/166] Remove unused QT_NO_QWS_SHARE_FONTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I47e8111d6caffd9b45096e52695acaa55945c612 Reviewed-by: Jørgen Lind --- src/corelib/global/qglobal.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 382a05deea..47d56d7c1b 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1451,7 +1451,6 @@ Q_CORE_EXPORT int qrand(); #ifdef Q_OS_QNX // QNX doesn't have SYSV style shared memory. Multiprocess QWS apps, // shared fonts and QSystemSemaphore + QSharedMemory are not available -# define QT_NO_QWS_SHARE_FONTS # define QT_NO_SYSTEMSEMAPHORE # define QT_NO_SHAREDMEMORY #endif From cbf2575740b324b8dfa1a79adac1ea4a97a7adad Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Mon, 20 Feb 2012 15:00:47 +0100 Subject: [PATCH 070/166] Minor fixes for RelationFlag. * Document AllRelations * Assigned new values (starting from 1) for the remaining members of the enum. Change-Id: I55ec197f24ff7d43ff3c0d101edd33b9615f9287 Reviewed-by: Frederik Gladhorn --- src/gui/accessible/qaccessible.cpp | 2 ++ src/gui/accessible/qaccessible.h | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 0d00df2a17..3f1295ab5e 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -364,6 +364,8 @@ QT_BEGIN_NAMESPACE \value Labelled The first object is labelled by the second object. \value Controller The first object controls the second object. \value Controlled The first object is controlled by the second object. + \value AllRelations Used as a mask to specify that we are interesting in information + about all relations Implementations of relations() return a combination of these flags. Some values are mutually exclusive. diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index e57033d9bf..a72b91a90f 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -306,10 +306,10 @@ public: }; enum RelationFlag { - Label = 0x00020000, - Labelled = 0x00040000, - Controller = 0x00080000, - Controlled = 0x00100000, + Label = 0x00000001, + Labelled = 0x00000002, + Controller = 0x00000004, + Controlled = 0x00000008, AllRelations = 0xffffffff }; Q_DECLARE_FLAGS(Relation, RelationFlag) From 9387a9de6d779590727474e546799bfb9730e57b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Feb 2012 13:21:26 +0100 Subject: [PATCH 071/166] QMimeMagicRule: declare as Q_MOVABLE_TYPE Change-Id: I3725696e7369eb59eeb08095ffe0b8aa7537b4f3 Reviewed-by: David Faure --- src/corelib/mimetypes/qmimemagicrule_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h index 655ca365fa..e35c1923f9 100644 --- a/src/corelib/mimetypes/qmimemagicrule_p.h +++ b/src/corelib/mimetypes/qmimemagicrule_p.h @@ -83,6 +83,7 @@ public: private: const QScopedPointer d; }; +Q_DECLARE_TYPEINFO(QMimeMagicRule, Q_MOVABLE_TYPE); QT_END_NAMESPACE From e8952aba2914722b0ad0e6f07e2193ead7f2e39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Thu, 23 Feb 2012 09:56:12 +0100 Subject: [PATCH 072/166] QHeaderView - change not needed if to Q_ASSERT This removes an if that should always be false. If it isn't false we had more logical indexes than sections. Unless visualIndices and logicalIndices are both 0-sized (meaning that visual and logical indexes are the same) then they better have exactly as many indexes as sectionCount. Otherwise there must be inconsistent data - some logicalindex would refer to non-existing visual sections or some visualindeces wouldn't be hit by logicalIndices. Change-Id: I2dc92f40895438d912bba20612131baf63df4fbe Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qheaderview.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 6a1f949258..c457f16a2c 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1802,9 +1802,8 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent, if (logicalFirst == logicalLast) { // Remove just one index. int l = logicalFirst; int visual = visualIndices.at(l); + Q_ASSERT(sectionCount == logicalIndices.count()); for (int v = 0; v < sectionCount; ++v) { - if (v >= logicalIndices.count()) - continue; // the section doesn't exist if (v > visual) { int logical = logicalIndices.at(v); --(visualIndices[logical]); From 5a2efb490bc3549ef42420a0dafcf22072785e0d Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Mon, 9 Jan 2012 11:25:40 +0100 Subject: [PATCH 073/166] QWheelEvent high-resolution delta support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support pixel-based deltas as well as sending dx and dy values in the same event. Keep source and behavior compatibility with Qt 4. New API: QPoint pixelDelta() const QPoint angleDelta() const Deprecate delta() and orientation(). Both pixel-based deltas and combined updates are necessary for smooth trackpad-based scrolling on OS X. Qt 4 compatible behavior is achieved by sending an extra wheel event in cases where the initial event has a combined dx and dy update. This extra event sends dx in delta() and orientation(), with pixelDelta() and angleDelta() set to null. Modify the Cocoa implementation to provide pixel deltas. It is expected that not all platforms can provide these. Angle deltas will always be available. Change-Id: I20c10f0df338ddcd6a3f7a4d40949ed5ae3b4795 Reviewed-by: Morten Johan Sørvig --- .../snippets/code/src_gui_kernel_qevent.cpp | 14 +- src/gui/kernel/qevent.cpp | 70 ++++- src/gui/kernel/qevent.h | 24 +- src/gui/kernel/qguiapplication.cpp | 3 +- src/gui/kernel/qwindowsysteminterface_qpa.cpp | 49 +++- src/gui/kernel/qwindowsysteminterface_qpa.h | 3 + src/gui/kernel/qwindowsysteminterface_qpa_p.h | 12 +- src/plugins/platforms/cocoa/qnsview.mm | 48 ++-- src/widgets/kernel/qapplication.cpp | 4 +- src/widgets/kernel/qwidgetwindow_qpa.cpp | 2 +- tests/manual/cocoa/wheelevent/main.cpp | 59 +++++ tests/manual/cocoa/wheelevent/wheelevent.pro | 6 + tests/manual/cocoa/wheelevent/window.cpp | 240 ++++++++++++++++++ tests/manual/cocoa/wheelevent/window.h | 76 ++++++ 14 files changed, 557 insertions(+), 53 deletions(-) create mode 100644 tests/manual/cocoa/wheelevent/main.cpp create mode 100644 tests/manual/cocoa/wheelevent/wheelevent.pro create mode 100644 tests/manual/cocoa/wheelevent/window.cpp create mode 100644 tests/manual/cocoa/wheelevent/window.h diff --git a/doc/src/snippets/code/src_gui_kernel_qevent.cpp b/doc/src/snippets/code/src_gui_kernel_qevent.cpp index 35c53337f4..d8bdeebe84 100644 --- a/doc/src/snippets/code/src_gui_kernel_qevent.cpp +++ b/doc/src/snippets/code/src_gui_kernel_qevent.cpp @@ -41,14 +41,16 @@ //! [0] void MyWidget::wheelEvent(QWheelEvent *event) { - int numDegrees = event->delta() / 8; - int numSteps = numDegrees / 15; + QPoint numPixels = envent->pixelDelta(); + QPoint numDegrees = envent->angleDelta() / 8; - if (event->orientation() == Qt::Horizontal) { - scrollHorizontally(numSteps); - } else { - scrollVertically(numSteps); + if (!numPixels.isNull()) { + scrollWithPixels(numpixels); + } else if (!numDegrees.isNull()) { + QPoint numSteps = numDegrees / 15; + scrollWithDegrees(numSteps); } + event->accept(); } //! [0] diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f99f3ddec3..281d4f61bc 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -453,7 +453,13 @@ QHoverEvent::~QHoverEvent() Wheel events are sent to the widget under the mouse cursor, but if that widget does not handle the event they are sent to the - focus widget. The rotation distance is provided by delta(). + focus widget. Wheel events are generated for both mouse wheels + and trackpad scroll gestures. There are two ways to read the + wheel event delta: angleDelta() returns the delta in wheel + degrees. This value is always provided. pixelDelta() returns + the delta in screen pixels and is available on platforms that + have high-resolution trackpads, such as Mac OS X. + The functions pos() and globalPos() return the mouse cursor's location at the time of the event. @@ -483,8 +489,11 @@ QHoverEvent::~QHoverEvent() */ /*! + \obsolete Constructs a wheel event object. + Use the QPoint-based constructor instead. + The position, \a pos, is the location of the mouse cursor within the widget. The globalPos() is initialized to QCursor::pos() which is usually, but not always, correct. @@ -496,13 +505,13 @@ QHoverEvent::~QHoverEvent() \a modifiers holds the keyboard modifier flags at the time of the event, and \a orient holds the wheel's orientation. - \sa pos() delta() state() + \sa pos() pixelDelta() angleDelta() state() */ #ifndef QT_NO_WHEELEVENT QWheelEvent::QWheelEvent(const QPointF &pos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient) - : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient) + : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons) { g = QCursor::pos(); } @@ -515,26 +524,69 @@ QWheelEvent::~QWheelEvent() } /*! + \obsolete Constructs a wheel event object. + Use the QPoint-based constructor instead. + The \a pos provides the location of the mouse cursor within the widget. The position in global coordinates is specified by \a globalPos. \a delta contains the rotation distance, \a modifiers holds the keyboard modifier flags at the time of the event, and \a orient holds the wheel's orientation. - \sa pos() globalPos() delta() state() + + \sa pos() pixelDelta() angleDelta() state() */ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient) - : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient) + : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons) {} +/*! + Constructs a wheel event object. + + The \a pos provides the location of the mouse cursor + within the window. The position in global coordinates is specified + by \a globalPos. \pixelDelta contains the scrolling distance + in pixels on screen, \a angleDelta contains the wheel rotation distance. + \pixelDelta is optional and can be null. + + \a modifiers holds the keyboard modifier flags at the time of the event. + + \a pixelDelta contains the scrolling delta in pixels, + \a angleDelta contains the rotation distance, and + \a orient holds the wheel's orientation. + + \sa pos() globalPos() delta() state() +*/ + +QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, + QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) + : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), + angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons) +{} + + #endif // QT_NO_WHEELEVENT /*! - \fn int QWheelEvent::delta() const + \fn QPoint QWheelEvent::pixelDelta() const + + Returns the scrolling distance in pixels on screen. This value is + provided on platforms that support high-resolution pixel-based + delta values, such as Mac OS X. The value should be used directly + to scroll content on screen. + + Example: + + \snippet doc/src/snippets/code/src_gui_kernel_qevent.cpp 0 +*/ + +/*! + \fn QPoint QWheelEvent::angleDelta() const Returns the distance that the wheel is rotated, in eighths of a degree. A positive value indicates that the wheel was rotated @@ -555,6 +607,12 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta \snippet doc/src/snippets/code/src_gui_kernel_qevent.cpp 0 */ +/*! + \fn int QWheelEvent::delta() const + + This function has been deprecated, use pixelDelta() or angleDelta() instead. +*/ + /*! \fn const QPoint &QWheelEvent::pos() const diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 93dea41de9..ca93095a94 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -148,9 +148,21 @@ public: QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient = Qt::Vertical); + QWheelEvent(const QPointF &pos, const QPointF& globalPos, + QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); + ~QWheelEvent(); - inline int delta() const { return d; } + + inline QPoint pixelDelta() const { return pixelD; } + inline QPoint angleDelta() const { return angleD; } + +#if QT_DEPRECATED_SINCE(5, 0) + inline QT_DEPRECATED int delta() const { return qt4D; } + inline QT_DEPRECATED Qt::Orientation orientation() const { return qt4O; } +#endif + #ifndef QT_NO_INTEGER_EVENT_COORDINATES inline QPoint pos() const { return p.toPoint(); } inline QPoint globalPos() const { return g.toPoint(); } @@ -163,15 +175,15 @@ public: inline const QPointF &globalPosF() const { return g; } inline Qt::MouseButtons buttons() const { return mouseState; } - Qt::Orientation orientation() const { return o; } - - protected: QPointF p; QPointF g; - int d; + QPoint pixelD; + QPoint angleD; + int qt4D; + Qt::Orientation qt4O; Qt::MouseButtons mouseState; - Qt::Orientation o; + int reserved; }; #endif diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 2e7441d62c..1cd448a6bb 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1032,8 +1032,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh QWindow *window = e->window.data(); if (window) { - QWheelEvent ev(e->localPos, e->globalPos, e->delta, buttons, e->modifiers, - e->orient); + QWheelEvent ev(e->localPos, e->globalPos, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, buttons, e->modifiers); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(window, &ev); return; diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index e6c4454104..40a4ec07a6 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -189,8 +189,53 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods) { - QWindowSystemInterfacePrivate::WheelEvent *e = - new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o, mods); + QPoint point = (o == Qt::Vertical) ? QPoint(0, d) : QPoint(d, 0); + handleWheelEvent(tlw, timestamp, local, global, point, point, mods); +} + +void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods) +{ + unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); + handleWheelEvent(w, time, local, global, pixelDelta, angleDelta, mods); +} + +void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods) +{ + // Qt 4 sends two separate wheel events for horizontal and vertical + // deltas. For Qt 5 we want to send the deltas in one event, but at the + // same time preserve source and behavior compatibility with Qt 4. + // + // In addition high-resolution pixel-based deltas are also supported. + // Platforms that does not support these may pass a null point here. + // Angle deltas must always be sent in addition to pixel deltas. + QWindowSystemInterfacePrivate::WheelEvent *e; + + if (angleDelta.isNull()) + return; + + // Simple case: vertical deltas only: + if (angleDelta.y() != 0 && angleDelta.x() == 0) { + e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); + return; + } + + // Simple case: horizontal deltas only: + if (angleDelta.y() == 0 && angleDelta.x() != 0) { + e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); + return; + } + + // Both horizontal and vertical deltas: Send two wheel events. + // The first event contains the Qt 5 pixel and angle delta as points, + // and in addition the Qt 4 compatibility vertical angle delta. + e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); + + // The second event contains null pixel and angle points and the + // Qt 4 compatibility horizontal angle delta. + e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h index 78152a1178..836fb40bd7 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa.h @@ -80,7 +80,10 @@ public: quint32 nativeModifiers, const QString& text = QString(), bool autorep = false, ushort count = 1); + static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier); + static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier); + // Wheel event compatibility functions. Will be removed: do not use. static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier); static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier); diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h index 661b39da88..f5c141b4c9 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h @@ -157,13 +157,15 @@ public: class WheelEvent : public InputEvent { public: - WheelEvent(QWindow *w, ulong time, const QPointF & local, const QPointF & global, int d, - Qt::Orientation o, Qt::KeyboardModifiers mods) - : InputEvent(w, time, Wheel, mods), delta(d), localPos(local), globalPos(global), orient(o) { } - int delta; + WheelEvent(QWindow *w, ulong time, const QPointF & local, const QPointF & global, QPoint pixelD, QPoint angleD, int qt4D, Qt::Orientation qt4O, + Qt::KeyboardModifiers mods) + : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), qt4Orientation(qt4O), localPos(local), globalPos(global) { } + QPoint pixelDelta; + QPoint angleDelta; + int qt4Delta; + Qt::Orientation qt4Orientation; QPointF localPos; QPointF globalPos; - Qt::Orientation orient; }; class KeyEvent : public InputEvent { diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 577e0751c6..a43b3fe893 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -371,14 +371,11 @@ static QTouchDevice *touchDevice = 0; #ifndef QT_NO_WHEELEVENT - (void)scrollWheel:(NSEvent *)theEvent { - int deltaX = 0; - int deltaY = 0; - int deltaZ = 0; - const EventRef carbonEvent = (EventRef)[theEvent eventRef]; const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0; const bool scrollEvent = carbonEventKind == kEventMouseScroll; + QPoint angleDelta; if (scrollEvent) { // The mouse device contains pixel scroll wheel support (Mighty Mouse, Trackpad). // Since deviceDelta is delivered as pixels rather than degrees, we need to @@ -389,40 +386,45 @@ static QTouchDevice *touchDevice = 0; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) { - deltaX = [theEvent scrollingDeltaX] * pixelsToDegrees; - deltaY = [theEvent scrollingDeltaY] * pixelsToDegrees; - // scrollingDeltaZ API is missing. + angleDelta.setX([theEvent scrollingDeltaX] * pixelsToDegrees); + angleDelta.setY([theEvent scrollingDeltaY] * pixelsToDegrees); } else #endif { - deltaX = [theEvent deviceDeltaX] * pixelsToDegrees; - deltaY = [theEvent deviceDeltaY] * pixelsToDegrees; - deltaZ = [theEvent deviceDeltaZ] * pixelsToDegrees; + angleDelta.setX([theEvent deviceDeltaX] * pixelsToDegrees); + angleDelta.setY([theEvent deviceDeltaY] * pixelsToDegrees); } } else { // carbonEventKind == kEventMouseWheelMoved // Remove acceleration, and use either -120 or 120 as delta: - deltaX = qBound(-120, int([theEvent deltaX] * 10000), 120); - deltaY = qBound(-120, int([theEvent deltaY] * 10000), 120); - deltaZ = qBound(-120, int([theEvent deltaZ] * 10000), 120); + angleDelta.setX(qBound(-120, int([theEvent deltaX] * 10000), 120)); + angleDelta.setY(qBound(-120, int([theEvent deltaY] * 10000), 120)); } + QPoint pixelDelta; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) { + if ([theEvent hasPreciseScrollingDeltas]) { + pixelDelta.setX([theEvent scrollingDeltaX]); + pixelDelta.setY([theEvent scrollingDeltaY]); + } else { + // docs: "In the case of !hasPreciseScrollingDeltas, multiply the delta with the line width." + // scrollingDeltaX seems to return a minimum value of 0.1 in this case, map that to two pixels. + const CGFloat lineWithEstimate = 20.0; + pixelDelta.setX([theEvent scrollingDeltaX] * lineWithEstimate); + pixelDelta.setY([theEvent scrollingDeltaY] * lineWithEstimate); + } + } +#endif + + NSPoint windowPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil]; QPoint qt_windowPoint(windowPoint.x, windowPoint.y); NSTimeInterval timestamp = [theEvent timestamp]; ulong qt_timestamp = timestamp * 1000; - if (deltaX != 0) - QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, deltaX, Qt::Horizontal); - - if (deltaY != 0) - QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, deltaY, Qt::Vertical); - - if (deltaZ != 0) - // Qt doesn't explicitly support wheels with a Z component. In a misguided attempt to - // try to be ahead of the pack, I'm adding this extra value. - QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, deltaY, (Qt::Orientation)3); + QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, pixelDelta, angleDelta); } #endif //QT_NO_WHEELEVENT diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 650d4af38b..c350223278 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3357,8 +3357,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } while (w) { - QWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->buttons(), - wheel->modifiers(), wheel->orientation()); + QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), + wheel->modifiers()); we.spont = wheel->spontaneous(); res = d->notify_helper(w, w == receiver ? wheel : &we); eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted(); diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index c04d8a9dc3..4d5e9d5774 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -364,7 +364,7 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) QPoint mapped = widget->mapFrom(m_widget, event->pos()); - QWheelEvent translated(mapped, event->globalPos(), event->delta(), event->buttons(), event->modifiers(), event->orientation()); + QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->pixelDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers()); QGuiApplication::sendSpontaneousEvent(widget, &translated); } diff --git a/tests/manual/cocoa/wheelevent/main.cpp b/tests/manual/cocoa/wheelevent/main.cpp new file mode 100644 index 0000000000..979498991d --- /dev/null +++ b/tests/manual/cocoa/wheelevent/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "window.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + Window window; + window.show(); + + + return app.exec(); +} + + + diff --git a/tests/manual/cocoa/wheelevent/wheelevent.pro b/tests/manual/cocoa/wheelevent/wheelevent.pro new file mode 100644 index 0000000000..6eca6d48cf --- /dev/null +++ b/tests/manual/cocoa/wheelevent/wheelevent.pro @@ -0,0 +1,6 @@ +TEMPLATE = app + +HEADERS += window.h +SOURCES += window.cpp main.cpp + +QT += core gui gui-private core-private diff --git a/tests/manual/cocoa/wheelevent/window.cpp b/tests/manual/cocoa/wheelevent/window.cpp new file mode 100644 index 0000000000..b305b057bf --- /dev/null +++ b/tests/manual/cocoa/wheelevent/window.cpp @@ -0,0 +1,240 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "window.h" + +#include + +#include +#include +#include + +static int colorIndexId = 0; + +QColor colorTable[] = +{ + QColor("#f09f8f"), + QColor("#a2bff2"), + QColor("#c0ef8f") +}; + +Window::Window(QScreen *screen) + : QWindow(screen) + , m_backgroundColorIndex(colorIndexId++) +{ + initialize(); +} + +Window::Window(QWindow *parent) + : QWindow(parent) + , m_backgroundColorIndex(colorIndexId++) +{ + initialize(); +} + +void Window::initialize() +{ + if (parent()) + setGeometry(QRect(160, 120, 320, 240)); + else { + setGeometry(QRect(10, 10, 640, 480)); + + setSizeIncrement(QSize(10, 10)); + setBaseSize(QSize(640, 480)); + setMinimumSize(QSize(240, 160)); + setMaximumSize(QSize(800, 600)); + } + + create(); + m_backingStore = new QBackingStore(this); + + m_image = QImage(geometry().size(), QImage::Format_RGB32); + m_image.fill(colorTable[m_backgroundColorIndex % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); + + m_lastPos = QPoint(-1, -1); + m_renderTimer = 0; +} + +void Window::mousePressEvent(QMouseEvent *event) +{ + m_lastPos = event->pos(); +} + +void Window::mouseMoveEvent(QMouseEvent *event) +{ + if (m_lastPos != QPoint(-1, -1)) { + QPainter p(&m_image); + p.setRenderHint(QPainter::Antialiasing); + p.drawLine(m_lastPos, event->pos()); + m_lastPos = event->pos(); + } + + scheduleRender(); +} + +void Window::wheelEvent(QWheelEvent *event) +{ + qDebug() << "wheelEvent delta" << event->delta() << "orientation" << event->orientation(); + qDebug() << "wheelEvent pixelDelta" << event->pixelDelta(); + qDebug() << "wheelEvent angleDelta" << event->angleDelta(); + + const bool useQt4API = false; + + if (useQt4API) { + if (event->orientation() == Qt::Horizontal) + scrollOffset.setX(scrollOffset.x() + event->delta()); + else + scrollOffset.setY(scrollOffset.y() + event->delta()); + scheduleRender(); + } else { + if (!event->pixelDelta().isNull()) { + scrollOffset += event->pixelDelta(); + scheduleRender(); + } + } +} + +void Window::mouseReleaseEvent(QMouseEvent *event) +{ + if (m_lastPos != QPoint(-1, -1)) { + QPainter p(&m_image); + p.setRenderHint(QPainter::Antialiasing); + p.drawLine(m_lastPos, event->pos()); + m_lastPos = QPoint(-1, -1); + } + + scheduleRender(); +} + +void Window::exposeEvent(QExposeEvent *) +{ + scheduleRender(); +} + +void Window::resizeEvent(QResizeEvent *) +{ + QImage old = m_image; + + //qDebug() << "Window::resizeEvent" << width << height; + + int width = qMax(geometry().width(), old.width()); + int height = qMax(geometry().height(), old.height()); + + if (width > old.width() || height > old.height()) { + m_image = QImage(width, height, QImage::Format_RGB32); + m_image.fill(colorTable[(m_backgroundColorIndex) % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); + + QPainter p(&m_image); + p.drawImage(0, 0, old); + } + + render(); +} + +void Window::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Backspace: + m_text.chop(1); + break; + case Qt::Key_Enter: + case Qt::Key_Return: + m_text.append('\n'); + break; + default: + m_text.append(event->text()); + break; + } + scheduleRender(); +} + +void Window::scheduleRender() +{ + if (!m_renderTimer) + m_renderTimer = startTimer(1); +} + +void Window::timerEvent(QTimerEvent *) +{ + render(); + killTimer(m_renderTimer); + m_renderTimer = 0; +} + +void Window::render() +{ + QRect rect(QPoint(), geometry().size()); + + m_backingStore->resize(rect.size()); + + m_backingStore->beginPaint(rect); + + QPaintDevice *device = m_backingStore->paintDevice(); + + QPainter p(device); + p.drawImage(0, 0, m_image); + + QFont font; + font.setPixelSize(32); + + p.setFont(font); + p.drawText(rect, 0, m_text); + + // draw grid: + int gridSpace = 80; + + for (int y = 0; y < geometry().height() + gridSpace; y+= gridSpace) { + int offset = scrollOffset.y() % gridSpace; + //int color = ((y + offset) %255);// + scrollOffset.y()) % 255); + p.drawLine(0, y + offset, geometry().width(), y + offset); + //p.setBrush(QColor(color,0, 0)); + //p.fillRect(0, y + offset, geometry().width(), gridSpace,QColor(color,0, 0)); + } + + for (int x = 0; x < geometry().width() + gridSpace; x+= gridSpace) { + p.drawLine(x + scrollOffset.x() % gridSpace, 0, x + scrollOffset.x() % gridSpace, geometry().height()); + } + + m_backingStore->endPaint(); + m_backingStore->flush(rect); +} + + diff --git a/tests/manual/cocoa/wheelevent/window.h b/tests/manual/cocoa/wheelevent/window.h new file mode 100644 index 0000000000..523c9f3dc9 --- /dev/null +++ b/tests/manual/cocoa/wheelevent/window.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class Window : public QWindow +{ +public: + Window(QWindow *parent = 0); + Window(QScreen *screen); + +protected: + void mousePressEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + void mouseReleaseEvent(QMouseEvent *); + void wheelEvent(QWheelEvent *event); + + void keyPressEvent(QKeyEvent *); + + void exposeEvent(QExposeEvent *); + void resizeEvent(QResizeEvent *); + + void timerEvent(QTimerEvent *); + +private: + void render(); + void scheduleRender(); + void initialize(); + + QString m_text; + QImage m_image; + QPoint m_lastPos; + int m_backgroundColorIndex; + QBackingStore *m_backingStore; + int m_renderTimer; + QPoint scrollOffset; +}; From 12c2a3d85256abcc5a69f05a7504e01e72f24593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sun, 12 Feb 2012 21:11:04 +0100 Subject: [PATCH 074/166] QHeaderView - fix setOffsetToSectionPosition a bit It might be silly to have sections with size 0 without using hideSection. Nevertheless we should still use the principle of least surprise. It does not make sense that hiding a row 'far' away should affect the semantics of setOffsetToSectionPosition on lower indexes. Change-Id: Iaf847eba2ea4d28fc7bcfe3a27d62f432f6f61e0 Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qheaderview.cpp | 4 +-- .../itemviews/qheaderview/tst_qheaderview.cpp | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index c457f16a2c..ed71c5a918 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3390,11 +3390,11 @@ int QHeaderViewPrivate::viewSectionSizeHint(int logical) const int QHeaderViewPrivate::adjustedVisualIndex(int visualIndex) const { - if (hiddenSectionSize.count() > 0) { + if (!sectionHidden.isEmpty()) { int adjustedVisualIndex = visualIndex; int currentVisualIndex = 0; for (int i = 0; i < sectionSpans.count(); ++i) { - if (sectionSpans.at(i).size == 0) + if (sectionHidden.testBit(i)) ++adjustedVisualIndex; else ++currentVisualIndex; diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 4dd57e1b90..3edc125b5a 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -205,6 +205,7 @@ private slots: void QTBUG12268_hiddenMovedSectionSorting(); void QTBUG14242_hideSectionAutoSize(); void ensureNoIndexAtLength(); + void offsetConsistent(); void initialSortOrderRole(); @@ -2168,6 +2169,33 @@ void tst_QHeaderView::ensureNoIndexAtLength() QVERIFY(hv->visualIndexAt(hv->length()) == -1); } +void tst_QHeaderView::offsetConsistent() +{ + // Ensure that a hidden section 'far away' + // does not affect setOffsetToSectionPosition .. + const int sectionToHide = 513; + QTableView qtv; + QStandardItemModel amodel(1000, 4); + qtv.setModel(&amodel); + QHeaderView *hv = qtv.verticalHeader(); + for (int u = 0; u < 100; u += 2) + hv->resizeSection(u, 0); + hv->setOffsetToSectionPosition(150); + int offset1 = hv->offset(); + hv->hideSection(sectionToHide); + hv->setOffsetToSectionPosition(150); + int offset2 = hv->offset(); + QVERIFY(offset1 == offset2); + // Ensure that hidden indexes (still) is considered. + hv->resizeSection(sectionToHide, hv->sectionSize(200) * 2); + hv->setOffsetToSectionPosition(800); + offset1 = hv->offset(); + hv->showSection(sectionToHide); + hv->setOffsetToSectionPosition(800); + offset2 = hv->offset(); + QVERIFY(offset2 > offset1); +} + void tst_QHeaderView::initialSortOrderRole() { QTableView view; // ### Shadowing member view (of type QHeaderView) From 92f37f00f91fbfc3164ab514d521f0975dc6c5d8 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 21 Feb 2012 11:21:06 +0100 Subject: [PATCH 075/166] Remove unused toolTip member variable (qt3 leftover) Change-Id: Ia68fb00afb81a0f521f9fbc3f0dbfc7e43075bbe Reviewed-by: laurent montel Reviewed-by: Stephen Kelly --- src/widgets/widgets/qworkspace.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/widgets/widgets/qworkspace.cpp b/src/widgets/widgets/qworkspace.cpp index be3f7836d5..80f0a7e44a 100644 --- a/src/widgets/widgets/qworkspace.cpp +++ b/src/widgets/widgets/qworkspace.cpp @@ -290,9 +290,6 @@ public: QWorkspaceTitleBarPrivate() : lastControl(QStyle::SC_None), -#ifndef QT_NO_TOOLTIP - toolTip(0), -#endif act(0), window(0), movable(1), pressed(0), autoraise(0), moving(0) { } @@ -301,9 +298,6 @@ public: QStyle::SubControl buttonDown; QStyle::SubControl lastControl; QPoint moveOffset; -#ifndef QT_NO_TOOLTIP - QToolTip *toolTip; -#endif bool act :1; QPointer window; bool movable :1; From 5ae1caed435139cea5881609dae51026f54ad1fe Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 23 Feb 2012 18:56:12 +0100 Subject: [PATCH 076/166] qmimetypeparser: more optimized definition of string constants Change-Id: I0cbc0fef63814ab037bea66ab35b3aa8b6ec800c Reviewed-by: Oswald Buddenhagen --- src/corelib/mimetypes/qmimetypeparser.cpp | 42 +++++++++++------------ src/corelib/mimetypes/qmimetypeparser_p.h | 24 ------------- 2 files changed, 21 insertions(+), 45 deletions(-) diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp index 23f57367e3..4a2ec0a0b2 100644 --- a/src/corelib/mimetypes/qmimetypeparser.cpp +++ b/src/corelib/mimetypes/qmimetypeparser.cpp @@ -58,29 +58,29 @@ QT_BEGIN_NAMESPACE // XML tags in MIME files -const char *const mimeInfoTagC = "mime-info"; -const char *const mimeTypeTagC = "mime-type"; -const char *const mimeTypeAttributeC = "type"; -const char *const subClassTagC = "sub-class-of"; -const char *const commentTagC = "comment"; -const char *const genericIconTagC = "generic-icon"; -const char *const iconTagC = "icon"; -const char *const nameAttributeC = "name"; -const char *const globTagC = "glob"; -const char *const aliasTagC = "alias"; -const char *const patternAttributeC = "pattern"; -const char *const weightAttributeC = "weight"; -const char *const caseSensitiveAttributeC = "case-sensitive"; -const char *const localeAttributeC = "xml:lang"; +static const char mimeInfoTagC[] = "mime-info"; +static const char mimeTypeTagC[] = "mime-type"; +static const char mimeTypeAttributeC[] = "type"; +static const char subClassTagC[] = "sub-class-of"; +static const char commentTagC[] = "comment"; +static const char genericIconTagC[] = "generic-icon"; +static const char iconTagC[] = "icon"; +static const char nameAttributeC[] = "name"; +static const char globTagC[] = "glob"; +static const char aliasTagC[] = "alias"; +static const char patternAttributeC[] = "pattern"; +static const char weightAttributeC[] = "weight"; +static const char caseSensitiveAttributeC[] = "case-sensitive"; +static const char localeAttributeC[] = "xml:lang"; -const char *const magicTagC = "magic"; -const char *const priorityAttributeC = "priority"; +static const char magicTagC[] = "magic"; +static const char priorityAttributeC[] = "priority"; -const char *const matchTagC = "match"; -const char *const matchValueAttributeC = "value"; -const char *const matchTypeAttributeC = "type"; -const char *const matchOffsetAttributeC = "offset"; -const char *const matchMaskAttributeC = "mask"; +static const char matchTagC[] = "match"; +static const char matchValueAttributeC[] = "value"; +static const char matchTypeAttributeC[] = "type"; +static const char matchOffsetAttributeC[] = "offset"; +static const char matchMaskAttributeC[] = "mask"; /*! \class QMimeTypeParser diff --git a/src/corelib/mimetypes/qmimetypeparser_p.h b/src/corelib/mimetypes/qmimetypeparser_p.h index 455c07063c..af01e1641a 100644 --- a/src/corelib/mimetypes/qmimetypeparser_p.h +++ b/src/corelib/mimetypes/qmimetypeparser_p.h @@ -50,30 +50,6 @@ QT_BEGIN_NAMESPACE class QIODevice; -// XML tags in MIME files -extern const char *const mimeInfoTagC; -extern const char *const mimeTypeTagC; -extern const char *const mimeTypeAttributeC; -extern const char *const subClassTagC; -extern const char *const commentTagC; -extern const char *const genericIconTagC; -extern const char *const nameAttributeC; -extern const char *const globTagC; -extern const char *const aliasTagC; -extern const char *const patternAttributeC; -extern const char *const weightAttributeC; -extern const char *const caseSensitiveAttributeC; -extern const char *const localeAttributeC; - -extern const char *const magicTagC; -extern const char *const priorityAttributeC; - -extern const char *const matchTagC; -extern const char *const matchValueAttributeC; -extern const char *const matchTypeAttributeC; -extern const char *const matchOffsetAttributeC; -extern const char *const matchMaskAttributeC; - class QMimeTypeParserBase { Q_DISABLE_COPY(QMimeTypeParserBase) From 219a688ac17052e4bb3aac9ff8a813e3f4d8da01 Mon Sep 17 00:00:00 2001 From: Hib Eris Date: Thu, 9 Feb 2012 10:03:15 +0100 Subject: [PATCH 077/166] Add TARGET_VERSION_EXT to pkgConfiglibName The libName that is used in pkgConfig files should include the TARGET_VERSION_EXT. This is needed because in Win32MakefileGenerator::fixTargetExt(), the TARGET_VERSION_EXT is added to the library name. In Win32MakefileGenerator::processVars(), if TARGET_VERSION_EXT is empty, it is set to VER_MAJ. On platforms != Windows, TARGET_VERSION_EXT does not seem to be used. We probably got away with this so far because pkgconfig files generation for win32 was just added in 4.8 and nobody uses them yet, and because on platforms != windows the TARGET_VERSION_EXT is not used. Change-Id: I56f239e389f0ef926030e4c2376cadd92c4f673c Reviewed-by: Oswald Buddenhagen --- qmake/generators/makefile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 7a00e0b48d..59a615e63a 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -3287,6 +3287,7 @@ MakefileGenerator::writePkgConfigFile() } else { pkgConfiglibDir = "-L${libdir}"; pkgConfiglibName = "-l" + lname.left(lname.length()-Option::libtool_ext.length()); + pkgConfiglibName += project->first("TARGET_VERSION_EXT"); } t << pkgConfiglibDir << " " << pkgConfiglibName << " " << endl; From ed7f78acba45e1142157e39154466a13f9d3ce4e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 17:27:47 +0100 Subject: [PATCH 078/166] Fix tst_qlineedit. - Fix key handling in QWidgetLineControl according to the keyboard scheme returned by the QPlatformTheme, remove #ifdefs. - Do the same in the test. Task-number: QTBUG-21402 Change-Id: I36d836584e7122309061af72819a4147cadd0a74 Reviewed-by: Miikka Heikkinen Reviewed-by: Bradley T. Hughes --- src/widgets/widgets/qwidgetlinecontrol.cpp | 49 +++++++---- src/widgets/widgets/qwidgetlinecontrol_p.h | 3 + .../widgets/widgets/qlineedit/qlineedit.pro | 4 +- .../widgets/qlineedit/tst_qlineedit.cpp | 82 +++++++++++-------- 4 files changed, 82 insertions(+), 56 deletions(-) diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 2f5793bcba..73c3d14f9b 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -45,6 +45,8 @@ #include "qabstractitemview.h" #include "qclipboard.h" +#include +#include #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif @@ -374,6 +376,14 @@ void QWidgetLineControl::init(const QString &txt) m_text = txt; updateDisplayText(); m_cursor = m_text.length(); + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); + // Generalize for X11 + if (m_keyboardScheme == QPlatformTheme::KdeKeyboardScheme + || m_keyboardScheme == QPlatformTheme::GnomeKeyboardScheme + || m_keyboardScheme == QPlatformTheme::CdeKeyboardScheme) { + m_keyboardScheme = QPlatformTheme::X11KeyboardScheme; + } } /*! @@ -1630,10 +1640,11 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) else if (event == QKeySequence::Paste) { if (!isReadOnly()) { QClipboard::Mode mode = QClipboard::Clipboard; -#ifdef Q_WS_X11 - if (event->modifiers() == (Qt::CTRL | Qt::SHIFT) && event->key() == Qt::Key_Insert) + if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme + && event->modifiers() == (Qt::CTRL | Qt::SHIFT) + && event->key() == Qt::Key_Insert) { mode = QClipboard::Selection; -#endif + } paste(mode); } } @@ -1664,12 +1675,14 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) end(1); } else if (event == QKeySequence::MoveToNextChar) { -#if !defined(Q_WS_WIN) || defined(QT_NO_COMPLETER) - if (hasSelectedText()) { +#if defined(QT_NO_COMPLETER) + const bool inlineCompletion = false; #else - if (hasSelectedText() && m_completer - && m_completer->completionMode() == QCompleter::InlineCompletion) { + const bool inlineCompletion = m_completer && m_completer->completionMode() == QCompleter::InlineCompletion; #endif + if (hasSelectedText() + && (m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme + || inlineCompletion)) { moveCursor(selectionEnd(), false); } else { cursorForward(0, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1)); @@ -1679,12 +1692,14 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) cursorForward(1, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1)); } else if (event == QKeySequence::MoveToPreviousChar) { -#if !defined(Q_WS_WIN) || defined(QT_NO_COMPLETER) - if (hasSelectedText()) { +#if defined(QT_NO_COMPLETER) + const bool inlineCompletion = false; #else - if (hasSelectedText() && m_completer - && m_completer->completionMode() == QCompleter::InlineCompletion) { + const bool inlineCompletion = m_completer && m_completer->completionMode() == QCompleter::InlineCompletion; #endif + if (hasSelectedText() + && (m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme + || inlineCompletion)) { moveCursor(selectionStart(), false); } else { cursorForward(0, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1)); @@ -1737,8 +1752,8 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) #endif // QT_NO_SHORTCUT else { bool handled = false; -#ifdef Q_WS_MAC - if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down) { + if (m_keyboardScheme == QPlatformTheme::MacKeyboardScheme + && (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)) { Qt::KeyboardModifiers myModifiers = (event->modifiers() & ~Qt::KeypadModifier); if (myModifiers & Qt::ShiftModifier) { if (myModifiers == (Qt::ControlModifier|Qt::ShiftModifier) @@ -1756,7 +1771,6 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) } handled = true; } -#endif if (event->modifiers() & Qt::ControlModifier) { switch (event->key()) { case Qt::Key_Backspace: @@ -1771,13 +1785,13 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) complete(event->key()); break; #endif -#if defined(Q_WS_X11) case Qt::Key_E: - end(0); + if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme) + end(0); break; case Qt::Key_U: - if (!isReadOnly()) { + if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme && !isReadOnly()) { setSelection(0, text().size()); #ifndef QT_NO_CLIPBOARD copy(); @@ -1785,7 +1799,6 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) del(); } break; -#endif default: if (!handled) unknown = true; diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index a0191188a7..72f25e9068 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -100,6 +100,7 @@ public: , m_threadChecks(false) , m_textLayoutThread(0) #endif + , m_keyboardScheme(0) { init(txt); } @@ -527,6 +528,8 @@ private Q_SLOTS: void _q_clipboardChanged(); void _q_deleteSelected(); +private: + int m_keyboardScheme; }; QT_END_NAMESPACE diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro index 77b2ae537c..f674ea3f05 100644 --- a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro +++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro @@ -1,6 +1,4 @@ CONFIG += testcase TARGET = tst_qlineedit -QT += widgets testlib +QT += gui-private core-private widgets testlib SOURCES += tst_qlineedit.cpp - -CONFIG += insignificant_test # QTBUG-21402 diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 645f47fc72..17632ec458 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -48,6 +48,8 @@ #include "qvalidator.h" #include "qcompleter.h" #include "qstandarditemmodel.h" +#include "qplatformtheme_qpa.h" +#include #ifndef QT_NO_CLIPBOARD #include "qclipboard.h" @@ -300,6 +302,7 @@ private: int lastCursorPos; int newCursorPos; QLineEdit *testWidget; + int m_keyboardScheme; }; typedef QList IntList; @@ -327,9 +330,16 @@ void tst_QLineEdit::getSetCheck() QCOMPARE(true, obj1.dragEnabled()); } -tst_QLineEdit::tst_QLineEdit() +tst_QLineEdit::tst_QLineEdit() : validInput(false), m_keyboardScheme(0) { - validInput = false; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); + // Generalize for X11 + if (m_keyboardScheme == QPlatformTheme::KdeKeyboardScheme + || m_keyboardScheme == QPlatformTheme::GnomeKeyboardScheme + || m_keyboardScheme == QPlatformTheme::CdeKeyboardScheme) { + m_keyboardScheme = QPlatformTheme::X11KeyboardScheme; + } } tst_QLineEdit::~tst_QLineEdit() @@ -1071,25 +1081,26 @@ void tst_QLineEdit::undo() QVERIFY(!testWidget->isUndoAvailable()); QVERIFY(testWidget->text().isEmpty()); -#ifdef Q_WS_WIN - // Repeat the test using shortcut instead of undo() - for (i=0; i -1) - testWidget->setCursorPosition(insertIndex[i]); - if (insertMode[i] == REPLACE_UNTIL_END) { - testWidget->setSelection(insertIndex[i], 8); + + if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) { + // Repeat the test using shortcut instead of undo() + for (i=0; i -1) + testWidget->setCursorPosition(insertIndex[i]); + if (insertMode[i] == REPLACE_UNTIL_END) + testWidget->setSelection(insertIndex[i], 8); + if (use_keys) + QTest::keyClicks(testWidget, insertString[i]); + else + testWidget->insert(insertString[i]); + } + for (i=0; itext(), expectedString[i]); + QVERIFY(testWidget->isUndoAvailable()); + QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); } - if (use_keys) - QTest::keyClicks(testWidget, insertString[i]); - else - testWidget->insert(insertString[i]); } - for (i=0; itext(), expectedString[i]); - QVERIFY(testWidget->isUndoAvailable()); - QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); - } -#endif + } void tst_QLineEdit::redo_data() @@ -1152,21 +1163,22 @@ void tst_QLineEdit::redo() QVERIFY(!testWidget->isRedoAvailable()); -#ifdef Q_WS_WIN - // repeat test, this time using shortcuts instead of undo()/redo() - while (!testWidget->text().isEmpty()) - QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); + if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) { + // repeat test, this time using shortcuts instead of undo()/redo() - for (i = 0; i < expectedString.size(); ++i) { - QVERIFY(testWidget->isRedoAvailable()); - QTest::keyClick(testWidget, Qt::Key_Backspace, - Qt::ShiftModifier | Qt::AltModifier); - QCOMPARE(testWidget->text() , expectedString[i]); + while (!testWidget->text().isEmpty()) + QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); + + for (i = 0; i < expectedString.size(); ++i) { + QVERIFY(testWidget->isRedoAvailable()); + QTest::keyClick(testWidget, Qt::Key_Backspace, + Qt::ShiftModifier | Qt::AltModifier); + QCOMPARE(testWidget->text() , expectedString[i]); + } + + QVERIFY(!testWidget->isRedoAvailable()); } - - QVERIFY(!testWidget->isRedoAvailable()); -#endif } void tst_QLineEdit::undo_keypressevents_data() @@ -1263,7 +1275,7 @@ void tst_QLineEdit::undo_keypressevents_data() // unselect any current selection keys.addKeyClick(Qt::Key_Right); -#ifdef Q_WS_WIN //Mac has a specialcase to handle jumping to the end of a selection +#ifdef Q_OS_WIN //Mac has a specialcase to handle jumping to the end of a selection keys.addKeyClick(Qt::Key_Left); #endif @@ -3080,6 +3092,7 @@ void tst_QLineEdit::leftKeyOnSelectedText() #ifdef Q_OS_WIN QCOMPARE(testWidget->cursorPosition(), 1); #else + // Selection is cleared ands cursor remains at position 2. // X11 used to behave like window prior to 4.2. Changes caused by QKeySequence // resulted in an inadvertant change in behavior QCOMPARE(testWidget->cursorPosition(), 2); @@ -3624,9 +3637,8 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup() { -#ifndef Q_WS_X11 - QSKIP("Only tested on X11"); -#endif + if (m_keyboardScheme != QPlatformTheme::X11KeyboardScheme) + QSKIP("Only tested on X11"); QLineEdit le; le.setText(" "); QPalette p = le.palette(); From b1995f2c96f90b20feb54a3368c2b8c2cfc1fa84 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2012 16:40:58 +0100 Subject: [PATCH 079/166] rcc: micro-optimization Declare a char array instead of a pointer variable. Change-Id: I2beff815d05b6dc9c35bb0a55d7294189afbf17e Reviewed-by: Marius Storm-Olsen Reviewed-by: Olivier Goffart --- src/tools/rcc/rcc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 5fbda35fc6..b31c47e7ad 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -687,7 +687,7 @@ bool RCCResourceLibrary::output(QIODevice &outDevice, QIODevice &errorDevice) void RCCResourceLibrary::writeHex(quint8 tmp) { - const char * const digits = "0123456789abcdef"; + const char digits[] = "0123456789abcdef"; writeChar('0'); writeChar('x'); if (tmp < 16) { From 5f320e2f97df1ef48a7877feb418e3f63421b485 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 13:13:29 +0100 Subject: [PATCH 080/166] Use new plugin system for network bearer plugins. Change-Id: Ic4a28d379033518f75d0e3e449ddf012109ed9ea Reviewed-by: Lars Knoll --- src/plugins/bearer/connman/connman.json | 3 +++ src/plugins/bearer/connman/connman.pro | 2 ++ src/plugins/bearer/connman/main.cpp | 8 +++++--- src/plugins/bearer/corewlan/corewlan.json | 3 +++ src/plugins/bearer/corewlan/corewlan.pro | 2 ++ src/plugins/bearer/corewlan/main.cpp | 8 +++++--- src/plugins/bearer/generic/generic.json | 3 +++ src/plugins/bearer/generic/generic.pro | 2 ++ src/plugins/bearer/generic/main.cpp | 8 +++++--- src/plugins/bearer/nativewifi/main.cpp | 8 +++++--- src/plugins/bearer/nativewifi/nativewifi.json | 3 +++ src/plugins/bearer/nativewifi/nativewifi.pro | 2 ++ src/plugins/bearer/networkmanager/main.cpp | 8 +++++--- src/plugins/bearer/networkmanager/networkmanager.json | 3 +++ src/plugins/bearer/networkmanager/networkmanager.pro | 2 ++ src/plugins/bearer/nla/main.cpp | 8 +++++--- src/plugins/bearer/nla/nla.json | 3 +++ src/plugins/bearer/nla/nla.pro | 4 +++- 18 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 src/plugins/bearer/connman/connman.json create mode 100644 src/plugins/bearer/corewlan/corewlan.json create mode 100644 src/plugins/bearer/generic/generic.json create mode 100644 src/plugins/bearer/nativewifi/nativewifi.json create mode 100644 src/plugins/bearer/networkmanager/networkmanager.json create mode 100644 src/plugins/bearer/nla/nla.json diff --git a/src/plugins/bearer/connman/connman.json b/src/plugins/bearer/connman/connman.json new file mode 100644 index 0000000000..7a80b8c9be --- /dev/null +++ b/src/plugins/bearer/connman/connman.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "connman" ] +} diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro index 25243f8e0a..679637b37f 100644 --- a/src/plugins/bearer/connman/connman.pro +++ b/src/plugins/bearer/connman/connman.pro @@ -15,6 +15,8 @@ SOURCES += main.cpp \ qconnmanengine.cpp \ ../qnetworksession_impl.cpp +OTHER_FILES += connman.json + DESTDIR = $$QT.network.plugins/bearer target.path += $$[QT_INSTALL_PLUGINS]/bearer INSTALLS += target diff --git a/src/plugins/bearer/connman/main.cpp b/src/plugins/bearer/connman/main.cpp index f612f0ca9f..be934c7282 100644 --- a/src/plugins/bearer/connman/main.cpp +++ b/src/plugins/bearer/connman/main.cpp @@ -51,6 +51,9 @@ QT_BEGIN_NAMESPACE class QConnmanEnginePlugin : public QBearerEnginePlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "connman.json") + public: QConnmanEnginePlugin(); ~QConnmanEnginePlugin(); @@ -84,10 +87,9 @@ QBearerEngine *QConnmanEnginePlugin::create(const QString &key) const return 0; } -Q_EXPORT_STATIC_PLUGIN(QConnmanEnginePlugin) -Q_EXPORT_PLUGIN2(qconnmanbearer, QConnmanEnginePlugin) - QT_END_NAMESPACE +#include "main.moc" + #endif #endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/corewlan/corewlan.json b/src/plugins/bearer/corewlan/corewlan.json new file mode 100644 index 0000000000..b43519ea90 --- /dev/null +++ b/src/plugins/bearer/corewlan/corewlan.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "corewlan" ] +} diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro index 6a214ac340..82a514fb14 100644 --- a/src/plugins/bearer/corewlan/corewlan.pro +++ b/src/plugins/bearer/corewlan/corewlan.pro @@ -19,6 +19,8 @@ SOURCES += main.cpp \ OBJECTIVE_SOURCES += qcorewlanengine.mm +OTHER_FILES += corewlan.json + DESTDIR = $$QT.network.plugins/bearer target.path += $$[QT_INSTALL_PLUGINS]/bearer INSTALLS += target diff --git a/src/plugins/bearer/corewlan/main.cpp b/src/plugins/bearer/corewlan/main.cpp index 0f5ad2c7fb..f2ba8bd879 100644 --- a/src/plugins/bearer/corewlan/main.cpp +++ b/src/plugins/bearer/corewlan/main.cpp @@ -51,6 +51,9 @@ QT_BEGIN_NAMESPACE class QCoreWlanEnginePlugin : public QBearerEnginePlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "corewlan.json") + public: QCoreWlanEnginePlugin(); ~QCoreWlanEnginePlugin(); @@ -80,9 +83,8 @@ QBearerEngine *QCoreWlanEnginePlugin::create(const QString &key) const return 0; } -Q_EXPORT_STATIC_PLUGIN(QCoreWlanEnginePlugin) -Q_EXPORT_PLUGIN2(qcorewlanbearer, QCoreWlanEnginePlugin) - QT_END_NAMESPACE +#include "main.moc" + #endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/generic/generic.json b/src/plugins/bearer/generic/generic.json new file mode 100644 index 0000000000..e9357f4c72 --- /dev/null +++ b/src/plugins/bearer/generic/generic.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "generic" ] +} diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro index 4f86c2a38c..e66c5b2c7a 100644 --- a/src/plugins/bearer/generic/generic.pro +++ b/src/plugins/bearer/generic/generic.pro @@ -11,6 +11,8 @@ SOURCES += qgenericengine.cpp \ ../qnetworksession_impl.cpp \ main.cpp +OTHER_FILES += generic.json + DESTDIR = $$QT.network.plugins/bearer target.path += $$[QT_INSTALL_PLUGINS]/bearer INSTALLS += target diff --git a/src/plugins/bearer/generic/main.cpp b/src/plugins/bearer/generic/main.cpp index 0311bcbef0..5f5ad7c238 100644 --- a/src/plugins/bearer/generic/main.cpp +++ b/src/plugins/bearer/generic/main.cpp @@ -51,6 +51,9 @@ QT_BEGIN_NAMESPACE class QGenericEnginePlugin : public QBearerEnginePlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "generic.json") + public: QGenericEnginePlugin(); ~QGenericEnginePlugin(); @@ -80,9 +83,8 @@ QBearerEngine *QGenericEnginePlugin::create(const QString &key) const return 0; } -Q_EXPORT_STATIC_PLUGIN(QGenericEnginePlugin) -Q_EXPORT_PLUGIN2(qgenericbearer, QGenericEnginePlugin) - QT_END_NAMESPACE +#include "main.moc" + #endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp index 74129c1d0a..8baa977a9d 100644 --- a/src/plugins/bearer/nativewifi/main.cpp +++ b/src/plugins/bearer/nativewifi/main.cpp @@ -92,6 +92,9 @@ static void resolveLibrary() class QNativeWifiEnginePlugin : public QBearerEnginePlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "nativewifi.json") + public: QNativeWifiEnginePlugin(); ~QNativeWifiEnginePlugin(); @@ -135,9 +138,8 @@ QBearerEngine *QNativeWifiEnginePlugin::create(const QString &key) const return engine; } -Q_EXPORT_STATIC_PLUGIN(QNativeWifiEnginePlugin) -Q_EXPORT_PLUGIN2(qnativewifibearer, QNativeWifiEnginePlugin) - QT_END_NAMESPACE +#include "main.moc" + #endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/nativewifi/nativewifi.json b/src/plugins/bearer/nativewifi/nativewifi.json new file mode 100644 index 0000000000..f3db199150 --- /dev/null +++ b/src/plugins/bearer/nativewifi/nativewifi.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "nativewifi" ] +} diff --git a/src/plugins/bearer/nativewifi/nativewifi.pro b/src/plugins/bearer/nativewifi/nativewifi.pro index ec86cc0b93..3124d58ff2 100644 --- a/src/plugins/bearer/nativewifi/nativewifi.pro +++ b/src/plugins/bearer/nativewifi/nativewifi.pro @@ -12,6 +12,8 @@ SOURCES += main.cpp \ qnativewifiengine.cpp \ ../qnetworksession_impl.cpp +OTHER_FILES += nativewifi.json + DESTDIR = $$QT.network.plugins/bearer target.path += $$[QT_INSTALL_PLUGINS]/bearer INSTALLS += target diff --git a/src/plugins/bearer/networkmanager/main.cpp b/src/plugins/bearer/networkmanager/main.cpp index 2278d221fd..c8a8a74e46 100644 --- a/src/plugins/bearer/networkmanager/main.cpp +++ b/src/plugins/bearer/networkmanager/main.cpp @@ -52,6 +52,9 @@ QT_BEGIN_NAMESPACE class QNetworkManagerEnginePlugin : public QBearerEnginePlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "networkmanager.json") + public: QNetworkManagerEnginePlugin(); ~QNetworkManagerEnginePlugin(); @@ -86,10 +89,9 @@ QBearerEngine *QNetworkManagerEnginePlugin::create(const QString &key) const return 0; } -Q_EXPORT_STATIC_PLUGIN(QNetworkManagerEnginePlugin) -Q_EXPORT_PLUGIN2(qnmbearer, QNetworkManagerEnginePlugin) - QT_END_NAMESPACE +#include "main.moc" + #endif // QT_NO_DBUS #endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/networkmanager/networkmanager.json b/src/plugins/bearer/networkmanager/networkmanager.json new file mode 100644 index 0000000000..3d408d5c20 --- /dev/null +++ b/src/plugins/bearer/networkmanager/networkmanager.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "networkmanager" ] +} diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro index 262f60a69c..c1c6664897 100644 --- a/src/plugins/bearer/networkmanager/networkmanager.pro +++ b/src/plugins/bearer/networkmanager/networkmanager.pro @@ -15,6 +15,8 @@ SOURCES += main.cpp \ qnetworkmanagerengine.cpp \ ../qnetworksession_impl.cpp +OTHER_FILES += networkmanager.json + DESTDIR = $$QT.network.plugins/bearer target.path += $$[QT_INSTALL_PLUGINS]/bearer INSTALLS += target diff --git a/src/plugins/bearer/nla/main.cpp b/src/plugins/bearer/nla/main.cpp index 4337c1748a..4a2c915d13 100644 --- a/src/plugins/bearer/nla/main.cpp +++ b/src/plugins/bearer/nla/main.cpp @@ -49,6 +49,9 @@ QT_BEGIN_NAMESPACE class QNlaEnginePlugin : public QBearerEnginePlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "nla.json") + public: QNlaEnginePlugin(); ~QNlaEnginePlugin(); @@ -78,7 +81,6 @@ QBearerEngine *QNlaEnginePlugin::create(const QString &key) const return 0; } -Q_EXPORT_STATIC_PLUGIN(QNlaEnginePlugin) -Q_EXPORT_PLUGIN2(qnlabearer, QNlaEnginePlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/bearer/nla/nla.json b/src/plugins/bearer/nla/nla.json new file mode 100644 index 0000000000..2554d2c5c4 --- /dev/null +++ b/src/plugins/bearer/nla/nla.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "nla" ] +} diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro index 76da098dbf..5444269f1f 100644 --- a/src/plugins/bearer/nla/nla.pro +++ b/src/plugins/bearer/nla/nla.pro @@ -1,7 +1,7 @@ TARGET = qnlabearer load(qt_plugin) -QT = core network +QT = core core-private network network-private !wince* { LIBS += -lWs2_32 @@ -18,6 +18,8 @@ SOURCES += main.cpp \ qnlaengine.cpp \ ../qnetworksession_impl.cpp +OTHER_FILES += nla.json + DESTDIR = $$QT.network.plugins/bearer target.path += $$[QT_INSTALL_PLUGINS]/bearer INSTALLS += target From 71fe29711fcb88adcc191f1350e13f7c2544c642 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 15:18:35 +0100 Subject: [PATCH 081/166] Use new plugin system for SQL drivers. Change-Id: I1d4db9ecc7e1cbca66674d13748070f4b19d5b8c Reviewed-by: Lars Knoll --- src/plugins/sqldrivers/db2/db2.json | 3 +++ src/plugins/sqldrivers/db2/db2.pro | 1 + src/plugins/sqldrivers/db2/main.cpp | 12 ++++++------ src/plugins/sqldrivers/ibase/ibase.json | 3 +++ src/plugins/sqldrivers/ibase/ibase.pro | 1 + src/plugins/sqldrivers/ibase/main.cpp | 12 ++++++------ src/plugins/sqldrivers/mysql/main.cpp | 8 +++++--- src/plugins/sqldrivers/mysql/mysql.json | 3 +++ src/plugins/sqldrivers/mysql/mysql.pro | 1 + src/plugins/sqldrivers/oci/main.cpp | 8 +++++--- src/plugins/sqldrivers/oci/oci.json | 3 +++ src/plugins/sqldrivers/oci/oci.pro | 1 + src/plugins/sqldrivers/odbc/main.cpp | 8 +++++--- src/plugins/sqldrivers/odbc/odbc.json | 3 +++ src/plugins/sqldrivers/odbc/odbc.pro | 1 + src/plugins/sqldrivers/psql/main.cpp | 8 +++++--- src/plugins/sqldrivers/psql/psql.json | 3 +++ src/plugins/sqldrivers/psql/psql.pro | 1 + src/plugins/sqldrivers/sqlite/smain.cpp | 12 ++++++------ src/plugins/sqldrivers/sqlite/sqlite.json | 3 +++ src/plugins/sqldrivers/sqlite/sqlite.pro | 1 + src/plugins/sqldrivers/sqlite2/smain.cpp | 12 ++++++------ src/plugins/sqldrivers/sqlite2/sqlite2.json | 3 +++ src/plugins/sqldrivers/sqlite2/sqlite2.pro | 1 + src/plugins/sqldrivers/tds/main.cpp | 8 +++++--- src/plugins/sqldrivers/tds/tds.json | 3 +++ src/plugins/sqldrivers/tds/tds.pro | 1 + 27 files changed, 85 insertions(+), 39 deletions(-) create mode 100644 src/plugins/sqldrivers/db2/db2.json create mode 100644 src/plugins/sqldrivers/ibase/ibase.json create mode 100644 src/plugins/sqldrivers/mysql/mysql.json create mode 100644 src/plugins/sqldrivers/oci/oci.json create mode 100644 src/plugins/sqldrivers/odbc/odbc.json create mode 100644 src/plugins/sqldrivers/psql/psql.json create mode 100644 src/plugins/sqldrivers/sqlite/sqlite.json create mode 100644 src/plugins/sqldrivers/sqlite2/sqlite2.json create mode 100644 src/plugins/sqldrivers/tds/tds.json diff --git a/src/plugins/sqldrivers/db2/db2.json b/src/plugins/sqldrivers/db2/db2.json new file mode 100644 index 0000000000..3f8678ae7a --- /dev/null +++ b/src/plugins/sqldrivers/db2/db2.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QDB2" ] +} diff --git a/src/plugins/sqldrivers/db2/db2.pro b/src/plugins/sqldrivers/db2/db2.pro index e053f3756b..d04e6f191b 100644 --- a/src/plugins/sqldrivers/db2/db2.pro +++ b/src/plugins/sqldrivers/db2/db2.pro @@ -1,6 +1,7 @@ TARGET = qsqldb2 SOURCES = main.cpp +OTHER_FILES += db2.json include(../../../sql/drivers/db2/qsql_db2.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/db2/main.cpp b/src/plugins/sqldrivers/db2/main.cpp index af5eb10c67..186eacf2e9 100644 --- a/src/plugins/sqldrivers/db2/main.cpp +++ b/src/plugins/sqldrivers/db2/main.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE class QDB2DriverPlugin : public QSqlDriverPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "db2.json") + public: QDB2DriverPlugin(); @@ -70,12 +73,9 @@ QSqlDriver* QDB2DriverPlugin::create(const QString &name) QStringList QDB2DriverPlugin::keys() const { - QStringList l; - l.append(QLatin1String("QDB2")); - return l; + return QStringList(QStringLiteral("QDB2")); } -Q_EXPORT_STATIC_PLUGIN(QDB2DriverPlugin) -Q_EXPORT_PLUGIN2(qsqldb2, QDB2DriverPlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/sqldrivers/ibase/ibase.json b/src/plugins/sqldrivers/ibase/ibase.json new file mode 100644 index 0000000000..e2186b32cd --- /dev/null +++ b/src/plugins/sqldrivers/ibase/ibase.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QIBASE" ] +} diff --git a/src/plugins/sqldrivers/ibase/ibase.pro b/src/plugins/sqldrivers/ibase/ibase.pro index 7870ec8465..ca2a91aa2e 100644 --- a/src/plugins/sqldrivers/ibase/ibase.pro +++ b/src/plugins/sqldrivers/ibase/ibase.pro @@ -1,6 +1,7 @@ TARGET = qsqlibase SOURCES = main.cpp +OTHER_FILES += ibase.json include(../../../sql/drivers/ibase/qsql_ibase.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/ibase/main.cpp b/src/plugins/sqldrivers/ibase/main.cpp index c1018944fd..e820c6a333 100644 --- a/src/plugins/sqldrivers/ibase/main.cpp +++ b/src/plugins/sqldrivers/ibase/main.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE class QIBaseDriverPlugin : public QSqlDriverPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "ibase.json") + public: QIBaseDriverPlugin(); @@ -70,12 +73,9 @@ QSqlDriver* QIBaseDriverPlugin::create(const QString &name) QStringList QIBaseDriverPlugin::keys() const { - QStringList l; - l << QLatin1String("QIBASE"); - return l; + return QStringList(QStringLiteral("QIBASE")); } -Q_EXPORT_STATIC_PLUGIN(QIBaseDriverPlugin) -Q_EXPORT_PLUGIN2(qsqlibase, QIBaseDriverPlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/sqldrivers/mysql/main.cpp b/src/plugins/sqldrivers/mysql/main.cpp index 86cae58701..70937218c3 100644 --- a/src/plugins/sqldrivers/mysql/main.cpp +++ b/src/plugins/sqldrivers/mysql/main.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE class QMYSQLDriverPlugin : public QSqlDriverPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "mysql.json") + public: QMYSQLDriverPlugin(); @@ -76,7 +79,6 @@ QStringList QMYSQLDriverPlugin::keys() const return l; } -Q_EXPORT_STATIC_PLUGIN(QMYSQLDriverPlugin) -Q_EXPORT_PLUGIN2(qsqlmysql, QMYSQLDriverPlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/sqldrivers/mysql/mysql.json b/src/plugins/sqldrivers/mysql/mysql.json new file mode 100644 index 0000000000..0caaadb7ce --- /dev/null +++ b/src/plugins/sqldrivers/mysql/mysql.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QMYSQL3", "QMYSQL" ] +} diff --git a/src/plugins/sqldrivers/mysql/mysql.pro b/src/plugins/sqldrivers/mysql/mysql.pro index b6d42fffc8..05d1073701 100644 --- a/src/plugins/sqldrivers/mysql/mysql.pro +++ b/src/plugins/sqldrivers/mysql/mysql.pro @@ -1,6 +1,7 @@ TARGET = qsqlmysql SOURCES = main.cpp +OTHER_FILES += mysql.json include(../../../sql/drivers/mysql/qsql_mysql.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/oci/main.cpp b/src/plugins/sqldrivers/oci/main.cpp index 4e5a07a64c..205bfae783 100644 --- a/src/plugins/sqldrivers/oci/main.cpp +++ b/src/plugins/sqldrivers/oci/main.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE class QOCIDriverPlugin : public QSqlDriverPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "oci.json") + public: QOCIDriverPlugin(); @@ -76,7 +79,6 @@ QStringList QOCIDriverPlugin::keys() const return l; } -Q_EXPORT_STATIC_PLUGIN(QOCIDriverPlugin) -Q_EXPORT_PLUGIN2(qsqloci, QOCIDriverPlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/sqldrivers/oci/oci.json b/src/plugins/sqldrivers/oci/oci.json new file mode 100644 index 0000000000..cbed8fc1ac --- /dev/null +++ b/src/plugins/sqldrivers/oci/oci.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QOCI8", "QOCI" ] +} diff --git a/src/plugins/sqldrivers/oci/oci.pro b/src/plugins/sqldrivers/oci/oci.pro index d7dcce9e35..89642f3653 100644 --- a/src/plugins/sqldrivers/oci/oci.pro +++ b/src/plugins/sqldrivers/oci/oci.pro @@ -1,6 +1,7 @@ TARGET = qsqloci SOURCES = main.cpp +OTHER_FILES += oci.json include(../../../sql/drivers/oci/qsql_oci.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/odbc/main.cpp b/src/plugins/sqldrivers/odbc/main.cpp index eada54da9e..c55af6e6fc 100644 --- a/src/plugins/sqldrivers/odbc/main.cpp +++ b/src/plugins/sqldrivers/odbc/main.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE class QODBCDriverPlugin : public QSqlDriverPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "odbc.json") + public: QODBCDriverPlugin(); @@ -76,7 +79,6 @@ QStringList QODBCDriverPlugin::keys() const return l; } -Q_EXPORT_STATIC_PLUGIN(QODBCDriverPlugin) -Q_EXPORT_PLUGIN2(qsqlodbc, QODBCDriverPlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/sqldrivers/odbc/odbc.json b/src/plugins/sqldrivers/odbc/odbc.json new file mode 100644 index 0000000000..41640776fb --- /dev/null +++ b/src/plugins/sqldrivers/odbc/odbc.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QODBC3", "QODBC" ] +} diff --git a/src/plugins/sqldrivers/odbc/odbc.pro b/src/plugins/sqldrivers/odbc/odbc.pro index 677eb6eedf..5ebd34fd17 100644 --- a/src/plugins/sqldrivers/odbc/odbc.pro +++ b/src/plugins/sqldrivers/odbc/odbc.pro @@ -1,6 +1,7 @@ TARGET = qsqlodbc SOURCES = main.cpp +OTHER_FILES += odbc.json include(../../../sql/drivers/odbc/qsql_odbc.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/psql/main.cpp b/src/plugins/sqldrivers/psql/main.cpp index db233b9486..117df561ab 100644 --- a/src/plugins/sqldrivers/psql/main.cpp +++ b/src/plugins/sqldrivers/psql/main.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE class QPSQLDriverPlugin : public QSqlDriverPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "psql.json") + public: QPSQLDriverPlugin(); @@ -76,7 +79,6 @@ QStringList QPSQLDriverPlugin::keys() const return l; } -Q_EXPORT_STATIC_PLUGIN(QPSQLDriverPlugin) -Q_EXPORT_PLUGIN2(qsqlpsql, QPSQLDriverPlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/sqldrivers/psql/psql.json b/src/plugins/sqldrivers/psql/psql.json new file mode 100644 index 0000000000..1579b99160 --- /dev/null +++ b/src/plugins/sqldrivers/psql/psql.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QPSQL7", "QPSQL" ] +} diff --git a/src/plugins/sqldrivers/psql/psql.pro b/src/plugins/sqldrivers/psql/psql.pro index 8276c0ae90..cb0d27e171 100644 --- a/src/plugins/sqldrivers/psql/psql.pro +++ b/src/plugins/sqldrivers/psql/psql.pro @@ -1,6 +1,7 @@ TARGET = qsqlpsql SOURCES = main.cpp +OTHER_FILES += psql.json include(../../../sql/drivers/psql/qsql_psql.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/sqlite/smain.cpp b/src/plugins/sqldrivers/sqlite/smain.cpp index 47cb08b75c..90ed72eedc 100644 --- a/src/plugins/sqldrivers/sqlite/smain.cpp +++ b/src/plugins/sqldrivers/sqlite/smain.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE class QSQLiteDriverPlugin : public QSqlDriverPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "sqlite.json") + public: QSQLiteDriverPlugin(); @@ -70,12 +73,9 @@ QSqlDriver* QSQLiteDriverPlugin::create(const QString &name) QStringList QSQLiteDriverPlugin::keys() const { - QStringList l; - l << QLatin1String("QSQLITE"); - return l; + return QStringList(QStringLiteral("QSQLITE")); } -Q_EXPORT_STATIC_PLUGIN(QSQLiteDriverPlugin) -Q_EXPORT_PLUGIN2(qsqlite, QSQLiteDriverPlugin) - QT_END_NAMESPACE + +#include "smain.moc" diff --git a/src/plugins/sqldrivers/sqlite/sqlite.json b/src/plugins/sqldrivers/sqlite/sqlite.json new file mode 100644 index 0000000000..3061d83145 --- /dev/null +++ b/src/plugins/sqldrivers/sqlite/sqlite.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QSQLITE" ] +} diff --git a/src/plugins/sqldrivers/sqlite/sqlite.pro b/src/plugins/sqldrivers/sqlite/sqlite.pro index f4c1671a4b..d1f4aa7233 100644 --- a/src/plugins/sqldrivers/sqlite/sqlite.pro +++ b/src/plugins/sqldrivers/sqlite/sqlite.pro @@ -1,6 +1,7 @@ TARGET = qsqlite SOURCES = smain.cpp +OTHER_FILES += sqlite.json include(../../../sql/drivers/sqlite/qsql_sqlite.pri) wince*: DEFINES += HAVE_LOCALTIME_S=0 diff --git a/src/plugins/sqldrivers/sqlite2/smain.cpp b/src/plugins/sqldrivers/sqlite2/smain.cpp index f16057c0a6..49cfd1cdfb 100644 --- a/src/plugins/sqldrivers/sqlite2/smain.cpp +++ b/src/plugins/sqldrivers/sqlite2/smain.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE class QSQLite2DriverPlugin : public QSqlDriverPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "sqlite2.json") + public: QSQLite2DriverPlugin(); @@ -70,12 +73,9 @@ QSqlDriver* QSQLite2DriverPlugin::create(const QString &name) QStringList QSQLite2DriverPlugin::keys() const { - QStringList l; - l << QLatin1String("QSQLITE2"); - return l; + return QStringList(QStringLiteral("QSQLITE2")); } -Q_EXPORT_STATIC_PLUGIN(QSQLite2DriverPlugin) -Q_EXPORT_PLUGIN2(qsqlite2, QSQLite2DriverPlugin) - QT_END_NAMESPACE + +#include "smain.moc" diff --git a/src/plugins/sqldrivers/sqlite2/sqlite2.json b/src/plugins/sqldrivers/sqlite2/sqlite2.json new file mode 100644 index 0000000000..47bdae4d60 --- /dev/null +++ b/src/plugins/sqldrivers/sqlite2/sqlite2.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QSQLITE2" ] +} diff --git a/src/plugins/sqldrivers/sqlite2/sqlite2.pro b/src/plugins/sqldrivers/sqlite2/sqlite2.pro index e6197b9906..1cbd31c3dc 100644 --- a/src/plugins/sqldrivers/sqlite2/sqlite2.pro +++ b/src/plugins/sqldrivers/sqlite2/sqlite2.pro @@ -1,6 +1,7 @@ TARGET = qsqlite2 SOURCES = smain.cpp +OTHER_FILES += sqlite2.json include(../../../sql/drivers/sqlite2/qsql_sqlite2.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/tds/main.cpp b/src/plugins/sqldrivers/tds/main.cpp index 97ca1c0ed0..c63f0e5606 100644 --- a/src/plugins/sqldrivers/tds/main.cpp +++ b/src/plugins/sqldrivers/tds/main.cpp @@ -54,6 +54,9 @@ QT_BEGIN_NAMESPACE class QTDSDriverPlugin : public QSqlDriverPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "tds.json") + public: QTDSDriverPlugin(); @@ -83,7 +86,6 @@ QStringList QTDSDriverPlugin::keys() const return l; } -Q_EXPORT_STATIC_PLUGIN(QTDSDriverPlugin) -Q_EXPORT_PLUGIN2(qsqltds, QTDSDriverPlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/sqldrivers/tds/tds.json b/src/plugins/sqldrivers/tds/tds.json new file mode 100644 index 0000000000..35955db9fa --- /dev/null +++ b/src/plugins/sqldrivers/tds/tds.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QTDS7", "QTDS" ] +} diff --git a/src/plugins/sqldrivers/tds/tds.pro b/src/plugins/sqldrivers/tds/tds.pro index b8e8ded321..9f7c2a193f 100644 --- a/src/plugins/sqldrivers/tds/tds.pro +++ b/src/plugins/sqldrivers/tds/tds.pro @@ -1,6 +1,7 @@ TARGET = qsqltds SOURCES = main.cpp +OTHER_FILES += tds.json include(../../../sql/drivers/tds/qsql_tds.pri) include(../qsqldriverbase.pri) From 88016d30a0bfb46910b6d45c8de9df93adc3af82 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 07:26:29 +0100 Subject: [PATCH 082/166] examples: compile w/o opengl Fixes remnants of an automated QtGui -> QtWidgets port. Change-Id: I31f63bdd6ae71aee8e70b20e24def30e0eafb725 Reviewed-by: Lars Knoll --- examples/animation/sub-attaq/mainwindow.cpp | 12 ++++++------ examples/animation/sub-attaq/sub-attaq.pro | 3 ++- examples/graphicsview/padnavigator/padnavigator.pro | 3 ++- examples/painting/affine/affine.pro | 3 ++- examples/painting/composition/composition.pro | 3 ++- examples/painting/deform/deform.pro | 3 ++- examples/painting/gradients/gradients.pro | 3 ++- examples/painting/pathstroke/pathstroke.pro | 3 ++- 8 files changed, 20 insertions(+), 13 deletions(-) diff --git a/examples/animation/sub-attaq/mainwindow.cpp b/examples/animation/sub-attaq/mainwindow.cpp index fd41cee6dc..70f0303177 100644 --- a/examples/animation/sub-attaq/mainwindow.cpp +++ b/examples/animation/sub-attaq/mainwindow.cpp @@ -45,13 +45,13 @@ //Qt #include +#include +#include +#include +#include -#ifdef QT_NO_OPENGL - #include - #include - #include -#else - #include +#ifndef QT_NO_OPENGL +# include #endif MainWindow::MainWindow() : QMainWindow(0) diff --git a/examples/animation/sub-attaq/sub-attaq.pro b/examples/animation/sub-attaq/sub-attaq.pro index e994694b54..6d9b3195ac 100644 --- a/examples/animation/sub-attaq/sub-attaq.pro +++ b/examples/animation/sub-attaq/sub-attaq.pro @@ -1,4 +1,5 @@ -contains(QT_CONFIG, opengl):QT += opengl widgets +QT += widgets +contains(QT_CONFIG, opengl):QT += opengl HEADERS += boat.h \ bomb.h \ mainwindow.h \ diff --git a/examples/graphicsview/padnavigator/padnavigator.pro b/examples/graphicsview/padnavigator/padnavigator.pro index 2c1d043a92..4b9733bb9b 100644 --- a/examples/graphicsview/padnavigator/padnavigator.pro +++ b/examples/graphicsview/padnavigator/padnavigator.pro @@ -16,7 +16,8 @@ RESOURCES += \ FORMS += \ form.ui -contains(QT_CONFIG, opengl):QT += opengl widgets +QT += widgets +contains(QT_CONFIG, opengl):QT += opengl # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/padnavigator diff --git a/examples/painting/affine/affine.pro b/examples/painting/affine/affine.pro index 80f966e59d..0977ea1c5b 100644 --- a/examples/painting/affine/affine.pro +++ b/examples/painting/affine/affine.pro @@ -3,8 +3,9 @@ HEADERS += xform.h contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) { DEFINES += QT_OPENGL_SUPPORT - QT += opengl widgets + QT += opengl } +QT += widgets SHARED_FOLDER = ../shared diff --git a/examples/painting/composition/composition.pro b/examples/painting/composition/composition.pro index 8641109cc0..eb63d0c47a 100644 --- a/examples/painting/composition/composition.pro +++ b/examples/painting/composition/composition.pro @@ -8,8 +8,9 @@ include($$SHARED_FOLDER/shared.pri) RESOURCES += composition.qrc contains(QT_CONFIG, opengl) { DEFINES += QT_OPENGL_SUPPORT - QT += opengl widgets + QT += opengl } +QT += widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/composition diff --git a/examples/painting/deform/deform.pro b/examples/painting/deform/deform.pro index bd704507c5..527133e7e5 100644 --- a/examples/painting/deform/deform.pro +++ b/examples/painting/deform/deform.pro @@ -9,8 +9,9 @@ RESOURCES += deform.qrc contains(QT_CONFIG, opengl) { DEFINES += QT_OPENGL_SUPPORT - QT += opengl widgets + QT += opengl } +QT += widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/deform diff --git a/examples/painting/gradients/gradients.pro b/examples/painting/gradients/gradients.pro index 4d3efe1255..4362d283ee 100644 --- a/examples/painting/gradients/gradients.pro +++ b/examples/painting/gradients/gradients.pro @@ -8,8 +8,9 @@ include($$SHARED_FOLDER/shared.pri) RESOURCES += gradients.qrc contains(QT_CONFIG, opengl) { DEFINES += QT_OPENGL_SUPPORT - QT += opengl widgets + QT += opengl } +QT += widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/gradients diff --git a/examples/painting/pathstroke/pathstroke.pro b/examples/painting/pathstroke/pathstroke.pro index 60a5cd75ca..916866d1f2 100644 --- a/examples/painting/pathstroke/pathstroke.pro +++ b/examples/painting/pathstroke/pathstroke.pro @@ -9,8 +9,9 @@ RESOURCES += pathstroke.qrc contains(QT_CONFIG, opengl) { DEFINES += QT_OPENGL_SUPPORT - QT += opengl widgets + QT += opengl } +QT += widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/pathstroke From 77772f21deeadde6eee0a51cb87bf5ee07f67966 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 12:24:49 +0100 Subject: [PATCH 083/166] compile fix: parse under C++11 See d94ab97b7741de7c73d4d203b9cca7bd150d581f for details. Change-Id: Ifc015be6575bd8f469f257d71fbbf79e07226729 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll Reviewed-by: Denis Dzyubenko --- tests/auto/corelib/json/tst_qtjson.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 4edbd14305..f5b4f17732 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -1208,7 +1208,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"foo"INVALID_UNICODE"bar\"]"; + QByteArray json = "[\n \"foo" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1224,7 +1224,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"c"UNICODE_DJE"a\\u12\"]"; + QByteArray json = "[\n \"c" UNICODE_DJE "a\\u12\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringEscapeSequence); @@ -1232,7 +1232,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"c"UNICODE_DJE"a"INVALID_UNICODE"bar\"]"; + QByteArray json = "[\n \"c" UNICODE_DJE "a" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1240,7 +1240,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"c"UNICODE_DJE"a ]"; + QByteArray json = "[\n \"c" UNICODE_DJE "a ]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::EndOfString); @@ -1381,7 +1381,7 @@ void TestQtJson::parseStrings() "abc\\rabc", "abc\\tabc", "abc\\u0019abc", - "abc"UNICODE_DJE"abc", + "abc" UNICODE_DJE "abc", }; int size = sizeof(strings)/sizeof(const char *); @@ -1407,7 +1407,7 @@ void TestQtJson::parseStrings() }; Pairs pairs [] = { { "abc\\/abc", "abc/abc" }, - { "abc\\u0402abc", "abc"UNICODE_DJE"abc" }, + { "abc\\u0402abc", "abc" UNICODE_DJE "abc" }, { "abc\\u0065abc", "abceabc" } }; size = sizeof(pairs)/sizeof(Pairs); From bf66eebbc28b1f405a49a68d3f6c341d433159ea Mon Sep 17 00:00:00 2001 From: jian liang Date: Sat, 18 Feb 2012 08:43:29 +0800 Subject: [PATCH 084/166] Fix to exit of adopted thread watcher in Windows Don't register the thread handle and QThread object pointer to watch list for adopted thread watcher thread in Windows. Otherwise the watcher thread will never exit and can't clean up its own QThreadData and QAdoptedThread object. Task-number: QTBUG-23961 Change-Id: Ia84326cf3cfd978d2b003ccc1bb6861db950e899 Reviewed-by: Friedemann Kleint Reviewed-by: Joerg Bornemann --- src/corelib/thread/qthread_win.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index afcfb2c949..38fb6ef8dd 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread); -void qt_adopted_thread_watcher_function(void *); +DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID); static DWORD qt_current_thread_data_tls_index = TLS_OUT_OF_INDEXES; void qt_create_tls() @@ -147,7 +147,7 @@ void QAdoptedThread::init() static QVector qt_adopted_thread_handles; static QVector qt_adopted_qthreads; static QMutex qt_adopted_thread_watcher_mutex; -static HANDLE qt_adopted_thread_watcher_handle = 0; +static DWORD qt_adopted_thread_watcher_id = 0; static HANDLE qt_adopted_thread_wakeup = 0; /*! \internal @@ -158,18 +158,25 @@ static HANDLE qt_adopted_thread_wakeup = 0; void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread) { QMutexLocker lock(&qt_adopted_thread_watcher_mutex); + + if (GetCurrentThreadId() == qt_adopted_thread_watcher_id) { +#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600)) + CloseHandle(adoptedThreadHandle); +#endif + return; + } + qt_adopted_thread_handles.append(adoptedThreadHandle); qt_adopted_qthreads.append(qthread); // Start watcher thread if it is not already running. - if (qt_adopted_thread_watcher_handle == 0) { + if (qt_adopted_thread_watcher_id == 0) { if (qt_adopted_thread_wakeup == 0) { qt_adopted_thread_wakeup = CreateEvent(0, false, false, 0); qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup); } - qt_adopted_thread_watcher_handle = - (HANDLE)_beginthread(qt_adopted_thread_watcher_function, 0, NULL); + CreateThread(0, 0, qt_adopted_thread_watcher_function, 0, 0, &qt_adopted_thread_watcher_id); } else { SetEvent(qt_adopted_thread_wakeup); } @@ -180,13 +187,13 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread) When this happens it derefs the QThreadData for the adopted thread to make sure it gets cleaned up properly. */ -void qt_adopted_thread_watcher_function(void *) +DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID) { forever { qt_adopted_thread_watcher_mutex.lock(); if (qt_adopted_thread_handles.count() == 1) { - qt_adopted_thread_watcher_handle = 0; + qt_adopted_thread_watcher_id = 0; qt_adopted_thread_watcher_mutex.unlock(); break; } @@ -244,6 +251,12 @@ void qt_adopted_thread_watcher_function(void *) qt_adopted_qthreads.remove(qthreadIndex); } } + + QThreadData *threadData = reinterpret_cast(TlsGetValue(qt_current_thread_data_tls_index)); + if (threadData) + threadData->deref(); + + return 0; } #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) From 6ee0135e9d43bfd56d948d088781dc014ef39aa1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 20 Feb 2012 15:16:25 +0100 Subject: [PATCH 085/166] QFutureWatcher: Make constructors explicit Change-Id: I363665725869993b10985004c1c6441ded435dbc Reviewed-by: Bradley T. Hughes --- src/concurrent/qfuturewatcher.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/concurrent/qfuturewatcher.h b/src/concurrent/qfuturewatcher.h index 11dab42174..439a25d844 100644 --- a/src/concurrent/qfuturewatcher.h +++ b/src/concurrent/qfuturewatcher.h @@ -63,7 +63,7 @@ class Q_CONCURRENT_EXPORT QFutureWatcherBase : public QObject Q_DECLARE_PRIVATE(QFutureWatcherBase) public: - QFutureWatcherBase(QObject *parent = 0); + explicit QFutureWatcherBase(QObject *parent = 0); int progressValue() const; int progressMinimum() const; @@ -119,7 +119,7 @@ template class QFutureWatcher : public QFutureWatcherBase { public: - QFutureWatcher(QObject *_parent = 0) + explicit QFutureWatcher(QObject *_parent = 0) : QFutureWatcherBase(_parent) { } ~QFutureWatcher() @@ -189,7 +189,7 @@ template <> class QFutureWatcher : public QFutureWatcherBase { public: - QFutureWatcher(QObject *_parent = 0) + explicit QFutureWatcher(QObject *_parent = 0) : QFutureWatcherBase(_parent) { } ~QFutureWatcher() From e430ddfafcc6e8fa9fecb9c816908c3edce08d77 Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Thu, 23 Feb 2012 16:50:29 +0200 Subject: [PATCH 086/166] Implement isSharing() and isValid() methods for QCocoaGLContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shared resources may have been used when initializing NSOpenGLContext but QCocoaGLContext did not implement isSharing(). This caused default implementation to return false always and therefore shared resource test case failed. Implemented also another missing method, isValid(). Task-number: QTBUG-23061 Change-Id: Ia912450035b584ea90a02a7d88d6ae531c3cbadf Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaglcontext.h | 4 ++++ .../platforms/cocoa/qcocoaglcontext.mm | 21 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index b8582022f6..4f80511f61 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -71,10 +71,14 @@ public: static NSOpenGLPixelFormat *createNSOpenGLPixelFormat(const QSurfaceFormat &format); NSOpenGLContext *nsOpenGLContext() const; + bool isSharing() const; + bool isValid() const; + private: void setActiveWindow(QWindow *window); NSOpenGLContext *m_context; + NSOpenGLContext *m_shareContext; QSurfaceFormat m_format; QWeakPointer m_currentWindow; }; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 960163d727..637678c19e 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -51,13 +51,19 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share) : m_format(format) { - QCocoaAutoReleasePool pool; // For the SG Canvas render thread. + QCocoaAutoReleasePool pool; // For the SG Canvas render thread NSOpenGLPixelFormat *pixelFormat = static_cast (qcgl_createNSOpenGLPixelFormat(format)); - NSOpenGLContext *actualShare = share ? static_cast(share)->m_context : 0; + m_shareContext = share ? static_cast(share)->nsOpenGLContext() : nil; m_context = [NSOpenGLContext alloc]; - [m_context initWithFormat:pixelFormat shareContext:actualShare]; + [m_context initWithFormat:pixelFormat shareContext:m_shareContext]; + + if (!m_context && m_shareContext) { + // try without shared context + m_shareContext = nil; + [m_context initWithFormat:pixelFormat shareContext:nil]; + } const GLint interval = 1; [m_context setValues:&interval forParameter:NSOpenGLCPSwapInterval]; @@ -139,3 +145,12 @@ NSOpenGLContext *QCocoaGLContext::nsOpenGLContext() const return m_context; } +bool QCocoaGLContext::isValid() const +{ + return m_context != nil; +} + +bool QCocoaGLContext::isSharing() const +{ + return m_shareContext != nil; +} From 71660ee5652f1509ff9632a45e4aa1bc0040387d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 11:07:52 +0100 Subject: [PATCH 087/166] Fix compilation without QT_DEPRECATED_SINCE QAbstractItemModel::reset() is deprecated Change-Id: I2d9aa9fade1660df14945ca11123341fce504050 Reviewed-by: Stephen Kelly --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index ebd1ce2a70..b7ef69423f 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -883,9 +883,10 @@ void QSortFilterProxyModelPrivate::source_items_removed( if (proxy_count > source_to_proxy.size()) { // mapping is in an inconsistent state -- redo the whole mapping qWarning("QSortFilterProxyModel: inconsistent changes reported by source model"); - remove_from_mapping(source_parent); Q_Q(QSortFilterProxyModel); - q->reset(); + q->beginResetModel(); + remove_from_mapping(source_parent); + q->endResetModel(); return; } From 1118f28b86993282b9fcf78e938bff5ef2017a09 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 24 Feb 2012 15:18:15 +0100 Subject: [PATCH 088/166] Fix a crash in QSystemLocalePrivate::uiLanguages(). Use the correct calling convention. Discovered by the mimetype test in Qt 5. Change-Id: I79b97325dd69466885a64c238935107bf14e9a0d Reviewed-by: Oswald Buddenhagen Reviewed-by: Marius Storm-Olsen (cherry picked from commit bc6e35d94325f4b18caec7ce0824c5beab95cdd7) Reviewed-by: Friedemann Kleint --- src/corelib/tools/qlocale_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index cd9fffc7a5..e787f2fa2a 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -525,7 +525,7 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS QVariant QSystemLocalePrivate::uiLanguages() { if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) { - typedef BOOL (*GetUserPreferredUILanguagesFunc) ( + typedef BOOL (WINAPI *GetUserPreferredUILanguagesFunc) ( DWORD dwFlags, PULONG pulNumLanguages, PWSTR pwszLanguagesBuffer, From e0acf6504356f14a6352b16ffed7b59453914863 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 24 Feb 2012 14:56:44 +0000 Subject: [PATCH 089/166] configure - fix detection of MSVC compiler in x64 x86 processes get redirected to the 32 bit area of the registry, while 64 bit processes access the registry in raw form. Added the registry paths for 64 bit processes to see the 32 bit registry keys for MS visual studio. (Wow6432Node) This problem was revealed when we stopped including configure.exe as a binary checkin to git. Running configure in an x64 compiler environment results in creating an x64 configure.exe Change-Id: I5e3e51ddbf20ccc65abf1833bf23ee5670bd973e Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- tools/configure/environment.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index 80542e7697..ae378f6b41 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -76,9 +76,13 @@ struct CompilerInfo{ {CC_MINGW, "MinGW (Minimalist GNU for Windows)", 0, "g++.exe"}, {CC_INTEL, "Intel(R) C++ Compiler for 32-bit applications", 0, "icl.exe"}, // xilink.exe, xilink5.exe, xilink6.exe, xilib.exe {CC_NET2003, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2003 (7.1)", "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir", "cl.exe"}, // link.exe, lib.exe + {CC_NET2003, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2003 (7.1)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir", "cl.exe"}, // link.exe, lib.exe {CC_NET2005, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2005 (8.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\8.0", "cl.exe"}, // link.exe, lib.exe + {CC_NET2005, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2005 (8.0)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7\\8.0", "cl.exe"}, // link.exe, lib.exe {CC_NET2008, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2008 (9.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\9.0", "cl.exe"}, // link.exe, lib.exe + {CC_NET2008, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2008 (9.0)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7\\9.0", "cl.exe"}, // link.exe, lib.exe {CC_NET2010, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2010 (10.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\10.0", "cl.exe"}, // link.exe, lib.exe + {CC_NET2010, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2010 (10.0)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7\\10.0", "cl.exe"}, // link.exe, lib.exe {CC_UNKNOWN, "Unknown", 0, 0}, }; From f5a03eec2d0f12917572bfa9cb48b4145768480a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 25 Feb 2012 13:48:49 +0100 Subject: [PATCH 090/166] process variable assignments with tabs as well Change-Id: If3caa4094aa9d8caefc9829bfea44426d59477d1 Reviewed-by: Thiago Macieira --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 5df1edf6a3..f4743c2753 100755 --- a/configure +++ b/configure @@ -134,7 +134,7 @@ BEGIN { values["LITERAL_WHITESPACE"] = " " values["LITERAL_DOLLAR"] = "$" } -/^[_A-Z0-9.]+ *\+?=/ { +/^[_A-Z0-9.]+[ \t]*\+?=/ { valStart = index($0, "=") + 1 append = 0 From bc8bc6018e8ad34512d3de3265f7ad34f91f59ff Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Fri, 24 Feb 2012 22:36:59 +1100 Subject: [PATCH 091/166] Fix MinGW configure bootstrap Makefile.mingw was using the test command which requires sh.exe. This adds support for bootstrap using cmd.exe instead. Change-Id: Ieb67843170d2745ce119cc8feaa5433aa82fd7d7 Reviewed-by: Oswald Buddenhagen --- tools/configure/Makefile.mingw | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tools/configure/Makefile.mingw b/tools/configure/Makefile.mingw index 5951cb4e92..086dd71a85 100644 --- a/tools/configure/Makefile.mingw +++ b/tools/configure/Makefile.mingw @@ -74,10 +74,38 @@ $(TARGET): $(OBJECTS) $(OBJECTS): $(PCH) -CHK_DIR_EXISTS = test -d -MKDIR=mkdir -p +# SHELL is the full path of sh.exe, unless +# 1) it is found in the current directory +# 2) it is not found at all +# 3) it is overridden on the command line with an existing file +# ... otherwise it is always sh.exe. Specifically, SHELL from the +# environment has no effect. +# +# This check will fail if SHELL is explicitly set to a not +# sh-compatible shell. This is not a problem, because configure.bat +# will not do that. +ifeq ($(SHELL), sh.exe) + ifeq ($(wildcard $(CURDIR)/sh.exe), ) + SH = 0 + else + SH = 1 + endif +else + SH = 1 +endif + +ifeq ($(SH), 1) + CHK_DIR_EXISTS = test -d + CHK_DIR_EXISTS_GLUE = || + MKDIR = mkdir -p +else + CHK_DIR_EXISTS = if not exist + CHK_DIR_EXISTS_GLUE = + MKDIR = md +endif + $(PCH): $(CONFSRC)/configure_pch.h - @$(CHK_DIR_EXISTS) $(RAW_PCH).gch || $(MKDIR) $(RAW_PCH).gch + @$(CHK_DIR_EXISTS) $(RAW_PCH).gch $(CHK_DIR_EXISTS_GLUE) $(MKDIR) $(RAW_PCH).gch $(CXX) -x c++-header -c $(CXXFLAGS_BARE) -o $@ $< VPATH = $(CONFSRC):$(TOOLSRC)/shared/windows:$(CORESRC)/global:$(CORESRC)/kernel:$(CORESRC)/tools:$(CORESRC)/codecs:$(CORESRC)/io:$(CORESRC)/xml:$(CORESRC)/plugin From d91add71e79dcae45f9cac02f6d3d542afee899c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Feb 2012 19:19:32 +0100 Subject: [PATCH 092/166] QSslError: fix wrong #endif placement This would break a namespaced Qt when QT_NO_DEBUG_STREAM was in effect. Unlikely to hit, but nevertheless fixworthy. Change-Id: Ie2a4cf4334a6a610c84233ab1ca89b928386c91a Reviewed-by: Richard J. Moore --- src/network/ssl/qsslerror.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp index acb8d70d09..224ef9db8f 100644 --- a/src/network/ssl/qsslerror.cpp +++ b/src/network/ssl/qsslerror.cpp @@ -95,9 +95,9 @@ #include "qsslsocket.h" #ifndef QT_NO_DEBUG_STREAM #include +#endif QT_BEGIN_NAMESPACE -#endif class QSslErrorPrivate { From ffa072655df50ba0f6d21d0696750f06abf20e4c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 19:23:06 +0100 Subject: [PATCH 093/166] Fix compilation of examples with QStringBuilder In sub-attack an interview, one can't make two implicit conversions at once, so explicitly convert to the right type. The change in the torrent example is required because of https://codereview.qt-project.org/16168 (commit 9491272) But in that case, using a QByteArray is better anyway. Change-Id: Ieed22ac7f0d700d5ba5d1e70af3db4dd6c139c8f Reviewed-by: Lars Knoll --- examples/animation/sub-attaq/pixmapitem.cpp | 4 ++-- examples/itemviews/interview/model.cpp | 2 +- examples/network/torrent/trackerclient.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/animation/sub-attaq/pixmapitem.cpp b/examples/animation/sub-attaq/pixmapitem.cpp index b2061dc06c..077151d708 100644 --- a/examples/animation/sub-attaq/pixmapitem.cpp +++ b/examples/animation/sub-attaq/pixmapitem.cpp @@ -48,9 +48,9 @@ PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsObject(parent) { if (mode == GraphicsScene::Big) - pix = ":/big/" + fileName; + pix = QPixmap(QStringLiteral(":/big/") + fileName); else - pix = ":/small/" + fileName; + pix = QPixmap(QStringLiteral(":/small/") + fileName); } PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) : QGraphicsObject(), pix(fileName) diff --git a/examples/itemviews/interview/model.cpp b/examples/itemviews/interview/model.cpp index 966dc7bfba..3b20f91ed6 100644 --- a/examples/itemviews/interview/model.cpp +++ b/examples/itemviews/interview/model.cpp @@ -95,7 +95,7 @@ QVariant Model::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); if (role == Qt::DisplayRole) - return "Item " + QString::number(index.row()) + ":" + QString::number(index.column()); + return QVariant("Item " + QString::number(index.row()) + ":" + QString::number(index.column())); if (role == Qt::DecorationRole) { if (index.column() == 0) return iconProvider.icon(QFileIconProvider::Folder); diff --git a/examples/network/torrent/trackerclient.cpp b/examples/network/torrent/trackerclient.cpp index 38f9eaf9fd..12f9504b7b 100644 --- a/examples/network/torrent/trackerclient.cpp +++ b/examples/network/torrent/trackerclient.cpp @@ -108,10 +108,10 @@ void TrackerClient::fetchPeerList() // Percent encode the hash QByteArray infoHash = torrentDownloader->infoHash(); - QString encodedSum; + QByteArray encodedSum; for (int i = 0; i < infoHash.size(); ++i) { encodedSum += '%'; - encodedSum += QString::number(infoHash[i], 16).right(2).rightJustified(2, '0'); + encodedSum += QByteArray::number(infoHash[i], 16).right(2).rightJustified(2, '0'); } bool seeding = (torrentDownloader->state() == TorrentClient::Seeding); From 4f4491e0b682e705cc958829a1d122298990dac7 Mon Sep 17 00:00:00 2001 From: ABBAPOH Date: Sun, 26 Feb 2012 11:48:53 +0400 Subject: [PATCH 094/166] Fix doc according to current method signature Change-Id: I23d0f7a88f4c092c1e7cd2742fdf6e6f68ad485a Reviewed-by: David Faure --- src/corelib/mimetypes/qmimetype.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index 77592880a0..4099487f9b 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -300,7 +300,6 @@ QString QMimeType::name() const Returns the description of the MIME type to be displayed on user interfaces. The system language (QLocale::system().name()) is used to select the appropriate translation. - Another language can be specified by setting the \a localeName argument. */ QString QMimeType::comment() const { From 5cc1a87250a45068e3ed4cf3e83611ea79b9e37a Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 26 Feb 2012 11:00:44 +0100 Subject: [PATCH 095/166] Remove usage of deprecated QRect::unite Change-Id: I1920da995fde6ff2a8b2e3facddeee6e3c17b44c Reviewed-by: Frederik Gladhorn --- src/widgets/itemviews/qcolumnview.cpp | 2 +- src/widgets/widgets/qworkspace.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index 5dec62acc2..6758aeb337 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -481,7 +481,7 @@ QRegion QColumnView::visualRegionForSelection(const QItemSelection &selection) c QRegion firstRegion = visualRect(firstIdx); QRegion lastRegion = visualRect(lastIdx); - return firstRegion.unite(lastRegion); + return firstRegion.united(lastRegion); } /*! diff --git a/src/widgets/widgets/qworkspace.cpp b/src/widgets/widgets/qworkspace.cpp index 80f0a7e44a..0031a71ccd 100644 --- a/src/widgets/widgets/qworkspace.cpp +++ b/src/widgets/widgets/qworkspace.cpp @@ -3204,7 +3204,7 @@ QRect QWorkspacePrivate::updateWorkspace() QWorkspaceChild *child = *it; ++it; if (!child->isHidden()) - r = r.unite(child->geometry()); + r = r.united(child->geometry()); } vbar->blockSignals(true); hbar->blockSignals(true); From 7679fcfeb504ac9641ce331704dbe669ea4b329d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 21 Feb 2012 13:41:53 +0100 Subject: [PATCH 096/166] QPrinterInfo: remove unused variable Change-Id: I1a3db07e7fe25066a6b13ca41854566ccb1298df Reviewed-by: Olivier Goffart --- src/printsupport/kernel/qprinterinfo_unix.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/printsupport/kernel/qprinterinfo_unix.cpp b/src/printsupport/kernel/qprinterinfo_unix.cpp index fba3b4d0a3..ae0885c0f4 100644 --- a/src/printsupport/kernel/qprinterinfo_unix.cpp +++ b/src/printsupport/kernel/qprinterinfo_unix.cpp @@ -587,7 +587,6 @@ void qt_parseEtcLpMember(QList *printers) if (dirs.isEmpty()) return; - QString tmp; for (int i = 0; i < dirs.size(); ++i) { QFileInfo printer = dirs.at(i); // I haven't found any real documentation, so I'm guessing that From 47525e689694df0eec0a2f03e8bf67eed91da295 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 26 Feb 2012 03:11:19 +0000 Subject: [PATCH 097/166] uic: remove unused QRegExp #includes QRegExp is not used, so they're unnecessary. Change-Id: I3480bcbe013a0bf15e2ee4fa30862fe035820eea Reviewed-by: Thiago Macieira --- src/tools/uic/driver.cpp | 1 - src/tools/uic/uic.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp index 16dc12f277..ea1d4f21f3 100644 --- a/src/tools/uic/driver.cpp +++ b/src/tools/uic/driver.cpp @@ -43,7 +43,6 @@ #include "uic.h" #include "ui4.h" -#include #include #include diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp index 2de3352cfc..4ae04149e8 100644 --- a/src/tools/uic/uic.cpp +++ b/src/tools/uic/uic.cpp @@ -58,7 +58,6 @@ #include #include -#include #include #include From 3e4a3bafb639f2ec77d44c80662157745b68f546 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2012 15:18:27 +0100 Subject: [PATCH 098/166] QFixed{,Size}: reformulate some functions in a constexpr-friendly way The main change is the addition of a new constructor that passes its argument into 'val' verbatim. In order to disambiguate it from the existing QFixed(int) constructor, it takes a second 'int' argument. This is too ugly for public API, so it's private, and only used by static QFixed fromFixed(int), which is the existing named constructor with the same semantics. The rest of the changes simply reformulate their operations in terms of fromFixed(). This makes them ready to be constexpr'ed. Change-Id: I2a3813d62bd4124064755de6b00526a60fc82c1d Reviewed-by: Olivier Goffart --- src/gui/painting/qfixed_p.h | 47 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/gui/painting/qfixed_p.h b/src/gui/painting/qfixed_p.h index d30328b0fa..95fb6893b3 100644 --- a/src/gui/painting/qfixed_p.h +++ b/src/gui/painting/qfixed_p.h @@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE struct QFixed { +private: + QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation public: QFixed() : val(0) {} QFixed(int i) : val(i<<6) {} @@ -67,8 +69,8 @@ public: QFixed &operator=(int i) { val = (i<<6); return *this; } QFixed &operator=(long i) { val = (i<<6); return *this; } - static QFixed fromReal(qreal r) { QFixed f; f.val = (int)(r*qreal(64)); return f; } - static QFixed fromFixed(int fixed) { QFixed f; f.val = fixed; return f; } + static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); } + static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor inline int value() const { return val; } inline void setValue(int value) { val = value; } @@ -77,23 +79,23 @@ public: inline qreal toReal() const { return ((qreal)val)/(qreal)64; } inline int truncate() const { return val>>6; } - inline QFixed round() const { QFixed f; f.val = ((val)+32) & -64; return f; } - inline QFixed floor() const { QFixed f; f.val = (val) & -64; return f; } - inline QFixed ceil() const { QFixed f; f.val = (val+63) & -64; return f; } + inline QFixed round() const { return fromFixed(((val)+32) & -64); } + inline QFixed floor() const { return fromFixed((val) & -64); } + inline QFixed ceil() const { return fromFixed((val+63) & -64); } - inline QFixed operator+(int i) const { QFixed f; f.val = (val + (i<<6)); return f; } - inline QFixed operator+(uint i) const { QFixed f; f.val = (val + (i<<6)); return f; } - inline QFixed operator+(const QFixed &other) const { QFixed f; f.val = (val + other.val); return f; } + inline QFixed operator+(int i) const { return fromFixed((val + (i<<6))); } + inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); } + inline QFixed operator+(const QFixed &other) const { return fromFixed((val + other.val)); } inline QFixed &operator+=(int i) { val += (i<<6); return *this; } inline QFixed &operator+=(uint i) { val += (i<<6); return *this; } inline QFixed &operator+=(const QFixed &other) { val += other.val; return *this; } - inline QFixed operator-(int i) const { QFixed f; f.val = (val - (i<<6)); return f; } - inline QFixed operator-(uint i) const { QFixed f; f.val = (val - (i<<6)); return f; } - inline QFixed operator-(const QFixed &other) const { QFixed f; f.val = (val - other.val); return f; } + inline QFixed operator-(int i) const { return fromFixed((val - (i<<6))); } + inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); } + inline QFixed operator-(const QFixed &other) const { return fromFixed((val - other.val)); } inline QFixed &operator-=(int i) { val -= (i<<6); return *this; } inline QFixed &operator-=(uint i) { val -= (i<<6); return *this; } inline QFixed &operator-=(const QFixed &other) { val -= other.val; return *this; } - inline QFixed operator-() const { QFixed f; f.val = -val; return f; } + inline QFixed operator-() const { return fromFixed(-val); } inline bool operator==(const QFixed &other) const { return val == other.val; } inline bool operator!=(const QFixed &other) const { return val != other.val; } @@ -120,7 +122,7 @@ public: } return *this; } - inline QFixed operator/(int d) const { QFixed f; f.val = val/d; return f; } + inline QFixed operator/(int d) const { return fromFixed(val/d); } inline QFixed operator/(QFixed b) const { QFixed f = *this; return (f /= b); } inline QFixed operator>>(int d) const { QFixed f = *this; f.val >>= d; return f; } inline QFixed &operator*=(int i) { val *= i; return *this; } @@ -136,21 +138,21 @@ public: val = neg ? -res : res; return *this; } - inline QFixed operator*(int i) const { QFixed f = *this; return (f *= i); } - inline QFixed operator*(uint i) const { QFixed f = *this; return (f *= i); } + inline QFixed operator*(int i) const { return fromFixed(val * i); } + inline QFixed operator*(uint i) const { return fromFixed(val * i); } inline QFixed operator*(const QFixed &o) const { QFixed f = *this; return (f *= o); } private: QFixed(qreal i) : val((int)(i*qreal(64))) {} QFixed &operator=(qreal i) { val = (int)(i*qreal(64)); return *this; } - inline QFixed operator+(qreal i) const { QFixed f; f.val = (val + (int)(i*qreal(64))); return f; } + inline QFixed operator+(qreal i) const { return fromFixed((val + (int)(i*qreal(64)))); } inline QFixed &operator+=(qreal i) { val += (int)(i*64); return *this; } - inline QFixed operator-(qreal i) const { QFixed f; f.val = (val - (int)(i*qreal(64))); return f; } + inline QFixed operator-(qreal i) const { return fromFixed((val - (int)(i*qreal(64)))); } inline QFixed &operator-=(qreal i) { val -= (int)(i*64); return *this; } inline QFixed &operator/=(qreal r) { val = (int)(val/r); return *this; } - inline QFixed operator/(qreal d) const { QFixed f; f.val = (int)(val/d); return f; } + inline QFixed operator/(qreal d) const { return fromFixed((int)(val/d)); } inline QFixed &operator*=(qreal d) { val = (int) (val*d); return *this; } - inline QFixed operator*(qreal d) const { QFixed f = *this; return (f *= d); } + inline QFixed operator*(qreal d) const { return fromFixed((int) (val*d)); } int val; }; Q_DECLARE_TYPEINFO(QFixed, Q_PRIMITIVE_TYPE); @@ -206,12 +208,11 @@ inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2) struct QFixedSize { QFixed width; QFixed height; + QFixedSize() {} + QFixedSize(QFixed _width, QFixed _height) : width(_width), height(_height) {} QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); } static QFixedSize fromSizeF(const QSizeF &s) { - QFixedSize size; - size.width = QFixed::fromReal(s.width()); - size.height = QFixed::fromReal(s.height()); - return size; + return QFixedSize(QFixed::fromReal(s.width()), QFixed::fromReal(s.height())); } }; Q_DECLARE_TYPEINFO(QFixedSize, Q_PRIMITIVE_TYPE); From 5f65d8ea25dcb5c4165890ad957a7b8869caa180 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2012 15:27:40 +0100 Subject: [PATCH 099/166] QFixed: make constexpr Make most QFixed{,Size,Point} members constexpr. See f3141c58badbd2da9eb42021e9704742c3e52a9b for rationale. Change-Id: I0b44f59bb768e1f79c57e1c9a0dc67afb515e03f Reviewed-by: Olivier Goffart --- src/gui/painting/qfixed_p.h | 132 ++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/gui/painting/qfixed_p.h b/src/gui/painting/qfixed_p.h index 95fb6893b3..44772a4bb5 100644 --- a/src/gui/painting/qfixed_p.h +++ b/src/gui/painting/qfixed_p.h @@ -61,49 +61,49 @@ QT_BEGIN_NAMESPACE struct QFixed { private: - QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation + Q_DECL_CONSTEXPR QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation public: - QFixed() : val(0) {} - QFixed(int i) : val(i<<6) {} - QFixed(long i) : val(i<<6) {} + Q_DECL_CONSTEXPR QFixed() : val(0) {} + Q_DECL_CONSTEXPR QFixed(int i) : val(i<<6) {} + Q_DECL_CONSTEXPR QFixed(long i) : val(i<<6) {} QFixed &operator=(int i) { val = (i<<6); return *this; } QFixed &operator=(long i) { val = (i<<6); return *this; } - static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); } - static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor + Q_DECL_CONSTEXPR static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); } + Q_DECL_CONSTEXPR static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor - inline int value() const { return val; } + Q_DECL_CONSTEXPR inline int value() const { return val; } inline void setValue(int value) { val = value; } - inline int toInt() const { return (((val)+32) & -64)>>6; } - inline qreal toReal() const { return ((qreal)val)/(qreal)64; } + Q_DECL_CONSTEXPR inline int toInt() const { return (((val)+32) & -64)>>6; } + Q_DECL_CONSTEXPR inline qreal toReal() const { return ((qreal)val)/(qreal)64; } - inline int truncate() const { return val>>6; } - inline QFixed round() const { return fromFixed(((val)+32) & -64); } - inline QFixed floor() const { return fromFixed((val) & -64); } - inline QFixed ceil() const { return fromFixed((val+63) & -64); } + Q_DECL_CONSTEXPR inline int truncate() const { return val>>6; } + Q_DECL_CONSTEXPR inline QFixed round() const { return fromFixed(((val)+32) & -64); } + Q_DECL_CONSTEXPR inline QFixed floor() const { return fromFixed((val) & -64); } + Q_DECL_CONSTEXPR inline QFixed ceil() const { return fromFixed((val+63) & -64); } - inline QFixed operator+(int i) const { return fromFixed((val + (i<<6))); } - inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); } - inline QFixed operator+(const QFixed &other) const { return fromFixed((val + other.val)); } + Q_DECL_CONSTEXPR inline QFixed operator+(int i) const { return fromFixed((val + (i<<6))); } + Q_DECL_CONSTEXPR inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); } + Q_DECL_CONSTEXPR inline QFixed operator+(const QFixed &other) const { return fromFixed((val + other.val)); } inline QFixed &operator+=(int i) { val += (i<<6); return *this; } inline QFixed &operator+=(uint i) { val += (i<<6); return *this; } inline QFixed &operator+=(const QFixed &other) { val += other.val; return *this; } - inline QFixed operator-(int i) const { return fromFixed((val - (i<<6))); } - inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); } - inline QFixed operator-(const QFixed &other) const { return fromFixed((val - other.val)); } + Q_DECL_CONSTEXPR inline QFixed operator-(int i) const { return fromFixed((val - (i<<6))); } + Q_DECL_CONSTEXPR inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); } + Q_DECL_CONSTEXPR inline QFixed operator-(const QFixed &other) const { return fromFixed((val - other.val)); } inline QFixed &operator-=(int i) { val -= (i<<6); return *this; } inline QFixed &operator-=(uint i) { val -= (i<<6); return *this; } inline QFixed &operator-=(const QFixed &other) { val -= other.val; return *this; } - inline QFixed operator-() const { return fromFixed(-val); } + Q_DECL_CONSTEXPR inline QFixed operator-() const { return fromFixed(-val); } - inline bool operator==(const QFixed &other) const { return val == other.val; } - inline bool operator!=(const QFixed &other) const { return val != other.val; } - inline bool operator<(const QFixed &other) const { return val < other.val; } - inline bool operator>(const QFixed &other) const { return val > other.val; } - inline bool operator<=(const QFixed &other) const { return val <= other.val; } - inline bool operator>=(const QFixed &other) const { return val >= other.val; } - inline bool operator!() const { return !val; } + Q_DECL_CONSTEXPR inline bool operator==(const QFixed &other) const { return val == other.val; } + Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &other) const { return val != other.val; } + Q_DECL_CONSTEXPR inline bool operator<(const QFixed &other) const { return val < other.val; } + Q_DECL_CONSTEXPR inline bool operator>(const QFixed &other) const { return val > other.val; } + Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &other) const { return val <= other.val; } + Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &other) const { return val >= other.val; } + Q_DECL_CONSTEXPR inline bool operator!() const { return !val; } inline QFixed &operator/=(int x) { val /= x; return *this; } inline QFixed &operator/=(const QFixed &o) { @@ -122,7 +122,7 @@ public: } return *this; } - inline QFixed operator/(int d) const { return fromFixed(val/d); } + Q_DECL_CONSTEXPR inline QFixed operator/(int d) const { return fromFixed(val/d); } inline QFixed operator/(QFixed b) const { QFixed f = *this; return (f /= b); } inline QFixed operator>>(int d) const { QFixed f = *this; f.val >>= d; return f; } inline QFixed &operator*=(int i) { val *= i; return *this; } @@ -138,50 +138,50 @@ public: val = neg ? -res : res; return *this; } - inline QFixed operator*(int i) const { return fromFixed(val * i); } - inline QFixed operator*(uint i) const { return fromFixed(val * i); } + Q_DECL_CONSTEXPR inline QFixed operator*(int i) const { return fromFixed(val * i); } + Q_DECL_CONSTEXPR inline QFixed operator*(uint i) const { return fromFixed(val * i); } inline QFixed operator*(const QFixed &o) const { QFixed f = *this; return (f *= o); } private: - QFixed(qreal i) : val((int)(i*qreal(64))) {} + Q_DECL_CONSTEXPR QFixed(qreal i) : val((int)(i*qreal(64))) {} QFixed &operator=(qreal i) { val = (int)(i*qreal(64)); return *this; } - inline QFixed operator+(qreal i) const { return fromFixed((val + (int)(i*qreal(64)))); } + Q_DECL_CONSTEXPR inline QFixed operator+(qreal i) const { return fromFixed((val + (int)(i*qreal(64)))); } inline QFixed &operator+=(qreal i) { val += (int)(i*64); return *this; } - inline QFixed operator-(qreal i) const { return fromFixed((val - (int)(i*qreal(64)))); } + Q_DECL_CONSTEXPR inline QFixed operator-(qreal i) const { return fromFixed((val - (int)(i*qreal(64)))); } inline QFixed &operator-=(qreal i) { val -= (int)(i*64); return *this; } inline QFixed &operator/=(qreal r) { val = (int)(val/r); return *this; } - inline QFixed operator/(qreal d) const { return fromFixed((int)(val/d)); } + Q_DECL_CONSTEXPR inline QFixed operator/(qreal d) const { return fromFixed((int)(val/d)); } inline QFixed &operator*=(qreal d) { val = (int) (val*d); return *this; } - inline QFixed operator*(qreal d) const { return fromFixed((int) (val*d)); } + Q_DECL_CONSTEXPR inline QFixed operator*(qreal d) const { return fromFixed((int) (val*d)); } int val; }; Q_DECLARE_TYPEINFO(QFixed, Q_PRIMITIVE_TYPE); #define QFIXED_MAX (INT_MAX/256) -inline int qRound(const QFixed &f) { return f.toInt(); } -inline int qFloor(const QFixed &f) { return f.floor().truncate(); } +Q_DECL_CONSTEXPR inline int qRound(const QFixed &f) { return f.toInt(); } +Q_DECL_CONSTEXPR inline int qFloor(const QFixed &f) { return f.floor().truncate(); } -inline QFixed operator*(int i, const QFixed &d) { return d*i; } -inline QFixed operator+(int i, const QFixed &d) { return d+i; } -inline QFixed operator-(int i, const QFixed &d) { return -(d-i); } -inline QFixed operator*(uint i, const QFixed &d) { return d*i; } -inline QFixed operator+(uint i, const QFixed &d) { return d+i; } -inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); } -// inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; } +Q_DECL_CONSTEXPR inline QFixed operator*(int i, const QFixed &d) { return d*i; } +Q_DECL_CONSTEXPR inline QFixed operator+(int i, const QFixed &d) { return d+i; } +Q_DECL_CONSTEXPR inline QFixed operator-(int i, const QFixed &d) { return -(d-i); } +Q_DECL_CONSTEXPR inline QFixed operator*(uint i, const QFixed &d) { return d*i; } +Q_DECL_CONSTEXPR inline QFixed operator+(uint i, const QFixed &d) { return d+i; } +Q_DECL_CONSTEXPR inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); } +// Q_DECL_CONSTEXPR inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; } -inline bool operator==(const QFixed &f, int i) { return f.value() == (i<<6); } -inline bool operator==(int i, const QFixed &f) { return f.value() == (i<<6); } -inline bool operator!=(const QFixed &f, int i) { return f.value() != (i<<6); } -inline bool operator!=(int i, const QFixed &f) { return f.value() != (i<<6); } -inline bool operator<=(const QFixed &f, int i) { return f.value() <= (i<<6); } -inline bool operator<=(int i, const QFixed &f) { return (i<<6) <= f.value(); } -inline bool operator>=(const QFixed &f, int i) { return f.value() >= (i<<6); } -inline bool operator>=(int i, const QFixed &f) { return (i<<6) >= f.value(); } -inline bool operator<(const QFixed &f, int i) { return f.value() < (i<<6); } -inline bool operator<(int i, const QFixed &f) { return (i<<6) < f.value(); } -inline bool operator>(const QFixed &f, int i) { return f.value() > (i<<6); } -inline bool operator>(int i, const QFixed &f) { return (i<<6) > f.value(); } +Q_DECL_CONSTEXPR inline bool operator==(const QFixed &f, int i) { return f.value() == (i<<6); } +Q_DECL_CONSTEXPR inline bool operator==(int i, const QFixed &f) { return f.value() == (i<<6); } +Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &f, int i) { return f.value() != (i<<6); } +Q_DECL_CONSTEXPR inline bool operator!=(int i, const QFixed &f) { return f.value() != (i<<6); } +Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &f, int i) { return f.value() <= (i<<6); } +Q_DECL_CONSTEXPR inline bool operator<=(int i, const QFixed &f) { return (i<<6) <= f.value(); } +Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &f, int i) { return f.value() >= (i<<6); } +Q_DECL_CONSTEXPR inline bool operator>=(int i, const QFixed &f) { return (i<<6) >= f.value(); } +Q_DECL_CONSTEXPR inline bool operator<(const QFixed &f, int i) { return f.value() < (i<<6); } +Q_DECL_CONSTEXPR inline bool operator<(int i, const QFixed &f) { return (i<<6) < f.value(); } +Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > (i<<6); } +Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return (i<<6) > f.value(); } #ifndef QT_NO_DEBUG_STREAM inline QDebug &operator<<(QDebug &dbg, const QFixed &f) @@ -191,27 +191,27 @@ inline QDebug &operator<<(QDebug &dbg, const QFixed &f) struct QFixedPoint { QFixed x; QFixed y; - inline QFixedPoint() {} - inline QFixedPoint(const QFixed &_x, const QFixed &_y) : x(_x), y(_y) {} - QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); } - static QFixedPoint fromPointF(const QPointF &p) { + Q_DECL_CONSTEXPR inline QFixedPoint() {} + Q_DECL_CONSTEXPR inline QFixedPoint(const QFixed &_x, const QFixed &_y) : x(_x), y(_y) {} + Q_DECL_CONSTEXPR QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); } + Q_DECL_CONSTEXPR static QFixedPoint fromPointF(const QPointF &p) { return QFixedPoint(QFixed::fromReal(p.x()), QFixed::fromReal(p.y())); } }; Q_DECLARE_TYPEINFO(QFixedPoint, Q_PRIMITIVE_TYPE); -inline QFixedPoint operator-(const QFixedPoint &p1, const QFixedPoint &p2) +Q_DECL_CONSTEXPR inline QFixedPoint operator-(const QFixedPoint &p1, const QFixedPoint &p2) { return QFixedPoint(p1.x - p2.x, p1.y - p2.y); } -inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2) +Q_DECL_CONSTEXPR inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2) { return QFixedPoint(p1.x + p2.x, p1.y + p2.y); } struct QFixedSize { QFixed width; QFixed height; - QFixedSize() {} - QFixedSize(QFixed _width, QFixed _height) : width(_width), height(_height) {} - QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); } - static QFixedSize fromSizeF(const QSizeF &s) { + Q_DECL_CONSTEXPR QFixedSize() {} + Q_DECL_CONSTEXPR QFixedSize(QFixed _width, QFixed _height) : width(_width), height(_height) {} + Q_DECL_CONSTEXPR QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); } + Q_DECL_CONSTEXPR static QFixedSize fromSizeF(const QSizeF &s) { return QFixedSize(QFixed::fromReal(s.width()), QFixed::fromReal(s.height())); } }; From 3688fac0402d0737985b2e70dcb0b96117902d93 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 10:39:34 +0100 Subject: [PATCH 100/166] RemoveRef should not remove the const This does not fix anything, because AreArgumentsCompatible already do all the type checks. But it make RemoveRef consistant with std::remove_reference Change-Id: Ic42c872356172d7f5ea10de050254b5d10e50a6e Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject_impl.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h index 5adffb708f..419fcc1dd4 100644 --- a/src/corelib/kernel/qobject_impl.h +++ b/src/corelib/kernel/qobject_impl.h @@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE namespace QtPrivate { template struct RemoveRef { typedef T Type; }; - template struct RemoveRef { typedef T Type; }; template struct RemoveRef { typedef T Type; }; template struct RemoveConstRef { typedef T Type; }; template struct RemoveConstRef { typedef T Type; }; From e34ee3127043773a037bfd18a2d457d409032ee5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 2 Feb 2012 18:11:16 +0100 Subject: [PATCH 101/166] remove fallback re-initialization of TARGET after parsing project we already initialize it before parsing a project. if a project is daft enough to clear TARGET, it does not deserve differently than breaking. Change-Id: I6c727bc27d72a00e84b676ae3c169024bdb2d929 Reviewed-by: Joerg Bornemann --- dist/changes-5.0.0 | 1 + qmake/project.cpp | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 8d928208de..5a9ce7e6c7 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -199,6 +199,7 @@ information about a particular change. You might need to adjust your code if it used a QIconEngine. - qmake + * Projects which explicitly set an empty TARGET are considered broken now. * several functions and built-in variables were modified to return normalized paths. - QTextCodecPlugin has been removed since it is no longer used. All text codecs diff --git a/qmake/project.cpp b/qmake/project.cpp index a8620334d8..3546ac9877 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1444,9 +1444,6 @@ QMakeProject::read(uchar cmd) parse("CONFIG += " + Option::after_user_configs.join(" "), vars); } - if(pfile != "-" && vars["TARGET"].isEmpty()) - vars["TARGET"].append(QFileInfo(pfile).baseName()); - if(cmd & ReadFeatures) { debug_msg(1, "Processing default_post: %s", vars["CONFIG"].join("::").toLatin1().constData()); doProjectInclude("default_post", IncludeFlagFeature, vars); From 2a771cef4a939d26f6ffc45caa690330b33882c9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Feb 2012 17:33:25 +0100 Subject: [PATCH 102/166] QFlags<>: let the compiler generate copy ctor/op= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The user-defined copy constructor and copy-assignment operators were 100% equivalent to the ones the compiler would generate, so let the compiler generate them (so we reap move constructors, too, even though they're not needed on this class). Change-Id: Iecdd579fa5a819d083ec9b2f25734ddba85515e6 Reviewed-by: João Abecasis Reviewed-by: Olivier Goffart --- src/corelib/global/qglobal.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 47d56d7c1b..b159a877b7 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1225,12 +1225,15 @@ class QFlags int i; public: typedef Enum enum_type; - Q_DECL_CONSTEXPR inline QFlags(const QFlags &f) : i(f.i) {} + // compiler-generated copy/move ctor/assignment operators are fine! +#ifdef qdoc + inline QFlags(const QFlags &other); + inline QFlags &operator=(const QFlags &other); +#endif Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {} Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {} inline QFlags(QFlag f) : i(f) {} - inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; } inline QFlags &operator&=(int mask) { i &= mask; return *this; } inline QFlags &operator&=(uint mask) { i &= mask; return *this; } inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; } From efb5a3a52e72a69309c10b6da704fb91258a9cc7 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 21 Feb 2012 13:54:11 +1000 Subject: [PATCH 103/166] Changed qnetworkreply unittest to return correct code - Changed waitForFinished() to return correct return code Change-Id: Ic6b0dfa195254783a2106011c4a108d907d73557 Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index c214b5fc57..5b34fa7c29 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1300,19 +1300,17 @@ QString tst_QNetworkReply::runCustomRequest(const QNetworkRequest &request, int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) { - int code = Success; int count = 0; connect(reply, SIGNAL(finished()), SLOT(finished())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(gotError())); - + returnCode = Success; loop = new QEventLoop; QSignalSpy spy(reply, SIGNAL(downloadProgress(qint64,qint64))); while (!reply->isFinished()) { - QTimer::singleShot(10000, loop, SLOT(quit())); - code = loop->exec(); - if (count == spy.count() && !reply->isFinished()) { - code = Timeout; + QTimer::singleShot(5000, loop, SLOT(quit())); + if ( loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { + returnCode = Timeout; break; } count = spy.count(); @@ -1320,7 +1318,7 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) delete loop; loop = 0; - return code; + return returnCode; } void tst_QNetworkReply::finished() From 35ef771d5a2b625ec057e3f60c3e7260b66741f7 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Fri, 24 Feb 2012 17:16:32 +1000 Subject: [PATCH 104/166] qfiledialog2: Skip test that is passing on CI and failing otherwise. Task-number: QTBUG-23602 Change-Id: Id5dfb85956048c60849d865161212b0764e8f250 Reviewed-by: Rohan McGovern Reviewed-by: Bradley T. Hughes --- .../auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 7ab3100cab..4a6f714a7c 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -489,6 +489,9 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog() void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() { +#ifdef Q_OS_MAC + QSKIP("This test currently fails on Mac OS X, see QTBUG-23602"); +#endif QDir current = QDir::currentPath(); current.mkdir("test"); current.cd("test"); @@ -515,9 +518,6 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Return); QTest::qWait(200); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "This test currently fails on Mac OS X, see QTBUG-23602", Continue); -#endif QCOMPARE(fd.isVisible(), true); QTest::qWait(200); file.close(); From 472b06d63a591c8caba2b5b3227881a41c589f78 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Mon, 27 Feb 2012 13:26:56 +1000 Subject: [PATCH 105/166] Skip unstable qlineedit autotest on Ubuntu 11.10. Task-number: QTBUG-24518 Change-Id: Ia271a820613c1f8a885779eddd20e261716afc6d Reviewed-by: Rohan McGovern Reviewed-by: Friedemann Kleint --- tests/auto/widgets/widgets/qlineedit/qlineedit.pro | 3 +++ tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro index f674ea3f05..83f93f0ba0 100644 --- a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro +++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro @@ -2,3 +2,6 @@ CONFIG += testcase TARGET = tst_qlineedit QT += gui-private core-private widgets testlib SOURCES += tst_qlineedit.cpp + +# QTBUG-24518 - unstable test +linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 17632ec458..81dc940c00 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3616,6 +3616,9 @@ void tst_QLineEdit::taskQTBUG_7902_contextMenuCrash() void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() { +#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__) + QSKIP("QTBUG-24518 - Unstable test for Ubuntu 11.10"); +#endif //ReadOnly QLineEdit should not intercept shortcut. QLineEdit le; le.setReadOnly(true); From 1a49a529ee3e721ea8736bd0c34a0086a2dbad4d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 22 Feb 2012 14:49:13 +0100 Subject: [PATCH 106/166] Remove more support for unsupported GCC versions. Change-Id: I827c9f982a7d7d20913b99c8fdaf98437a0a73db Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index b159a877b7..5fbc8cdd19 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -191,7 +191,7 @@ namespace QT_NAMESPACE {} #endif #ifndef Q_REQUIRED_RESULT -# if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) +# if defined(Q_CC_GNU) # define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result)) # else # define Q_REQUIRED_RESULT @@ -310,7 +310,7 @@ QT_END_INCLUDE_NAMESPACE /* Warnings and errors when using deprecated methods */ -#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT) +#if defined(Q_CC_GNU) || defined(Q_CC_RVCT) # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__)) #elif defined(Q_CC_MSVC) # define Q_DECL_DEPRECATED __declspec(deprecated) @@ -384,11 +384,7 @@ QT_END_INCLUDE_NAMESPACE #if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE) # if defined(Q_CC_GNU) -#if !defined(Q_CC_INTEL) && ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332) # define QT_FASTCALL __attribute__((regparm(3))) -#else -# define QT_FASTCALL -#endif # elif defined(Q_CC_MSVC) # define QT_FASTCALL __fastcall # else From 51f2a0c3318549a6f9388e3d4920eb23a60f8b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 10 Feb 2012 12:21:25 +0100 Subject: [PATCH 107/166] Cleanup usage of QVariant::Type. QVariant::Type is marked as obsolete. It is not possible to get rid of it completely, in a source compatible way, but at least we can remove it safely from a method arguments list. Change-Id: I26b58099bfa6d32f3a583a8ae0047f0bb36bcd0d Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 68 +++++++++++++------------- src/corelib/kernel/qvariant.h | 18 +++---- src/dbus/qdbusargument.cpp | 6 +-- src/gui/kernel/qguivariant.cpp | 2 +- src/widgets/kernel/qwidgetsvariant.cpp | 4 +- tests/auto/dbus/qdbusmarshall/common.h | 2 +- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 0b7866c3eb..1c18883fde 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -279,7 +279,7 @@ inline bool qt_convertToBool(const QVariant::Private *const d) Converts \a d to type \a t, which is placed in \a result. */ -static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, bool *ok) +static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) { Q_ASSERT(d->type != uint(t)); Q_ASSERT(result); @@ -763,7 +763,7 @@ static void dummyConstruct(QVariant::Private *, const void *) { Q_ASSERT_X(false static void dummyClear(QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to clear an unknown type"); } static bool dummyIsNull(const QVariant::Private *d) { Q_ASSERT_X(false, "QVariant::isNull", "Trying to call isNull on an unknown type"); return d->is_null; } static bool dummyCompare(const QVariant::Private *, const QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to compare an unknown types"); return false; } -static bool dummyConvert(const QVariant::Private *, QVariant::Type , void *, bool *) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); return false; } +static bool dummyConvert(const QVariant::Private *, int, void *, bool *) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); return false; } #if !defined(QT_NO_DEBUG_STREAM) static void dummyStreamDebug(QDebug, const QVariant &) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); } #endif @@ -840,7 +840,7 @@ static bool customCompare(const QVariant::Private *a, const QVariant::Private *b return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type)); } -static bool customConvert(const QVariant::Private *, QVariant::Type, void *, bool *ok) +static bool customConvert(const QVariant::Private *, int, void *, bool *ok) { if (ok) *ok = false; @@ -1062,9 +1062,9 @@ Q_CORE_EXPORT void QVariantPrivate::unregisterHandler(const int /* Modules::Name /*! - \fn QVariant::QVariant(int typeOrUserType, const void *copy) + \fn QVariant::QVariant(int typeId, const void *copy) - Constructs variant of type \a typeOrUserType, and initializes with + Constructs variant of type \a typeId, and initializes with \a copy if \a copy is not 0. Note that you have to pass the address of the variable you want stored. @@ -1166,7 +1166,7 @@ QVariant::QVariant(QDataStream &s) UTF-8 encoding on the input \a val. Note that \a val is converted to a QString for storing in the - variant and QVariant::type() will return QMetaType::QString for + variant and QVariant::userType() will return QMetaType::QString for the variant. You can disable this operator by defining \c @@ -1373,19 +1373,19 @@ QVariant::QVariant(const char *val) QVariant::QVariant(Type type) { create(type, 0); } -QVariant::QVariant(int typeOrUserType, const void *copy) -{ create(typeOrUserType, copy); d.is_null = false; } +QVariant::QVariant(int typeId, const void *copy) +{ create(typeId, copy); d.is_null = false; } /*! \internal flags is true if it is a pointer type */ -QVariant::QVariant(int typeOrUserType, const void *copy, uint flags) +QVariant::QVariant(int typeId, const void *copy, uint flags) { if (flags) { //type is a pointer type - d.type = typeOrUserType; + d.type = typeId; d.data.ptr = *reinterpret_cast(copy); } else { - create(typeOrUserType, copy); + create(typeId, copy); } d.is_null = false; } @@ -1563,7 +1563,7 @@ void QVariant::detach() */ const char *QVariant::typeName() const { - return typeToName(Type(d.type)); + return typeToName(d.type); } /*! @@ -1580,17 +1580,17 @@ void QVariant::clear() } /*! - Converts the enum representation of the storage type, \a typ, to + Converts the int representation of the storage type, \a typeId, to its string representation. Returns a null pointer if the type is QVariant::Invalid or doesn't exist. */ -const char *QVariant::typeToName(Type typ) +const char *QVariant::typeToName(int typeId) { - if (typ == Invalid) + if (typeId == Invalid) return 0; - return QMetaType::typeName(typ); + return QMetaType::typeName(typeId); } @@ -1840,7 +1840,7 @@ QDataStream& operator<<(QDataStream &s, const QVariant::Type p) template inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &handlerManager) { - const QVariant::Type targetType = static_cast(qMetaTypeId()); + const uint targetType = qMetaTypeId(); if (d.type == targetType) return *v_cast(&d); @@ -2161,7 +2161,7 @@ inline T qNumVariantToHelper(const QVariant::Private &d, return val; T ret = 0; - if (!handlerManager[d.type]->convert(&d, QVariant::Type(t), &ret, ok) && ok) + if (!handlerManager[d.type]->convert(&d, t, &ret, ok) && ok) *ok = false; return ret; } @@ -2405,7 +2405,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*! Returns true if the variant's type can be cast to the requested - type, \a t. Such casting is done automatically when calling the + type, \a targetTypeId. Such casting is done automatically when calling the toInt(), toBool(), ... methods. The following casts are done automatically: @@ -2437,18 +2437,18 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = \sa convert() */ -bool QVariant::canConvert(Type t) const +bool QVariant::canConvert(int targetTypeId) const { // TODO Reimplement this function, currently it works but it is a historical mess. const uint currentType = ((d.type == QMetaType::Float) ? QVariant::Double : d.type); - if (uint(t) == uint(QMetaType::Float)) t = QVariant::Double; + if (uint(targetTypeId) == uint(QMetaType::Float)) targetTypeId = QVariant::Double; - if (currentType == uint(t)) + if (currentType == uint(targetTypeId)) return true; // FIXME It should be LastCoreType intead of Uuid - if (currentType > QVariant::Uuid || t > QVariant::Uuid) { - switch (uint(t)) { + if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) { + switch (uint(targetTypeId)) { case QVariant::Int: return currentType == QVariant::KeySequence || currentType == QMetaType::ULong @@ -2490,14 +2490,14 @@ bool QVariant::canConvert(Type t) const } } - if(t == String && currentType == StringList) + if (targetTypeId == String && currentType == StringList) return v_cast(&d)->count() == 1; else - return qCanConvertMatrix[t] & (1 << currentType); + return qCanConvertMatrix[targetTypeId] & (1 << currentType); } /*! - Casts the variant to the requested type, \a t. If the cast cannot be + Casts the variant to the requested type, \a targetTypeId. If the cast cannot be done, the variant is cleared. Returns true if the current type of the variant was successfully cast; otherwise returns false. @@ -2508,23 +2508,23 @@ bool QVariant::canConvert(Type t) const \sa canConvert(), clear() */ -bool QVariant::convert(Type t) +bool QVariant::convert(int targetTypeId) { - if (d.type == uint(t)) + if (d.type == uint(targetTypeId)) return true; QVariant oldValue = *this; clear(); - if (!oldValue.canConvert(t)) + if (!oldValue.canConvert(targetTypeId)) return false; - create(t, 0); + create(targetTypeId, 0); if (oldValue.isNull()) return false; bool isOk = true; - if (!handlerManager[d.type]->convert(&oldValue.d, t, data(), &isOk)) + if (!handlerManager[d.type]->convert(&oldValue.d, targetTypeId, data(), &isOk)) isOk = false; d.is_null = !isOk; return isOk; @@ -2538,7 +2538,7 @@ bool QVariant::convert(Type t) bool QVariant::convert(const int type, void *ptr) const { Q_ASSERT(type < int(QMetaType::User)); - return handlerManager[type]->convert(&d, QVariant::Type(type), ptr, 0); + return handlerManager[type]->convert(&d, type, ptr, 0); } @@ -2605,7 +2605,7 @@ bool QVariant::cmp(const QVariant &v) const else return toLongLong() == v.toLongLong(); } - if (!v2.canConvert(Type(d.type)) || !v2.convert(Type(d.type))) + if (!v2.canConvert(d.type) || !v2.convert(d.type)) return false; } return handlerManager[d.type]->compare(&d, &v2.d); diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 20d3946ea1..5da482d5cd 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -194,8 +194,8 @@ class Q_CORE_EXPORT QVariant inline QVariant(); ~QVariant(); QVariant(Type type); - QVariant(int typeOrUserType, const void *copy); - QVariant(int typeOrUserType, const void *copy, uint flags); + QVariant(int typeId, const void *copy); + QVariant(int typeId, const void *copy, uint flags); QVariant(const QVariant &other); #ifndef QT_NO_DATASTREAM @@ -257,8 +257,8 @@ class Q_CORE_EXPORT QVariant int userType() const; const char *typeName() const; - bool canConvert(Type t) const; - bool convert(Type t); + bool canConvert(int targetTypeId) const; + bool convert(int targetTypeId); inline bool isValid() const; bool isNull() const; @@ -311,7 +311,7 @@ class Q_CORE_EXPORT QVariant void load(QDataStream &ds); void save(QDataStream &ds) const; #endif - static const char *typeToName(Type type); + static const char *typeToName(int typeId); static Type nameToType(const char *name); void *data(); @@ -331,7 +331,7 @@ class Q_CORE_EXPORT QVariant template bool canConvert() const - { return canConvert(Type(qMetaTypeId())); } + { return canConvert(qMetaTypeId()); } public: #ifndef qdoc @@ -381,8 +381,8 @@ class Q_CORE_EXPORT QVariant typedef void (*f_save)(const Private *, QDataStream &); #endif typedef bool (*f_compare)(const Private *, const Private *); - typedef bool (*f_convert)(const QVariant::Private *d, Type t, void *, bool *); - typedef bool (*f_canConvert)(const QVariant::Private *d, Type t); + typedef bool (*f_convert)(const QVariant::Private *d, int t, void *, bool *); + typedef bool (*f_canConvert)(const QVariant::Private *d, int t); typedef void (*f_debugStream)(QDebug, const QVariant &); struct Handler { f_construct construct; @@ -527,7 +527,7 @@ namespace QtPrivate { return *reinterpret_cast(v.constData()); if (vid < int(QMetaType::User)) { T t; - if (v.convert(QVariant::Type(vid), &t)) + if (v.convert(vid, &t)) return t; } return T(); diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index 1c2cb6f0f0..6e6e676dae 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -89,7 +89,7 @@ QByteArray QDBusArgumentPrivate::createSignature(int id) if (signature.isEmpty() || !ok || !QDBusUtil::isValidSingleSignature(QString::fromLatin1(signature))) { qWarning("QDBusMarshaller: type `%s' produces invalid D-BUS signature `%s' " "(Did you forget to call beginStructure() ?)", - QVariant::typeToName( QVariant::Type(id) ), + QMetaType::typeName(id), signature.isEmpty() ? "" : signature.constData()); return ""; } else if ((signature.at(0) != DBUS_TYPE_ARRAY && signature.at(0) != DBUS_STRUCT_BEGIN_CHAR) || @@ -97,9 +97,9 @@ QByteArray QDBusArgumentPrivate::createSignature(int id) signature.at(1) == DBUS_TYPE_STRING))) { qWarning("QDBusMarshaller: type `%s' attempts to redefine basic D-BUS type '%s' (%s) " "(Did you forget to call beginStructure() ?)", - QVariant::typeToName( QVariant::Type(id) ), + QMetaType::typeName(id), signature.constData(), - QVariant::typeToName( QVariant::Type(QDBusMetaType::signatureToType(signature))) ); + QMetaType::typeName(QDBusMetaType::signatureToType(signature))); return ""; } return signature; diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index 2ebfb32bc3..0492e48bee 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -221,7 +221,7 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b) return QMetaTypeSwitcher::switcher(comparator, a->type, 0); } -static bool convert(const QVariant::Private *d, QVariant::Type t, +static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) { switch (t) { diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index cf85cbf063..81847681e4 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -117,7 +117,7 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b) return false; } -static bool convert(const QVariant::Private *d, QVariant::Type type, void *result, bool *ok) +static bool convert(const QVariant::Private *d, int type, void *result, bool *ok) { Q_UNUSED(d); Q_UNUSED(type); @@ -141,7 +141,7 @@ static void streamDebug(QDebug dbg, const QVariant &v) dbg.nospace() << *v_cast(d); break; default: - dbg.nospace() << "QVariant::Type(" << d->type << ")"; + dbg.nospace() << "QMetaType::Type(" << d->type << ")"; } } #endif diff --git a/tests/auto/dbus/qdbusmarshall/common.h b/tests/auto/dbus/qdbusmarshall/common.h index 87c434b71e..025641531d 100644 --- a/tests/auto/dbus/qdbusmarshall/common.h +++ b/tests/auto/dbus/qdbusmarshall/common.h @@ -581,7 +581,7 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2) qWarning() << "Unexpected QVariant type" << v2.userType() << QByteArray(QDBusMetaType::typeToSignature(v2.userType())) - << QVariant::typeToName(QVariant::Type(v2.userType())); + << QMetaType::typeName(v2.userType()); return false; } From b58631ce472ce2bfce6319874468aa4e7e11b405 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 26 Feb 2012 10:54:07 +0100 Subject: [PATCH 108/166] Don't use deprecated QAbstractItemModel::reset() Change-Id: Idf9971668a372a12ba319d954c35e157d8a08bd1 Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qlistwidget.cpp | 3 ++- src/widgets/itemviews/qstandarditemmodel.cpp | 3 ++- src/widgets/itemviews/qtablewidget.cpp | 3 ++- src/widgets/itemviews/qtreewidget.cpp | 3 ++- src/widgets/util/qcompleter.cpp | 3 ++- src/widgets/util/qundoview.cpp | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 97fbea6c3d..bb39546ec8 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -75,6 +75,7 @@ QListModel::~QListModel() void QListModel::clear() { + beginResetModel(); for (int i = 0; i < items.count(); ++i) { if (items.at(i)) { items.at(i)->d->theid = -1; @@ -83,7 +84,7 @@ void QListModel::clear() } } items.clear(); - reset(); + endResetModel(); } QListWidgetItem *QListModel::at(int row) const diff --git a/src/widgets/itemviews/qstandarditemmodel.cpp b/src/widgets/itemviews/qstandarditemmodel.cpp index 112b533f4f..5616d76c4a 100644 --- a/src/widgets/itemviews/qstandarditemmodel.cpp +++ b/src/widgets/itemviews/qstandarditemmodel.cpp @@ -2097,13 +2097,14 @@ void QStandardItemModel::setItemRoleNames(const QHash &roleNames void QStandardItemModel::clear() { Q_D(QStandardItemModel); + beginResetModel(); d->root.reset(new QStandardItem); d->root->d_func()->setModel(this); qDeleteAll(d->columnHeaderItems); d->columnHeaderItems.clear(); qDeleteAll(d->rowHeaderItems); d->rowHeaderItems.clear(); - reset(); + endResetModel(); } /*! diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 82055ad11e..5932f20327 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -755,6 +755,7 @@ void QTableModel::clear() void QTableModel::clearContents() { + beginResetModel(); for (int i = 0; i < tableItems.count(); ++i) { if (tableItems.at(i)) { tableItems.at(i)->view = 0; @@ -762,7 +763,7 @@ void QTableModel::clearContents() tableItems[i] = 0; } } - reset(); + endResetModel(); } void QTableModel::itemChanged(QTableWidgetItem *item) diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index ca8b9c4e09..cec709a816 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -160,6 +160,7 @@ QTreeModel::~QTreeModel() void QTreeModel::clear() { SkipSorting skipSorting(this); + beginResetModel(); for (int i = 0; i < rootItem->childCount(); ++i) { QTreeWidgetItem *item = rootItem->children.at(i); item->par = 0; @@ -168,7 +169,7 @@ void QTreeModel::clear() } rootItem->children.clear(); sortPendingTimer.stop(); - reset(); + endResetModel(); } /*! diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 503e5aa596..d416f26f51 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -421,7 +421,8 @@ void QCompletionModel::filter(const QStringList& parts) void QCompletionModel::resetModel() { if (rowCount() == 0) { - reset(); + beginResetModel(); + endResetModel(); return; } diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp index 4b09d5fc70..a87e9e0f05 100644 --- a/src/widgets/util/qundoview.cpp +++ b/src/widgets/util/qundoview.cpp @@ -142,7 +142,8 @@ void QUndoModel::stackDestroyed(QObject *obj) void QUndoModel::stackChanged() { - reset(); + beginResetModel(); + endResetModel(); m_sel_model->setCurrentIndex(selectedIndex(), QItemSelectionModel::ClearAndSelect); } From 96cfca6151b674f0266e879013d69de826ce3311 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 21:27:03 +0100 Subject: [PATCH 109/166] Remove usage of deprecated QAbstractItemModel::setRoleNames Change-Id: If41bf0d6d50969156269c67a15e006d38edc8e1f Reviewed-by: Stephen Kelly --- src/widgets/dialogs/qfilesystemmodel.cpp | 10 ++++------ src/widgets/itemviews/qdirmodel.cpp | 8 +++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 7ea4302a56..0211b2512c 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1926,12 +1926,10 @@ void QFileSystemModelPrivate::init() q, SIGNAL(directoryLoaded(QString))); q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); - QHash roles = q->roleNames(); - roles.insertMulti(QFileSystemModel::FileIconRole, "fileIcon"); // == Qt::decoration - roles.insert(QFileSystemModel::FilePathRole, "filePath"); - roles.insert(QFileSystemModel::FileNameRole, "fileName"); - roles.insert(QFileSystemModel::FilePermissions, "filePermissions"); - q->setRoleNames(roles); + roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration + roleNames.insert(QFileSystemModel::FilePathRole, QByteArrayLiteral("filePath")); + roleNames.insert(QFileSystemModel::FileNameRole, QByteArrayLiteral("fileName")); + roleNames.insert(QFileSystemModel::FilePermissions, QByteArrayLiteral("filePermissions")); } /*! diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 67a16a836d..ee097e5c41 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1169,11 +1169,9 @@ void QDirModelPrivate::init() root.parent = 0; root.info = QFileInfo(); clear(&root); - QHash roles = q->roleNames(); - roles.insertMulti(QDirModel::FileIconRole, "fileIcon"); // == Qt::decoration - roles.insert(QDirModel::FilePathRole, "filePath"); - roles.insert(QDirModel::FileNameRole, "fileName"); - q->setRoleNames(roles); + roleNames.insertMulti(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration + roleNames.insert(QDirModel::FilePathRole, QByteArrayLiteral("filePath")); + roleNames.insert(QDirModel::FileNameRole, QByteArrayLiteral("fileName")); } QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) const From ec739707d70d6450a261f7dd4726380e59d403ef Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 11:42:57 +0100 Subject: [PATCH 110/166] Remove deprecated usage of QKeySequence from qguivariant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The implicit conversion operators are deprecated. Change-Id: I0e94c0671413da1ab58c6c7b8bb31614e2696409 Reviewed-by: Jędrzej Nowacki --- src/gui/kernel/qguivariant.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index 0492e48bee..50d3f0b7d1 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -236,7 +236,7 @@ static bool convert(const QVariant::Private *d, int t, switch (d->type) { #ifndef QT_NO_SHORTCUT case QVariant::KeySequence: - *str = QString(*v_cast(d)); + *str = (*v_cast(d)).toString(QKeySequence::NativeText); return true; #endif case QVariant::Font: @@ -285,7 +285,8 @@ static bool convert(const QVariant::Private *d, int t, #ifndef QT_NO_SHORTCUT case QVariant::Int: if (d->type == QVariant::KeySequence) { - *static_cast(result) = (int)(*(v_cast(d))); + const QKeySequence &seq = *v_cast(d); + *static_cast(result) = seq.isEmpty() ? 0 : seq[0]; return true; } break; From df055acc81f555011524a79cae3509669bbd0b8b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 17:54:00 +0100 Subject: [PATCH 111/166] Fix selftests while using QStringBuilder Change-Id: I6dcd830b96023765447c9683fd95209d4312fb1b Reviewed-by: Jason McDonald --- tests/auto/testlib/selftests/tst_selftests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index decaa55386..7367d664b2 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -155,7 +155,7 @@ static inline QString logFormat(const QString &logger) // Return the log file name, or an empty string if the log goes to stdout. static inline QString logName(const QString &logger) { - return (logger.startsWith("stdout") ? "" : "test_output." + logger); + return (logger.startsWith("stdout") ? "" : QString("test_output." + logger)); } // Load the expected test output for the nominated test (subdir) and logger From beab403d9fcf1fb41f3c133fc6d58e1e864a8d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 10 Feb 2012 09:14:41 +0100 Subject: [PATCH 112/166] Reduce QtCore lib binary size by around ~3KB, by removing template code Reusing a template is much better then creating a new one, even if it should inline the same code. For some reason replacing T* by void* force gcc to remove a few bytes per template instantiation too, it is not really significant, but it alows us to simplify the code. Benchmarks don't show any regressions. Change-Id: I4fdf1e4dc311b23021eb5758605602937d05b183 Reviewed-by: Bradley T. Hughes Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.cpp | 8 +-- src/corelib/kernel/qmetatype.h | 74 +++++++++------------- src/corelib/kernel/qmetatype_p.h | 47 ++------------ tests/auto/other/compiler/tst_compiler.cpp | 4 +- 4 files changed, 42 insertions(+), 91 deletions(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 0021c0ced2..003ad1c32d 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1290,7 +1290,7 @@ namespace { class TypeDestroyer { template::IsAccepted> struct DestroyerImpl { - static void Destroy(const int /* type */, T *where) { delete where; } + static void Destroy(const int /* type */, void *where) { qMetaTypeDeleteHelper(where); } }; template struct DestroyerImpl { @@ -1354,11 +1354,11 @@ namespace { class TypeConstructor { template::IsAccepted> struct ConstructorImpl { - static void *Construct(const int /*type*/, void *where, const T *copy) { return qMetaTypeConstructHelper(where, copy); } + static void *Construct(const int /*type*/, void *where, const void *copy) { return qMetaTypeConstructHelper(where, copy); } }; template struct ConstructorImpl { - static void *Construct(const int type, void *where, const T *copy) + static void *Construct(const int type, void *where, const void *copy) { if (QTypeModuleInfo::IsGui) return Q_LIKELY(qMetaTypeGuiHelper) ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].constructor(where, copy) : 0; @@ -1440,7 +1440,7 @@ namespace { class TypeDestructor { template::IsAccepted> struct DestructorImpl { - static void Destruct(const int /* type */, T *where) { qMetaTypeDestructHelper(where); } + static void Destruct(const int /* type */, void *where) { qMetaTypeDestructHelper(where); } }; template struct DestructorImpl { diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 4af77fcedc..4e75e1414b 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -318,46 +318,57 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaType::TypeFlags) template -void qMetaTypeDeleteHelper(T *t) +void qMetaTypeDeleteHelper(void *t) { - delete t; + delete static_cast(t); } +template <> inline void qMetaTypeDeleteHelper(void *) {} template -void *qMetaTypeCreateHelper(const T *t) +void *qMetaTypeCreateHelper(const void *t) { if (t) return new T(*static_cast(t)); return new T(); } -template -void qMetaTypeDestructHelper(T *t) -{ - Q_UNUSED(t) // Silence MSVC that warns for POD types. - t->~T(); -} +template <> inline void *qMetaTypeCreateHelper(const void *) { return 0; } template -void *qMetaTypeConstructHelper(void *where, const T *t) +void qMetaTypeDestructHelper(void *t) +{ + Q_UNUSED(t) // Silence MSVC that warns for POD types. + static_cast(t)->~T(); +} + +template <> inline void qMetaTypeDestructHelper(void *) {} + +template +void *qMetaTypeConstructHelper(void *where, const void *t) { if (t) return new (where) T(*static_cast(t)); return new (where) T; } +template <> inline void *qMetaTypeConstructHelper(void *, const void *) { return 0; } + #ifndef QT_NO_DATASTREAM template -void qMetaTypeSaveHelper(QDataStream &stream, const T *t) +void qMetaTypeSaveHelper(QDataStream &stream, const void *t) { - stream << *t; + stream << *static_cast(t); } +template <> inline void qMetaTypeSaveHelper(QDataStream &, const void *) {} + template -void qMetaTypeLoadHelper(QDataStream &stream, T *t) +void qMetaTypeLoadHelper(QDataStream &stream, void *t) { - stream >> *t; + stream >> *static_cast(t); } + +template <> inline void qMetaTypeLoadHelper(QDataStream &, void *) {} #endif // QT_NO_DATASTREAM template @@ -442,15 +453,6 @@ int qRegisterMetaType(const char *typeName if (typedefOf != -1) return QMetaType::registerTypedef(typeName, typedefOf); - typedef void*(*CreatePtr)(const T*); - CreatePtr cptr = qMetaTypeCreateHelper; - typedef void(*DeletePtr)(T*); - DeletePtr dptr = qMetaTypeDeleteHelper; - typedef void*(*ConstructPtr)(void *, const T*); - ConstructPtr ipcptr = qMetaTypeConstructHelper; - typedef void(*DestructPtr)(T*); - DestructPtr ipdptr = qMetaTypeDestructHelper; - QMetaType::TypeFlags flags; if (!QTypeInfo::isStatic) flags |= QMetaType::MovableType; @@ -461,10 +463,10 @@ int qRegisterMetaType(const char *typeName if (QtPrivate::IsPointerToTypeDerivedFromQObject::Value) flags |= QMetaType::PointerToQObject; - return QMetaType::registerType(typeName, reinterpret_cast(dptr), - reinterpret_cast(cptr), - reinterpret_cast(ipdptr), - reinterpret_cast(ipcptr), + return QMetaType::registerType(typeName, qMetaTypeDeleteHelper, + qMetaTypeCreateHelper, + qMetaTypeDestructHelper, + qMetaTypeConstructHelper, sizeof(T), flags); } @@ -477,14 +479,8 @@ void qRegisterMetaTypeStreamOperators(const char *typeName #endif ) { - typedef void(*SavePtr)(QDataStream &, const T *); - typedef void(*LoadPtr)(QDataStream &, T *); - SavePtr sptr = qMetaTypeSaveHelper; - LoadPtr lptr = qMetaTypeLoadHelper; - qRegisterMetaType(typeName); - QMetaType::registerStreamOperators(typeName, reinterpret_cast(sptr), - reinterpret_cast(lptr)); + QMetaType::registerStreamOperators(typeName, qMetaTypeSaveHelper, qMetaTypeLoadHelper); } #endif // QT_NO_DATASTREAM @@ -516,16 +512,8 @@ inline int qRegisterMetaType( template inline int qRegisterMetaTypeStreamOperators() { - typedef void(*SavePtr)(QDataStream &, const T *); - typedef void(*LoadPtr)(QDataStream &, T *); - SavePtr sptr = qMetaTypeSaveHelper; - LoadPtr lptr = qMetaTypeLoadHelper; - register int id = qMetaTypeId(); - QMetaType::registerStreamOperators(id, - reinterpret_cast(sptr), - reinterpret_cast(lptr)); - + QMetaType::registerStreamOperators(id, qMetaTypeSaveHelper, qMetaTypeLoadHelper); return id; } #endif diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index e48c5d3033..b50521c7a6 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -122,31 +122,6 @@ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_DECLARE_WIDGETS_MODULE_TYPES_ITER) class QMetaTypeInterface { public: - template - struct Impl { - static void *creator(const T *t) - { - if (t) - return new T(*t); - return new T(); - } - - static void deleter(T *t) { delete t; } - static void saver(QDataStream &stream, const T *t) { stream << *t; } - static void loader(QDataStream &stream, T *t) { stream >> *t; } - static void destructor(T *t) - { - Q_UNUSED(t) // Silence MSVC that warns for POD types. - t->~T(); - } - static void *constructor(void *where, const T *t) - { - if (t) - return new (where) T(*static_cast(t)); - return new (where) T; - } - }; - QMetaType::Creator creator; QMetaType::Deleter deleter; QMetaType::SaveOperator saveOp; @@ -157,20 +132,10 @@ public: quint32 flags; // same as QMetaType::TypeFlags }; -template<> -struct QMetaTypeInterface::Impl { - static void *creator(const void *) { return 0; } - static void deleter(void *) {} - static void saver(QDataStream &, const void *) {} - static void loader(QDataStream &, void *) {} - static void destructor(void *){} - static void *constructor(void *, const void *) { return 0; } -}; - #ifndef QT_NO_DATASTREAM # define QT_METATYPE_INTERFACE_INIT_DATASTREAM_IMPL(Type) \ - /*saveOp*/(reinterpret_cast(QMetaTypeInterface::Impl::saver)), \ - /*loadOp*/(reinterpret_cast(QMetaTypeInterface::Impl::loader)), + /*saveOp*/(qMetaTypeSaveHelper), \ + /*loadOp*/(qMetaTypeLoadHelper), # define QT_METATYPE_INTERFACE_INIT_EMPTY_DATASTREAM_IMPL(Type) \ /*saveOp*/ 0, \ /*loadOp*/ 0, @@ -184,11 +149,11 @@ struct QMetaTypeInterface::Impl { #define QT_METATYPE_INTERFACE_INIT_IMPL(Type, DATASTREAM_DELEGATE) \ { \ - /*creator*/(reinterpret_cast(QMetaTypeInterface::Impl::creator)), \ - /*deleter*/(reinterpret_cast(QMetaTypeInterface::Impl::deleter)), \ + /*creator*/(qMetaTypeCreateHelper), \ + /*deleter*/(qMetaTypeDeleteHelper), \ DATASTREAM_DELEGATE(Type) \ - /*constructor*/(reinterpret_cast(QMetaTypeInterface::Impl::constructor)), \ - /*destructor*/(reinterpret_cast(QMetaTypeInterface::Impl::destructor)), \ + /*constructor*/(qMetaTypeConstructHelper), \ + /*destructor*/(qMetaTypeDestructHelper), \ /*size*/(QTypeInfo::sizeOf), \ /*flags*/(!QTypeInfo::isStatic * QMetaType::MovableType) \ | (QTypeInfo::isComplex * QMetaType::NeedsConstruction) \ diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index 43e3788098..d72a04c8aa 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -268,9 +268,7 @@ namespace QtTestInternal struct Getter { static QMetaType::SaveOperator saveOp() { - typedef void(*SavePtr)(QDataStream &, const T *); - SavePtr op = ::qMetaTypeSaveHelper; - return reinterpret_cast(op); + return ::qMetaTypeSaveHelper; } }; From 184c9e346e298bbda2cc8f30e2f318c1c11e4b13 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 12:59:21 +0100 Subject: [PATCH 113/166] Optimize space for the QEventLoopQuitLocker. Use a union and a type enum instead of three pointers. Change-Id: I02b11733a4f2e95099064fa9325497d4e04ac615 Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qeventloop.cpp | 32 ++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index 2fb351797c..dfdd178c35 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -322,37 +322,51 @@ class QEventLoopLockerPrivate { public: explicit QEventLoopLockerPrivate(QEventLoopPrivate *loop) - : loop(loop), thread(0), app(0) + : loop(loop), type(EventLoop) { loop->ref(); } explicit QEventLoopLockerPrivate(QThreadPrivate *thread) - : loop(0), thread(thread), app(0) + : thread(thread), type(Thread) { thread->ref(); } explicit QEventLoopLockerPrivate(QCoreApplicationPrivate *app) - : loop(0), thread(0), app(app) + : app(app), type(Application) { app->ref(); } ~QEventLoopLockerPrivate() { - if (loop) + switch (type) + { + case EventLoop: loop->deref(); - else if (thread) + break; + case Thread: thread->deref(); - else + break; + default: app->deref(); + break; + } } private: - QEventLoopPrivate *loop; - QThreadPrivate *thread; - QCoreApplicationPrivate *app; + union { + QEventLoopPrivate * loop; + QThreadPrivate * thread; + QCoreApplicationPrivate * app; + }; + enum Type { + EventLoop, + Thread, + Application + }; + const Type type; }; /*! From 6df396286a3221d12e810c0aaa71c4aa68db3331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 24 Feb 2012 14:27:01 +0100 Subject: [PATCH 114/166] Simplify QMetaTypeSwitcher. We do not need to distinguish between different types in the switcher. Before this patch it was not possible to overload DelegateObject::delegate with a pointer type. Now it is fixed. Change-Id: Icd73a53e73e5e66b1b6f6407ba4e0f79e584d930 Reviewed-by: Olivier Goffart --- src/corelib/kernel/qmetatypeswitcher_p.h | 31 +++++------------------- src/corelib/kernel/qvariant_p.h | 3 ++- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/corelib/kernel/qmetatypeswitcher_p.h b/src/corelib/kernel/qmetatypeswitcher_p.h index 05db2cb4c7..e9c15ea214 100644 --- a/src/corelib/kernel/qmetatypeswitcher_p.h +++ b/src/corelib/kernel/qmetatypeswitcher_p.h @@ -59,46 +59,27 @@ QT_BEGIN_NAMESPACE class QMetaTypeSwitcher { public: - - typedef void *NotBuiltinType; + class NotBuiltinType; template static ReturnType switcher(DelegateObject &logic, int type, const void *data); }; -#define QT_METATYPE_SWICHER_CASE_PRIMITIVE(TypeName, TypeId, Name)\ - case QMetaType::TypeName: return logic.delegate(static_cast(data)); - -#define QT_METATYPE_SWICHER_CASE_PRIMITIVE_POINTER(TypeName, TypeId, Name)\ - case QMetaType::TypeName: return logic.delegate(static_cast< Name * const *>(data)); - -#define QT_METATYPE_SWICHER_CASE_POINTER(TypeName, TypeId, Name)\ - case QMetaType::TypeName: return logic.delegate(static_cast< QT_PREPEND_NAMESPACE(Name) * const *>(data)); - -#define QT_METATYPE_SWICHER_CASE_QCLASS(TypeName, TypeId, Name)\ - case QMetaType::TypeName: return logic.delegate(static_cast(data)); +#define QT_METATYPE_SWICHER_CASE(TypeName, TypeId, Name)\ + case QMetaType::TypeName: return logic.delegate(static_cast(data)); template ReturnType QMetaTypeSwitcher::switcher(DelegateObject &logic, int type, const void *data) { switch (QMetaType::Type(type)) { - QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(QT_METATYPE_SWICHER_CASE_PRIMITIVE) - QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(QT_METATYPE_SWICHER_CASE_PRIMITIVE_POINTER) - QT_FOR_EACH_STATIC_CORE_POINTER(QT_METATYPE_SWICHER_CASE_POINTER) - QT_FOR_EACH_STATIC_CORE_CLASS(QT_METATYPE_SWICHER_CASE_QCLASS) - QT_FOR_EACH_STATIC_CORE_TEMPLATE(QT_METATYPE_SWICHER_CASE_QCLASS) - QT_FOR_EACH_STATIC_GUI_CLASS(QT_METATYPE_SWICHER_CASE_QCLASS) - QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_METATYPE_SWICHER_CASE_QCLASS) + QT_FOR_EACH_STATIC_TYPE(QT_METATYPE_SWICHER_CASE) default: - return logic.delegate(static_cast(data)); + return logic.delegate(static_cast(data)); } } -#undef QT_METATYPE_SWICHER_CASE_PRIMITIVE -#undef QT_METATYPE_SWICHER_CASE_PRIMITIVE_POINTER -#undef QT_METATYPE_SWICHER_CASE_QCLASS -#undef QT_METATYPE_SWICHER_CASE_POINTER +#undef QT_METATYPE_SWICHER_CASE QT_END_NAMESPACE diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index 708a427860..a754bc4363 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -188,7 +188,7 @@ public: } bool delegate(const void*) { return true; } - + bool delegate(const QMetaTypeSwitcher::NotBuiltinType*) { return false; } protected: const QVariant::Private *m_a; const QVariant::Private *m_b; @@ -282,6 +282,7 @@ public: } // we need that as sizof(void) is undefined and it is needed in HasIsNullMethod bool delegate(const void *) { return m_d->is_null; } + bool delegate(const QMetaTypeSwitcher::NotBuiltinType *) { return m_d->is_null; } protected: const QVariant::Private *m_d; }; From efde205586a70320d0525e941e5a1cd9657bdd30 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 12:26:10 +0100 Subject: [PATCH 115/166] Use new plugin system in qtbase. - AccessibleWidgets - Windows printer support - Examples Change-Id: Icc162bd7fc284b3c76d9966210f983728085c743 Reviewed-by: Lars Knoll --- .../echoplugin/echowindow/echointerface.h | 6 ++- .../tools/echoplugin/plugin/echoplugin.cpp | 4 -- examples/tools/echoplugin/plugin/echoplugin.h | 2 + .../tools/echoplugin/plugin/echoplugin.json | 1 + examples/tools/echoplugin/plugin/plugin.pro | 1 + examples/tools/plugandpaint/interfaces.h | 16 +++--- examples/tools/plugandpaint/main.cpp | 4 +- .../basictools/basictools.json | 1 + .../basictools/basictools.pro | 1 + .../basictools/basictoolsplugin.cpp | 6 --- .../basictools/basictoolsplugin.h | 2 + .../extrafilters/extrafilters.json | 1 + .../extrafilters/extrafilters.pro | 1 + .../extrafilters/extrafiltersplugin.cpp | 2 - .../extrafilters/extrafiltersplugin.h | 2 + examples/tools/styleplugin/plugin/plugin.pro | 1 + .../tools/styleplugin/plugin/simplestyle.json | 3 ++ .../styleplugin/plugin/simplestyleplugin.cpp | 4 -- .../styleplugin/plugin/simplestyleplugin.h | 3 +- src/plugins/accessible/widgets/main.cpp | 10 ++-- src/plugins/accessible/widgets/widgets.json | 52 +++++++++++++++++++ src/plugins/printsupport/windows/main.cpp | 4 +- src/plugins/printsupport/windows/windows.json | 3 ++ src/plugins/printsupport/windows/windows.pro | 2 + 24 files changed, 97 insertions(+), 35 deletions(-) create mode 100644 examples/tools/echoplugin/plugin/echoplugin.json create mode 100644 examples/tools/plugandpaintplugins/basictools/basictools.json create mode 100644 examples/tools/plugandpaintplugins/extrafilters/extrafilters.json create mode 100644 examples/tools/styleplugin/plugin/simplestyle.json create mode 100644 src/plugins/accessible/widgets/widgets.json create mode 100644 src/plugins/printsupport/windows/windows.json diff --git a/examples/tools/echoplugin/echowindow/echointerface.h b/examples/tools/echoplugin/echowindow/echointerface.h index 412e37b7d2..13494c8d28 100644 --- a/examples/tools/echoplugin/echowindow/echointerface.h +++ b/examples/tools/echoplugin/echowindow/echointerface.h @@ -53,8 +53,10 @@ public: QT_BEGIN_NAMESPACE -Q_DECLARE_INTERFACE(EchoInterface, - "com.trolltech.Plugin.EchoInterface/1.0"); + +#define EchoInterface_iid "org.qt-project.Qt.Examples.EchoInterface" + +Q_DECLARE_INTERFACE(EchoInterface, EchoInterface_iid) QT_END_NAMESPACE //! [0] diff --git a/examples/tools/echoplugin/plugin/echoplugin.cpp b/examples/tools/echoplugin/plugin/echoplugin.cpp index d22e7ead23..07520899f5 100644 --- a/examples/tools/echoplugin/plugin/echoplugin.cpp +++ b/examples/tools/echoplugin/plugin/echoplugin.cpp @@ -48,7 +48,3 @@ QString EchoPlugin::echo(const QString &message) return message; } //! [0] - -//! [1] -Q_EXPORT_PLUGIN2(echoplugin, EchoPlugin); -//! [1] diff --git a/examples/tools/echoplugin/plugin/echoplugin.h b/examples/tools/echoplugin/plugin/echoplugin.h index d5e24b3b76..47373fc8cb 100644 --- a/examples/tools/echoplugin/plugin/echoplugin.h +++ b/examples/tools/echoplugin/plugin/echoplugin.h @@ -42,6 +42,7 @@ #define ECHOPLUGIN_H #include +#include #include "echoplugin.h" #include "echointerface.h" @@ -49,6 +50,7 @@ class EchoPlugin : public QObject, EchoInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.EchoInterface" FILE "echoplugin.json") Q_INTERFACES(EchoInterface) public: diff --git a/examples/tools/echoplugin/plugin/echoplugin.json b/examples/tools/echoplugin/plugin/echoplugin.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/tools/echoplugin/plugin/echoplugin.json @@ -0,0 +1 @@ +{} diff --git a/examples/tools/echoplugin/plugin/plugin.pro b/examples/tools/echoplugin/plugin/plugin.pro index 2be6de80d1..308c1b8236 100644 --- a/examples/tools/echoplugin/plugin/plugin.pro +++ b/examples/tools/echoplugin/plugin/plugin.pro @@ -4,6 +4,7 @@ CONFIG += plugin INCLUDEPATH += ../echowindow HEADERS = echoplugin.h SOURCES = echoplugin.cpp +OTHER_FILES += echoplugin.json TARGET = $$qtLibraryTarget(echoplugin) DESTDIR = ../plugins #! [0] diff --git a/examples/tools/plugandpaint/interfaces.h b/examples/tools/plugandpaint/interfaces.h index e48683cf68..5c1e0c302d 100644 --- a/examples/tools/plugandpaint/interfaces.h +++ b/examples/tools/plugandpaint/interfaces.h @@ -96,14 +96,18 @@ public: QT_BEGIN_NAMESPACE //! [3] //! [4] -Q_DECLARE_INTERFACE(BrushInterface, - "com.trolltech.PlugAndPaint.BrushInterface/1.0") +#define BrushInterface_iid "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface" + +Q_DECLARE_INTERFACE(BrushInterface, BrushInterface_iid) //! [3] -Q_DECLARE_INTERFACE(ShapeInterface, - "com.trolltech.PlugAndPaint.ShapeInterface/1.0") + +#define ShapeInterface_iid "org.qt-project.Qt.Examples.PlugAndPaint.ShapeInterface" + +Q_DECLARE_INTERFACE(ShapeInterface, ShapeInterface_iid) //! [5] -Q_DECLARE_INTERFACE(FilterInterface, - "com.trolltech.PlugAndPaint.FilterInterface/1.0") +#define FilterInterface_iid "org.qt-project.Qt.Examples.PlugAndPaint.FilterInterface" + +Q_DECLARE_INTERFACE(FilterInterface, FilterInterface_iid) //! [4] //! [5] QT_END_NAMESPACE diff --git a/examples/tools/plugandpaint/main.cpp b/examples/tools/plugandpaint/main.cpp index 841d5b417b..3c3693ec0b 100644 --- a/examples/tools/plugandpaint/main.cpp +++ b/examples/tools/plugandpaint/main.cpp @@ -43,9 +43,7 @@ #include #include -QT_BEGIN_NAMESPACE -Q_IMPORT_PLUGIN(pnp_basictools) -QT_END_NAMESPACE +Q_IMPORT_PLUGIN(BasicToolsPlugin) int main(int argc, char *argv[]) { diff --git a/examples/tools/plugandpaintplugins/basictools/basictools.json b/examples/tools/plugandpaintplugins/basictools/basictools.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/tools/plugandpaintplugins/basictools/basictools.json @@ -0,0 +1 @@ +{} diff --git a/examples/tools/plugandpaintplugins/basictools/basictools.pro b/examples/tools/plugandpaintplugins/basictools/basictools.pro index 6175de34a3..89023d19cc 100644 --- a/examples/tools/plugandpaintplugins/basictools/basictools.pro +++ b/examples/tools/plugandpaintplugins/basictools/basictools.pro @@ -4,6 +4,7 @@ CONFIG += plugin static INCLUDEPATH += ../.. HEADERS = basictoolsplugin.h SOURCES = basictoolsplugin.cpp +OTHER_FILES += basictools.json TARGET = $$qtLibraryTarget(pnp_basictools) DESTDIR = ../../plugandpaint/plugins #! [0] diff --git a/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp b/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp index d55048dc0c..bbcae608fa 100644 --- a/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp +++ b/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp @@ -189,9 +189,3 @@ QImage BasicToolsPlugin::filterImage(const QString &filter, const QImage &image, return result; } //! [8] - -QT_BEGIN_NAMESPACE -//! [9] -Q_EXPORT_PLUGIN2(pnp_basictools, BasicToolsPlugin) -//! [9] -QT_END_NAMESPACE diff --git a/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.h b/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.h index c857e4c7a0..a895b60a18 100644 --- a/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.h +++ b/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.h @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -57,6 +58,7 @@ class BasicToolsPlugin : public QObject, public FilterInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface" FILE "basictools.json") Q_INTERFACES(BrushInterface ShapeInterface FilterInterface) //! [0] diff --git a/examples/tools/plugandpaintplugins/extrafilters/extrafilters.json b/examples/tools/plugandpaintplugins/extrafilters/extrafilters.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/tools/plugandpaintplugins/extrafilters/extrafilters.json @@ -0,0 +1 @@ +{} diff --git a/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro b/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro index 70e7c42c76..89acbabb23 100644 --- a/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro +++ b/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro @@ -4,6 +4,7 @@ CONFIG += plugin INCLUDEPATH += ../.. HEADERS = extrafiltersplugin.h SOURCES = extrafiltersplugin.cpp +OTHER_FILES += extrafilters.json TARGET = $$qtLibraryTarget(pnp_extrafilters) DESTDIR = ../../plugandpaint/plugins diff --git a/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.cpp b/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.cpp index 9303fbb6a6..186f364b77 100644 --- a/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.cpp +++ b/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.cpp @@ -120,5 +120,3 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter, } return result; } - -Q_EXPORT_PLUGIN2(pnp_extrafilters, ExtraFiltersPlugin) diff --git a/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h b/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h index b88febe347..6693287294 100644 --- a/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h +++ b/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h @@ -43,6 +43,7 @@ //! [0] #include +#include #include #include @@ -51,6 +52,7 @@ class ExtraFiltersPlugin : public QObject, public FilterInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.FilterInterface" FILE "extrafilters.json") Q_INTERFACES(FilterInterface) public: diff --git a/examples/tools/styleplugin/plugin/plugin.pro b/examples/tools/styleplugin/plugin/plugin.pro index e5cdbe072b..b0dd871b7b 100644 --- a/examples/tools/styleplugin/plugin/plugin.pro +++ b/examples/tools/styleplugin/plugin/plugin.pro @@ -5,6 +5,7 @@ HEADERS = simplestyle.h \ simplestyleplugin.h SOURCES = simplestyle.cpp \ simplestyleplugin.cpp +OTHER_FILES += simplestyle.json TARGET = simplestyleplugin #! [0] win32 { diff --git a/examples/tools/styleplugin/plugin/simplestyle.json b/examples/tools/styleplugin/plugin/simplestyle.json new file mode 100644 index 0000000000..a708e2aafe --- /dev/null +++ b/examples/tools/styleplugin/plugin/simplestyle.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "simplestyle" ] +} diff --git a/examples/tools/styleplugin/plugin/simplestyleplugin.cpp b/examples/tools/styleplugin/plugin/simplestyleplugin.cpp index caf3e01dcf..4b37b2adf2 100644 --- a/examples/tools/styleplugin/plugin/simplestyleplugin.cpp +++ b/examples/tools/styleplugin/plugin/simplestyleplugin.cpp @@ -58,7 +58,3 @@ QStyle *SimpleStylePlugin::create(const QString &key) return 0; } //! [1] - -QT_BEGIN_NAMESPACE -Q_EXPORT_PLUGIN2(simplestyleplugin, SimpleStylePlugin) -QT_END_NAMESPACE diff --git a/examples/tools/styleplugin/plugin/simplestyleplugin.h b/examples/tools/styleplugin/plugin/simplestyleplugin.h index 873ac59a67..eb2cdedfed 100644 --- a/examples/tools/styleplugin/plugin/simplestyleplugin.h +++ b/examples/tools/styleplugin/plugin/simplestyleplugin.h @@ -52,9 +52,10 @@ QT_END_NAMESPACE class SimpleStylePlugin : public QStylePlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "simplestyle.json") public: - SimpleStylePlugin() {}; + SimpleStylePlugin() {} QStringList keys() const; QStyle *create(const QString &key); diff --git a/src/plugins/accessible/widgets/main.cpp b/src/plugins/accessible/widgets/main.cpp index dfa9594d5b..ca8bf816b6 100644 --- a/src/plugins/accessible/widgets/main.cpp +++ b/src/plugins/accessible/widgets/main.cpp @@ -61,6 +61,9 @@ QT_BEGIN_NAMESPACE class AccessibleFactory : public QAccessiblePlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QAccessibleFactoryInterface" FILE "widgets.json") + public: AccessibleFactory(); @@ -109,7 +112,6 @@ QStringList AccessibleFactory::keys() const list << QLatin1String("QStatusBar"); list << QLatin1String("QProgressBar"); list << QLatin1String("QMenuBar"); - list << QLatin1String("Q3PopupMenu"); list << QLatin1String("QMenu"); list << QLatin1String("QHeaderView"); list << QLatin1String("QTabBar"); @@ -251,8 +253,6 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec #ifndef QT_NO_MENU } else if (classname == QLatin1String("QMenu")) { iface = new QAccessibleMenu(widget); - } else if (classname == QLatin1String("Q3PopupMenu")) { - iface = new QAccessibleMenu(widget); #endif #ifndef QT_NO_ITEMVIEWS } else if (classname == QLatin1String("QAbstractItemView")) { @@ -345,9 +345,9 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec return iface; } -Q_EXPORT_STATIC_PLUGIN(AccessibleFactory) -Q_EXPORT_PLUGIN2(qtaccessiblewidgets, AccessibleFactory) QT_END_NAMESPACE +#include "main.moc" + #endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/widgets/widgets.json b/src/plugins/accessible/widgets/widgets.json new file mode 100644 index 0000000000..fdeb6f2b52 --- /dev/null +++ b/src/plugins/accessible/widgets/widgets.json @@ -0,0 +1,52 @@ +{ + "Keys": [ + "QLineEdit", + "QComboBox", + "QAbstractSpinBox", + "QSpinBox", + "QDoubleSpinBox", + "QScrollBar", + "QSlider", + "QAbstractSlider", + "QToolButton", + "QCheckBox", + "QRadioButton", + "QPushButton", + "QAbstractButton", + "QDialog", + "QMessageBox", + "QMainWindow", + "QLabel", + "QLCDNumber", + "QGroupBox", + "QStatusBar", + "QProgressBar", + "QMenuBar", + "QMenu", + "QHeaderView", + "QTabBar", + "QToolBar", + "QWorkspaceChild", + "QSizeGrip", + "QAbstractItemView", + "QWidget", + "QSplitter", + "QSplitterHandle", + "QTextEdit", + "QTipLabel", + "QFrame", + "QStackedWidget", + "QToolBox", + "QMdiArea", + "QMdiSubWindow", + "QWorkspace", + "QDialogButtonBox", + "QDial", + "QRubberBand", + "QTextBrowser", + "QAbstractScrollArea", + "QScrollArea", + "QCalendarWidget", + "QDockWidget", + "QAccessibleWidget" ] +} diff --git a/src/plugins/printsupport/windows/main.cpp b/src/plugins/printsupport/windows/main.cpp index baf18504ee..e29705a8a7 100644 --- a/src/plugins/printsupport/windows/main.cpp +++ b/src/plugins/printsupport/windows/main.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE class QWindowsPrinterSupportPlugin : public QPlatformPrinterSupportPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.QPlatformPrinterSupportFactoryInterface" FILE "windows.json") + public: QStringList keys() const; QPlatformPrinterSupport *create(const QString &); @@ -67,8 +69,6 @@ QPlatformPrinterSupport *QWindowsPrinterSupportPlugin::create(const QString &key return 0; } -Q_EXPORT_PLUGIN2(windowsprint, QWindowsPrinterSupportPlugin) - QT_END_NAMESPACE #include "main.moc" diff --git a/src/plugins/printsupport/windows/windows.json b/src/plugins/printsupport/windows/windows.json new file mode 100644 index 0000000000..803052854e --- /dev/null +++ b/src/plugins/printsupport/windows/windows.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "windowsprintsupport" ] +} diff --git a/src/plugins/printsupport/windows/windows.pro b/src/plugins/printsupport/windows/windows.pro index 2032125f4b..97d90a6a9d 100644 --- a/src/plugins/printsupport/windows/windows.pro +++ b/src/plugins/printsupport/windows/windows.pro @@ -15,6 +15,8 @@ SOURCES += \ HEADERS += \ qwindowsprintersupport.h +OTHER_FILES += windows.json + target.path += $$[QT_INSTALL_PLUGINS]/printsupport INSTALLS += target LIBS += -lWinspool -lComdlg32 From 568e714fdf9d3243bfc684a5650332e432e70461 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 24 Feb 2012 22:12:18 +0100 Subject: [PATCH 116/166] remove library version matching from qt.conf this feature was introduced in feb 2005 by Sam with this comment: > I have implemented a versioning into the keys and do environment > expansion there as well, these aren't immediately usefull but Marius > and I agreed that distributors will probably want such features at > times. The versioning fallbacks will be usefull to us over time no > doubt. imo the versioning is a contestant for the most useless feature ever: - (linux) distributors couldn't care less - they simply configure qtcore correctly. additionally, the packaging policies state that no config files should live in the binary dir at all, so no qt.conf for them. - ISVs don't care, because they ship their software with a particular qt version anyway. - SDK distributors don't care, because it doesn't solve any real problem for them: a) they will isolate the (qmake) versions and b) a distinction based on version number (as opposed to build configuration) is utterly useless in the first place. i left in the variable expansion, as it could at least theoretically be useful for creating relocatable packages. debatable - the file it easy enough to modify at installation time. Change-Id: Ida8a50b16d55d8d8613d1a98a51df56753f6a6e3 Reviewed-by: Bradley T. Hughes Reviewed-by: Lars Knoll --- src/corelib/global/qlibraryinfo.cpp | 65 +---------------------------- 1 file changed, 1 insertion(+), 64 deletions(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 61c750acaf..c871675334 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -348,71 +348,8 @@ QLibraryInfo::location(LibraryLocation loc) QSettings *config = QLibraryInfoPrivate::configuration(); config->beginGroup(QLatin1String("Paths")); - QString subKey; - { - /* - find the child group whose version number is closest - to the library version. for example and we have the - following groups: + ret = config->value(key, defaultValue).toString(); - Paths - Paths/4.0 - Paths/4.1.2 - Paths/4.2.5 - Paths/5 - - if QT_VERSION is 4.0.1, then we use 'Paths/4.0' - if QT_VERSION is 4.1.5, then we use 'Paths/4.1.2' - if QT_VERSION is 4.6.3, then we use 'Paths/4.2.5' - if QT_VERSION is 6.0.2, then we use 'Paths/5' - - note: any of the trailing version numbers may be - omitted (in which case, they default to zero), - i.e. 4 == 4.0.0, 4.1 == 4.1.0, and so on - */ - enum { - QT_MAJOR = ((QT_VERSION >> 16) & 0xFF), - QT_MINOR = ((QT_VERSION >> 8) & 0xFF), - QT_PATCH = (QT_VERSION & 0xFF) - }; - int maj = 0, min = 0, pat = 0; - QStringList children = config->childGroups(); - for(int child = 0; child < children.size(); ++child) { - QString cver = children.at(child); - QStringList cver_list = cver.split(QLatin1Char('.')); - if(cver_list.size() > 0 && cver_list.size() < 4) { - bool ok; - int cmaj = -1, cmin = -1, cpat = -1; - cmaj = cver_list[0].toInt(&ok); - if(!ok || cmaj < 0) - continue; - if(cver_list.size() >= 2) { - cmin = cver_list[1].toInt(&ok); - if(!ok) - continue; - if(cmin < 0) - cmin = -1; - } - if(cver_list.size() >= 3) { - cpat = cver_list[2].toInt(&ok); - if(!ok) - continue; - if(cpat < 0) - cpat = -1; - } - if((cmaj >= maj && cmaj <= QT_MAJOR) && - (cmin == -1 || (cmin >= min && cmin <= QT_MINOR)) && - (cpat == -1 || (cpat >= pat && cpat <= QT_PATCH)) && - config->contains(cver + QLatin1Char('/') + key)) { - subKey = cver + QLatin1Char('/'); - maj = cmaj; - min = cmin; - pat = cpat; - } - } - } - } - ret = config->value(subKey + key, defaultValue).toString(); // expand environment variables in the form $(ENVVAR) int rep; QRegExp reg_var(QLatin1String("\\$\\(.*\\)")); From 136c2bf18446f2bbe7052d638c29edbc0b8ef6bc Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 26 Feb 2012 01:45:53 +0000 Subject: [PATCH 117/166] QRegExp: fix crash Fixes a crash when invoking various QRegExp methods on an object *before* doing any match. For instance fixes: QRegExp re; re.matchedLength(); // crash Task-number: QTBUG-23352 Change-Id: I9c239ff790a139c7820ef1aeced89d31320ae6b0 Reviewed-by: Andy Shaw Reviewed-by: Thiago Macieira --- src/corelib/tools/qregexp.cpp | 2 ++ .../corelib/tools/qregexp/tst_qregexp.cpp | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index e8c0d4eccc..d7bcd0edbc 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -3934,6 +3934,7 @@ static void invalidateEngine(QRegExpPrivate *priv) QRegExp::QRegExp() { priv = new QRegExpPrivate; + prepareEngine(priv); } /*! @@ -3949,6 +3950,7 @@ QRegExp::QRegExp() QRegExp::QRegExp(const QString &pattern, Qt::CaseSensitivity cs, PatternSyntax syntax) { priv = new QRegExpPrivate(QRegExpEngineKey(pattern, syntax, cs)); + prepareEngine(priv); } /*! diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index 0148e933e4..a697e23270 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -79,6 +79,8 @@ private slots: void posAndCapConsistency_data(); void posAndCapConsistency(); void interval(); + void validityCheck_data(); + void validityCheck(); }; // Testing get/set functions @@ -1344,6 +1346,33 @@ void tst_QRegExp::interval() } } +void tst_QRegExp::validityCheck_data() +{ + QTest::addColumn("pattern"); + QTest::addColumn("validity"); + QTest::newRow("validity01") << QString() << true; + QTest::newRow("validity02") << QString("abc.*abc") << true; + QTest::newRow("validity03") << QString("[a-z") << false; + QTest::newRow("validity04") << QString("a(b") << false; +} + +void tst_QRegExp::validityCheck() +{ + QFETCH(QString, pattern); + + QRegExp rx(pattern); + QTEST(rx.isValid(), "validity"); + QCOMPARE(rx.matchedLength(), -1); + QCOMPARE(rx.pos(), -1); + QCOMPARE(rx.cap(), QString("")); + + QRegExp rx2(rx); + QTEST(rx2.isValid(), "validity"); + QCOMPARE(rx2.matchedLength(), -1); + QCOMPARE(rx2.pos(), -1); + QCOMPARE(rx2.cap(), QString("")); +} + QTEST_APPLESS_MAIN(tst_QRegExp) #include "tst_qregexp.moc" From 7a4b6f8cdd932c193ac027438fc48f0ce7732339 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 26 Feb 2012 10:51:52 +0100 Subject: [PATCH 118/166] Fix inconsistent auto test executable names Change-Id: I3b6b5b37e32be25d1b9933395c43f6d5aa5b8810 Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- tests/auto/corelib/io/qresourceengine/qresourceengine.pro | 1 + tests/auto/widgets/itemviews/qtableview/qtableview.pro | 2 +- tests/auto/widgets/styles/qstyle/qstyle.pro | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro index d6e2cb3171..e59746c158 100644 --- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro @@ -1,4 +1,5 @@ CONFIG += testcase parallel_test +TARGET = tst_qresourceengine load(resources) QT = core testlib SOURCES = tst_qresourceengine.cpp diff --git a/tests/auto/widgets/itemviews/qtableview/qtableview.pro b/tests/auto/widgets/itemviews/qtableview/qtableview.pro index 528fa7d014..889caaf3c8 100644 --- a/tests/auto/widgets/itemviews/qtableview/qtableview.pro +++ b/tests/auto/widgets/itemviews/qtableview/qtableview.pro @@ -1,5 +1,5 @@ CONFIG += testcase - +TARGET = tst_qtableview QT += widgets widgets-private testlib QT += core-private gui-private diff --git a/tests/auto/widgets/styles/qstyle/qstyle.pro b/tests/auto/widgets/styles/qstyle/qstyle.pro index 5a18a70d9e..842fd11062 100644 --- a/tests/auto/widgets/styles/qstyle/qstyle.pro +++ b/tests/auto/widgets/styles/qstyle/qstyle.pro @@ -1,4 +1,5 @@ CONFIG += testcase +TARGET = tst_qstyle TARGET.EPOCHEAPSIZE = 0x200000 0x800000 QT += widgets testlib SOURCES += tst_qstyle.cpp From 3d3b3de83adf62b3dc4c76e8bfd178e3a4969d07 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 24 Feb 2012 15:17:23 +0100 Subject: [PATCH 119/166] QtTest: add missing \since 5.0 to the new macros Change-Id: I8f7060c41df1e0bf1a8c35930400a31a4239a3d6 Reviewed-by: Jason McDonald --- src/testlib/qtestcase.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index e867b9629a..b8678ba04c 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -166,6 +166,7 @@ QT_BEGIN_NAMESPACE */ /*! \macro QTRY_VERIFY_WITH_TIMEOUT(condition, timeout) + \since 5.0 \relates QTest @@ -183,6 +184,7 @@ QT_BEGIN_NAMESPACE /*! \macro QTRY_VERIFY(condition) + \since 5.0 \relates QTest @@ -195,6 +197,7 @@ QT_BEGIN_NAMESPACE */ /*! \macro QTRY_COMPARE_WITH_TIMEOUT(actual, expected, timeout) + \since 5.0 \relates QTest @@ -211,6 +214,7 @@ QT_BEGIN_NAMESPACE */ /*! \macro QTRY_COMPARE(actual, expected) + \since 5.0 \relates QTest @@ -360,6 +364,7 @@ QT_BEGIN_NAMESPACE */ /*! \macro QFINDTESTDATA(filename) + \since 5.0 \relates QTest @@ -449,6 +454,7 @@ QT_BEGIN_NAMESPACE */ /*! \macro QTEST_GUILESS_MAIN(TestClass) + \since 5.0 \relates QTest From 5a0eb4e768435b9ce32b074e620fca33be4df2fb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Feb 2012 12:38:04 +0100 Subject: [PATCH 120/166] Fix icon loading in style sheets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QIcon was moved to QtWidgets, while the parser is still in QtGui. Introduce a QCss::IconValue struct that contains the icon data and convert to QIcon in widgets. Change-Id: I09ac8a12a4b02bdca91ee2e8fcc28c86b5a001e7 Reviewed-by: Morten Johan Sørvig --- src/gui/text/qcssparser.cpp | 40 +++++++++---------------- src/gui/text/qcssparser_p.h | 21 +++++++++++-- src/widgets/styles/qstylesheetstyle.cpp | 19 ++++++++++-- 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 38070458b7..fd01934eae 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1272,11 +1272,9 @@ void ValueExtractor::extractFont() extractFont(&f, &dummy); } -bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size) +bool ValueExtractor::extractImage(QCss::IconValue *icon, Qt::Alignment *a, QSize *size) { bool hit = false; -#if 0 - // ### Qt5 for (int i = 0; i < declarations.count(); ++i) { const Declaration &decl = declarations.at(i); switch (decl.d->propertyId) { @@ -1297,7 +1295,6 @@ bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size) } hit = true; } -#endif return hit; } @@ -1646,30 +1643,27 @@ void Declaration::borderImageValue(QString *image, int *cuts, *h = *v; } -#if 0 -// ### Qt 5 -QIcon Declaration::iconValue() const +IconValue Declaration::iconValue() const { if (d->parsed.isValid()) - return qvariant_cast(d->parsed); + return qvariant_cast(d->parsed); - QIcon icon; + IconValue icon; for (int i = 0; i < d->values.count();) { const Value &value = d->values.at(i++); if (value.type != Value::Uri) break; - QString uri = value.variant.toString(); - QIcon::Mode mode = QIcon::Normal; - QIcon::State state = QIcon::Off; + IconValue::IconEntry entry; + entry.uri = value.variant.toString(); for (int j = 0; j < 2; j++) { if (i != d->values.count() && d->values.at(i).type == Value::KnownIdentifier) { switch (d->values.at(i).variant.toInt()) { - case Value_Disabled: mode = QIcon::Disabled; break; - case Value_Active: mode = QIcon::Active; break; - case Value_Selected: mode = QIcon::Selected; break; - case Value_Normal: mode = QIcon::Normal; break; - case Value_On: state = QIcon::On; break; - case Value_Off: state = QIcon::Off; break; + case Value_Disabled: entry.mode = IconValue::Disabled; break; + case Value_Active: entry.mode = IconValue::Active; break; + case Value_Selected: entry.mode = IconValue::Selected; break; + case Value_Normal: entry.mode = IconValue::Normal; break; + case Value_On: entry.state = IconValue::On; break; + case Value_Off: entry.state = IconValue::Off; break; default: break; } ++i; @@ -1677,12 +1671,7 @@ QIcon Declaration::iconValue() const break; } } - - // QIcon is soo broken - if (icon.isNull()) - icon = QIcon(uri); - else - icon.addPixmap(uri, mode, state); + icon.entries.push_back(entry); if (i == d->values.count()) break; @@ -1691,10 +1680,9 @@ QIcon Declaration::iconValue() const i++; } - d->parsed = QVariant::fromValue(icon); + d->parsed = QVariant::fromValue(icon); return icon; } -#endif /////////////////////////////////////////////////////////////////////////////// // Selector diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index d50b87dcd5..b19fd8326e 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -411,6 +411,22 @@ struct BorderData { BrushData color; }; +struct Q_GUI_EXPORT IconValue +{ + enum Mode { Normal, Disabled, Active, Selected }; // In sync with QIcon. + enum State { On, Off }; + + struct Q_GUI_EXPORT IconEntry + { + IconEntry() : mode(Normal) , state(On) {} + + Mode mode; + State state; + QString uri; + }; + + QList entries; +}; // 1. StyleRule - x:hover, y:clicked > z:checked { prop1: value1; prop2: value2; } // 2. QVector - x:hover, y:clicked z:checked @@ -455,7 +471,7 @@ struct Q_GUI_EXPORT Declaration QSize sizeValue() const; QRect rectValue() const; QString uriValue() const; -// QIcon iconValue() const; + IconValue iconValue() const; void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const; }; @@ -582,7 +598,7 @@ struct Q_GUI_EXPORT ValueExtractor bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets); bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg); int extractStyleFeatures(); - bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size); + bool extractImage(QCss::IconValue *icon, Qt::Alignment *a, QSize *size); int lengthValue(const Declaration &decl); @@ -842,6 +858,7 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE( QCss::BackgroundData ) Q_DECLARE_METATYPE( QCss::LengthData ) Q_DECLARE_METATYPE( QCss::BorderData ) +Q_DECLARE_METATYPE( QCss::IconValue ) #endif // QT_NO_CSSPARSER diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 30c6ed5e74..5c0ee254d4 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -860,6 +860,19 @@ static QStyle::StandardPixmap subControlIcon(int pe) return QStyle::SP_CustomBase; } +static inline QIcon cssIconValueToIcon(const QCss::IconValue &iconValue) +{ + if (iconValue.entries.isEmpty()) + return QIcon(); + QIcon icon = QIcon(iconValue.entries.first().uri); + for (int i = 1; i < iconValue.entries.size(); ++i) { + const QCss::IconValue::IconEntry &entry = iconValue.entries.at(i); + icon.addPixmap(entry.uri, static_cast(entry.mode), + static_cast(entry.state)); + } + return icon; +} + QRenderRule::QRenderRule(const QVector &declarations, const QWidget *widget) : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { @@ -919,11 +932,11 @@ QRenderRule::QRenderRule(const QVector &declarations, const QWidget if (v.extractPalette(&fg, &sfg, &sbg, &abg)) pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg); - QIcon icon; alignment = Qt::AlignCenter; QSize size; - if (v.extractImage(&icon, &alignment, &size)) - img = new QStyleSheetImageData(icon, alignment, size); + QCss::IconValue iconValue; + if (v.extractImage(&iconValue, &alignment, &size)) + img = new QStyleSheetImageData(cssIconValueToIcon(iconValue), alignment, size); int adj = -255; hasFont = v.extractFont(&font, &adj); From ed8d8451c4174d9f200445c8476a9216be51af70 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Feb 2012 11:09:27 +0100 Subject: [PATCH 121/166] Fix QThreadstorage test. - Create subdirectories containing profiles to avoid problems with -fast. - Use QFINDTESTDATA to locate binary. - Make it a console application, no Mac-bundle. - Add error messages to the test, give it a longer time-out and ensure sub-process is killed if it hangs. Change-Id: Ibc177b786c4bc8fdbc068a8c45f4801a41c9f660 Reviewed-by: Sergio Ahumada --- .../thread/qthreadstorage/crashOnExit.pro | 8 --- .../{ => crashonexit}/crashOnExit.cpp | 0 .../crashonexit/crashonexit.pro | 9 ++++ .../thread/qthreadstorage/qthreadstorage.pro | 6 +-- .../thread/qthreadstorage/test/test.pro | 6 +++ .../qthreadstorage/tst_qthreadstorage.cpp | 54 +++++++++++++++---- .../qthreadstorage/tst_qthreadstorage.pro | 4 -- 7 files changed, 62 insertions(+), 25 deletions(-) delete mode 100644 tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro rename tests/auto/corelib/thread/qthreadstorage/{ => crashonexit}/crashOnExit.cpp (100%) create mode 100644 tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro create mode 100644 tests/auto/corelib/thread/qthreadstorage/test/test.pro delete mode 100644 tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro diff --git a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro b/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro deleted file mode 100644 index 68d0f1202b..0000000000 --- a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro +++ /dev/null @@ -1,8 +0,0 @@ -SOURCES += crashOnExit.cpp -QT = core -CONFIG-=app_bundle -CONFIG+=console - -# This app is testdata for tst_qthreadstorage -target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage -INSTALLS += target diff --git a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp similarity index 100% rename from tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp rename to tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp diff --git a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro new file mode 100644 index 0000000000..94a0a01e94 --- /dev/null +++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro @@ -0,0 +1,9 @@ +SOURCES += crashOnExit.cpp +DESTDIR = ./ +QT = core +CONFIG -= app_bundle +CONFIG += console + +# This app is testdata for tst_qthreadstorage +target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro index 0dc8d086df..2fa973d2f7 100644 --- a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro +++ b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs SUBDIRS = \ - tst_qthreadstorage.pro \ - crashOnExit.pro -CONFIG += parallel_test + crashonexit \ + test +CONFIG += ordered parallel_test diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro new file mode 100644 index 0000000000..a7d8eb0106 --- /dev/null +++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = ../tst_qthreadstorage +CONFIG -= app_bundle +CONFIG += console +QT = core testlib +SOURCES = ../tst_qthreadstorage.cpp diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp index fff361ea2a..0529e67e0f 100644 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp @@ -46,6 +46,8 @@ #include #include #include +#include +#include #ifdef Q_OS_UNIX #include @@ -61,6 +63,7 @@ class tst_QThreadStorage : public QObject { Q_OBJECT private slots: + void initTestCase(); void hasLocalData(); void localData(); void localData_const(); @@ -72,6 +75,9 @@ private slots: void leakInDestructor(); void resetInDestructor(); void valueBased(); + +private: + QString m_crashOnExit; }; class Pointer @@ -83,6 +89,20 @@ public: }; int Pointer::count = 0; +void tst_QThreadStorage::initTestCase() +{ + const QString crashOnExitDir = QFINDTESTDATA("crashonexit"); + QVERIFY2(!crashOnExitDir.isEmpty(), + qPrintable(QString::fromLatin1("Could not find 'crashonexit' starting from '%1'") + .arg(QDir::toNativeSeparators(QDir::currentPath())))); + m_crashOnExit = crashOnExitDir + QStringLiteral("/crashonexit"); +#ifdef Q_OS_WIN + m_crashOnExit += QStringLiteral(".exe"); +#endif + QVERIFY2(QFileInfo(m_crashOnExit).isExecutable(), + qPrintable(QDir::toNativeSeparators(m_crashOnExit) + QStringLiteral(" does not exist or is not executable."))); +} + void tst_QThreadStorage::hasLocalData() { QThreadStorage pointers; @@ -285,18 +305,32 @@ void tst_QThreadStorage::ensureCleanupOrder() QVERIFY(First::order < Second::order); } +static inline bool runCrashOnExit(const QString &binary, QString *errorMessage) +{ + const int timeout = 60000; + QProcess process; + process.start(binary); + if (!process.waitForStarted()) { + *errorMessage = QString::fromLatin1("Could not start '%1': %2").arg(binary, process.errorString()); + return false; + } + if (!process.waitForFinished(timeout)) { + process.kill(); + *errorMessage = QString::fromLatin1("Timeout (%1ms) waiting for %2.").arg(timeout).arg(binary); + return false; + } + if (process.exitStatus() != QProcess::NormalExit) { + *errorMessage = binary + QStringLiteral(" crashed."); + return false; + } + return true; +} + void tst_QThreadStorage::crashOnExit() { - QProcess process; - // crashOnExit is always expected to be in the same directory - // as this test binary -#ifdef Q_OS_MAC - process.start(QCoreApplication::applicationDirPath() + "/../../../crashOnExit"); -#else - process.start(QCoreApplication::applicationDirPath() + "/crashOnExit"); -#endif - QVERIFY(process.waitForFinished()); - QVERIFY(process.exitStatus() != QProcess::CrashExit); + QString errorMessage; + QVERIFY2(runCrashOnExit(m_crashOnExit, &errorMessage), + qPrintable(errorMessage)); } // S stands for thread Safe. diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro deleted file mode 100644 index 15ced107d3..0000000000 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qthreadstorage -QT = core testlib -SOURCES = tst_qthreadstorage.cpp From a62dfb7a72ae08fac377e3140b9dd20f74a7c9dc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 24 Feb 2012 19:08:13 +0100 Subject: [PATCH 122/166] bump version of QMAKE_TARGET_PRODUCT ... whatever that may be good for Change-Id: I06695a06aae52386236a7a31fe7865cc8389d3b9 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_targets.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/qt_targets.prf b/mkspecs/features/qt_targets.prf index ec15869b0f..c23d63fc7f 100644 --- a/mkspecs/features/qt_targets.prf +++ b/mkspecs/features/qt_targets.prf @@ -1,4 +1,4 @@ QMAKE_TARGET_COMPANY = Nokia Corporation and/or its subsidiary(-ies) -QMAKE_TARGET_PRODUCT = Qt4 +QMAKE_TARGET_PRODUCT = Qt5 QMAKE_TARGET_DESCRIPTION = C++ application development framework. QMAKE_TARGET_COPYRIGHT = Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). From e76d72aec544878d976423e2136e7787aba980ab Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 24 Feb 2012 09:10:52 +0100 Subject: [PATCH 123/166] don't generate bogus TARGETs Change-Id: Ia99cd8862157e5630506d02b3c7e9b35d4bc3302 Reviewed-by: Joerg Bornemann --- qmake/generators/projectgenerator.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp index 4d1a310daf..a2eb45ef40 100644 --- a/qmake/generators/projectgenerator.cpp +++ b/qmake/generators/projectgenerator.cpp @@ -85,12 +85,6 @@ ProjectGenerator::init() templ.prepend(Option::user_template_prefix); v["TEMPLATE_ASSIGN"] += templ; - //figure out target - if(Option::output.fileName() == "-") - v["TARGET_ASSIGN"] = QStringList("unknown"); - else - v["TARGET_ASSIGN"] = QStringList(QFileInfo(Option::output).baseName()); - //the scary stuff if(project->first("TEMPLATE_ASSIGN") != "subdirs") { QString builtin_regex = project_builtin_regx(); @@ -360,6 +354,12 @@ ProjectGenerator::writeMakefile(QTextStream &t) t << endl << "# Directories" << "\n" << getWritableVar("SUBDIRS"); } else { + //figure out target + QString ofn = QFileInfo(static_cast(t.device())->fileName()).completeBaseName(); + if (ofn.isEmpty() || ofn == "-") + ofn = "unknown"; + project->variables()["TARGET_ASSIGN"] = QStringList(ofn); + t << getWritableVar("TARGET_ASSIGN") << getWritableVar("CONFIG", false) << getWritableVar("CONFIG_REMOVE", false) From 63017136a1a6625c3528f9b237468a55b7fab12c Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 24 Feb 2012 10:51:18 -0800 Subject: [PATCH 124/166] QClipboard: Fix autotest fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tst_qclipboard.cpp still has Q_WS_WIN which must be clear away. After clean up, auto test will fail under windows: When setMimeData() is called, dataChanged() signal will be emited twice. The solution for QTBUG-24184 has partially solved the problem, but it still there. Make sure emitChanged() only called by QPlatformClipboard will give our more control for this. Task-number: QTBUG-24484 Change-Id: I23566c6d3b32828b6865234c311af3635fe9e299 Reviewed-by: Friedemann Kleint Reviewed-by: Samuel Rødal --- src/gui/kernel/qclipboard_qpa.cpp | 2 - src/gui/kernel/qplatformclipboard_qpa.cpp | 2 + .../platforms/windows/qwindowsclipboard.cpp | 3 +- src/plugins/platforms/xcb/qxcbclipboard.cpp | 1 + src/plugins/platforms/xlib/qxlibclipboard.cpp | 1 + .../gui/kernel/qclipboard/tst_qclipboard.cpp | 44 +++++++++---------- 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/gui/kernel/qclipboard_qpa.cpp b/src/gui/kernel/qclipboard_qpa.cpp index b33ccd42a2..0d97fdd0be 100644 --- a/src/gui/kernel/qclipboard_qpa.cpp +++ b/src/gui/kernel/qclipboard_qpa.cpp @@ -76,8 +76,6 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode) if (!clipboard->supportsMode(mode)) return; clipboard->setMimeData(src,mode); - - emitChanged(mode); } bool QClipboard::supportsMode(Mode mode) const diff --git a/src/gui/kernel/qplatformclipboard_qpa.cpp b/src/gui/kernel/qplatformclipboard_qpa.cpp index 9e0c60b3f6..bc08a73a7f 100644 --- a/src/gui/kernel/qplatformclipboard_qpa.cpp +++ b/src/gui/kernel/qplatformclipboard_qpa.cpp @@ -96,6 +96,8 @@ void QPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) //we know its clipboard Q_UNUSED(mode); q_clipboardData()->setSource(data); + + emitChanged(mode); } bool QPlatformClipboard::supportsMode(QClipboard::Mode mode) const diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 4f083e93d2..cd555d71a1 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -287,8 +287,7 @@ bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM w const bool owned = ownsClipboard(); if (QWindowsContext::verboseOLE) qDebug("Clipboard changed owned %d", owned); - if (!owned) // changed is emitted by QClipboard in that case. - emitChanged(QClipboard::Clipboard); + emitChanged(QClipboard::Clipboard); // clean up the clipboard object if we no longer own the clipboard if (!owned && m_data) releaseIData(); diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index bad80568e3..f8d35ed4da 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -295,6 +295,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) qWarning("QClipboard::setData: Cannot set X11 selection owner"); } + emitChanged(mode); } bool QXcbClipboard::supportsMode(QClipboard::Mode mode) const diff --git a/src/plugins/platforms/xlib/qxlibclipboard.cpp b/src/plugins/platforms/xlib/qxlibclipboard.cpp index 920b4a4cff..69a0f20777 100644 --- a/src/plugins/platforms/xlib/qxlibclipboard.cpp +++ b/src/plugins/platforms/xlib/qxlibclipboard.cpp @@ -223,6 +223,7 @@ void QXlibClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) qWarning("QClipboard::setData: Cannot set X11 selection owner"); } + emitChanged(mode); } bool QXlibClipboard::supportsMode(QClipboard::Mode mode) const diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index e1b0535e2f..7f41f0651e 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -291,19 +291,17 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->clear(QClipboard::Selection); // used to crash on X11 QGuiApplication::clipboard()->clear(QClipboard::FindBuffer); -#if defined(Q_WS_X11) - QCOMPARE(spySelection.count(), 1); + if (QGuiApplication::clipboard()->supportsSelection()) + QCOMPARE(spySelection.count(), 1); + else + QCOMPARE(spySelection.count(), 0); + + if (QGuiApplication::clipboard()->supportsFindBuffer()) + QCOMPARE(spyFindBuffer.count(), 1); + else + QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#elif defined(Q_OS_MAC) - QCOMPARE(spySelection.count(), 0); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 1); -#elif defined(Q_WS_WIN) - QCOMPARE(spySelection.count(), 0); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#endif // an other crash test data = new QMimeData; @@ -324,19 +322,17 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Selection); // used to crash on X11 QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer); -#if defined(Q_WS_X11) - QCOMPARE(spySelection.count(), 1); + if (QGuiApplication::clipboard()->supportsSelection()) + QCOMPARE(spySelection.count(), 1); + else + QCOMPARE(spySelection.count(), 0); + + if (QGuiApplication::clipboard()->supportsFindBuffer()) + QCOMPARE(spyFindBuffer.count(), 1); + else + QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#elif defined(Q_OS_MAC) - QCOMPARE(spySelection.count(), 0); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 1); -#elif defined(Q_WS_WIN) - QCOMPARE(spySelection.count(), 0); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#endif } void tst_QClipboard::clearBeforeSetText() From 446d63be1b85284d6175b4781859d14668755ae3 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 24 Feb 2012 13:46:33 -0800 Subject: [PATCH 125/166] Fix tst_qmenu. Clear away Q_WS_WIN/Q_WS_X11 from QMenu. Using the hint returned by the QPlatformTheme. Task-number: QTBUG-24325 Change-Id: Iaa4da26c74273d7cfc1fbec6519c52d09e10f7bb Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qmenu.cpp | 34 ++++++++-------------- tests/auto/widgets/widgets/qmenu/qmenu.pro | 1 - 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index e619cdf4fc..dad12fe6ab 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -70,10 +70,8 @@ #include #include #include - -#ifdef Q_WS_X11 -# include -#endif +#include +#include QT_BEGIN_NAMESPACE @@ -177,31 +175,23 @@ int QMenuPrivate::scrollerHeight() const //Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't QRect QMenuPrivate::popupGeometry(const QWidget *widget) const { -#ifdef Q_WS_WIN - return QApplication::desktop()->screenGeometry(widget); -#elif defined Q_WS_X11 - if (X11->desktopEnvironment == DE_KDE) + if (QGuiApplicationPrivate::platformTheme() && + QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) { return QApplication::desktop()->screenGeometry(widget); - else + } else { return QApplication::desktop()->availableGeometry(widget); -#else - return QApplication::desktop()->availableGeometry(widget); -#endif + } } //Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't QRect QMenuPrivate::popupGeometry(int screen) const { -#ifdef Q_WS_WIN - return QApplication::desktop()->screenGeometry(screen); -#elif defined Q_WS_X11 - if (X11->desktopEnvironment == DE_KDE) + if (QGuiApplicationPrivate::platformTheme() && + QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) { return QApplication::desktop()->screenGeometry(screen); - else + } else { return QApplication::desktop()->availableGeometry(screen); -#else - return QApplication::desktop()->availableGeometry(screen); -#endif + } } QList > QMenuPrivate::calcCausedStack() const @@ -2261,7 +2251,7 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e) if (action && action == d->currentAction) { if (!action->menu()){ -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) //On Windows only context menus can be activated with the right button if (e->button() == Qt::LeftButton || d->topCausedWidget() == 0) #endif @@ -3000,7 +2990,7 @@ void QMenu::internalDelayedPopup() */ void QMenu::setNoReplayFor(QWidget *noReplayFor) { -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN d_func()->noReplayFor = noReplayFor; #else Q_UNUSED(noReplayFor); diff --git a/tests/auto/widgets/widgets/qmenu/qmenu.pro b/tests/auto/widgets/widgets/qmenu/qmenu.pro index 55099f1c54..9efd0302bf 100644 --- a/tests/auto/widgets/widgets/qmenu/qmenu.pro +++ b/tests/auto/widgets/widgets/qmenu/qmenu.pro @@ -3,4 +3,3 @@ TARGET = tst_qmenu QT += widgets testlib SOURCES += tst_qmenu.cpp -win32:CONFIG += insignificant_test # QTBUG-24325 From f4f97555a2d31b920cba9584f91755376a29ca6a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 21 Feb 2012 21:30:57 +0100 Subject: [PATCH 126/166] avoid using infile() needlessly it's rather pointless to first query the variable's presence in the file. instead, just fetch it and see what is in there. for this to work cleanly we defer the concatenation of the filename. Change-Id: I322db8ae897272fae049074d8b7676787286aedd Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_config.prf | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/qt_config.prf b/mkspecs/features/qt_config.prf index 3d0028c3a3..8441728815 100644 --- a/mkspecs/features/qt_config.prf +++ b/mkspecs/features/qt_config.prf @@ -6,9 +6,10 @@ exists($$_QMAKE_CACHE_) { QMAKE_EXTRA_MODULE_FORWARDS = $$fromfile($$_QMAKE_CACHE_, QMAKE_EXTRA_MODULE_FORWARDS) } isEmpty(QMAKE_QT_CONFIG)|!exists($$QMAKE_QT_CONFIG) { - !isEmpty(QT_BUILD_TREE):QMAKE_QT_CONFIG = $$QT_BUILD_TREE/mkspecs/qconfig.pri - else:exists($$_QMAKE_CACHE_):infile($$_QMAKE_CACHE_, QT_BUILD_TREE):QMAKE_QT_CONFIG = $$fromfile($$_QMAKE_CACHE_, QT_BUILD_TREE)/mkspecs/qconfig.pri - isEmpty(QMAKE_QT_CONFIG):exists($$[QT_INSTALL_DATA]/mkspecs/qconfig.pri):QMAKE_QT_CONFIG = $$[QT_INSTALL_DATA]/mkspecs/qconfig.pri + !isEmpty(QT_BUILD_TREE):QMAKE_QT_CONFIG = $$QT_BUILD_TREE + else:exists($$_QMAKE_CACHE_):QMAKE_QT_CONFIG = $$fromfile($$_QMAKE_CACHE_, QT_BUILD_TREE) + isEmpty(QMAKE_QT_CONFIG):QMAKE_QT_CONFIG = $$[QT_INSTALL_DATA] + QMAKE_QT_CONFIG = $$QMAKE_QT_CONFIG/mkspecs/qconfig.pri } !exists($$QMAKE_QT_CONFIG)|!include($$QMAKE_QT_CONFIG, "", true) { debug(1, "Cannot load qconfig.pri!") From 5bbfe4d6d8752067e51983b34169a99f563088f8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 21 Feb 2012 21:41:28 +0100 Subject: [PATCH 127/166] remove over-uses of $$list() not sure why anyone would do *that* ... Change-Id: Id91e9e8bd602a9d9275ade2ca86aaa4f4698ff72 Reviewed-by: Joerg Bornemann --- src/src.pro | 4 ++-- src/tools/tools.pro | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/src.pro b/src/src.pro index f3f6937c50..6e1517fb07 100644 --- a/src/src.pro +++ b/src/src.pro @@ -90,8 +90,8 @@ for(subname, SRC_SUBDIRS) { subdir = $$replace(subdir, $$reg_src, $$QT_BUILD_TREE) subdir = $$replace(subdir, /, $$QMAKE_DIR_SEP) subdir = $$replace(subdir, \\\\, $$QMAKE_DIR_SEP) - SUB_TEMPLATE = $$list($$fromfile($$subpro, TEMPLATE)) - !isEqual(subname, src_tools_bootstrap):if(isEqual($$SUB_TEMPLATE, lib) | isEqual($$SUB_TEMPLATE, subdirs)):!separate_debug_info { + SUB_TEMPLATE = $$fromfile($$subpro, TEMPLATE) + !isEqual(subname, src_tools_bootstrap):if(isEqual(SUB_TEMPLATE, lib) | isEqual(SUB_TEMPLATE, subdirs)):!separate_debug_info { #debug debug-$${subtarget}.depends = $${subdir}$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_DEBUG_TARGETS debug-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) debug) diff --git a/src/tools/tools.pro b/src/tools/tools.pro index e6b9eefc69..cf10163539 100644 --- a/src/tools/tools.pro +++ b/src/tools/tools.pro @@ -32,8 +32,8 @@ for(subname, TOOLS_SUBDIRS) { subdir = $$replace(subdir, $$reg_src, $$QT_BUILD_TREE) subdir = $$replace(subdir, /, $$QMAKE_DIR_SEP) subdir = $$replace(subdir, \\\\, $$QMAKE_DIR_SEP) - SUB_TEMPLATE = $$list($$fromfile($$subpro, TEMPLATE)) - !isEqual(subname, src_tools_bootstrap):if(isEqual($$SUB_TEMPLATE, lib) | isEqual($$SUB_TEMPLATE, subdirs)):!separate_debug_info { + SUB_TEMPLATE = $$fromfile($$subpro, TEMPLATE) + !isEqual(subname, src_tools_bootstrap):if(isEqual(SUB_TEMPLATE, lib) | isEqual(SUB_TEMPLATE, subdirs)):!separate_debug_info { #debug debug-$${subtarget}.depends = $${subdir}$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_DEBUG_TARGETS debug-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) debug) From 091dd54a6c145c477ade2b910519fc4d6d0e3591 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 14:46:08 +0100 Subject: [PATCH 128/166] don't rely on $PATH for finding rcc Change-Id: I7e6ffad6d84cca0b548920b3e620375fb5e314e9 Reviewed-by: Joerg Bornemann --- .../tools/qmake/testdata/quotedfilenames/quotedfilenames.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro b/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro index 7f22f437c2..13d4d6c4ad 100644 --- a/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro +++ b/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro @@ -6,7 +6,9 @@ SOURCES = main.cpp RCCINPUT = "rc folder/test.qrc" RCCOUTPUT = test.cpp -rcc_test.commands = rcc -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} +qtPrepareTool(QMAKE_RCC, rcc) + +rcc_test.commands = $$QMAKE_RCC -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} rcc_test.output = $$RCCOUTPUT rcc_test.input = RCCINPUT rcc_test.variable_out = SOURCES From edde6152094702aa4c3415920d2c962009619743 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 15:35:04 +0100 Subject: [PATCH 129/166] TestCompiler: split commands from arguments this allows us to temporarily set some extra args without (incorrectly) instantiating a second TestCompiler (and on the way relying on $PATH for finding qmake). Change-Id: Icce5bf7314148ddbe705606f77a26e3362b31f67 Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/testcompiler.cpp | 16 ++++++++++++++-- tests/auto/tools/qmake/testcompiler.h | 8 ++++++-- tests/auto/tools/qmake/tst_qmake.cpp | 14 +++++++------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index d2cb9f2435..8864d4d435 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -160,6 +160,18 @@ void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) qmakeCmd_ = qmakeCmd; } +void TestCompiler::resetArguments() +{ + makeArgs_.clear(); + qmakeArgs_.clear(); +} + +void TestCompiler::setArguments( QString makeArgs, QString qmakeArgs ) +{ + makeArgs_ = makeArgs; + qmakeArgs_ = qmakeArgs; +} + void TestCompiler::resetEnvironment() { environment_.clear(); @@ -222,7 +234,7 @@ bool TestCompiler::qmake( const QString &workDir, const QString &proName, const makeFile += "Makefile"; // Now start qmake and generate the makefile - return runCommand( qmakeCmd_ + " " + projectFile + " -o " + makeFile ); + return runCommand( qmakeCmd_ + " " + qmakeArgs_ + " " + projectFile + " -o " + makeFile ); } bool TestCompiler::make( const QString &workPath, const QString &target ) @@ -230,7 +242,7 @@ bool TestCompiler::make( const QString &workPath, const QString &target ) QDir D; D.setCurrent( workPath ); - QString cmdline = makeCmd_; + QString cmdline = makeCmd_ + " " + makeArgs_; if ( cmdline.contains("nmake", Qt::CaseInsensitive) ) cmdline.append(" /NOLOGO"); if ( !target.isEmpty() ) diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h index 116e424551..c438b52db2 100644 --- a/tests/auto/tools/qmake/testcompiler.h +++ b/tests/auto/tools/qmake/testcompiler.h @@ -55,6 +55,10 @@ public: virtual ~TestCompiler(); void setBaseCommands( QString makeCmd, QString qmakeCmd ); + + void resetArguments(); + void setArguments( QString makeArgs, QString qmakeArgs ); + void resetEnvironment(); void addToEnvironment( QString varAssignment ); @@ -78,8 +82,8 @@ public: private: bool runCommand( QString cmdLine ); - QString makeCmd_; - QString qmakeCmd_; + QString makeCmd_, makeArgs_; + QString qmakeCmd_, qmakeArgs_; QStringList environment_; // need to make this available somewhere diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 4da781f763..c01900c26e 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -138,6 +138,7 @@ void tst_qmake::init() void tst_qmake::cleanup() { + test_compiler.resetArguments(); test_compiler.clearCommandOutput(); } @@ -448,31 +449,30 @@ void tst_qmake::bundle_spaces() { QString workDir = base_path + "/testdata/bundle-spaces"; - // We set up alternate commands here, to make sure we're testing Mac + // We set up alternate arguments here, to make sure we're testing Mac // Bundles and since this might be the wrong output we rely on dry-running // make (-n). - TestCompiler local_tc; - local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++"); + test_compiler.setArguments("-n", "-spec macx-g++"); - QVERIFY( local_tc.qmake(workDir, "bundle-spaces") ); + QVERIFY( test_compiler.qmake(workDir, "bundle-spaces") ); TempFile non_existing_file(workDir + "/non-existing file"); QVERIFY( !non_existing_file.exists() ); // Make fails: no rule to make "non-existing file" - QVERIFY( !local_tc.make(workDir) ); + QVERIFY( !test_compiler.make(workDir, QString()) ); QVERIFY( non_existing_file.open(QIODevice::WriteOnly) ); QVERIFY( non_existing_file.exists() ); // Aha! - QVERIFY( local_tc.make(workDir) ); + QVERIFY( test_compiler.make(workDir) ); // Cleanup QVERIFY( non_existing_file.remove() ); QVERIFY( !non_existing_file.exists() ); - QVERIFY( local_tc.removeMakefile(workDir) ); + QVERIFY( test_compiler.removeMakefile(workDir) ); } #endif // Q_OS_WIN From fd1d98b6af09d7cff73c3316097277131d82cd38 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 15:38:30 +0100 Subject: [PATCH 130/166] make qmake test suite a tad more verbose on failure automatically dump the collected output on non-expected return code Change-Id: Ifda7287869f329c5a6714e6f21aa9c3991e9ee4e Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/testcompiler.cpp | 24 +++++++++++++++--------- tests/auto/tools/qmake/testcompiler.h | 6 +++--- tests/auto/tools/qmake/tst_qmake.cpp | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index 8864d4d435..97c640b28f 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -126,7 +126,13 @@ TestCompiler::~TestCompiler() { } -bool TestCompiler::runCommand( QString cmdline ) +bool TestCompiler::errorOut() +{ + qDebug(qPrintable(testOutput_.join("\n"))); + return false; +} + +bool TestCompiler::runCommand( QString cmdline, bool expectFail ) { testOutput_.append("Running command: " + cmdline); @@ -137,21 +143,21 @@ bool TestCompiler::runCommand( QString cmdline ) child.start(cmdline); if (!child.waitForStarted(-1)) { testOutput_.append( "Unable to start child process." ); - return false; + return errorOut(); } - bool failed = false; child.setReadChannel(QProcess::StandardError); child.waitForFinished(-1); + bool ok = child.exitStatus() == QProcess::NormalExit && (expectFail ^ (child.exitCode() == 0)); foreach (const QByteArray &output, child.readAllStandardError().split('\n')) { testOutput_.append(QString::fromLocal8Bit(output)); if (output.startsWith("Project MESSAGE: FAILED")) - failed = true; + ok = false; } - return !failed && child.exitStatus() == QProcess::NormalExit && child.exitCode() == 0; + return ok ? true : errorOut(); } void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) @@ -187,7 +193,7 @@ bool TestCompiler::makeClean( const QString &workPath ) QDir D; if (!D.exists(workPath)) { testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); - return false; + return errorOut(); } D.setCurrent(workPath); @@ -204,7 +210,7 @@ bool TestCompiler::makeDistClean( const QString &workPath ) QDir D; if (!D.exists(workPath)) { testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); - return false; + return errorOut(); } D.setCurrent(workPath); @@ -237,7 +243,7 @@ bool TestCompiler::qmake( const QString &workDir, const QString &proName, const return runCommand( qmakeCmd_ + " " + qmakeArgs_ + " " + projectFile + " -o " + makeFile ); } -bool TestCompiler::make( const QString &workPath, const QString &target ) +bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail ) { QDir D; D.setCurrent( workPath ); @@ -248,7 +254,7 @@ bool TestCompiler::make( const QString &workPath, const QString &target ) if ( !target.isEmpty() ) cmdline += " " + target; - return runCommand( cmdline ); + return runCommand( cmdline, expectFail ); } bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ) diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h index c438b52db2..8aed3a9987 100644 --- a/tests/auto/tools/qmake/testcompiler.h +++ b/tests/auto/tools/qmake/testcompiler.h @@ -69,7 +69,7 @@ public: // executes a qmake on proName in the specified workDir, output goes to buildDir or workDir if it's null bool qmake( const QString &workDir, const QString &proName, const QString &buildDir = QString() ); // executes a make in the specified workPath, with an optional target (eg. install) - bool make( const QString &workPath, const QString &target = QString() ); + bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false ); // checks if the executable exists in destDir bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ); // removes the makefile @@ -80,13 +80,13 @@ public: void clearCommandOutput(); private: - bool runCommand( QString cmdLine ); + bool runCommand( QString cmdLine, bool expectFail = false ); + bool errorOut(); QString makeCmd_, makeArgs_; QString qmakeCmd_, qmakeArgs_; QStringList environment_; - // need to make this available somewhere QStringList testOutput_; }; diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index c01900c26e..f6d88ffce3 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -461,7 +461,7 @@ void tst_qmake::bundle_spaces() QVERIFY( !non_existing_file.exists() ); // Make fails: no rule to make "non-existing file" - QVERIFY( !test_compiler.make(workDir, QString()) ); + QVERIFY( test_compiler.make(workDir, QString(), true) ); QVERIFY( non_existing_file.open(QIODevice::WriteOnly) ); QVERIFY( non_existing_file.exists() ); From 0957085f3d5cd6555e1018e480b14982fe604fb7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 15:39:23 +0100 Subject: [PATCH 131/166] move resetEnvironment() call to cleanup() we want to call it even if the test fails Change-Id: Ie8f3f9d2df5d52990d6b9f9a632e49826278175a Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/tst_qmake.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index f6d88ffce3..4db09c6c4b 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -139,6 +139,7 @@ void tst_qmake::init() void tst_qmake::cleanup() { test_compiler.resetArguments(); + test_compiler.resetEnvironment(); test_compiler.clearCommandOutput(); } @@ -306,7 +307,6 @@ void tst_qmake::export_across_file_boundaries() test_compiler.addToEnvironment("QMAKEFEATURES=."); QString workDir = base_path + "/testdata/export_across_file_boundaries"; QVERIFY( test_compiler.qmake( workDir, "foo" )); - test_compiler.resetEnvironment(); } void tst_qmake::include_dir() From 494ed1d53603e82ecdc20d766464be2b817145ae Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 15:26:56 +0100 Subject: [PATCH 132/166] remove useless init() function it did the same cleanup() did, and they are always called consecutively anyway (except at start and end where it does not matter). Change-Id: I4c82024d19d6c670f1f4037d43147a15680614ae Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/tst_qmake.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 4db09c6c4b..88ff10a764 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -57,7 +57,6 @@ public: public slots: void initTestCase(); void cleanupTestCase(); - void init(); void cleanup(); private slots: @@ -131,11 +130,6 @@ void tst_qmake::cleanupTestCase() { } -void tst_qmake::init() -{ - test_compiler.clearCommandOutput(); -} - void tst_qmake::cleanup() { test_compiler.resetArguments(); From fa5cf01e7468e53508b15726625fd681892119a4 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 27 Feb 2012 11:21:10 +0100 Subject: [PATCH 133/166] Make configure.exe only detect each compiler once After commit e0acf6504356f14a6352b16ffed7b59453914863, configure.exe built with the x64 compiler could detect the same compiler twice, breaking the -platform detection even when only one compiler is in the path. Fix this by taking advantage of the CompilerInfo struct ordering and ignore detection of the same compiler. Change-Id: I583230520d2e0859196f9d7c8af31adbb981a6ca Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- tools/configure/environment.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index ae378f6b41..b9af9eca8f 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -162,8 +162,18 @@ Compiler Environment::detectCompiler() QStringList::iterator it; for(it = pathlist.begin(); it != pathlist.end(); ++it) { if((*it).contains(productPath)) { - ++installed; - detectedCompiler = compiler_info[i].compiler; + if (detectedCompiler != compiler_info[i].compiler) { + ++installed; + detectedCompiler = compiler_info[i].compiler; + } + /* else { + + We detected the same compiler again, which happens when + configure is build with the 64-bit compiler. Skip the + duplicate so that we don't think it's installed twice. + + } + */ break; } } @@ -175,8 +185,18 @@ Compiler Environment::detectCompiler() for(int i = 0; compiler_info[i].compiler; ++i) { QString executable = QString(compiler_info[i].executable).toLower(); if (executable.length() && Environment::detectExecutable(executable)) { - ++installed; - detectedCompiler = compiler_info[i].compiler; + if (detectedCompiler != compiler_info[i].compiler) { + ++installed; + detectedCompiler = compiler_info[i].compiler; + } + /* else { + + We detected the same compiler again, which happens when + configure is build with the 64-bit compiler. Skip the + duplicate so that we don't think it's installed twice. + + } + */ break; } } From 64e0560ff451676fc96dfadd21bef436ac25bb52 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 27 Feb 2012 13:54:21 +0200 Subject: [PATCH 134/166] Fix submenu positioning Submenus are now positioned to the correct side of the parent menu based on layout direction, if there is enough space on screen to fit the menu. If there is insufficient space, then the menu is positioned to the other side of the parent menu. In case that also causes submenu to be partially ofscreen (very wide menu relative to the screen), then the submenu will be aligned with the screen edge and will overlap the parent menu. This seems like a lesser evil compared to having submenu partially offscreen, which could obscure important details such as checkmarks. Task-number: QTBUG-23568 Change-Id: I6a9ab2c232713a2ee5a6dde3227c40419d46bd3d Reviewed-by: Bradley T. Hughes Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qmenu.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index dad12fe6ab..2c97f3355c 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1898,13 +1898,21 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if ((pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset) && (pos.x() < parentActionRect.right())) { + pos.rx() = parentActionRect.left() - menuSize.width(); + if (pos.x() < screen.x()) pos.rx() = parentActionRect.right(); + if (pos.x() + menuSize.width() > screen.x() + screen.width()) + pos.rx() = screen.x(); } } else { if ((pos.x() < parentActionRect.right() + subMenuOffset) && (pos.x() + menuSize.width() > parentActionRect.left())) { + pos.rx() = parentActionRect.right(); + if (pos.x() + menuSize.width() > screen.x() + screen.width()) pos.rx() = parentActionRect.left() - menuSize.width(); + if (pos.x() < screen.x()) + pos.rx() = screen.x() + screen.width() - menuSize.width(); } } } From e2f295e27c10a9f3633344427959219caf63753d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 27 Feb 2012 12:00:07 +0100 Subject: [PATCH 135/166] Detect QMetaType::QReal from the definition of qreal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of relying to complex preprocessor expression that need to be maintained to be kept the same as in qglobal.h This aslo fix the case where QT_COORD_TYPE is defined (It is meant to be defined to float or double, any other type would not make sense) So now there should hopefully be only one place to change if one need to adjust the type of qreal Change-Id: I778312112603173562dbe675ab491b53d6cd2174 Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qmetatype.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 4e75e1414b..beb7294abd 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -200,14 +200,7 @@ public: LastWidgetsType = QSizePolicy, HighestInternalId = LastWidgetsType, -// This logic must match the one in qglobal.h -#if defined(QT_COORD_TYPE) - QReal = 0, -#elif defined(QT_NO_FPU) || defined(Q_PROCESSOR_ARM) || defined(Q_OS_WINCE) - QReal = Float, -#else - QReal = Double, -#endif + QReal = sizeof(qreal) == sizeof(double) ? Double : Float, User = 256 }; From 05e24901a14f1a656359bc649686674a9bca1473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Thu, 23 Feb 2012 08:24:21 +0100 Subject: [PATCH 136/166] QHeaderView - minor cleanup in viewportEvent This is an improvement to a previous fix with SHA e62e71162606fec134600955a89b7e0c34a7840b We actually never want to call resizeSections if the parent is hidden. Therefore we can both simplify and improve the code with this patch. When we do show/hide on parent then the visible status is updated before we get into this code. I have verified the patch on the code from: Task-number: QTBUG-14234 Change-Id: If7bfa3b3813c97b4a545e48423526e9cfe118de4 Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qheaderview.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index ed71c5a918..5d2aceaade 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2433,20 +2433,15 @@ bool QHeaderView::viewportEvent(QEvent *e) } return true; } #endif // QT_NO_STATUSTIP - case QEvent::Hide: { - d->invalidateCachedSizeHint(); + case QEvent::Hide: + case QEvent::Show: + case QEvent::FontChange: + case QEvent::StyleChange:{ QAbstractScrollArea *parent = qobject_cast(parentWidget()); if (parent && parent->isVisible()) // Only resize if we have a visible parent resizeSections(); emit geometriesChanged(); break;} - case QEvent::Show: - case QEvent::FontChange: - case QEvent::StyleChange: - d->invalidateCachedSizeHint(); - resizeSections(); - emit geometriesChanged(); - break; case QEvent::ContextMenu: { d->state = QHeaderViewPrivate::NoState; d->pressed = d->section = d->target = -1; From bc6ad75d18a029da363afc4f6007aefc7962a8ad Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 26 Feb 2012 10:56:49 +0100 Subject: [PATCH 137/166] Remove use of deprecated conversion from QKeySequence Note: UNICODE_ACCEL is Qt3 compatibility and is equal to 0 Change-Id: I808a66772abceb3822d515d69386728264eb1b40 Reviewed-by: Lars Knoll --- src/plugins/accessible/widgets/simplewidgets.cpp | 2 +- src/widgets/accessible/qaccessiblewidget.cpp | 2 +- src/widgets/dialogs/qmessagebox.cpp | 6 +++--- src/widgets/kernel/qaction.cpp | 2 +- src/widgets/widgets/qlineedit.cpp | 3 ++- src/widgets/widgets/qmenu.cpp | 4 ++-- src/widgets/widgets/qwidgettextcontrol.cpp | 4 +++- src/widgets/widgets/qworkspace.cpp | 3 ++- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 0fdd4490f7..39d7e03a1b 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -115,7 +115,7 @@ QString QAccessibleButton::text(QAccessible::Text t) const #ifndef QT_NO_SHORTCUT QPushButton *pb = qobject_cast(object()); if (pb && pb->isDefault()) - str = (QString)QKeySequence(Qt::Key_Enter); + str = QKeySequence(Qt::Key_Enter).toString(QKeySequence::NativeText); #endif if (str.isEmpty()) str = qt_accHotKey(button()->text()); diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index feac42780d..790b51102c 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -128,7 +128,7 @@ QString Q_WIDGETS_EXPORT qt_accHotKey(const QString &text) } if (ac.isNull()) return QString(); - return (QString)QKeySequence(Qt::ALT) + ac.toUpper(); + return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + ac.toUpper(); #else Q_UNUSED(text); return QString(); diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 634e911cd1..a737584e3f 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1365,13 +1365,13 @@ void QMessageBox::keyPressEvent(QKeyEvent *e) #ifndef QT_NO_SHORTCUT if (!(e->modifiers() & Qt::AltModifier)) { - int key = e->key() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL); + int key = e->key() & ~Qt::MODIFIER_MASK; if (key) { const QList buttons = d->buttonBox->buttons(); for (int i = 0; i < buttons.count(); ++i) { QAbstractButton *pb = buttons.at(i); - int acc = pb->shortcut() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL); - if (acc == key) { + QKeySequence shortcut = pb->shortcut(); + if (!shortcut.isEmpty() && key == (shortcut[0] & ~Qt::MODIFIER_MASK)) { pb->animateClick(); return; } diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index d3d63a8c7b..f450d13a39 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -1119,7 +1119,7 @@ QAction::event(QEvent *e) "QAction::event", "Received shortcut event from incorrect shortcut"); if (se->isAmbiguous()) - qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", QString(se->key()).toLatin1().constData()); + qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); else activate(Trigger); return true; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 77d6f5422a..7118881ef2 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -75,7 +75,8 @@ #include "private/qapplication_p.h" #include "private/qshortcutmap_p.h" #include "qkeysequence.h" -#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1Char('\t') + QString(QKeySequence(k)) : QString()) +#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ + QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString()) #else #define ACCEL_KEY(k) QString() #endif diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 2c97f3355c..7ebfdbecae 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -295,7 +295,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const } else { QKeySequence seq = action->shortcut(); if (!seq.isEmpty()) - tabWidth = qMax(int(tabWidth), qfm.width(seq)); + tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText))); #endif } sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width()); @@ -1187,7 +1187,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) if (textAndAccel.indexOf(QLatin1Char('\t')) == -1) { QKeySequence seq = action->shortcut(); if (!seq.isEmpty()) - textAndAccel += QLatin1Char('\t') + QString(seq); + textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText); } #endif option->text = textAndAccel; diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index a2c7915a5e..9eeffc1231 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -84,7 +84,9 @@ #include "private/qapplication_p.h" #include "private/qshortcutmap_p.h" #include -#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1Char('\t') + QString(QKeySequence(k)) : QString()) +#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ + QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString()) + #else #define ACCEL_KEY(k) QString() #endif diff --git a/src/widgets/widgets/qworkspace.cpp b/src/widgets/widgets/qworkspace.cpp index 0031a71ccd..5cc8e363f1 100644 --- a/src/widgets/widgets/qworkspace.cpp +++ b/src/widgets/widgets/qworkspace.cpp @@ -1079,7 +1079,8 @@ QWorkspacePrivate::init() actions[QWorkspacePrivate::CloseAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, q)), QWorkspace::tr("&Close") #ifndef QT_NO_SHORTCUT - +QLatin1Char('\t')+(QString)QKeySequence(Qt::CTRL+Qt::Key_F4) + + QLatin1Char('\t') + + QKeySequence(Qt::CTRL+Qt::Key_F4).toString(QKeySequence::NativeText) #endif ,q); QObject::connect(actions[QWorkspacePrivate::CloseAct], SIGNAL(triggered()), q, SLOT(closeActiveWindow())); From b51296c06433d4923e4dcfd2bc104ae3ab67fb43 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 3 Feb 2012 12:28:13 +0100 Subject: [PATCH 138/166] Add SHA-224, SHA-256, SHA-384, and SHA-512 support to QCryptographicHash This adds Sha224, Sha256, Sha384, and Sha512 enum values to QCryptographicHash::Algorithm. The implementation comes from RFC 6234, http://tools.ietf.org/html/rfc6234, which is added to src/3rdparty/rfc6234. Only the headers and SHA-2 code is included in src/3rdparty/rfc6234 (the SHA1, HMAC, and HKDF code is not included). Change-Id: I85139fd118291f15efc22899a5ddd1cc83810cfb Reviewed-by: Lars Knoll --- src/3rdparty/rfc6234/sha-private.h | 28 + src/3rdparty/rfc6234/sha.h | 356 ++++++ src/3rdparty/rfc6234/sha224-256.c | 583 ++++++++++ src/3rdparty/rfc6234/sha384-512.c | 1034 +++++++++++++++++ src/corelib/tools/qcryptographichash.cpp | 95 +- src/corelib/tools/qcryptographichash.h | 6 +- .../tst_qcryptographichash.cpp | 16 + 7 files changed, 2115 insertions(+), 3 deletions(-) create mode 100644 src/3rdparty/rfc6234/sha-private.h create mode 100644 src/3rdparty/rfc6234/sha.h create mode 100644 src/3rdparty/rfc6234/sha224-256.c create mode 100644 src/3rdparty/rfc6234/sha384-512.c diff --git a/src/3rdparty/rfc6234/sha-private.h b/src/3rdparty/rfc6234/sha-private.h new file mode 100644 index 0000000000..6e9c4520fb --- /dev/null +++ b/src/3rdparty/rfc6234/sha-private.h @@ -0,0 +1,28 @@ +/************************ sha-private.h ************************/ +/***************** See RFC 6234 for details. *******************/ +#ifndef _SHA_PRIVATE__H +#define _SHA_PRIVATE__H +/* + * These definitions are defined in FIPS 180-3, section 4.1. + * Ch() and Maj() are defined identically in sections 4.1.1, + * 4.1.2, and 4.1.3. + * + * The definitions used in FIPS 180-3 are as follows: + */ + +#ifndef USE_MODIFIED_MACROS +#define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) +#define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) +#else /* USE_MODIFIED_MACROS */ +/* + * The following definitions are equivalent and potentially faster. + */ + +#define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z)) +#define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) + +#endif /* USE_MODIFIED_MACROS */ + +#define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z)) + +#endif /* _SHA_PRIVATE__H */ diff --git a/src/3rdparty/rfc6234/sha.h b/src/3rdparty/rfc6234/sha.h new file mode 100644 index 0000000000..1ffd688079 --- /dev/null +++ b/src/3rdparty/rfc6234/sha.h @@ -0,0 +1,356 @@ +/**************************** sha.h ****************************/ +/***************** See RFC 6234 for details. *******************/ +/* + Copyright (c) 2011 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, are permitted provided that the following + conditions are met: + + - Redistributions of source code must retain the above + copyright notice, this list of conditions and + the following disclaimer. + + - Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + - Neither the name of Internet Society, IETF or IETF Trust, nor + the names of specific contributors, may be used to endorse or + promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef _SHA_H_ +#define _SHA_H_ + +/* + * Description: + * This file implements the Secure Hash Algorithms + * as defined in the U.S. National Institute of Standards + * and Technology Federal Information Processing Standards + * Publication (FIPS PUB) 180-3 published in October 2008 + * and formerly defined in its predecessors, FIPS PUB 180-1 + * and FIP PUB 180-2. + * + * A combined document showing all algorithms is available at + * http://csrc.nist.gov/publications/fips/ + * fips180-3/fips180-3_final.pdf + * + * The five hashes are defined in these sizes: + * SHA-1 20 byte / 160 bit + * SHA-224 28 byte / 224 bit + * SHA-256 32 byte / 256 bit + * SHA-384 48 byte / 384 bit + * SHA-512 64 byte / 512 bit + * + * Compilation Note: + * These files may be compiled with two options: + * USE_32BIT_ONLY - use 32-bit arithmetic only, for systems + * without 64-bit integers + * + * USE_MODIFIED_MACROS - use alternate form of the SHA_Ch() + * and SHA_Maj() macros that are equivalent + * and potentially faster on many systems + * + */ + +#include +/* + * If you do not have the ISO standard stdint.h header file, then you + * must typedef the following: + * name meaning + * uint64_t unsigned 64-bit integer + * uint32_t unsigned 32-bit integer + * uint8_t unsigned 8-bit integer (i.e., unsigned char) + * int_least16_t integer of >= 16 bits + * + * See stdint-example.h + */ + +#ifndef _SHA_enum_ +#define _SHA_enum_ +/* + * All SHA functions return one of these values. + */ +enum { + shaSuccess = 0, + shaNull, /* Null pointer parameter */ + shaInputTooLong, /* input data too long */ + shaStateError, /* called Input after FinalBits or Result */ + shaBadParam /* passed a bad parameter */ +}; +#endif /* _SHA_enum_ */ + +/* + * These constants hold size information for each of the SHA + * hashing operations + */ +enum { + SHA1_Message_Block_Size = 64, SHA224_Message_Block_Size = 64, + SHA256_Message_Block_Size = 64, SHA384_Message_Block_Size = 128, + SHA512_Message_Block_Size = 128, + USHA_Max_Message_Block_Size = SHA512_Message_Block_Size, + + SHA1HashSize = 20, SHA224HashSize = 28, SHA256HashSize = 32, + SHA384HashSize = 48, SHA512HashSize = 64, + USHAMaxHashSize = SHA512HashSize, + + SHA1HashSizeBits = 160, SHA224HashSizeBits = 224, + SHA256HashSizeBits = 256, SHA384HashSizeBits = 384, + SHA512HashSizeBits = 512, USHAMaxHashSizeBits = SHA512HashSizeBits +}; + +/* + * These constants are used in the USHA (Unified SHA) functions. + */ +typedef enum SHAversion { + SHA1, SHA224, SHA256, SHA384, SHA512 +} SHAversion; + +/* + * This structure will hold context information for the SHA-1 + * hashing operation. + */ +typedef struct SHA1Context { + uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */ + + uint32_t Length_High; /* Message length in bits */ + uint32_t Length_Low; /* Message length in bits */ + + int_least16_t Message_Block_Index; /* Message_Block array index */ + /* 512-bit message blocks */ + uint8_t Message_Block[SHA1_Message_Block_Size]; + + int Computed; /* Is the hash computed? */ + int Corrupted; /* Cumulative corruption code */ +} SHA1Context; + +/* + * This structure will hold context information for the SHA-256 + * hashing operation. + */ +typedef struct SHA256Context { + uint32_t Intermediate_Hash[SHA256HashSize/4]; /* Message Digest */ + + uint32_t Length_High; /* Message length in bits */ + uint32_t Length_Low; /* Message length in bits */ + + int_least16_t Message_Block_Index; /* Message_Block array index */ + /* 512-bit message blocks */ + uint8_t Message_Block[SHA256_Message_Block_Size]; + + int Computed; /* Is the hash computed? */ + int Corrupted; /* Cumulative corruption code */ +} SHA256Context; + +/* + * This structure will hold context information for the SHA-512 + * hashing operation. + */ +typedef struct SHA512Context { +#ifdef USE_32BIT_ONLY + uint32_t Intermediate_Hash[SHA512HashSize/4]; /* Message Digest */ + uint32_t Length[4]; /* Message length in bits */ +#else /* !USE_32BIT_ONLY */ + uint64_t Intermediate_Hash[SHA512HashSize/8]; /* Message Digest */ + uint64_t Length_High, Length_Low; /* Message length in bits */ +#endif /* USE_32BIT_ONLY */ + + int_least16_t Message_Block_Index; /* Message_Block array index */ + /* 1024-bit message blocks */ + uint8_t Message_Block[SHA512_Message_Block_Size]; + + int Computed; /* Is the hash computed?*/ + int Corrupted; /* Cumulative corruption code */ +} SHA512Context; + +/* + * This structure will hold context information for the SHA-224 + * hashing operation. It uses the SHA-256 structure for computation. + */ +typedef struct SHA256Context SHA224Context; + +/* + * This structure will hold context information for the SHA-384 + * hashing operation. It uses the SHA-512 structure for computation. + */ +typedef struct SHA512Context SHA384Context; + +/* + * This structure holds context information for all SHA + * hashing operations. + */ +typedef struct USHAContext { + int whichSha; /* which SHA is being used */ + union { + SHA1Context sha1Context; + SHA224Context sha224Context; SHA256Context sha256Context; + SHA384Context sha384Context; SHA512Context sha512Context; + } ctx; +} USHAContext; + +/* + * This structure will hold context information for the HMAC + * keyed-hashing operation. + */ +typedef struct HMACContext { + int whichSha; /* which SHA is being used */ + int hashSize; /* hash size of SHA being used */ + int blockSize; /* block size of SHA being used */ + USHAContext shaContext; /* SHA context */ + unsigned char k_opad[USHA_Max_Message_Block_Size]; + /* outer padding - key XORd with opad */ + int Computed; /* Is the MAC computed? */ + int Corrupted; /* Cumulative corruption code */ + +} HMACContext; + +/* + * This structure will hold context information for the HKDF + * extract-and-expand Key Derivation Functions. + */ +typedef struct HKDFContext { + int whichSha; /* which SHA is being used */ + HMACContext hmacContext; + int hashSize; /* hash size of SHA being used */ + unsigned char prk[USHAMaxHashSize]; + /* pseudo-random key - output of hkdfInput */ + int Computed; /* Is the key material computed? */ + int Corrupted; /* Cumulative corruption code */ +} HKDFContext; + +/* + * Function Prototypes + */ + +/* SHA-1 */ +extern int SHA1Reset(SHA1Context *); +extern int SHA1Input(SHA1Context *, const uint8_t *bytes, + unsigned int bytecount); +extern int SHA1FinalBits(SHA1Context *, uint8_t bits, + unsigned int bit_count); +extern int SHA1Result(SHA1Context *, + uint8_t Message_Digest[SHA1HashSize]); + +/* SHA-224 */ +extern int SHA224Reset(SHA224Context *); +extern int SHA224Input(SHA224Context *, const uint8_t *bytes, + unsigned int bytecount); +extern int SHA224FinalBits(SHA224Context *, uint8_t bits, + unsigned int bit_count); +extern int SHA224Result(SHA224Context *, + uint8_t Message_Digest[SHA224HashSize]); + +/* SHA-256 */ +extern int SHA256Reset(SHA256Context *); +extern int SHA256Input(SHA256Context *, const uint8_t *bytes, + unsigned int bytecount); +extern int SHA256FinalBits(SHA256Context *, uint8_t bits, + unsigned int bit_count); +extern int SHA256Result(SHA256Context *, + uint8_t Message_Digest[SHA256HashSize]); + +/* SHA-384 */ +extern int SHA384Reset(SHA384Context *); +extern int SHA384Input(SHA384Context *, const uint8_t *bytes, + unsigned int bytecount); +extern int SHA384FinalBits(SHA384Context *, uint8_t bits, + unsigned int bit_count); +extern int SHA384Result(SHA384Context *, + uint8_t Message_Digest[SHA384HashSize]); + +/* SHA-512 */ +extern int SHA512Reset(SHA512Context *); +extern int SHA512Input(SHA512Context *, const uint8_t *bytes, + unsigned int bytecount); +extern int SHA512FinalBits(SHA512Context *, uint8_t bits, + unsigned int bit_count); +extern int SHA512Result(SHA512Context *, + uint8_t Message_Digest[SHA512HashSize]); + +/* Unified SHA functions, chosen by whichSha */ +extern int USHAReset(USHAContext *context, SHAversion whichSha); +extern int USHAInput(USHAContext *context, + const uint8_t *bytes, unsigned int bytecount); +extern int USHAFinalBits(USHAContext *context, + uint8_t bits, unsigned int bit_count); +extern int USHAResult(USHAContext *context, + uint8_t Message_Digest[USHAMaxHashSize]); +extern int USHABlockSize(enum SHAversion whichSha); +extern int USHAHashSize(enum SHAversion whichSha); +extern int USHAHashSizeBits(enum SHAversion whichSha); +extern const char *USHAHashName(enum SHAversion whichSha); + +/* + * HMAC Keyed-Hashing for Message Authentication, RFC 2104, + * for all SHAs. + * This interface allows a fixed-length text input to be used. + */ +extern int hmac(SHAversion whichSha, /* which SHA algorithm to use */ + const unsigned char *text, /* pointer to data stream */ + int text_len, /* length of data stream */ + const unsigned char *key, /* pointer to authentication key */ + int key_len, /* length of authentication key */ + uint8_t digest[USHAMaxHashSize]); /* caller digest to fill in */ + +/* + * HMAC Keyed-Hashing for Message Authentication, RFC 2104, + * for all SHAs. + * This interface allows any length of text input to be used. + */ +extern int hmacReset(HMACContext *context, enum SHAversion whichSha, + const unsigned char *key, int key_len); +extern int hmacInput(HMACContext *context, const unsigned char *text, + int text_len); +extern int hmacFinalBits(HMACContext *context, uint8_t bits, + unsigned int bit_count); +extern int hmacResult(HMACContext *context, + uint8_t digest[USHAMaxHashSize]); + +/* + * HKDF HMAC-based Extract-and-Expand Key Derivation Function, + * RFC 5869, for all SHAs. + */ +extern int hkdf(SHAversion whichSha, const unsigned char *salt, + int salt_len, const unsigned char *ikm, int ikm_len, + const unsigned char *info, int info_len, + uint8_t okm[ ], int okm_len); +extern int hkdfExtract(SHAversion whichSha, const unsigned char *salt, + int salt_len, const unsigned char *ikm, + int ikm_len, uint8_t prk[USHAMaxHashSize]); +extern int hkdfExpand(SHAversion whichSha, const uint8_t prk[ ], + int prk_len, const unsigned char *info, + int info_len, uint8_t okm[ ], int okm_len); + +/* + * HKDF HMAC-based Extract-and-Expand Key Derivation Function, + * RFC 5869, for all SHAs. + * This interface allows any length of text input to be used. + */ +extern int hkdfReset(HKDFContext *context, enum SHAversion whichSha, + const unsigned char *salt, int salt_len); +extern int hkdfInput(HKDFContext *context, const unsigned char *ikm, + int ikm_len); +extern int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits, + unsigned int ikm_bit_count); +extern int hkdfResult(HKDFContext *context, + uint8_t prk[USHAMaxHashSize], + const unsigned char *info, int info_len, + uint8_t okm[USHAMaxHashSize], int okm_len); +#endif /* _SHA_H_ */ diff --git a/src/3rdparty/rfc6234/sha224-256.c b/src/3rdparty/rfc6234/sha224-256.c new file mode 100644 index 0000000000..9546540ea5 --- /dev/null +++ b/src/3rdparty/rfc6234/sha224-256.c @@ -0,0 +1,583 @@ +/************************* sha224-256.c ************************/ +/***************** See RFC 6234 for details. *******************/ +/* Copyright (c) 2011 IETF Trust and the persons identified as */ +/* authors of the code. All rights reserved. */ +/* See sha.h for terms of use and redistribution. */ + +/* + * Description: + * This file implements the Secure Hash Algorithms SHA-224 and + * SHA-256 as defined in the U.S. National Institute of Standards + * and Technology Federal Information Processing Standards + * Publication (FIPS PUB) 180-3 published in October 2008 + * and formerly defined in its predecessors, FIPS PUB 180-1 + * and FIP PUB 180-2. + * + * A combined document showing all algorithms is available at + * http://csrc.nist.gov/publications/fips/ + * fips180-3/fips180-3_final.pdf + * + * The SHA-224 and SHA-256 algorithms produce 224-bit and 256-bit + * message digests for a given data stream. It should take about + * 2**n steps to find a message with the same digest as a given + * message and 2**(n/2) to find any two messages with the same + * digest, when n is the digest size in bits. Therefore, this + * algorithm can serve as a means of providing a + * "fingerprint" for a message. + * + * Portability Issues: + * SHA-224 and SHA-256 are defined in terms of 32-bit "words". + * This code uses (included via "sha.h") to define 32- + * and 8-bit unsigned integer types. If your C compiler does not + * support 32-bit unsigned integers, this code is not + * appropriate. + * + * Caveats: + * SHA-224 and SHA-256 are designed to work with messages less + * than 2^64 bits long. This implementation uses SHA224/256Input() + * to hash the bits that are a multiple of the size of an 8-bit + * octet, and then optionally uses SHA224/256FinalBits() + * to hash the final few bits of the input. + */ + +#include "sha.h" +#include "sha-private.h" + +/* Define the SHA shift, rotate left, and rotate right macros */ +#define SHA256_SHR(bits,word) ((word) >> (bits)) +#define SHA256_ROTL(bits,word) \ + (((word) << (bits)) | ((word) >> (32-(bits)))) +#define SHA256_ROTR(bits,word) \ + (((word) >> (bits)) | ((word) << (32-(bits)))) + +/* Define the SHA SIGMA and sigma macros */ +#define SHA256_SIGMA0(word) \ + (SHA256_ROTR( 2,word) ^ SHA256_ROTR(13,word) ^ SHA256_ROTR(22,word)) +#define SHA256_SIGMA1(word) \ + (SHA256_ROTR( 6,word) ^ SHA256_ROTR(11,word) ^ SHA256_ROTR(25,word)) +#define SHA256_sigma0(word) \ + (SHA256_ROTR( 7,word) ^ SHA256_ROTR(18,word) ^ SHA256_SHR( 3,word)) +#define SHA256_sigma1(word) \ + (SHA256_ROTR(17,word) ^ SHA256_ROTR(19,word) ^ SHA256_SHR(10,word)) + +/* + * Add "length" to the length. + * Set Corrupted when overflow has occurred. + */ +/* addTemp commented out by Nokia, static variables are not thread-safe */ +/* static uint32_t addTemp; */ +/* 'M' appended to Macro name by Nokia */ +#define SHA224_256AddLengthM(context, length) \ + (addTemp = (context)->Length_Low, (context)->Corrupted = \ + (((context)->Length_Low += (length)) < addTemp) && \ + (++(context)->Length_High == 0) ? shaInputTooLong : \ + (context)->Corrupted ) + +/* Local Function Prototypes */ +static int SHA224_256Reset(SHA256Context *context, uint32_t *H0); +static void SHA224_256ProcessMessageBlock(SHA256Context *context); +static void SHA224_256Finalize(SHA256Context *context, + uint8_t Pad_Byte); +static void SHA224_256PadMessage(SHA256Context *context, + uint8_t Pad_Byte); +static int SHA224_256ResultN(SHA256Context *context, + uint8_t Message_Digest[ ], int HashSize); + +/* Initial Hash Values: FIPS 180-3 section 5.3.2 */ +static uint32_t SHA224_H0[SHA256HashSize/4] = { + 0xC1059ED8, 0x367CD507, 0x3070DD17, 0xF70E5939, + 0xFFC00B31, 0x68581511, 0x64F98FA7, 0xBEFA4FA4 +}; + +/* Initial Hash Values: FIPS 180-3 section 5.3.3 */ +static uint32_t SHA256_H0[SHA256HashSize/4] = { + 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, + 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 +}; + +/* + * SHA224Reset + * + * Description: + * This function will initialize the SHA224Context in preparation + * for computing a new SHA224 message digest. + * + * Parameters: + * context: [in/out] + * The context to reset. + * + * Returns: + * sha Error Code. + */ +int SHA224Reset(SHA224Context *context) +{ + return SHA224_256Reset(context, SHA224_H0); +} + +/* + * SHA224Input + * + * Description: + * This function accepts an array of octets as the next portion + * of the message. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * message_array[ ]: [in] + * An array of octets representing the next portion of + * the message. + * length: [in] + * The length of the message in message_array. + * + * Returns: + * sha Error Code. + * + */ +int SHA224Input(SHA224Context *context, const uint8_t *message_array, + unsigned int length) +{ + return SHA256Input(context, message_array, length); +} + +/* + * SHA224FinalBits + * + * Description: + * This function will add in any final bits of the message. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * message_bits: [in] + * The final bits of the message, in the upper portion of the + * byte. (Use 0b###00000 instead of 0b00000### to input the + * three bits ###.) + * length: [in] + * The number of bits in message_bits, between 1 and 7. + * + * Returns: + * sha Error Code. + */ +int SHA224FinalBits(SHA224Context *context, + uint8_t message_bits, unsigned int length) +{ + return SHA256FinalBits(context, message_bits, length); +} + +/* + * SHA224Result + * + * Description: + * This function will return the 224-bit message digest + * into the Message_Digest array provided by the caller. + * NOTE: + * The first octet of hash is stored in the element with index 0, + * the last octet of hash in the element with index 27. + * + * Parameters: + * context: [in/out] + * The context to use to calculate the SHA hash. + * Message_Digest[ ]: [out] + * Where the digest is returned. + * + * Returns: + * sha Error Code. + */ +int SHA224Result(SHA224Context *context, + uint8_t Message_Digest[SHA224HashSize]) +{ + return SHA224_256ResultN(context, Message_Digest, SHA224HashSize); +} + +/* + * SHA256Reset + * + * Description: + * This function will initialize the SHA256Context in preparation + * for computing a new SHA256 message digest. + * + * Parameters: + * context: [in/out] + * The context to reset. + * + * Returns: + * sha Error Code. + */ +int SHA256Reset(SHA256Context *context) +{ + return SHA224_256Reset(context, SHA256_H0); +} + +/* + * SHA256Input + * + * Description: + * This function accepts an array of octets as the next portion + * of the message. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * message_array[ ]: [in] + * An array of octets representing the next portion of + * the message. + * length: [in] + * The length of the message in message_array. + * + * Returns: + * sha Error Code. + */ +int SHA256Input(SHA256Context *context, const uint8_t *message_array, + unsigned int length) +{ + if (!context) return shaNull; + if (!length) return shaSuccess; + if (!message_array) return shaNull; + if (context->Computed) return context->Corrupted = shaStateError; + if (context->Corrupted) return context->Corrupted; + + while (length--) { + context->Message_Block[context->Message_Block_Index++] = + *message_array; + + if ((SHA224_256AddLength(context, 8) == shaSuccess) && + (context->Message_Block_Index == SHA256_Message_Block_Size)) + SHA224_256ProcessMessageBlock(context); + + message_array++; + } + + return context->Corrupted; + +} + +/* + * SHA256FinalBits + * + * Description: + * This function will add in any final bits of the message. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * message_bits: [in] + * The final bits of the message, in the upper portion of the + * byte. (Use 0b###00000 instead of 0b00000### to input the + * three bits ###.) + * length: [in] + * The number of bits in message_bits, between 1 and 7. + * + * Returns: + * sha Error Code. + */ +int SHA256FinalBits(SHA256Context *context, + uint8_t message_bits, unsigned int length) +{ + static uint8_t masks[8] = { + /* 0 0b00000000 */ 0x00, /* 1 0b10000000 */ 0x80, + /* 2 0b11000000 */ 0xC0, /* 3 0b11100000 */ 0xE0, + /* 4 0b11110000 */ 0xF0, /* 5 0b11111000 */ 0xF8, + /* 6 0b11111100 */ 0xFC, /* 7 0b11111110 */ 0xFE + }; + static uint8_t markbit[8] = { + /* 0 0b10000000 */ 0x80, /* 1 0b01000000 */ 0x40, + /* 2 0b00100000 */ 0x20, /* 3 0b00010000 */ 0x10, + /* 4 0b00001000 */ 0x08, /* 5 0b00000100 */ 0x04, + /* 6 0b00000010 */ 0x02, /* 7 0b00000001 */ 0x01 + }; + + if (!context) return shaNull; + if (!length) return shaSuccess; + if (context->Corrupted) return context->Corrupted; + if (context->Computed) return context->Corrupted = shaStateError; + if (length >= 8) return context->Corrupted = shaBadParam; + + SHA224_256AddLength(context, length); + SHA224_256Finalize(context, (uint8_t) + ((message_bits & masks[length]) | markbit[length])); + + return context->Corrupted; +} + +/* + * SHA256Result + * + * Description: + * This function will return the 256-bit message digest + * into the Message_Digest array provided by the caller. + * NOTE: + * The first octet of hash is stored in the element with index 0, + * the last octet of hash in the element with index 31. + * + * Parameters: + * context: [in/out] + * The context to use to calculate the SHA hash. + * Message_Digest[ ]: [out] + * Where the digest is returned. + * + * Returns: + * sha Error Code. + */ +int SHA256Result(SHA256Context *context, + uint8_t Message_Digest[SHA256HashSize]) +{ + return SHA224_256ResultN(context, Message_Digest, SHA256HashSize); +} + +/* + * SHA224_256Reset + * + * Description: + * This helper function will initialize the SHA256Context in + * preparation for computing a new SHA-224 or SHA-256 message digest. + * + * Parameters: + * context: [in/out] + * The context to reset. + * H0[ ]: [in] + * The initial hash value array to use. + * + * Returns: + * sha Error Code. + */ +static int SHA224_256Reset(SHA256Context *context, uint32_t *H0) +{ + if (!context) return shaNull; + + context->Length_High = context->Length_Low = 0; + context->Message_Block_Index = 0; + + context->Intermediate_Hash[0] = H0[0]; + context->Intermediate_Hash[1] = H0[1]; + context->Intermediate_Hash[2] = H0[2]; + context->Intermediate_Hash[3] = H0[3]; + context->Intermediate_Hash[4] = H0[4]; + context->Intermediate_Hash[5] = H0[5]; + context->Intermediate_Hash[6] = H0[6]; + context->Intermediate_Hash[7] = H0[7]; + + context->Computed = 0; + context->Corrupted = shaSuccess; + + return shaSuccess; +} + +/* + * SHA224_256ProcessMessageBlock + * + * Description: + * This helper function will process the next 512 bits of the + * message stored in the Message_Block array. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * + * Returns: + * Nothing. + * + * Comments: + * Many of the variable names in this code, especially the + * single character names, were used because those were the + * names used in the Secure Hash Standard. + */ +static void SHA224_256ProcessMessageBlock(SHA256Context *context) +{ + /* Constants defined in FIPS 180-3, section 4.2.2 */ + static const uint32_t K[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, + 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, + 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, + 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, + 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, + 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, + 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, + 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, + 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, + 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + }; + int t, t4; /* Loop counter */ + uint32_t temp1, temp2; /* Temporary word value */ + uint32_t W[64]; /* Word sequence */ + uint32_t A, B, C, D, E, F, G, H; /* Word buffers */ + + /* + * Initialize the first 16 words in the array W + */ + for (t = t4 = 0; t < 16; t++, t4 += 4) + W[t] = (((uint32_t)context->Message_Block[t4]) << 24) | + (((uint32_t)context->Message_Block[t4 + 1]) << 16) | + (((uint32_t)context->Message_Block[t4 + 2]) << 8) | + (((uint32_t)context->Message_Block[t4 + 3])); + + for (t = 16; t < 64; t++) + W[t] = SHA256_sigma1(W[t-2]) + W[t-7] + + SHA256_sigma0(W[t-15]) + W[t-16]; + + A = context->Intermediate_Hash[0]; + B = context->Intermediate_Hash[1]; + C = context->Intermediate_Hash[2]; + D = context->Intermediate_Hash[3]; + E = context->Intermediate_Hash[4]; + F = context->Intermediate_Hash[5]; + G = context->Intermediate_Hash[6]; + H = context->Intermediate_Hash[7]; + + for (t = 0; t < 64; t++) { + temp1 = H + SHA256_SIGMA1(E) + SHA_Ch(E,F,G) + K[t] + W[t]; + temp2 = SHA256_SIGMA0(A) + SHA_Maj(A,B,C); + H = G; + G = F; + F = E; + E = D + temp1; + D = C; + C = B; + B = A; + A = temp1 + temp2; + } + + context->Intermediate_Hash[0] += A; + context->Intermediate_Hash[1] += B; + context->Intermediate_Hash[2] += C; + context->Intermediate_Hash[3] += D; + context->Intermediate_Hash[4] += E; + context->Intermediate_Hash[5] += F; + context->Intermediate_Hash[6] += G; + context->Intermediate_Hash[7] += H; + + context->Message_Block_Index = 0; +} + +/* + * SHA224_256Finalize + * + * Description: + * This helper function finishes off the digest calculations. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * Pad_Byte: [in] + * The last byte to add to the message block before the 0-padding + * and length. This will contain the last bits of the message + * followed by another single bit. If the message was an + * exact multiple of 8-bits long, Pad_Byte will be 0x80. + * + * Returns: + * sha Error Code. + */ +static void SHA224_256Finalize(SHA256Context *context, + uint8_t Pad_Byte) +{ + int i; + SHA224_256PadMessage(context, Pad_Byte); + /* message may be sensitive, so clear it out */ + for (i = 0; i < SHA256_Message_Block_Size; ++i) + context->Message_Block[i] = 0; + context->Length_High = 0; /* and clear length */ + context->Length_Low = 0; + context->Computed = 1; +} + +/* + * SHA224_256PadMessage + * + * Description: + * According to the standard, the message must be padded to the next + * even multiple of 512 bits. The first padding bit must be a '1'. + * The last 64 bits represent the length of the original message. + * All bits in between should be 0. This helper function will pad + * the message according to those rules by filling the + * Message_Block array accordingly. When it returns, it can be + * assumed that the message digest has been computed. + * + * Parameters: + * context: [in/out] + * The context to pad. + * Pad_Byte: [in] + * The last byte to add to the message block before the 0-padding + * and length. This will contain the last bits of the message + * followed by another single bit. If the message was an + * exact multiple of 8-bits long, Pad_Byte will be 0x80. + * + * Returns: + * Nothing. + */ +static void SHA224_256PadMessage(SHA256Context *context, + uint8_t Pad_Byte) +{ + /* + * Check to see if the current message block is too small to hold + * the initial padding bits and length. If so, we will pad the + * block, process it, and then continue padding into a second + * block. + */ + if (context->Message_Block_Index >= (SHA256_Message_Block_Size-8)) { + context->Message_Block[context->Message_Block_Index++] = Pad_Byte; + while (context->Message_Block_Index < SHA256_Message_Block_Size) + context->Message_Block[context->Message_Block_Index++] = 0; + SHA224_256ProcessMessageBlock(context); + } else + context->Message_Block[context->Message_Block_Index++] = Pad_Byte; + + while (context->Message_Block_Index < (SHA256_Message_Block_Size-8)) + context->Message_Block[context->Message_Block_Index++] = 0; + + /* + * Store the message length as the last 8 octets + */ + context->Message_Block[56] = (uint8_t)(context->Length_High >> 24); + context->Message_Block[57] = (uint8_t)(context->Length_High >> 16); + context->Message_Block[58] = (uint8_t)(context->Length_High >> 8); + context->Message_Block[59] = (uint8_t)(context->Length_High); + context->Message_Block[60] = (uint8_t)(context->Length_Low >> 24); + context->Message_Block[61] = (uint8_t)(context->Length_Low >> 16); + context->Message_Block[62] = (uint8_t)(context->Length_Low >> 8); + context->Message_Block[63] = (uint8_t)(context->Length_Low); + + SHA224_256ProcessMessageBlock(context); +} + +/* + * SHA224_256ResultN + * + * Description: + * This helper function will return the 224-bit or 256-bit message + * digest into the Message_Digest array provided by the caller. + * NOTE: + * The first octet of hash is stored in the element with index 0, + * the last octet of hash in the element with index 27/31. + * + * Parameters: + * context: [in/out] + * The context to use to calculate the SHA hash. + * Message_Digest[ ]: [out] + * Where the digest is returned. + * HashSize: [in] + * The size of the hash, either 28 or 32. + * + * Returns: + * sha Error Code. + */ +static int SHA224_256ResultN(SHA256Context *context, + uint8_t Message_Digest[ ], int HashSize) +{ + int i; + + if (!context) return shaNull; + if (!Message_Digest) return shaNull; + if (context->Corrupted) return context->Corrupted; + + if (!context->Computed) + SHA224_256Finalize(context, 0x80); + + for (i = 0; i < HashSize; ++i) + Message_Digest[i] = (uint8_t) + (context->Intermediate_Hash[i>>2] >> 8 * ( 3 - ( i & 0x03 ) )); + + return shaSuccess; +} diff --git a/src/3rdparty/rfc6234/sha384-512.c b/src/3rdparty/rfc6234/sha384-512.c new file mode 100644 index 0000000000..7d9ba3fa52 --- /dev/null +++ b/src/3rdparty/rfc6234/sha384-512.c @@ -0,0 +1,1034 @@ +/************************* sha384-512.c ************************/ +/***************** See RFC 6234 for details. *******************/ +/* Copyright (c) 2011 IETF Trust and the persons identified as */ +/* authors of the code. All rights reserved. */ +/* See sha.h for terms of use and redistribution. */ + +/* + * Description: + * This file implements the Secure Hash Algorithms SHA-384 and + * SHA-512 as defined in the U.S. National Institute of Standards + * and Technology Federal Information Processing Standards + * Publication (FIPS PUB) 180-3 published in October 2008 + * and formerly defined in its predecessors, FIPS PUB 180-1 + * and FIP PUB 180-2. + * + * A combined document showing all algorithms is available at + * http://csrc.nist.gov/publications/fips/ + * fips180-3/fips180-3_final.pdf + * + * The SHA-384 and SHA-512 algorithms produce 384-bit and 512-bit + * message digests for a given data stream. It should take about + * 2**n steps to find a message with the same digest as a given + * message and 2**(n/2) to find any two messages with the same + * digest, when n is the digest size in bits. Therefore, this + * algorithm can serve as a means of providing a + * "fingerprint" for a message. + * + * Portability Issues: + * SHA-384 and SHA-512 are defined in terms of 64-bit "words", + * but if USE_32BIT_ONLY is #defined, this code is implemented in + * terms of 32-bit "words". This code uses (included + * via "sha.h") to define the 64-, 32- and 8-bit unsigned integer + * types. If your C compiler does not support 64-bit unsigned + * integers and you do not #define USE_32BIT_ONLY, this code is + * not appropriate. + * + * Caveats: + * SHA-384 and SHA-512 are designed to work with messages less + * than 2^128 bits long. This implementation uses SHA384/512Input() + * to hash the bits that are a multiple of the size of an 8-bit + * octet, and then optionally uses SHA384/256FinalBits() + * to hash the final few bits of the input. + * + */ + +#include "sha.h" + +#ifdef USE_32BIT_ONLY +/* + * Define 64-bit arithmetic in terms of 32-bit arithmetic. + * Each 64-bit number is represented in a 2-word array. + * All macros are defined such that the result is the last parameter. + */ + +/* + * Define shift, rotate left, and rotate right functions + */ +#define SHA512_SHR(bits, word, ret) ( \ + /* (((uint64_t)((word))) >> (bits)) */ \ + (ret)[0] = (((bits) < 32) && ((bits) >= 0)) ? \ + ((word)[0] >> (bits)) : 0, \ + (ret)[1] = ((bits) > 32) ? ((word)[0] >> ((bits) - 32)) : \ + ((bits) == 32) ? (word)[0] : \ + ((bits) >= 0) ? \ + (((word)[0] << (32 - (bits))) | \ + ((word)[1] >> (bits))) : 0 ) + +#define SHA512_SHL(bits, word, ret) ( \ + /* (((uint64_t)(word)) << (bits)) */ \ + (ret)[0] = ((bits) > 32) ? ((word)[1] << ((bits) - 32)) : \ + ((bits) == 32) ? (word)[1] : \ + ((bits) >= 0) ? \ + (((word)[0] << (bits)) | \ + ((word)[1] >> (32 - (bits)))) : \ + 0, \ + (ret)[1] = (((bits) < 32) && ((bits) >= 0)) ? \ + ((word)[1] << (bits)) : 0 ) + +/* + * Define 64-bit OR + */ +#define SHA512_OR(word1, word2, ret) ( \ + (ret)[0] = (word1)[0] | (word2)[0], \ + (ret)[1] = (word1)[1] | (word2)[1] ) + +/* + * Define 64-bit XOR + */ +#define SHA512_XOR(word1, word2, ret) ( \ + (ret)[0] = (word1)[0] ^ (word2)[0], \ + (ret)[1] = (word1)[1] ^ (word2)[1] ) + +/* + * Define 64-bit AND + */ +#define SHA512_AND(word1, word2, ret) ( \ + (ret)[0] = (word1)[0] & (word2)[0], \ + (ret)[1] = (word1)[1] & (word2)[1] ) + +/* + * Define 64-bit TILDA + */ +#define SHA512_TILDA(word, ret) \ + ( (ret)[0] = ~(word)[0], (ret)[1] = ~(word)[1] ) + +/* + * Define 64-bit ADD + */ +#define SHA512_ADD(word1, word2, ret) ( \ + (ret)[1] = (word1)[1], (ret)[1] += (word2)[1], \ + (ret)[0] = (word1)[0] + (word2)[0] + ((ret)[1] < (word1)[1]) ) + +/* + * Add the 4word value in word2 to word1. + */ +static uint32_t ADDTO4_temp, ADDTO4_temp2; +#define SHA512_ADDTO4(word1, word2) ( \ + ADDTO4_temp = (word1)[3], \ + (word1)[3] += (word2)[3], \ + ADDTO4_temp2 = (word1)[2], \ + (word1)[2] += (word2)[2] + ((word1)[3] < ADDTO4_temp), \ + ADDTO4_temp = (word1)[1], \ + (word1)[1] += (word2)[1] + ((word1)[2] < ADDTO4_temp2), \ + (word1)[0] += (word2)[0] + ((word1)[1] < ADDTO4_temp) ) + +/* + * Add the 2word value in word2 to word1. + */ +static uint32_t ADDTO2_temp; +#define SHA512_ADDTO2(word1, word2) ( \ + ADDTO2_temp = (word1)[1], \ + (word1)[1] += (word2)[1], \ + (word1)[0] += (word2)[0] + ((word1)[1] < ADDTO2_temp) ) + +/* + * SHA rotate ((word >> bits) | (word << (64-bits))) + */ +static uint32_t ROTR_temp1[2], ROTR_temp2[2]; +#define SHA512_ROTR(bits, word, ret) ( \ + SHA512_SHR((bits), (word), ROTR_temp1), \ + SHA512_SHL(64-(bits), (word), ROTR_temp2), \ + SHA512_OR(ROTR_temp1, ROTR_temp2, (ret)) ) + +/* + * Define the SHA SIGMA and sigma macros + * + * SHA512_ROTR(28,word) ^ SHA512_ROTR(34,word) ^ SHA512_ROTR(39,word) + */ +static uint32_t SIGMA0_temp1[2], SIGMA0_temp2[2], + SIGMA0_temp3[2], SIGMA0_temp4[2]; +#define SHA512_SIGMA0(word, ret) ( \ + SHA512_ROTR(28, (word), SIGMA0_temp1), \ + SHA512_ROTR(34, (word), SIGMA0_temp2), \ + SHA512_ROTR(39, (word), SIGMA0_temp3), \ + SHA512_XOR(SIGMA0_temp2, SIGMA0_temp3, SIGMA0_temp4), \ + SHA512_XOR(SIGMA0_temp1, SIGMA0_temp4, (ret)) ) + +/* + * SHA512_ROTR(14,word) ^ SHA512_ROTR(18,word) ^ SHA512_ROTR(41,word) + */ +static uint32_t SIGMA1_temp1[2], SIGMA1_temp2[2], + SIGMA1_temp3[2], SIGMA1_temp4[2]; +#define SHA512_SIGMA1(word, ret) ( \ + SHA512_ROTR(14, (word), SIGMA1_temp1), \ + SHA512_ROTR(18, (word), SIGMA1_temp2), \ + SHA512_ROTR(41, (word), SIGMA1_temp3), \ + SHA512_XOR(SIGMA1_temp2, SIGMA1_temp3, SIGMA1_temp4), \ + SHA512_XOR(SIGMA1_temp1, SIGMA1_temp4, (ret)) ) + +/* + * (SHA512_ROTR( 1,word) ^ SHA512_ROTR( 8,word) ^ SHA512_SHR( 7,word)) + */ +static uint32_t sigma0_temp1[2], sigma0_temp2[2], + sigma0_temp3[2], sigma0_temp4[2]; +#define SHA512_sigma0(word, ret) ( \ + SHA512_ROTR( 1, (word), sigma0_temp1), \ + SHA512_ROTR( 8, (word), sigma0_temp2), \ + SHA512_SHR( 7, (word), sigma0_temp3), \ + SHA512_XOR(sigma0_temp2, sigma0_temp3, sigma0_temp4), \ + SHA512_XOR(sigma0_temp1, sigma0_temp4, (ret)) ) + +/* + * (SHA512_ROTR(19,word) ^ SHA512_ROTR(61,word) ^ SHA512_SHR( 6,word)) + */ +static uint32_t sigma1_temp1[2], sigma1_temp2[2], + sigma1_temp3[2], sigma1_temp4[2]; +#define SHA512_sigma1(word, ret) ( \ + SHA512_ROTR(19, (word), sigma1_temp1), \ + SHA512_ROTR(61, (word), sigma1_temp2), \ + SHA512_SHR( 6, (word), sigma1_temp3), \ + SHA512_XOR(sigma1_temp2, sigma1_temp3, sigma1_temp4), \ + SHA512_XOR(sigma1_temp1, sigma1_temp4, (ret)) ) + +#ifndef USE_MODIFIED_MACROS +/* + * These definitions are the ones used in FIPS 180-3, section 4.1.3 + * Ch(x,y,z) ((x & y) ^ (~x & z)) + */ +static uint32_t Ch_temp1[2], Ch_temp2[2], Ch_temp3[2]; +#define SHA_Ch(x, y, z, ret) ( \ + SHA512_AND(x, y, Ch_temp1), \ + SHA512_TILDA(x, Ch_temp2), \ + SHA512_AND(Ch_temp2, z, Ch_temp3), \ + SHA512_XOR(Ch_temp1, Ch_temp3, (ret)) ) + +/* + * Maj(x,y,z) (((x)&(y)) ^ ((x)&(z)) ^ ((y)&(z))) + */ +static uint32_t Maj_temp1[2], Maj_temp2[2], + Maj_temp3[2], Maj_temp4[2]; +#define SHA_Maj(x, y, z, ret) ( \ + SHA512_AND(x, y, Maj_temp1), \ + SHA512_AND(x, z, Maj_temp2), \ + SHA512_AND(y, z, Maj_temp3), \ + SHA512_XOR(Maj_temp2, Maj_temp3, Maj_temp4), \ + SHA512_XOR(Maj_temp1, Maj_temp4, (ret)) ) +#else /* !USE_MODIFIED_MACROS */ +/* + * These definitions are potentially faster equivalents for the ones + * used in FIPS 180-3, section 4.1.3. + * ((x & y) ^ (~x & z)) becomes + * ((x & (y ^ z)) ^ z) + */ +#define SHA_Ch(x, y, z, ret) ( \ + (ret)[0] = (((x)[0] & ((y)[0] ^ (z)[0])) ^ (z)[0]), \ + (ret)[1] = (((x)[1] & ((y)[1] ^ (z)[1])) ^ (z)[1]) ) + +/* + * ((x & y) ^ (x & z) ^ (y & z)) becomes + * ((x & (y | z)) | (y & z)) + */ +#define SHA_Maj(x, y, z, ret) ( \ + ret[0] = (((x)[0] & ((y)[0] | (z)[0])) | ((y)[0] & (z)[0])), \ + ret[1] = (((x)[1] & ((y)[1] | (z)[1])) | ((y)[1] & (z)[1])) ) +#endif /* USE_MODIFIED_MACROS */ + +/* + * Add "length" to the length. + * Set Corrupted when overflow has occurred. + */ +static uint32_t addTemp[4] = { 0, 0, 0, 0 }; +#define SHA384_512AddLength(context, length) ( \ + addTemp[3] = (length), SHA512_ADDTO4((context)->Length, addTemp), \ + (context)->Corrupted = (((context)->Length[3] < (length)) && \ + ((context)->Length[2] == 0) && ((context)->Length[1] == 0) && \ + ((context)->Length[0] == 0)) ? shaInputTooLong : \ + (context)->Corrupted ) + +/* Local Function Prototypes */ +static int SHA384_512Reset(SHA512Context *context, + uint32_t H0[SHA512HashSize/4]); +static void SHA384_512ProcessMessageBlock(SHA512Context *context); +static void SHA384_512Finalize(SHA512Context *context, + uint8_t Pad_Byte); +static void SHA384_512PadMessage(SHA512Context *context, + uint8_t Pad_Byte); +static int SHA384_512ResultN( SHA512Context *context, + uint8_t Message_Digest[ ], int HashSize); + +/* Initial Hash Values: FIPS 180-3 sections 5.3.4 and 5.3.5 */ +static uint32_t SHA384_H0[SHA512HashSize/4] = { + 0xCBBB9D5D, 0xC1059ED8, 0x629A292A, 0x367CD507, 0x9159015A, + 0x3070DD17, 0x152FECD8, 0xF70E5939, 0x67332667, 0xFFC00B31, + 0x8EB44A87, 0x68581511, 0xDB0C2E0D, 0x64F98FA7, 0x47B5481D, + 0xBEFA4FA4 +}; +static uint32_t SHA512_H0[SHA512HashSize/4] = { + 0x6A09E667, 0xF3BCC908, 0xBB67AE85, 0x84CAA73B, 0x3C6EF372, + 0xFE94F82B, 0xA54FF53A, 0x5F1D36F1, 0x510E527F, 0xADE682D1, + 0x9B05688C, 0x2B3E6C1F, 0x1F83D9AB, 0xFB41BD6B, 0x5BE0CD19, + 0x137E2179 +}; + +#else /* !USE_32BIT_ONLY */ + +#include "sha-private.h" + +/* Define the SHA shift, rotate left and rotate right macros */ +#define SHA512_SHR(bits,word) (((uint64_t)(word)) >> (bits)) +#define SHA512_ROTR(bits,word) ((((uint64_t)(word)) >> (bits)) | \ + (((uint64_t)(word)) << (64-(bits)))) + +/* + * Define the SHA SIGMA and sigma macros + * + * SHA512_ROTR(28,word) ^ SHA512_ROTR(34,word) ^ SHA512_ROTR(39,word) + */ +#define SHA512_SIGMA0(word) \ + (SHA512_ROTR(28,word) ^ SHA512_ROTR(34,word) ^ SHA512_ROTR(39,word)) +#define SHA512_SIGMA1(word) \ + (SHA512_ROTR(14,word) ^ SHA512_ROTR(18,word) ^ SHA512_ROTR(41,word)) +#define SHA512_sigma0(word) \ + (SHA512_ROTR( 1,word) ^ SHA512_ROTR( 8,word) ^ SHA512_SHR( 7,word)) +#define SHA512_sigma1(word) \ + (SHA512_ROTR(19,word) ^ SHA512_ROTR(61,word) ^ SHA512_SHR( 6,word)) + +/* + * Add "length" to the length. + * Set Corrupted when overflow has occurred. + */ +/* addTemp commented out by Nokia, static variables are not thread-safe */ +/* static uint64_t addTemp; */ +/* 'M' appended to Macro name by Nokia */ +#define SHA384_512AddLengthM(context, length) \ + (addTemp = context->Length_Low, context->Corrupted = \ + ((context->Length_Low += length) < addTemp) && \ + (++context->Length_High == 0) ? shaInputTooLong : \ + (context)->Corrupted) + +/* Local Function Prototypes */ +static int SHA384_512Reset(SHA512Context *context, + uint64_t H0[SHA512HashSize/8]); +static void SHA384_512ProcessMessageBlock(SHA512Context *context); +static void SHA384_512Finalize(SHA512Context *context, + uint8_t Pad_Byte); +static void SHA384_512PadMessage(SHA512Context *context, + uint8_t Pad_Byte); +static int SHA384_512ResultN(SHA512Context *context, + uint8_t Message_Digest[ ], int HashSize); + +/* Initial Hash Values: FIPS 180-3 sections 5.3.4 and 5.3.5 */ +static uint64_t SHA384_H0[ ] = { + 0xCBBB9D5DC1059ED8ll, 0x629A292A367CD507ll, 0x9159015A3070DD17ll, + 0x152FECD8F70E5939ll, 0x67332667FFC00B31ll, 0x8EB44A8768581511ll, + 0xDB0C2E0D64F98FA7ll, 0x47B5481DBEFA4FA4ll +}; +static uint64_t SHA512_H0[ ] = { + 0x6A09E667F3BCC908ll, 0xBB67AE8584CAA73Bll, 0x3C6EF372FE94F82Bll, + 0xA54FF53A5F1D36F1ll, 0x510E527FADE682D1ll, 0x9B05688C2B3E6C1Fll, + 0x1F83D9ABFB41BD6Bll, 0x5BE0CD19137E2179ll +}; + +#endif /* USE_32BIT_ONLY */ + +/* + * SHA384Reset + * + * Description: + * This function will initialize the SHA384Context in preparation + * for computing a new SHA384 message digest. + * + * Parameters: + * context: [in/out] + * The context to reset. + * + * Returns: + * sha Error Code. + * + */ +int SHA384Reset(SHA384Context *context) +{ + return SHA384_512Reset(context, SHA384_H0); +} + +/* + * SHA384Input + * + * Description: + * This function accepts an array of octets as the next portion + * of the message. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * message_array[ ]: [in] + * An array of octets representing the next portion of + * the message. + * length: [in] + * The length of the message in message_array. + * + * Returns: + * sha Error Code. + * + */ +int SHA384Input(SHA384Context *context, + const uint8_t *message_array, unsigned int length) +{ + return SHA512Input(context, message_array, length); +} + +/* + * SHA384FinalBits + * + * Description: + * This function will add in any final bits of the message. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * message_bits: [in] + * The final bits of the message, in the upper portion of the + * byte. (Use 0b###00000 instead of 0b00000### to input the + * three bits ###.) + * length: [in] + * The number of bits in message_bits, between 1 and 7. + * + * Returns: + * sha Error Code. + * + */ +int SHA384FinalBits(SHA384Context *context, + uint8_t message_bits, unsigned int length) +{ + return SHA512FinalBits(context, message_bits, length); +} + +/* + * SHA384Result + * + * Description: + * This function will return the 384-bit message digest + * into the Message_Digest array provided by the caller. + * NOTE: + * The first octet of hash is stored in the element with index 0, + * the last octet of hash in the element with index 47. + * + * Parameters: + * context: [in/out] + * The context to use to calculate the SHA hash. + * Message_Digest[ ]: [out] + * Where the digest is returned. + * + * Returns: + * sha Error Code. + * + */ +int SHA384Result(SHA384Context *context, + uint8_t Message_Digest[SHA384HashSize]) +{ + return SHA384_512ResultN(context, Message_Digest, SHA384HashSize); +} + +/* + * SHA512Reset + * + * Description: + * This function will initialize the SHA512Context in preparation + * for computing a new SHA512 message digest. + * + * Parameters: + * context: [in/out] + * The context to reset. + * + * Returns: + * sha Error Code. + * + */ +int SHA512Reset(SHA512Context *context) +{ + return SHA384_512Reset(context, SHA512_H0); +} + +/* + * SHA512Input + * + * Description: + * This function accepts an array of octets as the next portion + * of the message. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * message_array[ ]: [in] + * An array of octets representing the next portion of + * the message. + * length: [in] + * The length of the message in message_array. + * + * Returns: + * sha Error Code. + * + */ +int SHA512Input(SHA512Context *context, + const uint8_t *message_array, + unsigned int length) +{ + if (!context) return shaNull; + if (!length) return shaSuccess; + if (!message_array) return shaNull; + if (context->Computed) return context->Corrupted = shaStateError; + if (context->Corrupted) return context->Corrupted; + + while (length--) { + context->Message_Block[context->Message_Block_Index++] = + *message_array; + + if ((SHA384_512AddLength(context, 8) == shaSuccess) && + (context->Message_Block_Index == SHA512_Message_Block_Size)) + SHA384_512ProcessMessageBlock(context); + + message_array++; + } + + return context->Corrupted; +} + +/* + * SHA512FinalBits + * + * Description: + * This function will add in any final bits of the message. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * message_bits: [in] + * The final bits of the message, in the upper portion of the + * byte. (Use 0b###00000 instead of 0b00000### to input the + * three bits ###.) + * length: [in] + * The number of bits in message_bits, between 1 and 7. + * + * Returns: + * sha Error Code. + * + */ +int SHA512FinalBits(SHA512Context *context, + uint8_t message_bits, unsigned int length) +{ + static uint8_t masks[8] = { + /* 0 0b00000000 */ 0x00, /* 1 0b10000000 */ 0x80, + /* 2 0b11000000 */ 0xC0, /* 3 0b11100000 */ 0xE0, + /* 4 0b11110000 */ 0xF0, /* 5 0b11111000 */ 0xF8, + /* 6 0b11111100 */ 0xFC, /* 7 0b11111110 */ 0xFE + }; + static uint8_t markbit[8] = { + /* 0 0b10000000 */ 0x80, /* 1 0b01000000 */ 0x40, + /* 2 0b00100000 */ 0x20, /* 3 0b00010000 */ 0x10, + /* 4 0b00001000 */ 0x08, /* 5 0b00000100 */ 0x04, + /* 6 0b00000010 */ 0x02, /* 7 0b00000001 */ 0x01 + }; + + if (!context) return shaNull; + if (!length) return shaSuccess; + if (context->Corrupted) return context->Corrupted; + if (context->Computed) return context->Corrupted = shaStateError; + if (length >= 8) return context->Corrupted = shaBadParam; + + SHA384_512AddLength(context, length); + SHA384_512Finalize(context, (uint8_t) + ((message_bits & masks[length]) | markbit[length])); + + return context->Corrupted; +} + +/* + * SHA512Result + * + * Description: + * This function will return the 512-bit message digest + * into the Message_Digest array provided by the caller. + * NOTE: + * The first octet of hash is stored in the element with index 0, + * the last octet of hash in the element with index 63. + * + * Parameters: + * context: [in/out] + * The context to use to calculate the SHA hash. + * Message_Digest[ ]: [out] + * Where the digest is returned. + * + * Returns: + * sha Error Code. + * + */ +int SHA512Result(SHA512Context *context, + uint8_t Message_Digest[SHA512HashSize]) +{ + return SHA384_512ResultN(context, Message_Digest, SHA512HashSize); +} + +/* + * SHA384_512Reset + * + * Description: + * This helper function will initialize the SHA512Context in + * preparation for computing a new SHA384 or SHA512 message + * digest. + * + * Parameters: + * context: [in/out] + * The context to reset. + * H0[ ]: [in] + * The initial hash value array to use. + * + * Returns: + * sha Error Code. + * + */ +#ifdef USE_32BIT_ONLY +static int SHA384_512Reset(SHA512Context *context, + uint32_t H0[SHA512HashSize/4]) +#else /* !USE_32BIT_ONLY */ +static int SHA384_512Reset(SHA512Context *context, + uint64_t H0[SHA512HashSize/8]) +#endif /* USE_32BIT_ONLY */ +{ + int i; + if (!context) return shaNull; + + context->Message_Block_Index = 0; + +#ifdef USE_32BIT_ONLY + context->Length[0] = context->Length[1] = + context->Length[2] = context->Length[3] = 0; + + for (i = 0; i < SHA512HashSize/4; i++) + context->Intermediate_Hash[i] = H0[i]; +#else /* !USE_32BIT_ONLY */ + context->Length_High = context->Length_Low = 0; + + for (i = 0; i < SHA512HashSize/8; i++) + context->Intermediate_Hash[i] = H0[i]; +#endif /* USE_32BIT_ONLY */ + + context->Computed = 0; + context->Corrupted = shaSuccess; + + return shaSuccess; +} + +/* + * SHA384_512ProcessMessageBlock + * + * Description: + * This helper function will process the next 1024 bits of the + * message stored in the Message_Block array. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * + * Returns: + * Nothing. + * + * Comments: + * Many of the variable names in this code, especially the + * single character names, were used because those were the + * names used in the Secure Hash Standard. + * + * + */ +static void SHA384_512ProcessMessageBlock(SHA512Context *context) +{ +#ifdef USE_32BIT_ONLY + /* Constants defined in FIPS 180-3, section 4.2.3 */ + static const uint32_t K[80*2] = { + 0x428A2F98, 0xD728AE22, 0x71374491, 0x23EF65CD, 0xB5C0FBCF, + 0xEC4D3B2F, 0xE9B5DBA5, 0x8189DBBC, 0x3956C25B, 0xF348B538, + 0x59F111F1, 0xB605D019, 0x923F82A4, 0xAF194F9B, 0xAB1C5ED5, + 0xDA6D8118, 0xD807AA98, 0xA3030242, 0x12835B01, 0x45706FBE, + 0x243185BE, 0x4EE4B28C, 0x550C7DC3, 0xD5FFB4E2, 0x72BE5D74, + 0xF27B896F, 0x80DEB1FE, 0x3B1696B1, 0x9BDC06A7, 0x25C71235, + 0xC19BF174, 0xCF692694, 0xE49B69C1, 0x9EF14AD2, 0xEFBE4786, + 0x384F25E3, 0x0FC19DC6, 0x8B8CD5B5, 0x240CA1CC, 0x77AC9C65, + 0x2DE92C6F, 0x592B0275, 0x4A7484AA, 0x6EA6E483, 0x5CB0A9DC, + 0xBD41FBD4, 0x76F988DA, 0x831153B5, 0x983E5152, 0xEE66DFAB, + 0xA831C66D, 0x2DB43210, 0xB00327C8, 0x98FB213F, 0xBF597FC7, + 0xBEEF0EE4, 0xC6E00BF3, 0x3DA88FC2, 0xD5A79147, 0x930AA725, + 0x06CA6351, 0xE003826F, 0x14292967, 0x0A0E6E70, 0x27B70A85, + 0x46D22FFC, 0x2E1B2138, 0x5C26C926, 0x4D2C6DFC, 0x5AC42AED, + 0x53380D13, 0x9D95B3DF, 0x650A7354, 0x8BAF63DE, 0x766A0ABB, + 0x3C77B2A8, 0x81C2C92E, 0x47EDAEE6, 0x92722C85, 0x1482353B, + 0xA2BFE8A1, 0x4CF10364, 0xA81A664B, 0xBC423001, 0xC24B8B70, + 0xD0F89791, 0xC76C51A3, 0x0654BE30, 0xD192E819, 0xD6EF5218, + 0xD6990624, 0x5565A910, 0xF40E3585, 0x5771202A, 0x106AA070, + 0x32BBD1B8, 0x19A4C116, 0xB8D2D0C8, 0x1E376C08, 0x5141AB53, + 0x2748774C, 0xDF8EEB99, 0x34B0BCB5, 0xE19B48A8, 0x391C0CB3, + 0xC5C95A63, 0x4ED8AA4A, 0xE3418ACB, 0x5B9CCA4F, 0x7763E373, + 0x682E6FF3, 0xD6B2B8A3, 0x748F82EE, 0x5DEFB2FC, 0x78A5636F, + 0x43172F60, 0x84C87814, 0xA1F0AB72, 0x8CC70208, 0x1A6439EC, + 0x90BEFFFA, 0x23631E28, 0xA4506CEB, 0xDE82BDE9, 0xBEF9A3F7, + 0xB2C67915, 0xC67178F2, 0xE372532B, 0xCA273ECE, 0xEA26619C, + 0xD186B8C7, 0x21C0C207, 0xEADA7DD6, 0xCDE0EB1E, 0xF57D4F7F, + 0xEE6ED178, 0x06F067AA, 0x72176FBA, 0x0A637DC5, 0xA2C898A6, + 0x113F9804, 0xBEF90DAE, 0x1B710B35, 0x131C471B, 0x28DB77F5, + 0x23047D84, 0x32CAAB7B, 0x40C72493, 0x3C9EBE0A, 0x15C9BEBC, + 0x431D67C4, 0x9C100D4C, 0x4CC5D4BE, 0xCB3E42B6, 0x597F299C, + 0xFC657E2A, 0x5FCB6FAB, 0x3AD6FAEC, 0x6C44198C, 0x4A475817 + }; + int t, t2, t8; /* Loop counter */ + uint32_t temp1[2], temp2[2], /* Temporary word values */ + temp3[2], temp4[2], temp5[2]; + uint32_t W[2*80]; /* Word sequence */ + uint32_t A[2], B[2], C[2], D[2], /* Word buffers */ + E[2], F[2], G[2], H[2]; + + /* Initialize the first 16 words in the array W */ + for (t = t2 = t8 = 0; t < 16; t++, t8 += 8) { + W[t2++] = ((((uint32_t)context->Message_Block[t8 ])) << 24) | + ((((uint32_t)context->Message_Block[t8 + 1])) << 16) | + ((((uint32_t)context->Message_Block[t8 + 2])) << 8) | + ((((uint32_t)context->Message_Block[t8 + 3]))); + W[t2++] = ((((uint32_t)context->Message_Block[t8 + 4])) << 24) | + ((((uint32_t)context->Message_Block[t8 + 5])) << 16) | + ((((uint32_t)context->Message_Block[t8 + 6])) << 8) | + ((((uint32_t)context->Message_Block[t8 + 7]))); + } + + for (t = 16; t < 80; t++, t2 += 2) { + /* W[t] = SHA512_sigma1(W[t-2]) + W[t-7] + + SHA512_sigma0(W[t-15]) + W[t-16]; */ + uint32_t *Wt2 = &W[t2-2*2]; + uint32_t *Wt7 = &W[t2-7*2]; + uint32_t *Wt15 = &W[t2-15*2]; + uint32_t *Wt16 = &W[t2-16*2]; + SHA512_sigma1(Wt2, temp1); + SHA512_ADD(temp1, Wt7, temp2); + SHA512_sigma0(Wt15, temp1); + SHA512_ADD(temp1, Wt16, temp3); + SHA512_ADD(temp2, temp3, &W[t2]); + } + + A[0] = context->Intermediate_Hash[0]; + A[1] = context->Intermediate_Hash[1]; + B[0] = context->Intermediate_Hash[2]; + B[1] = context->Intermediate_Hash[3]; + C[0] = context->Intermediate_Hash[4]; + C[1] = context->Intermediate_Hash[5]; + D[0] = context->Intermediate_Hash[6]; + D[1] = context->Intermediate_Hash[7]; + E[0] = context->Intermediate_Hash[8]; + E[1] = context->Intermediate_Hash[9]; + F[0] = context->Intermediate_Hash[10]; + F[1] = context->Intermediate_Hash[11]; + G[0] = context->Intermediate_Hash[12]; + G[1] = context->Intermediate_Hash[13]; + H[0] = context->Intermediate_Hash[14]; + H[1] = context->Intermediate_Hash[15]; + + for (t = t2 = 0; t < 80; t++, t2 += 2) { + /* + * temp1 = H + SHA512_SIGMA1(E) + SHA_Ch(E,F,G) + K[t] + W[t]; + */ + SHA512_SIGMA1(E,temp1); + SHA512_ADD(H, temp1, temp2); + SHA_Ch(E,F,G,temp3); + SHA512_ADD(temp2, temp3, temp4); + SHA512_ADD(&K[t2], &W[t2], temp5); + SHA512_ADD(temp4, temp5, temp1); + /* + * temp2 = SHA512_SIGMA0(A) + SHA_Maj(A,B,C); + */ + SHA512_SIGMA0(A,temp3); + SHA_Maj(A,B,C,temp4); + SHA512_ADD(temp3, temp4, temp2); + H[0] = G[0]; H[1] = G[1]; + G[0] = F[0]; G[1] = F[1]; + F[0] = E[0]; F[1] = E[1]; + SHA512_ADD(D, temp1, E); + D[0] = C[0]; D[1] = C[1]; + C[0] = B[0]; C[1] = B[1]; + B[0] = A[0]; B[1] = A[1]; + SHA512_ADD(temp1, temp2, A); + } + + SHA512_ADDTO2(&context->Intermediate_Hash[0], A); + SHA512_ADDTO2(&context->Intermediate_Hash[2], B); + SHA512_ADDTO2(&context->Intermediate_Hash[4], C); + SHA512_ADDTO2(&context->Intermediate_Hash[6], D); + SHA512_ADDTO2(&context->Intermediate_Hash[8], E); + SHA512_ADDTO2(&context->Intermediate_Hash[10], F); + SHA512_ADDTO2(&context->Intermediate_Hash[12], G); + SHA512_ADDTO2(&context->Intermediate_Hash[14], H); + +#else /* !USE_32BIT_ONLY */ + /* Constants defined in FIPS 180-3, section 4.2.3 */ + static const uint64_t K[80] = { + 0x428A2F98D728AE22ll, 0x7137449123EF65CDll, 0xB5C0FBCFEC4D3B2Fll, + 0xE9B5DBA58189DBBCll, 0x3956C25BF348B538ll, 0x59F111F1B605D019ll, + 0x923F82A4AF194F9Bll, 0xAB1C5ED5DA6D8118ll, 0xD807AA98A3030242ll, + 0x12835B0145706FBEll, 0x243185BE4EE4B28Cll, 0x550C7DC3D5FFB4E2ll, + 0x72BE5D74F27B896Fll, 0x80DEB1FE3B1696B1ll, 0x9BDC06A725C71235ll, + 0xC19BF174CF692694ll, 0xE49B69C19EF14AD2ll, 0xEFBE4786384F25E3ll, + 0x0FC19DC68B8CD5B5ll, 0x240CA1CC77AC9C65ll, 0x2DE92C6F592B0275ll, + 0x4A7484AA6EA6E483ll, 0x5CB0A9DCBD41FBD4ll, 0x76F988DA831153B5ll, + 0x983E5152EE66DFABll, 0xA831C66D2DB43210ll, 0xB00327C898FB213Fll, + 0xBF597FC7BEEF0EE4ll, 0xC6E00BF33DA88FC2ll, 0xD5A79147930AA725ll, + 0x06CA6351E003826Fll, 0x142929670A0E6E70ll, 0x27B70A8546D22FFCll, + 0x2E1B21385C26C926ll, 0x4D2C6DFC5AC42AEDll, 0x53380D139D95B3DFll, + 0x650A73548BAF63DEll, 0x766A0ABB3C77B2A8ll, 0x81C2C92E47EDAEE6ll, + 0x92722C851482353Bll, 0xA2BFE8A14CF10364ll, 0xA81A664BBC423001ll, + 0xC24B8B70D0F89791ll, 0xC76C51A30654BE30ll, 0xD192E819D6EF5218ll, + 0xD69906245565A910ll, 0xF40E35855771202All, 0x106AA07032BBD1B8ll, + 0x19A4C116B8D2D0C8ll, 0x1E376C085141AB53ll, 0x2748774CDF8EEB99ll, + 0x34B0BCB5E19B48A8ll, 0x391C0CB3C5C95A63ll, 0x4ED8AA4AE3418ACBll, + 0x5B9CCA4F7763E373ll, 0x682E6FF3D6B2B8A3ll, 0x748F82EE5DEFB2FCll, + 0x78A5636F43172F60ll, 0x84C87814A1F0AB72ll, 0x8CC702081A6439ECll, + 0x90BEFFFA23631E28ll, 0xA4506CEBDE82BDE9ll, 0xBEF9A3F7B2C67915ll, + 0xC67178F2E372532Bll, 0xCA273ECEEA26619Cll, 0xD186B8C721C0C207ll, + 0xEADA7DD6CDE0EB1Ell, 0xF57D4F7FEE6ED178ll, 0x06F067AA72176FBAll, + 0x0A637DC5A2C898A6ll, 0x113F9804BEF90DAEll, 0x1B710B35131C471Bll, + 0x28DB77F523047D84ll, 0x32CAAB7B40C72493ll, 0x3C9EBE0A15C9BEBCll, + 0x431D67C49C100D4Cll, 0x4CC5D4BECB3E42B6ll, 0x597F299CFC657E2All, + 0x5FCB6FAB3AD6FAECll, 0x6C44198C4A475817ll + }; + int t, t8; /* Loop counter */ + uint64_t temp1, temp2; /* Temporary word value */ + uint64_t W[80]; /* Word sequence */ + uint64_t A, B, C, D, E, F, G, H; /* Word buffers */ + + /* + * Initialize the first 16 words in the array W + */ + for (t = t8 = 0; t < 16; t++, t8 += 8) + W[t] = ((uint64_t)(context->Message_Block[t8 ]) << 56) | + ((uint64_t)(context->Message_Block[t8 + 1]) << 48) | + ((uint64_t)(context->Message_Block[t8 + 2]) << 40) | + ((uint64_t)(context->Message_Block[t8 + 3]) << 32) | + ((uint64_t)(context->Message_Block[t8 + 4]) << 24) | + ((uint64_t)(context->Message_Block[t8 + 5]) << 16) | + ((uint64_t)(context->Message_Block[t8 + 6]) << 8) | + ((uint64_t)(context->Message_Block[t8 + 7])); + + for (t = 16; t < 80; t++) + W[t] = SHA512_sigma1(W[t-2]) + W[t-7] + + SHA512_sigma0(W[t-15]) + W[t-16]; + A = context->Intermediate_Hash[0]; + B = context->Intermediate_Hash[1]; + C = context->Intermediate_Hash[2]; + D = context->Intermediate_Hash[3]; + E = context->Intermediate_Hash[4]; + F = context->Intermediate_Hash[5]; + G = context->Intermediate_Hash[6]; + H = context->Intermediate_Hash[7]; + + for (t = 0; t < 80; t++) { + temp1 = H + SHA512_SIGMA1(E) + SHA_Ch(E,F,G) + K[t] + W[t]; + temp2 = SHA512_SIGMA0(A) + SHA_Maj(A,B,C); + H = G; + G = F; + F = E; + E = D + temp1; + D = C; + C = B; + B = A; + A = temp1 + temp2; + } + + context->Intermediate_Hash[0] += A; + context->Intermediate_Hash[1] += B; + context->Intermediate_Hash[2] += C; + context->Intermediate_Hash[3] += D; + context->Intermediate_Hash[4] += E; + context->Intermediate_Hash[5] += F; + context->Intermediate_Hash[6] += G; + context->Intermediate_Hash[7] += H; +#endif /* USE_32BIT_ONLY */ + + context->Message_Block_Index = 0; +} + +/* + * SHA384_512Finalize + * + * Description: + * This helper function finishes off the digest calculations. + * + * Parameters: + * context: [in/out] + * The SHA context to update. + * Pad_Byte: [in] + * The last byte to add to the message block before the 0-padding + * and length. This will contain the last bits of the message + * followed by another single bit. If the message was an + * exact multiple of 8-bits long, Pad_Byte will be 0x80. + * + * Returns: + * sha Error Code. + * + */ +static void SHA384_512Finalize(SHA512Context *context, + uint8_t Pad_Byte) +{ + int_least16_t i; + SHA384_512PadMessage(context, Pad_Byte); + /* message may be sensitive, clear it out */ + for (i = 0; i < SHA512_Message_Block_Size; ++i) + context->Message_Block[i] = 0; +#ifdef USE_32BIT_ONLY /* and clear length */ + context->Length[0] = context->Length[1] = 0; + context->Length[2] = context->Length[3] = 0; +#else /* !USE_32BIT_ONLY */ + context->Length_High = context->Length_Low = 0; +#endif /* USE_32BIT_ONLY */ + context->Computed = 1; +} + +/* + * SHA384_512PadMessage + * + * Description: + * According to the standard, the message must be padded to the next + * even multiple of 1024 bits. The first padding bit must be a '1'. + * The last 128 bits represent the length of the original message. + * All bits in between should be 0. This helper function will + * pad the message according to those rules by filling the + * Message_Block array accordingly. When it returns, it can be + * assumed that the message digest has been computed. + * + * Parameters: + * context: [in/out] + * The context to pad. + * Pad_Byte: [in] + * The last byte to add to the message block before the 0-padding + * and length. This will contain the last bits of the message + * followed by another single bit. If the message was an + * exact multiple of 8-bits long, Pad_Byte will be 0x80. + * + * Returns: + * Nothing. + * + */ +static void SHA384_512PadMessage(SHA512Context *context, + uint8_t Pad_Byte) +{ + /* + * Check to see if the current message block is too small to hold + * the initial padding bits and length. If so, we will pad the + * block, process it, and then continue padding into a second + * block. + */ + if (context->Message_Block_Index >= (SHA512_Message_Block_Size-16)) { + context->Message_Block[context->Message_Block_Index++] = Pad_Byte; + while (context->Message_Block_Index < SHA512_Message_Block_Size) + context->Message_Block[context->Message_Block_Index++] = 0; + + SHA384_512ProcessMessageBlock(context); + } else + context->Message_Block[context->Message_Block_Index++] = Pad_Byte; + + while (context->Message_Block_Index < (SHA512_Message_Block_Size-16)) + context->Message_Block[context->Message_Block_Index++] = 0; + + /* + * Store the message length as the last 16 octets + */ +#ifdef USE_32BIT_ONLY + context->Message_Block[112] = (uint8_t)(context->Length[0] >> 24); + context->Message_Block[113] = (uint8_t)(context->Length[0] >> 16); + context->Message_Block[114] = (uint8_t)(context->Length[0] >> 8); + context->Message_Block[115] = (uint8_t)(context->Length[0]); + context->Message_Block[116] = (uint8_t)(context->Length[1] >> 24); + context->Message_Block[117] = (uint8_t)(context->Length[1] >> 16); + context->Message_Block[118] = (uint8_t)(context->Length[1] >> 8); + context->Message_Block[119] = (uint8_t)(context->Length[1]); + + context->Message_Block[120] = (uint8_t)(context->Length[2] >> 24); + context->Message_Block[121] = (uint8_t)(context->Length[2] >> 16); + context->Message_Block[122] = (uint8_t)(context->Length[2] >> 8); + context->Message_Block[123] = (uint8_t)(context->Length[2]); + context->Message_Block[124] = (uint8_t)(context->Length[3] >> 24); + context->Message_Block[125] = (uint8_t)(context->Length[3] >> 16); + context->Message_Block[126] = (uint8_t)(context->Length[3] >> 8); + context->Message_Block[127] = (uint8_t)(context->Length[3]); +#else /* !USE_32BIT_ONLY */ + context->Message_Block[112] = (uint8_t)(context->Length_High >> 56); + context->Message_Block[113] = (uint8_t)(context->Length_High >> 48); + context->Message_Block[114] = (uint8_t)(context->Length_High >> 40); + context->Message_Block[115] = (uint8_t)(context->Length_High >> 32); + context->Message_Block[116] = (uint8_t)(context->Length_High >> 24); + context->Message_Block[117] = (uint8_t)(context->Length_High >> 16); + context->Message_Block[118] = (uint8_t)(context->Length_High >> 8); + context->Message_Block[119] = (uint8_t)(context->Length_High); + + context->Message_Block[120] = (uint8_t)(context->Length_Low >> 56); + context->Message_Block[121] = (uint8_t)(context->Length_Low >> 48); + context->Message_Block[122] = (uint8_t)(context->Length_Low >> 40); + context->Message_Block[123] = (uint8_t)(context->Length_Low >> 32); + context->Message_Block[124] = (uint8_t)(context->Length_Low >> 24); + context->Message_Block[125] = (uint8_t)(context->Length_Low >> 16); + context->Message_Block[126] = (uint8_t)(context->Length_Low >> 8); + context->Message_Block[127] = (uint8_t)(context->Length_Low); +#endif /* USE_32BIT_ONLY */ + + SHA384_512ProcessMessageBlock(context); +} + +/* + * SHA384_512ResultN + * + * Description: + * This helper function will return the 384-bit or 512-bit message + * digest into the Message_Digest array provided by the caller. + * NOTE: + * The first octet of hash is stored in the element with index 0, + * the last octet of hash in the element with index 47/63. + * + * Parameters: + * context: [in/out] + * The context to use to calculate the SHA hash. + * Message_Digest[ ]: [out] + * Where the digest is returned. + * HashSize: [in] + * The size of the hash, either 48 or 64. + * + * Returns: + * sha Error Code. + * + */ +static int SHA384_512ResultN(SHA512Context *context, + uint8_t Message_Digest[ ], int HashSize) +{ + int i; +#ifdef USE_32BIT_ONLY + int i2; +#endif /* USE_32BIT_ONLY */ + + if (!context) return shaNull; + if (!Message_Digest) return shaNull; + if (context->Corrupted) return context->Corrupted; + + if (!context->Computed) + SHA384_512Finalize(context, 0x80); + +#ifdef USE_32BIT_ONLY + for (i = i2 = 0; i < HashSize; ) { + Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>24); + Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>16); + Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>8); + Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2++]); + Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>24); + Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>16); + Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2]>>8); + Message_Digest[i++]=(uint8_t)(context->Intermediate_Hash[i2++]); + } +#else /* !USE_32BIT_ONLY */ + for (i = 0; i < HashSize; ++i) + Message_Digest[i] = (uint8_t) + (context->Intermediate_Hash[i>>3] >> 8 * ( 7 - ( i % 8 ) )); +#endif /* USE_32BIT_ONLY */ + + return shaSuccess; +} diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 164660f818..9c27af032f 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -46,8 +46,42 @@ #include "../../3rdparty/md4/md4.h" #include "../../3rdparty/md4/md4.cpp" #include "../../3rdparty/sha1/sha1.cpp" + +/* + These 2 functions replace macros of the same name in sha224-256.c and + sha384-512.c. Originally, these macros relied on a global static 'addTemp' + variable. We do not want this for 2 reasons: + + 1. since we are including the sources directly, the declaration of the 2 conflict + + 2. static variables are not thread-safe, we do not want multiple threads + computing a hash to corrupt one another +*/ +// Header from rfc6234 without modifications +#include "../../3rdparty/rfc6234/sha.h" +static int SHA224_256AddLength(SHA256Context *context, unsigned int length); +static int SHA384_512AddLength(SHA512Context *context, unsigned int length); + +// Sources from rfc6234, with 4 modifications: +// sha224-256.c - commented out 'static uint32_t addTemp;' on line 68 +// sha224-256.c - appended 'M' to the SHA224_256AddLength macro on line 70 +#include "../../3rdparty/rfc6234/sha224-256.c" +// sha384-512.c - commented out 'static uint64_t addTemp;' on line 302 +// sha384-512.c - appended 'M' to the SHA224_256AddLength macro on line 304 +#include "../../3rdparty/rfc6234/sha384-512.c" + #include +static inline int SHA224_256AddLength(SHA256Context *context, unsigned int length) +{ + uint32_t addTemp; + return SHA224_256AddLengthM(context, length); +} +static inline int SHA384_512AddLength(SHA512Context *context, unsigned int length) +{ + uint64_t addTemp; + return SHA384_512AddLengthM(context, length); +} QT_BEGIN_NAMESPACE @@ -59,6 +93,10 @@ public: MD5Context md5Context; md4_context md4Context; Sha1State sha1Context; + SHA224Context sha224Context; + SHA256Context sha256Context; + SHA384Context sha384Context; + SHA512Context sha512Context; }; QByteArray result; }; @@ -75,7 +113,7 @@ public: QCryptographicHash can be used to generate cryptographic hashes of binary or text data. - Currently MD4, MD5, and SHA-1 are supported. + Currently MD4, MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 are supported. */ /*! @@ -83,7 +121,11 @@ public: \value Md4 Generate an MD4 hash sum \value Md5 Generate an MD5 hash sum - \value Sha1 Generate an SHA1 hash sum + \value Sha1 Generate an SHA-1 hash sum + \value Sha224 Generate an SHA-224 hash sum + \value Sha256 Generate an SHA-256 hash sum + \value Sha384 Generate an SHA-384 hash sum + \value Sha512 Generate an SHA-512 hash sum */ /*! @@ -119,6 +161,18 @@ void QCryptographicHash::reset() case Sha1: sha1InitState(&d->sha1Context); break; + case Sha224: + SHA224Reset(&d->sha224Context); + break; + case Sha256: + SHA256Reset(&d->sha256Context); + break; + case Sha384: + SHA384Reset(&d->sha384Context); + break; + case Sha512: + SHA512Reset(&d->sha512Context); + break; } d->result.clear(); } @@ -139,6 +193,18 @@ void QCryptographicHash::addData(const char *data, int length) case Sha1: sha1Update(&d->sha1Context, (const unsigned char *)data, length); break; + case Sha224: + SHA224Input(&d->sha224Context, reinterpret_cast(data), length); + break; + case Sha256: + SHA256Input(&d->sha256Context, reinterpret_cast(data), length); + break; + case Sha384: + SHA384Input(&d->sha384Context, reinterpret_cast(data), length); + break; + case Sha512: + SHA512Input(&d->sha512Context, reinterpret_cast(data), length); + break; } d->result.clear(); } @@ -201,6 +267,31 @@ QByteArray QCryptographicHash::result() const d->result.resize(20); sha1FinalizeState(©); sha1ToHash(©, (unsigned char *)d->result.data()); + break; + } + case Sha224: { + SHA224Context copy = d->sha224Context; + d->result.resize(SHA224HashSize); + SHA224Result(©, reinterpret_cast(d->result.data())); + break; + } + case Sha256:{ + SHA256Context copy = d->sha256Context; + d->result.resize(SHA256HashSize); + SHA256Result(©, reinterpret_cast(d->result.data())); + break; + } + case Sha384:{ + SHA384Context copy = d->sha384Context; + d->result.resize(SHA384HashSize); + SHA384Result(©, reinterpret_cast(d->result.data())); + break; + } + case Sha512:{ + SHA512Context copy = d->sha512Context; + d->result.resize(SHA512HashSize); + SHA512Result(©, reinterpret_cast(d->result.data())); + break; } } return d->result; diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h index 59314e1963..2bfc03373a 100644 --- a/src/corelib/tools/qcryptographichash.h +++ b/src/corelib/tools/qcryptographichash.h @@ -58,7 +58,11 @@ public: enum Algorithm { Md4, Md5, - Sha1 + Sha1, + Sha224, + Sha256, + Sha384, + Sha512 }; QCryptographicHash(Algorithm method); diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp index 81cc66f045..67c15682a2 100644 --- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp +++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp @@ -102,6 +102,22 @@ void tst_QCryptographicHash::intermediary_result_data() << QByteArray("abc") << QByteArray("abc") << QByteArray::fromHex("A9993E364706816ABA3E25717850C26C9CD0D89D") << QByteArray::fromHex("F8C1D87006FBF7E5CC4B026C3138BC046883DC71"); + QTest::newRow("sha224") << int(QCryptographicHash::Sha224) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("23097D223405D8228642A477BDA255B32AADBCE4BDA0B3F7E36C9DA7") + << QByteArray::fromHex("7C9C91FC479626AA1A525301084DEB96716131D146A2DB61B533F4C9"); + QTest::newRow("sha256") << int(QCryptographicHash::Sha256) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD") + << QByteArray::fromHex("BBB59DA3AF939F7AF5F360F2CEB80A496E3BAE1CD87DDE426DB0AE40677E1C2C"); + QTest::newRow("sha384") << int(QCryptographicHash::Sha384) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7") + << QByteArray::fromHex("CAF33A735C9535CE7F5D24FB5B3A4834F0E9316664AD15A9E8221679D4A3B4FB7E962404BA0C10C1D43AB49D03A08B8D"); + QTest::newRow("sha512") << int(QCryptographicHash::Sha512) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F") + << QByteArray::fromHex("F3C41E7B63EE869596FC28BAD64120612C520F65928AB4D126C72C6998B551B8FF1CEDDFED4373E6717554DC89D1EEE6F0AB22FD3675E561ABA9AE26A3EEC53B"); } void tst_QCryptographicHash::intermediary_result() From 394e45199fa1aa45036dd787c5052ef7bcd98c52 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 25 Feb 2012 12:12:09 +0100 Subject: [PATCH 139/166] directfb: Switch to the new style plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The plugin might advertize more keys than supported at runtime. E.g. the directfbegl key might not be available. I would like to have a directfb.json.in and then generate the right file or if moc would pre-process the file... Change-Id: Ia8ad4e1367c06f5e35d02822d4f830ce1e9dc577 Reviewed-by: Jørgen Lind --- src/plugins/platforms/directfb/directfb.json | 3 +++ src/plugins/platforms/directfb/directfb.pro | 2 ++ src/plugins/platforms/directfb/main.cpp | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 src/plugins/platforms/directfb/directfb.json diff --git a/src/plugins/platforms/directfb/directfb.json b/src/plugins/platforms/directfb/directfb.json new file mode 100644 index 0000000000..5c74095fe6 --- /dev/null +++ b/src/plugins/platforms/directfb/directfb.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "directfb", "directfbegl" ] +} diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index 0585777889..ae47ec397b 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -43,3 +43,5 @@ directfbegl: { CONFIG += qpa/genericunixfontdatabase target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target + +OTHER_FILES += directfb.json diff --git a/src/plugins/platforms/directfb/main.cpp b/src/plugins/platforms/directfb/main.cpp index 048e9ed611..26bdd719ca 100644 --- a/src/plugins/platforms/directfb/main.cpp +++ b/src/plugins/platforms/directfb/main.cpp @@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE class QDirectFbIntegrationPlugin : public QPlatformIntegrationPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformIntegrationFactoryInterface" FILE "directfb.json") public: QStringList keys() const; QPlatformIntegration *create(const QString&, const QStringList&); @@ -86,6 +88,6 @@ QPlatformIntegration * QDirectFbIntegrationPlugin::create(const QString& system, return integration; } -Q_EXPORT_PLUGIN2(directfb, QDirectFbIntegrationPlugin) - QT_END_NAMESPACE + +#include "main.moc" From c2baf45c73beaa01df91d466296fd4efca25ee7a Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Sat, 18 Feb 2012 20:05:53 +0000 Subject: [PATCH 140/166] Prevent stack corruption when using OpenGL Core Profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an OpenGL Core Profile context is requested the function glGetStringi() is used to query the supported extensions as glGetString(GL_EXTENSIONS) has been removed in the core profile. The signature for glGetStringi used in Qt missed off the APIENTRY calling convention. This results in stack corruption on windows each time glGetStringi() is called leading to a crash. Change-Id: Iff62c42e2bb5fc4a5c0561fae97ddc5a8ae3a45e Reviewed-by: Samuel Rødal --- src/gui/opengl/qopengl.cpp | 3 ++- src/opengl/qgl.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index f39dc12239..290fcb287e 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -42,6 +42,7 @@ #include "qopengl_p.h" #include "qopenglcontext.h" +#include "qopenglfunctions.h" QT_BEGIN_NAMESPACE @@ -50,7 +51,7 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher(const char *str) init(str); } -typedef GLubyte * (*qt_glGetStringi)(GLenum, GLuint); +typedef const GLubyte * (QOPENGLF_APIENTRYP qt_glGetStringi)(GLenum, GLuint); #ifndef GL_NUM_EXTENSIONS #define GL_NUM_EXTENSIONS 0x821D diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 836e7225be..31d6064e90 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4680,7 +4680,7 @@ QPaintEngine *QGLWidget::paintEngine() const return qt_qgl_paint_engine(); } -typedef GLubyte * (*qt_glGetStringi)(GLenum, GLuint); +typedef const GLubyte * (QGLF_APIENTRYP qt_glGetStringi)(GLenum, GLuint); #ifndef GL_NUM_EXTENSIONS #define GL_NUM_EXTENSIONS 0x821D From 7df4890d8a98d872deaebd46ca8d92473a3c6585 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 27 Feb 2012 09:51:46 +0100 Subject: [PATCH 141/166] Fix divide by zero when glyphWidth is 0 Change-Id: Ic0108b76b8d73cc977f8d64e036a65cb93db4684 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 30170759a0..c63f0fede8 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2702,6 +2702,8 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end, QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos); // the approximate width of each individual element of the ligature QFixed perItemWidth = glyphWidth / clusterLength; + if (perItemWidth <= 0) + return si->position + clusterStart; QFixed left = x > edge ? edge : edge - glyphWidth; int n = ((x - left) / perItemWidth).floor().toInt(); QFixed dist = x - left - n * perItemWidth; From 99d5decbcfbce35b6d20f816a07c5ed1625aadae Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Thu, 23 Feb 2012 23:09:06 +0100 Subject: [PATCH 142/166] Make accessible interfaces private for Qt 5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we're not yet confident if they serve their purpose well enough, we have decided to make them internal so that we are free to tune them later Change-Id: Id79d154e0537aca07303afea5d057cfcb0773384 Reviewed-by: Morten Johan Sørvig --- src/gui/accessible/qaccessible.cpp | 4 ++++ src/gui/accessible/qaccessible2.cpp | 8 ++++++++ src/gui/accessible/qaccessiblebridge.cpp | 2 ++ src/gui/accessible/qaccessibleobject.cpp | 1 + src/gui/accessible/qaccessibleplugin.cpp | 1 + src/gui/kernel/qwindow.cpp | 2 +- 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 3f1295ab5e..37e7a1dbb4 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE \class QAccessible \brief The QAccessible class provides enums and static functions related to accessibility. + \internal \ingroup accessibility \inmodule QtWidgets @@ -692,6 +693,7 @@ void QAccessible::updateAccessibility(const QAccessibleEvent &event) \class QAccessibleEvent \brief The QAccessibleEvent is use to notify about changes that are relevant for accessibility in the application. + \internal \ingroup accessibility \inmodule QtGui @@ -727,6 +729,7 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const \class QAccessibleInterface \brief The QAccessibleInterface class defines an interface that exposes information about accessible objects. + \internal \ingroup accessibility \inmodule QtGui @@ -1172,6 +1175,7 @@ const char *qAccessibleEventString(QAccessible::Event event) return QAccessible::staticMetaObject.enumerator(eventEnum).valueToKey(event); } +/*! \internal */ bool operator==(const QAccessible::State &first, const QAccessible::State &second) { return memcmp(&first, &second, sizeof(QAccessible::State)) == 0; diff --git a/src/gui/accessible/qaccessible2.cpp b/src/gui/accessible/qaccessible2.cpp index 0f854c6158..db3028b371 100644 --- a/src/gui/accessible/qaccessible2.cpp +++ b/src/gui/accessible/qaccessible2.cpp @@ -51,6 +51,7 @@ QT_BEGIN_NAMESPACE /*! \namespace QAccessible2 \ingroup accessibility + \internal \brief The QAccessible2 namespace defines constants relating to IAccessible2-based interfaces @@ -60,6 +61,7 @@ QT_BEGIN_NAMESPACE /*! \class QAccessibleTextInterface + \internal \ingroup accessibility @@ -180,6 +182,7 @@ QT_BEGIN_NAMESPACE /*! \class QAccessibleEditableTextInterface \ingroup accessibility + \internal \brief The QAccessibleEditableTextInterface class implements support for objects with editable text. @@ -247,6 +250,7 @@ QT_BEGIN_NAMESPACE /*! \class QAccessibleSimpleEditableTextInterface \ingroup accessibility + \internal \brief The QAccessibleSimpleEditableTextInterface class is a convenience class for text-based widgets. It can be inherited instead of \l QAccessibleEditableTextInterface. @@ -259,6 +263,7 @@ QT_BEGIN_NAMESPACE /*! \class QAccessibleValueInterface \ingroup accessibility + \internal \brief The QAccessibleValueInterface class implements support for objects that manipulate a value. @@ -323,6 +328,7 @@ QT_BEGIN_NAMESPACE /*! \class QAccessibleTableCellInterface \ingroup accessibility + \internal \brief The QAccessibleTableCellInterface class implements support for the IAccessibleTable2 Cell interface. @@ -333,6 +339,7 @@ QT_BEGIN_NAMESPACE /*! \class QAccessibleTableInterface \ingroup accessibility + \internal \brief The QAccessibleTableInterface class implements support for the IAccessibleTable2 interface. @@ -344,6 +351,7 @@ QT_BEGIN_NAMESPACE /*! \class QAccessibleActionInterface \ingroup accessibility + \internal \brief The QAccessibleActionInterface class implements support for invocable actions in the interface. diff --git a/src/gui/accessible/qaccessiblebridge.cpp b/src/gui/accessible/qaccessiblebridge.cpp index 8fcf0474a1..d6d0796701 100644 --- a/src/gui/accessible/qaccessiblebridge.cpp +++ b/src/gui/accessible/qaccessiblebridge.cpp @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE \class QAccessibleBridge \brief The QAccessibleBridge class is the base class for accessibility back-ends. + \internal \ingroup accessibility \inmodule QtWidgets @@ -100,6 +101,7 @@ QT_BEGIN_NAMESPACE \class QAccessibleBridgePlugin \brief The QAccessibleBridgePlugin class provides an abstract base for accessibility bridge plugins. + \internal \ingroup plugins \ingroup accessibility diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index d277f39c43..e587ad077c 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -92,6 +92,7 @@ QList QAccessibleObjectPrivate::actionList() const \class QAccessibleObject \brief The QAccessibleObject class implements parts of the QAccessibleInterface for QObjects. + \internal \ingroup accessibility \inmodule QtWidgets diff --git a/src/gui/accessible/qaccessibleplugin.cpp b/src/gui/accessible/qaccessibleplugin.cpp index 8823d63b79..c2fe9c7a7a 100644 --- a/src/gui/accessible/qaccessibleplugin.cpp +++ b/src/gui/accessible/qaccessibleplugin.cpp @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE \class QAccessiblePlugin \brief The QAccessiblePlugin class provides an abstract base for accessibility plugins. + \internal \ingroup plugins \ingroup accessibility diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 77731f776b..04c2617838 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1192,7 +1192,7 @@ void QWindow::screenDestroyed(QObject *object) /*! Returns the accessibility interface for the object that the window represents - \preliminary + \internal \sa QAccessible */ QAccessibleInterface *QWindow::accessibleRoot() const From 8cacf68cdf5a8211811ca8a30a75f6979682cb1f Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 27 Feb 2012 14:01:47 +1000 Subject: [PATCH 143/166] testlib: Remove commented-out code from plain text logger. Change-Id: Ica2e294d1f08cac4697d037dbc2803012e0ba58a Reviewed-by: Rohan McGovern --- src/testlib/qplaintestlogger.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index bd4f26b493..ca86387216 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -251,7 +251,6 @@ void QPlainTestLogger::printMessage(const char *type, const char *msg, const cha outputMessage(buf.data()); } -//void QPlainTestLogger::printBenchmarkResult(const char *bmtag, int value, int iterations) void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result) { const char *bmtag = QTest::benchmarkResult2String(); @@ -381,7 +380,6 @@ void QPlainTestLogger::addIncident(IncidentTypes type, const char *description, void QPlainTestLogger::addBenchmarkResult(const QBenchmarkResult &result) { -// printBenchmarkResult(QTest::benchmarkResult2String(), value, iterations); printBenchmarkResult(result); } From cbc777374a26134e87054b2292a800d4b3835d82 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 27 Feb 2012 16:31:03 +1000 Subject: [PATCH 144/166] testlib: Improve the silent logging mode Previously the silent logging mode suppressed passes, skips and internal testlib info messages, but did not suppress debugging output, making it hard to see the fails in a noisy test. This commit changes silent mode so that it suppresses all output except test failures and fatal errors, making silent mode truly useful for seeing just the important test output. This commit also adds a selftest to verify the behaviour of silent mode. Change-Id: I75420aead03682306210746a87e2a3b608b58fc6 Reviewed-by: Rohan McGovern --- src/testlib/qplaintestlogger.cpp | 14 ++- src/testlib/qtestcase.cpp | 2 +- .../testlib/selftests/expected_silent.txt | 9 ++ tests/auto/testlib/selftests/selftests.pri | 1 + tests/auto/testlib/selftests/selftests.qrc | 1 + .../auto/testlib/selftests/silent/silent.pro | 7 ++ .../testlib/selftests/silent/tst_silent.cpp | 99 +++++++++++++++++++ .../auto/testlib/selftests/tst_selftests.cpp | 7 ++ 8 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 tests/auto/testlib/selftests/expected_silent.txt create mode 100644 tests/auto/testlib/selftests/silent/silent.pro create mode 100644 tests/auto/testlib/selftests/silent/tst_silent.cpp diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index ca86387216..2f87e08c3c 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -371,8 +371,9 @@ void QPlainTestLogger::leaveTestFunction() void QPlainTestLogger::addIncident(IncidentTypes type, const char *description, const char *file, int line) { - // suppress PASS in silent mode - if (type == QAbstractTestLogger::Pass && QTestLog::verboseLevel() < 0) + // suppress PASS and XFAIL in silent mode + if ((type == QAbstractTestLogger::Pass || type == QAbstractTestLogger::XFail) + && QTestLog::verboseLevel() < 0) return; printMessage(QTest::incidentType2String(type), description, file, line); @@ -380,15 +381,18 @@ void QPlainTestLogger::addIncident(IncidentTypes type, const char *description, void QPlainTestLogger::addBenchmarkResult(const QBenchmarkResult &result) { + // suppress benchmark results in silent mode + if (QTestLog::verboseLevel() < 0) + return; + printBenchmarkResult(result); } void QPlainTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line) { - // suppress PASS in silent mode - if ((type == QAbstractTestLogger::Skip || type == QAbstractTestLogger::Info) - && QTestLog::verboseLevel() < 0) + // suppress non-fatal messages in silent mode + if (type != QAbstractTestLogger::QFatal && QTestLog::verboseLevel() < 0) return; printMessage(QTest::messageType2String(type), message, file, line); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index b8678ba04c..a4f1a39bbd 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1192,7 +1192,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) " *** If no output format is specified, -txt is assumed.\n" "\n" " Detail options:\n" - " -silent : Only outputs warnings and failures\n" + " -silent : Only output failures and fatal errors in plain text output\n" " -v1 : Print enter messages for each testfunction\n" " -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n" " -vs : Print every signal emitted\n" diff --git a/tests/auto/testlib/selftests/expected_silent.txt b/tests/auto/testlib/selftests/expected_silent.txt new file mode 100644 index 0000000000..39e0bfc601 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_silent.txt @@ -0,0 +1,9 @@ +Testing tst_Silent +FAIL! : tst_Silent::fail() 'false' returned FALSE. (This test should fail) + Loc: [/home/jasmcdon/depot/qt5-test/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp(73)] +XPASS : tst_Silent::xpass() 'true' returned TRUE unexpectedly. (This test should XPASS) + Loc: [/home/jasmcdon/depot/qt5-test/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp(85)] +QFATAL : tst_Silent::messages() This is a fatal error message that should still appear in silent test output +FAIL! : tst_Silent::messages() Received a fatal error. + Loc: [Unknown file(0)] +Totals: 3 passed, 3 failed, 1 skipped diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 0809c4d497..1fc66e6364 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -30,6 +30,7 @@ SUBPROGRAMS = \ printdatatags \ printdatatagswithglobaltags \ qexecstringlist \ + silent \ singleskip \ skip \ skipcleanup \ diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index baa539a259..d05ac2a516 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -93,6 +93,7 @@ expected_printdatatags.txt expected_printdatatagswithglobaltags.txt expected_qexecstringlist.txt + expected_silent.txt expected_singleskip.lightxml expected_singleskip.txt expected_singleskip.xml diff --git a/tests/auto/testlib/selftests/silent/silent.pro b/tests/auto/testlib/selftests/silent/silent.pro new file mode 100644 index 0000000000..3150f65a5e --- /dev/null +++ b/tests/auto/testlib/selftests/silent/silent.pro @@ -0,0 +1,7 @@ +SOURCES += tst_silent.cpp +QT = core testlib-private + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = silent diff --git a/tests/auto/testlib/selftests/silent/tst_silent.cpp b/tests/auto/testlib/selftests/silent/tst_silent.cpp new file mode 100644 index 0000000000..ec280f9f1a --- /dev/null +++ b/tests/auto/testlib/selftests/silent/tst_silent.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +class tst_Silent : public QObject +{ + Q_OBJECT + +private slots: + void pass(); + void skip(); + void fail(); + void xfail(); + void xpass(); + + // This test function must be last, as it calls qFatal(). + void messages(); +}; + +void tst_Silent::pass() +{ + QVERIFY(true); +} + +void tst_Silent::skip() +{ + QSKIP("This test should skip"); +} + +void tst_Silent::fail() +{ + QVERIFY2(false, "This test should fail"); +} + +void tst_Silent::xfail() +{ + QEXPECT_FAIL("", "This test should XFAIL", Abort); + QVERIFY(false); +} + +void tst_Silent::xpass() +{ + QEXPECT_FAIL("", "This test should XPASS", Abort); + QVERIFY2(true, "This test should XPASS"); +} + +void tst_Silent::messages() +{ + qWarning("This is a warning that should not appear in silent test output"); + QWARN("This is an internal testlib warning that should not appear in silent test output"); + qDebug("This is a debug message that should not appear in silent test output"); + qCritical("This is a critical message that should not appear in silent test output"); + QTestLog::info("This is an internal testlib info message that should not appear in silent test output", __FILE__, __LINE__); + qFatal("This is a fatal error message that should still appear in silent test output"); +} + +QTEST_MAIN(tst_Silent) +#include "tst_silent.moc" diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 7367d664b2..2b90bdb389 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -354,6 +354,7 @@ void tst_Selftests::runSubTest_data() << "printdatatags" << "printdatatagswithglobaltags" << "qexecstringlist" + << "silent" << "singleskip" << "skip" << "skipcleanup" @@ -409,6 +410,9 @@ void tst_Selftests::runSubTest_data() else if (subtest == "printdatatagswithglobaltags") { arguments << "-datatags"; } + else if (subtest == "silent") { + arguments << "-silent"; + } // These tests don't work right unless logging plain text to @@ -434,6 +438,9 @@ void tst_Selftests::runSubTest_data() if (subtest == "printdatatagswithglobaltags") { continue; } + if (subtest == "silent") { + continue; + } // `crashes' will not output valid XML on platforms without a crash handler if (subtest == "crashes") { continue; From 46ce1185fb8411c3dd775d19d2012c97b1d2e5fa Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Thu, 16 Feb 2012 13:25:41 +0100 Subject: [PATCH 145/166] restore previously non-working disabled test Change-Id: I419863a681f7be96cb855a274c68eaea25efebcb Reviewed-by: Yunqiao Yin --- .../qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index 45b9c26824..ddafeea427 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -1406,8 +1406,7 @@ void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() QCOMPARE(model.data(model.index(0, 1)).toString(), QString("Washington")); QCOMPARE(model.data(model.index(0, 2)).toInt(), 7); - //TODO: For some reson setting a record using manual submit fails - //model.setEditStrategy(QSqlTableModel::OnManualSubmit); + model.setEditStrategy(QSqlTableModel::OnManualSubmit); QSqlRecord recNew; QSqlField f1New("id", QVariant::Int); From 53338de52b9e654e667df38ca47acc4984b2de2a Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Wed, 15 Feb 2012 15:02:05 +0100 Subject: [PATCH 146/166] QSqlTableModel::isDirty(): simplify and improve logic Change-Id: Ic1332befa9078a94f872e38ff779e5b4cec7c100 Reviewed-by: Yunqiao Yin --- src/sql/models/qsqltablemodel.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index c895c39212..b36a54bbe9 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -461,23 +461,14 @@ bool QSqlTableModel::isDirty(const QModelIndex &index) const if (!index.isValid()) return false; - switch (d->strategy) { - case OnFieldChange: - return false; - case OnRowChange: { - const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row()); - return row.op() == QSqlTableModelPrivate::Update - && row.rec().isGenerated(index.column()); - } - case OnManualSubmit: { - const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row()); - return row.op() == QSqlTableModelPrivate::Insert - || row.op() == QSqlTableModelPrivate::Delete - || (row.op() == QSqlTableModelPrivate::Update - && row.rec().isGenerated(index.column())); - } - } - return false; + const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row()); + if (row.submitted()) + return false; + + return row.op() == QSqlTableModelPrivate::Insert + || row.op() == QSqlTableModelPrivate::Delete + || (row.op() == QSqlTableModelPrivate::Update + && row.rec().isGenerated(index.column())); } /*! From 8f872ee0e815b27ac6fc13345bb3c80b7e71d083 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 28 Feb 2012 15:16:09 +1000 Subject: [PATCH 147/166] configure: fixed stray output from endian.test when not verbose The output of building and running config.tests are generally silent unless -verbose is passed to configure. However, there was one place in endian.test where a check for $VERBOSE was missed, leading to confusing output like: Creating qmake. Please wait... rm -f endiantest.o rm -f *~ core *.core rm -f endiantest rm -f Makefile rm -f endiantest.o rm -f *~ core *.core rm -f endiantest rm -f Makefile Change-Id: Idabe85f2b188ed9da713392d116d4d2853be2189 Reviewed-by: Jason McDonald --- config.tests/unix/endian.test | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config.tests/unix/endian.test b/config.tests/unix/endian.test index 6c5c311888..a662011a27 100755 --- a/config.tests/unix/endian.test +++ b/config.tests/unix/endian.test @@ -41,7 +41,11 @@ elif strings - $binary | grep MostSignificantByteFirst >/dev/null 2>&1; then fi # make clean as this tests is compiled for both the host and the target -$MAKE distclean +if [ "$VERBOSE" = "yes" ]; then + $MAKE distclean +else + $MAKE distclean >/dev/null 2>&1 +fi # done if [ "$ENDIAN" = "LITTLE" ]; then From 52dab549868d41fbfb6f3f612c380fb750755aa3 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Tue, 14 Feb 2012 22:26:43 +0100 Subject: [PATCH 148/166] QSqlTableModel: unify code for cache-clearing before select The code in submitAll() had the same goal as the code in select, so it has been unified. The new code in select() avoids sending lots of dataChanged() signals for rows that are going to be removed by QSqlQueryModel anyway. Change-Id: Ic22e038223720185e47ed0cc573147745ecc8fc9 Reviewed-by: Yunqiao Yin --- src/sql/models/qsqltablemodel.cpp | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index b36a54bbe9..571c28f515 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -378,13 +378,19 @@ bool QSqlTableModel::select() if (query.isEmpty()) return false; - // clear the submitted flags so revertAll can do its job - for (QSqlTableModelPrivate::CacheMap::Iterator it = d->cache.begin(); - it != d->cache.constEnd(); - ++it) - it.value().setSubmitted(false); + QSqlTableModelPrivate::CacheMap::Iterator it = d->cache.end(); + while (it != d->cache.constBegin()) { + --it; + // rows must be accounted for + if (it.value().op() == QSqlTableModelPrivate::Insert) { + beginRemoveRows(QModelIndex(), it.key(), it.key()); + it = d->cache.erase(it); + endRemoveRows(); + } else { + it = d->cache.erase(it); + } + } - revertAll(); QSqlQuery qu(query, d->db); setQuery(qu); @@ -681,19 +687,6 @@ bool QSqlTableModel::submitAll() it.value().setSubmitted(true); } - // all changes have been committed - - // clean up inserted rows - QSqlTableModelPrivate::CacheMap::Iterator it = d->cache.end(); - while (it != d->cache.constBegin()) { - --it; - if (it.value().op() == QSqlTableModelPrivate::Insert) { - beginRemoveRows(QModelIndex(), it.key(), it.key()); - it = d->cache.erase(it); - endRemoveRows(); - } - } - d->clearCache(); return select(); } From 838f828a1d76c1f9fc1fba669d336e91f622fb94 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Feb 2012 17:09:43 +0100 Subject: [PATCH 149/166] QComboBox: Use platform theme hint to determine popup geometry. Change-Id: I1f81be1394455715c5dfcd2d426758c4c7cd91fc Reviewed-by: Bradley T. Hughes --- src/widgets/widgets/qcombobox.cpp | 21 +++++++----------- .../widgets/qcombobox/tst_qcombobox.cpp | 22 +++++++++---------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index d6af8d6044..c5f5d6e6e1 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -43,6 +43,7 @@ #ifndef QT_NO_COMBOBOX #include +#include #include #include #include @@ -57,15 +58,13 @@ #include #include #include +#include #include #include #include #include #include #include -#ifdef Q_WS_X11 -#include -#endif #if defined(Q_WS_MAC) && !defined(QT_NO_EFFECTS) && !defined(QT_NO_STYLE_MAC) #include #include @@ -219,16 +218,12 @@ void QComboBoxPrivate::_q_modelDestroyed() //Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't QRect QComboBoxPrivate::popupGeometry(int screen) const { -#ifdef Q_WS_WIN - return QApplication::desktop()->screenGeometry(screen); -#elif defined Q_WS_X11 - if (X11->desktopEnvironment == DE_KDE) - return QApplication::desktop()->screenGeometry(screen); - else - return QApplication::desktop()->availableGeometry(screen); -#else - return QApplication::desktop()->availableGeometry(screen); -#endif + bool useFullScreenForPopupMenu = false; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool(); + return useFullScreenForPopupMenu ? + QApplication::desktop()->screenGeometry(screen) : + QApplication::desktop()->availableGeometry(screen); } bool QComboBoxPrivate::updateHoverControl(const QPoint &pos) diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 907a239912..0fe93995a1 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -43,6 +43,8 @@ #include "qcombobox.h" #include +#include +#include #include #include @@ -1915,19 +1917,15 @@ void tst_QComboBox::itemListPosition() QWidget topLevel; QFontComboBox combo(&topLevel); - //the code to get the avaialbe screen space is copied from QComboBox code + //the code to get the available screen space is copied from QComboBox code const int scrNumber = QApplication::desktop()->screenNumber(&combo); - QRect screen; -#ifdef Q_WS_WIN - screen = QApplication::desktop()->screenGeometry(scrNumber); -#elif defined Q_WS_X11 - if (X11->desktopEnvironment == DE_KDE) - screen = QApplication::desktop()->screenGeometry(scrNumber); - else - screen = QApplication::desktop()->availableGeometry(scrNumber); -#else - screen = QApplication::desktop()->availableGeometry(scrNumber); -#endif + + bool useFullScreenForPopupMenu = false; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool(); + const QRect screen = useFullScreenForPopupMenu ? + QApplication::desktop()->screenGeometry(scrNumber) : + QApplication::desktop()->availableGeometry(scrNumber); combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo to the top-right corner From ced029e87d9bf4b0d7f526d8e611c0e1e8c56a45 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 24 Feb 2012 18:11:16 -0800 Subject: [PATCH 150/166] Fix QSettings autotest fails under Windows The Windows registry and INI files use case-insensitive key. This is a side effect of 1d01bc1e83560cb2fc4f9f7f00762ffa5134448a Task-number: QTBUG-24145 Change-Id: I862bddae68ef27569e6ffa901f98ca107d3f300b Reviewed-by: Miikka Heikkinen Reviewed-by: Bradley T. Hughes --- src/corelib/io/qsettings_p.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h index f4f285bae4..534c377102 100644 --- a/src/corelib/io/qsettings_p.h +++ b/src/corelib/io/qsettings_p.h @@ -66,7 +66,9 @@ QT_BEGIN_NAMESPACE +#ifndef Q_OS_WIN #define QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER +#endif // used in testing framework #define QSETTINGS_P_H_VERSION 3 From dd7befcfd84a9a648fa467dda3fe45988bfc5604 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 3 Feb 2012 18:28:54 +0100 Subject: [PATCH 151/166] scope context saving more minimally no point in saving the context when we are not actually modifying the current context. Change-Id: Id6f51a163e86bdf402aa0713737b655db68e7ee8 Reviewed-by: Joerg Bornemann Reviewed-by: Marius Storm-Olsen --- qmake/project.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index 3546ac9877..eb07dea654 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1712,9 +1712,6 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QHash sc = scope_blocks; - IteratorBlock *it = iterator; - FunctionBlock *fu = function; if(flags & (IncludeFlagNewProject|IncludeFlagNewParser)) { // The "project's variables" are used in other places (eg. export()) so it's not // possible to use "place" everywhere. Instead just set variables and grab them later @@ -1730,11 +1727,14 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QHash sc = scope_blocks; + IteratorBlock *it = iterator; + FunctionBlock *fu = function; parsed = read(file, place); + iterator = it; + function = fu; + scope_blocks = sc; } - iterator = it; - function = fu; - scope_blocks = sc; } if(parsed) { if(place["QMAKE_INTERNAL_INCLUDED_FILES"].indexOf(orig_file) == -1) From bf29a8a27dad02f4956695e60e5be929e5ede039 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 22 Feb 2012 19:33:53 +0100 Subject: [PATCH 152/166] don't look for features in PrefixPath it's generally redundant with DataPath which we already look into. this is consistent with where mkspecs are looked for. i don't think anyone will notice this "loss" ... Change-Id: Iab7c35cc22ba53e1005f26b5d85d41cf4dafad07 Reviewed-by: Joerg Bornemann --- qmake/project.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index eb07dea654..0445c8eee9 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -590,10 +590,6 @@ QStringList qmake_feature_paths(QMakeProperty *prop=0) } } } - for(QStringList::Iterator concat_it = concat.begin(); - concat_it != concat.end(); ++concat_it) - feature_roots << (QLibraryInfo::location(QLibraryInfo::PrefixPath) + - mkspecs_concat + (*concat_it)); for(QStringList::Iterator concat_it = concat.begin(); concat_it != concat.end(); ++concat_it) feature_roots << (QLibraryInfo::location(QLibraryInfo::DataPath) + From 059200a44ba7177d0c9ec6bb5e6ee0b7e0c3f017 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 17:05:28 +0100 Subject: [PATCH 153/166] move .qmake.cache search to Option this is a one-time operation which depends only on the invocation, so this new home is much more appropriate. Change-Id: I11ef30a8227afed06e58e64e65809dba25e81567 Reviewed-by: Joerg Bornemann --- qmake/main.cpp | 5 +++++ qmake/option.cpp | 29 +++++++++++++++++++++++++++++ qmake/option.h | 2 ++ qmake/project.cpp | 32 +++----------------------------- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/qmake/main.cpp b/qmake/main.cpp index 38e09f60fd..54cf9f9bdf 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -163,6 +163,11 @@ int runQMake(int argc, char **argv) fn = fn.right(fn.length() - di - 1); } + if (!Option::prepareProject()) { + exit_val = 3; + break; + } + // read project.. if(!project.read(fn)) { fprintf(stderr, "Error processing project file: %s\n", diff --git a/qmake/option.cpp b/qmake/option.cpp index 431299b46b..306e6b5286 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -116,6 +116,7 @@ bool Option::mkfile::do_dep_heuristics = true; bool Option::mkfile::do_preprocess = false; bool Option::mkfile::do_stub_makefile = false; bool Option::mkfile::do_cache = true; +QString Option::mkfile::project_build_root; QString Option::mkfile::cachefile; QStringList Option::mkfile::project_files; QString Option::mkfile::qmakespec_commandline; @@ -567,6 +568,34 @@ void Option::applyHostMode() } } +bool Option::prepareProject() +{ + mkfile::project_build_root.clear(); + if (mkfile::do_cache) { + if (mkfile::cachefile.isEmpty()) { //find it as it has not been specified + QDir dir(output_dir); + while (!dir.exists(QLatin1String(".qmake.cache"))) + if (dir.isRoot() || !dir.cdUp()) + goto no_cache; + mkfile::cachefile = dir.filePath(QLatin1String(".qmake.cache")); + mkfile::project_build_root = dir.path(); + } else { + QFileInfo fi(mkfile::cachefile); + mkfile::cachefile = QDir::cleanPath(fi.absoluteFilePath()); + mkfile::project_build_root = QDir::cleanPath(fi.absolutePath()); + } + + if (mkfile::qmakespec.isEmpty()) { + QMakeProject cproj; + if (!cproj.read(mkfile::cachefile, QMakeProject::ReadProFile)) + return false; + mkfile::qmakespec = cproj.first(QLatin1String("QMAKESPEC")); + } + } + no_cache: + return true; +} + bool Option::postProcessProject(QMakeProject *project) { Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"]; diff --git a/qmake/option.h b/qmake/option.h index ee8a1c2403..b8a3b561fa 100644 --- a/qmake/option.h +++ b/qmake/option.h @@ -108,6 +108,7 @@ struct Option //both of these must be called.. static int init(int argc=0, char **argv=0); //parse cmdline static void applyHostMode(); + static bool prepareProject(); static bool postProcessProject(QMakeProject *); enum StringFixFlags { @@ -201,6 +202,7 @@ struct Option static bool do_dep_heuristics; static bool do_preprocess; static bool do_stub_makefile; + static QString project_build_root; static QString cachefile; static int cachefile_depth; static QStringList project_files; diff --git a/qmake/project.cpp b/qmake/project.cpp index 0445c8eee9..1179812b1b 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1281,35 +1281,9 @@ QMakeProject::read(uchar cmd) base_vars["TEMPLATE_PREFIX"] = QStringList(Option::user_template_prefix); if ((cmd & ReadSetup) && Option::mkfile::do_cache) { // parse the cache - int cache_depth = -1; - QString qmake_cache = Option::mkfile::cachefile; - if(qmake_cache.isEmpty()) { //find it as it has not been specified - QString dir = Option::output_dir; - while(!QFile::exists((qmake_cache = dir + QLatin1String("/.qmake.cache")))) { - dir = dir.left(dir.lastIndexOf(QLatin1Char('/'))); - if(dir.isEmpty() || dir.indexOf(QLatin1Char('/')) == -1) { - qmake_cache = ""; - break; - } - if(cache_depth == -1) - cache_depth = 1; - else - cache_depth++; - } - } else { - QString abs_cache = QFileInfo(Option::mkfile::cachefile).absoluteDir().path(); - if(Option::output_dir.startsWith(abs_cache)) - cache_depth = Option::output_dir.mid(abs_cache.length()).count('/'); - } - if(!qmake_cache.isEmpty()) { - QHash cache; - if(read(qmake_cache, cache)) { - Option::mkfile::cachefile_depth = cache_depth; - Option::mkfile::cachefile = qmake_cache; - if(Option::mkfile::qmakespec.isEmpty() && !cache["QMAKESPEC"].isEmpty()) - Option::mkfile::qmakespec = cache["QMAKESPEC"].first(); - } - } + if (Option::output_dir.startsWith(Option::mkfile::project_build_root)) + Option::mkfile::cachefile_depth = + Option::output_dir.mid(Option::mkfile::project_build_root.length()).count('/'); } if (cmd & ReadSetup) { // parse mkspec QString qmakespec = fixEnvVariables(Option::mkfile::qmakespec); From 08fe1f6871169bf36ee58025da40824547c21b5f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 24 Feb 2012 12:11:51 +0100 Subject: [PATCH 154/166] resolve relative spec paths already on the command line this is way more predictable than resolving it later. Change-Id: I0ce27977b795bde9235e1d51d6f2d0d917f2398c Reviewed-by: Joerg Bornemann --- qmake/option.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qmake/option.cpp b/qmake/option.cpp index 306e6b5286..0c649fdd77 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -147,6 +147,14 @@ static QString detectProjectFile(const QString &path) return ret; } +static QString cleanSpec(const QString &spec) +{ + QString ret = QDir::cleanPath(spec); + if (ret.contains('/')) + ret = QDir::cleanPath(QFileInfo(ret).absoluteFilePath()); + return ret; +} + QString project_builtin_regx(); bool usage(const char *a0) { @@ -315,7 +323,7 @@ Option::parseCommandLine(int argc, char **argv, int skip) } else if(opt == "cache") { Option::mkfile::cachefile = argv[++x]; } else if(opt == "platform" || opt == "spec") { - Option::mkfile::qmakespec = argv[++x]; + Option::mkfile::qmakespec = cleanSpec(argv[++x]); Option::mkfile::qmakespec_commandline = argv[x]; } else { fprintf(stderr, "***Unknown option -%s\n", opt.toLatin1().constData()); From f220f99a6d13a395ca723e9f923b16ef9ac9716b Mon Sep 17 00:00:00 2001 From: Donald Carr Date: Thu, 23 Feb 2012 19:33:48 +0000 Subject: [PATCH 155/166] Remove stale QWS considerations from configure Remove all reference to QWS/EMBEDDED in configure script Remove legacy qws config tests Change-Id: I09ed3d82bdda0fd0f9da87634d0cd1b7457a782b Reviewed-by: Donald Carr Reviewed-by: Johannes Zellner Reviewed-by: Oswald Buddenhagen --- config.tests/qws/ahi/ahi.cpp | 50 --- config.tests/qws/ahi/ahi.pro | 3 - config.tests/qws/directfb/directfb.cpp | 50 --- config.tests/qws/directfb/directfb.pro | 5 - config.tests/qws/sound/sound.cpp | 49 --- config.tests/qws/sound/sound.pro | 2 - config.tests/qws/svgalib/svgalib.cpp | 51 --- config.tests/qws/svgalib/svgalib.pro | 3 - configure | 544 ++----------------------- 9 files changed, 24 insertions(+), 733 deletions(-) delete mode 100644 config.tests/qws/ahi/ahi.cpp delete mode 100644 config.tests/qws/ahi/ahi.pro delete mode 100644 config.tests/qws/directfb/directfb.cpp delete mode 100644 config.tests/qws/directfb/directfb.pro delete mode 100644 config.tests/qws/sound/sound.cpp delete mode 100644 config.tests/qws/sound/sound.pro delete mode 100644 config.tests/qws/svgalib/svgalib.cpp delete mode 100644 config.tests/qws/svgalib/svgalib.pro diff --git a/config.tests/qws/ahi/ahi.cpp b/config.tests/qws/ahi/ahi.cpp deleted file mode 100644 index 166fc4e2b4..0000000000 --- a/config.tests/qws/ahi/ahi.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -int main(int, char **) -{ - AhiInit(0); - AhiTerm(); - - return 0; -} diff --git a/config.tests/qws/ahi/ahi.pro b/config.tests/qws/ahi/ahi.pro deleted file mode 100644 index 532a565bc4..0000000000 --- a/config.tests/qws/ahi/ahi.pro +++ /dev/null @@ -1,3 +0,0 @@ -SOURCES = ahi.cpp -CONFIG -= qt -LIBS += -lahi -lahioem diff --git a/config.tests/qws/directfb/directfb.cpp b/config.tests/qws/directfb/directfb.cpp deleted file mode 100644 index d781702ab6..0000000000 --- a/config.tests/qws/directfb/directfb.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -int main(int, char **) -{ - DFBResult result = DFB_OK; - result = DirectFBInit(0, 0); - - return (result == DFB_OK); -} diff --git a/config.tests/qws/directfb/directfb.pro b/config.tests/qws/directfb/directfb.pro deleted file mode 100644 index db14d3ba48..0000000000 --- a/config.tests/qws/directfb/directfb.pro +++ /dev/null @@ -1,5 +0,0 @@ -SOURCES = directfb.cpp -CONFIG -= qt - -QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB -LIBS += $$QT_LIBS_DIRECTFB diff --git a/config.tests/qws/sound/sound.cpp b/config.tests/qws/sound/sound.cpp deleted file mode 100644 index fbc602b42a..0000000000 --- a/config.tests/qws/sound/sound.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -int main(int, char **) -{ - audio_buf_info info; - - return 0; -} diff --git a/config.tests/qws/sound/sound.pro b/config.tests/qws/sound/sound.pro deleted file mode 100644 index 4ad3376dca..0000000000 --- a/config.tests/qws/sound/sound.pro +++ /dev/null @@ -1,2 +0,0 @@ -SOURCES = sound.cpp -CONFIG -= qt diff --git a/config.tests/qws/svgalib/svgalib.cpp b/config.tests/qws/svgalib/svgalib.cpp deleted file mode 100644 index d42705597d..0000000000 --- a/config.tests/qws/svgalib/svgalib.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -int main(int, char **) -{ - int mode = vga_getdefaultmode(); - gl_setcontextvga(mode); - - return 0; -} diff --git a/config.tests/qws/svgalib/svgalib.pro b/config.tests/qws/svgalib/svgalib.pro deleted file mode 100644 index 169065239b..0000000000 --- a/config.tests/qws/svgalib/svgalib.pro +++ /dev/null @@ -1,3 +0,0 @@ -SOURCES = svgalib.cpp -CONFIG -= qt -LIBS += -lvgagl -lvga diff --git a/configure b/configure index f4743c2753..3d5f262cea 100755 --- a/configure +++ b/configure @@ -245,7 +245,6 @@ fi #------------------------------------------------------------------------------- PLATFORM_X11=no -PLATFORM_QWS=no PLATFORM_QPA=yes BUILD_ON_MAC=no PLATFORM_MAC=no @@ -290,7 +289,6 @@ fi #------------------------------------------------------------------------------- COMMERCIAL_USER=ask CFG_DEV=no -CFG_EMBEDDED=no CFG_RTOS_ENABLED=yes EditionString=Commercial @@ -318,16 +316,6 @@ earlyArgParse() VAR=`echo $1 | sed "s,^--no-\(.*\),\1,"` VAL=no ;; - -embedded) - VAR=embedded - # this option may or may not be followed by an argument - if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then - VAL=auto - else - shift; - VAL=$1 - fi - ;; -embedded-lite|-qpa) VAR=qpa # this option may or may not be followed by an argument @@ -367,25 +355,15 @@ earlyArgParse() UNKNOWN_OPT=no case "$VAR" in - embedded) - CFG_EMBEDDED="$VAL" - PLATFORM_X11=no - PLATFORM_MAC=no - PLATFORM_QWS=yes - PLATFORM_QPA=no - ;; qpa) - CFG_EMBEDDED="no" if [ "$PLATFORM_QPA" != "no" ]; then if [ "$PLATFORM_QPA" = "maybe" ]; then PLATFORM_X11=no PLATFORM_MAC=no - PLATFORM_QWS=no PLATFORM_QPA=yes fi else echo "No license exists to enable Qt QPA. Disabling." - CFG_EMBEDDED=no fi ;; developer-build) @@ -436,7 +414,6 @@ elif [ $COMMERCIAL_USER = "yes" ]; then # one of commercial editions [ "$PLATFORM_MAC" = "maybe" ] && PLATFORM_MAC=yes [ "$PLATFORM_QPA" = "maybe" ] && PLATFORM_QPA=no - [ "$PLATFORM_QWS" = "maybe" ] && PLATFORM_QWS=no # read in the license file if [ -f "$LICENSE_FILE" ]; then @@ -549,7 +526,6 @@ elif [ $COMMERCIAL_USER = "yes" ]; then *) Platform=Linux/X11 [ "$PLATFORM_MAC" = "yes" ] && Platform='Mac OS X' - [ "$PLATFORM_QWS" = "yes" ] && Platform='Embedded Linux' echo echo "You are not licensed for the $Platform platform." echo @@ -719,7 +695,6 @@ CFG_EGL=no CFG_EGL_GLES_INCLUDES=no CFG_SSE=auto CFG_FONTCONFIG=auto -CFG_QWS_FREETYPE=auto CFG_LIBFREETYPE=auto CFG_SQL_AVAILABLE= QT_DEFAULT_BUILD_PARTS="libs examples tests" @@ -741,17 +716,6 @@ CFG_KBD_ON="tty" #default, see QMakeVar above CFG_MOUSE_AVAILABLE="pc linuxtp linuxinput tslib qvfb" CFG_MOUSE_ON="pc linuxtp" #default, see QMakeVar above -if [ -f "$relpath/src/gui/embedded/qscreenqnx_qws.cpp" ]; then - CFG_KBD_AVAILABLE="${CFG_KBD_AVAILABLE} qnx" - CFG_MOUSE_AVAILABLE="${CFG_MOUSE_AVAILABLE} qnx" - CFG_GFX_AVAILABLE="${CFG_GFX_AVAILABLE} qnx" -fi -if [ -f "$relpath/src/gui/embedded/qscreenintegrityfb_qws.cpp" ]; then - CFG_KBD_AVAILABLE="${CFG_KBD_AVAILABLE} integrity" - CFG_MOUSE_AVAILABLE="${CFG_MOUSE_AVAILABLE} integrity" - CFG_GFX_AVAILABLE="${CFG_GFX_AVAILABLE} integrityfb" -fi - CFG_ARCH= CFG_HOST_ARCH= CFG_KBD_PLUGIN_AVAILABLE= @@ -799,7 +763,6 @@ CFG_SSE4_2=auto CFG_AVX=auto CFG_REDUCE_RELOCATIONS=auto CFG_NAS=no -CFG_QWS_DEPTHS=all CFG_ACCESSIBILITY=auto CFG_ENDIAN=auto CFG_HOST_ENDIAN=auto @@ -1005,7 +968,7 @@ while [ "$#" -gt 0 ]; do ;; #Qt style options that pass an argument -qconfig) - if [ "$PLATFORM_QWS" != "yes" -a "$PLATFORM_QPA" != "yes" ]; then + if [ "$PLATFORM_QPA" != "yes" ]; then echo echo "WARNING: -qconfig is only tested and supported on Qt for Embedded Linux." echo @@ -1035,16 +998,6 @@ while [ "$#" -gt 0 ]; do VAR=fatal_error VAL=no ;; - -embedded) - VAR=embedded - # this option may or may not be followed by an argument - if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then - VAL=auto - else - shift; - VAL=$1 - fi - ;; -embedded-lite|-qpa) VAR=qpa # this option may or may not be followed by an argument @@ -1267,18 +1220,9 @@ while [ "$#" -gt 0 ]; do sxe) CFG_SXE="$VAL" ;; - embedded) - CFG_EMBEDDED="$VAL" - PLATFORM_X11=no - PLATFORM_MAC=no - PLATFORM_QWS=yes - PLATFORM_QPA=no - ;; embedded-lite|qpa) - CFG_EMBEDDED="no" PLATFORM_X11=no PLATFORM_MAC=no - PLATFORM_QWS=no PLATFORM_QPA=yes ;; sse) @@ -1313,9 +1257,6 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; - depths) - CFG_QWS_DEPTHS="$VAL" - ;; opengl) if [ "$VAL" = "auto" ] || [ "$VAL" = "desktop" ] || [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || @@ -1361,7 +1302,6 @@ while [ "$#" -gt 0 ]; do x11) PLATFORM_QPA=no PLATFORM_MAC=no - PLATFORM_QWS=no PLATFORM_X11=yes ;; sdk) @@ -1742,14 +1682,6 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; - freetype) - [ "$VAL" = "qt" ] && VAL=yes - if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then - CFG_QWS_FREETYPE="$VAL" - else - UNKNOWN_OPT=yes - fi - ;; zlib) [ "$VAL" = "qt" ] && VAL=yes if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then @@ -2293,7 +2225,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then [ "$OPT_VERBOSE" = "yes" ] && echo "Performing shadow build..." fi -if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "yes" ]; then +if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QPA" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "yes" ]; then echo echo "WARNING: -debug-and-release is not supported anymore on Qt/X11 and Qt for Embedded Linux" echo "Qt can be built in release mode with separate debug information, so" @@ -2389,7 +2321,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then fi # symlink fonts to be able to run application from build directory -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ] && [ ! -d "${outpath}/lib/fonts" ]; then +if [ "$PLATFORM_QPA" = "yes" ] && [ ! -d "${outpath}/lib/fonts" ]; then if [ "$PLATFORM" = "$XPLATFORM" ]; then mkdir -p "${outpath}/lib" ln -s "${relpath}/lib/fonts" "${outpath}/lib/fonts" @@ -2428,85 +2360,6 @@ fi ### help # auto-detect all that hasn't been specified in the arguments #------------------------------------------------------------------------------- -[ "$PLATFORM_QWS" = "yes" -a "$CFG_EMBEDDED" = "no" ] && CFG_EMBEDDED=auto -if [ "$CFG_EMBEDDED" != "no" ]; then - case "$UNAME_SYSTEM:$UNAME_RELEASE" in - Darwin:*) - [ -z "$PLATFORM" ] && PLATFORM=qws/macx-generic-g++ - if [ -z "$XPLATFORM" ]; then - [ "$CFG_EMBEDDED" = "auto" ] && CFG_EMBEDDED=generic - XPLATFORM="qws/macx-$CFG_EMBEDDED-g++" - fi - ;; - FreeBSD:*) - [ -z "$PLATFORM" ] && PLATFORM=qws/freebsd-generic-g++ - if [ -z "$XPLATFORM" ]; then - [ "$CFG_EMBEDDED" = "auto" ] && CFG_EMBEDDED=generic - XPLATFORM="qws/freebsd-$CFG_EMBEDDED-g++" - fi - ;; - SunOS:5*) - [ -z "$PLATFORM" ] && PLATFORM=qws/solaris-generic-g++ - if [ -z "$XPLATFORM" ]; then - [ "$CFG_EMBEDDED" = "auto" ] && CFG_EMBEDDED=generic - XPLATFORM="qws/solaris-$CFG_EMBEDDED-g++" - fi - ;; - Linux:*) - if [ -z "$PLATFORM" ]; then - case "$UNAME_MACHINE" in - *86) - PLATFORM=qws/linux-x86-g++ - ;; - *86_64) - PLATFORM=qws/linux-x86_64-g++ - ;; - *) - PLATFORM=qws/linux-generic-g++ - ;; - esac - fi - if [ -z "$XPLATFORM" ]; then - if [ "$CFG_EMBEDDED" = "auto" ]; then - if [ -n "$CFG_ARCH" ]; then - CFG_EMBEDDED=$CFG_ARCH - else - case "$UNAME_MACHINE" in - *86) - CFG_EMBEDDED=x86 - ;; - *86_64) - CFG_EMBEDDED=x86_64 - ;; - *) - CFG_EMBEDDED=generic - ;; - esac - fi - fi - XPLATFORM="qws/linux-$CFG_EMBEDDED-g++" - fi - ;; - QNX:*) - [ -z "$PLATFORM" ] && PLATFORM=unsupported/qws/qnx-generic-g++ - if [ -z "$XPLATFORM" ]; then - [ "$CFG_EMBEDDED" = "auto" ] && CFG_EMBEDDED=generic - XPLATFORM="unsupported/qws/qnx-$CFG_EMBEDDED-g++" - fi - ;; - CYGWIN*:*) - if [ -z "$XPLATFORM" ]; then - CFG_EMBEDDED=x86 - fi - ;; - *) - echo "Qt for Embedded Linux is not supported on this platform. Disabling." - CFG_EMBEDDED=no - PLATFORM_QWS=no - PLATFORM_QPA=no - ;; - esac -fi if [ -z "$PLATFORM" ]; then PLATFORM_NOTES= case "$UNAME_SYSTEM:$UNAME_RELEASE" in @@ -2685,12 +2538,7 @@ if [ -z "$PLATFORM" ]; then esac fi -if [ "$PLATFORM_QWS" = "yes" ]; then - CFG_SM=no - PLATFORMS=`find "$relpath/mkspecs/qws" | sed "s,$relpath/mkspecs/qws/,,"` -else - PLATFORMS=`find "$relpath/mkspecs/" -type f | grep -v qws | sed "s,$relpath/mkspecs/qws/,,"` -fi +PLATFORMS=`find "$relpath/mkspecs/" -type f | grep -v qws | sed "s,$relpath/mkspecs/qws/,,"` [ -z "$XPLATFORM" ] && XPLATFORM="$PLATFORM" @@ -2757,7 +2605,7 @@ if [ '!' -f "${XQMAKESPEC}/qplatformdefs.h" ]; then fi # now look at the configs and figure out what platform we are config'd for -[ "$CFG_EMBEDDED" = "no" ] && [ "$PLATFORM_QPA" != "yes" ] \ +[ "$PLATFORM_QPA" != "yes" ] \ && [ -n "`getXQMakeConf QMAKE_LIBS_X11`" ] \ && PLATFORM_X11=yes ### echo "$XQMAKESPEC" | grep mkspecs/qws >/dev/null 2>&1 && PLATFORM_QWS=yes @@ -2777,17 +2625,6 @@ if [ "$OPT_VERBOSE" = "yes" ]; then echo "Determining system architecture... ($UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_MACHINE)" fi -if [ "$CFG_EMBEDDED" != "no" -a "$CFG_EMBEDDED" != "auto" ] && [ -n "$CFG_ARCH" ]; then - if [ "$CFG_ARCH" != "$CFG_EMBEDDED" ]; then - echo "" - echo "You have specified a target architecture with -embedded and -arch." - echo "The two architectures you have specified are different, so we can" - echo "not proceed. Either set both to be the same, or only use -embedded." - echo "" - exit 1 - fi -fi - if [ "$CFG_RTOS_ENABLED" = "no" ]; then case `basename "$XPLATFORM"` in qnx-* | vxworks-*) @@ -2926,38 +2763,7 @@ if [ -z "${CFG_HOST_ARCH}" ]; then esac fi -if [ "$PLATFORM" != "$XPLATFORM" -a "$CFG_EMBEDDED" != "no" ]; then - if [ -n "$CFG_ARCH" ]; then - CFG_EMBEDDED=$CFG_ARCH - fi - - case "$CFG_EMBEDDED" in - x86) - CFG_ARCH=i386 - ;; - x86_64) - CFG_ARCH=x86_64 - ;; - ipaq|sharp) - CFG_ARCH=arm - ;; - dm7000) - CFG_ARCH=powerpc - ;; - dm800) - CFG_ARCH=mips - ;; - sh4al) - CFG_ARCH=sh4a - ;; - arm*) - CFG_ARCH=arm - ;; - *) - CFG_ARCH="$CFG_EMBEDDED" - ;; - esac -elif [ "$XPLATFORM_MINGW" = "yes" ]; then +if [ "$XPLATFORM_MINGW" = "yes" ]; then [ -z "$CFG_ARCH" ] && CFG_ARCH="windows" elif [ "$PLATFORM_MAC" = "yes" ] || [ -z "$CFG_ARCH" ]; then CFG_ARCH=$CFG_HOST_ARCH @@ -2975,7 +2781,7 @@ esac if [ "$OPT_VERBOSE" = "yes" ]; then echo "System architecture: '$CFG_ARCH'" - if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then + if [ "$PLATFORM_QPA" = "yes" ]; then echo "Host architecture: '$CFG_HOST_ARCH'" fi fi @@ -3155,11 +2961,6 @@ if [ "$CFG_USE_GNUMAKE" = "auto" ] && "$MAKE" -v | grep "GNU Make" >/dev/null 2> CFG_USE_GNUMAKE=yes fi -# If -opengl wasn't specified, don't try to auto-detect -if [ "$PLATFORM_QWS" = "yes" ] && [ "$CFG_OPENGL" = "auto" ]; then - CFG_OPENGL=no -fi - # find the default framework value if [ "$BUILD_ON_MAC" = "yes" ]; then if [ "$CFG_FRAMEWORK" = "auto" ]; then @@ -3426,7 +3227,7 @@ Installation options: -prefix ...... This will install everything relative to (default $QT_INSTALL_PREFIX) EOF -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then +if [ "$PLATFORM_QPA" = "yes" ]; then cat < Sets an alternate graphics system. Available options are: raster - Software rasterizer @@ -3680,7 +3481,7 @@ else SBN="*" fi -if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then +if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then cat << EOF @@ -3695,7 +3496,7 @@ if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "ye EOF -fi # X11/QWS +fi # X11 if [ "$XPLATFORM_MAEMO" = "yes" ]; then @@ -3922,23 +3723,13 @@ Qt/Mac only: EOF fi -if [ "$PLATFORM_QWS" = "yes" ]; then - cat << EOF -Qt for Embedded Linux: - - -embedded .... This will enable the embedded build, you must have a - proper license for this switch to work. - Example values for : arm mips x86 generic -EOF -fi - if [ "$PLATFORM_QPA" = "yes" ]; then cat << EOF Qt for QPA only: EOF fi -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then +if [ "$PLATFORM_QPA" = "yes" ]; then cat << EOF -xplatform target ... The target platform when cross-compiling. @@ -3979,53 +3770,7 @@ if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then EOF fi -if [ "$PLATFORM_QWS" = "yes" ]; then - cat << EOF - - -depths ...... Comma-separated list of supported bit-per-pixel - depths, from: 1, 4, 8, 12, 15, 16, 18, 24, 32 and 'all'. - - -qt-decoration-