From e1f89037c3a54f03ac69d231e34c6e3d816e2a93 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 10 Jan 2014 11:55:28 +0100 Subject: [PATCH 01/72] fix memory leaks in MSVC generators Change-Id: I11bfc8259ac4e175c9ecc37d64f1d2e5037f15aa Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msbuild_objectmodel.cpp | 7 ++++--- qmake/generators/win32/msvc_objectmodel.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index f5a6e15a7b..d1420e95f6 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -44,6 +44,7 @@ #include "msvc_objectmodel.h" #include "msvc_vcproj.h" #include "msvc_vcxproj.h" +#include #include #include @@ -1756,11 +1757,11 @@ void VCXProjectWriter::addFilters(VCProject &project, XmlOutput &xmlFilter, cons // outputs a given filter for all existing configurations of a project void VCXProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername) { - XNode *root; + QScopedPointer root; if (project.SingleProjects.at(0).flat_files) - root = new XFlatNode; + root.reset(new XFlatNode); else - root = new XTreeNode; + root.reset(new XTreeNode); for (int i = 0; i < project.SingleProjects.count(); ++i) { VCFilter filter; diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 019bb2504d..8159cf58e2 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -42,6 +42,7 @@ #include "msvc_objectmodel.h" #include "msvc_vcproj.h" #include "msvc_vcxproj.h" +#include #include #include @@ -2854,11 +2855,11 @@ void VCProjectWriter::write(XmlOutput &xml, VCFilter &tool) // outputs a given filter for all existing configurations of a project void VCProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, const QString &filtername) { - Node *root; + QScopedPointer root; if (project.SingleProjects.at(0).flat_files) - root = new FlatNode; + root.reset(new FlatNode); else - root = new TreeNode; + root.reset(new TreeNode); QString name, extfilter, guid; triState parse = unset; From 95984487586f0699829c35278efbc73e01bf3c23 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 Jan 2014 18:54:46 -0800 Subject: [PATCH 02/72] Remove #ifdef from outside test functions It's usually a bad idea to surround slots or signals with #ifdef since moc may not parse it the same way the compiler does. Change-Id: I6a3623ed7cb9fbc1b966df9d60f71b7fdf91acfe Reviewed-by: Olivier Goffart --- .../corelib/io/largefile/tst_largefile.cpp | 6 ++---- .../kernel/qkeysequence/tst_qkeysequence.cpp | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index 88b4abe2e3..7564e3fc1f 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -121,9 +121,7 @@ private slots: // Map/unmap large file void mapFile(); -#ifndef Q_OS_MAC void mapOffsetOverflow(); -#endif void closeFile() { largeFile.close(); } @@ -513,9 +511,9 @@ void tst_LargeFile::mapFile() } //Mac: memory-mapping beyond EOF may succeed but it could generate bus error on access -#ifndef Q_OS_MAC void tst_LargeFile::mapOffsetOverflow() { +#ifndef Q_OS_MAC // Out-of-range mappings should fail, and not silently clip the offset for (int i = 50; i < 63; ++i) { uchar *address = 0; @@ -529,8 +527,8 @@ void tst_LargeFile::mapOffsetOverflow() address = largeFile.map(((qint64)1 << i) + blockSize, blockSize); QVERIFY( !address ); } -} #endif +} QTEST_APPLESS_MAIN(tst_LargeFile) #include "tst_largefile.moc" diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index bd7bd3a464..493d7e20c5 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -120,10 +120,8 @@ private slots: void symetricConstructors(); void checkMultipleNames(); void checkMultipleCodes(); -#ifndef Q_OS_MAC void mnemonic_data(); void mnemonic(); -#endif void toString_data(); void toString(); void toStringFromKeycode_data(); @@ -144,10 +142,8 @@ private slots: void standardKeys_data(); void standardKeys(); void keyBindings(); -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) void translated_data(); void translated(); -#endif void i18nKeys_data(); void i18nKeys(); @@ -405,9 +401,11 @@ void tst_QKeySequence::keyBindings() QCOMPARE(bindings, expected); } -#ifndef Q_OS_MAC void tst_QKeySequence::mnemonic_data() { +#ifdef Q_OS_MAC + QSKIP("Test not applicable to Mac OS X"); +#endif QTest::addColumn("string"); QTest::addColumn("key"); QTest::addColumn("warning"); @@ -427,6 +425,7 @@ void tst_QKeySequence::mnemonic_data() void tst_QKeySequence::mnemonic() { +#ifndef Q_OS_MAC QFETCH(QString, string); QFETCH(QString, key); QFETCH(bool, warning); @@ -444,8 +443,8 @@ void tst_QKeySequence::mnemonic() QKeySequence res = QKeySequence(key); QCOMPARE(seq, res); -} #endif +} void tst_QKeySequence::toString_data() { @@ -734,9 +733,12 @@ void tst_QKeySequence::listFromString() QCOMPARE(QKeySequence::listFromString(strSequences), sequences); } -#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) void tst_QKeySequence::translated_data() { +#if defined (Q_OS_MAC) || defined (Q_OS_WINCE) + QSKIP("Test not applicable"); +#endif + qApp->installTranslator(ourTranslator); qApp->installTranslator(qtTranslator); @@ -764,6 +766,7 @@ void tst_QKeySequence::translated_data() void tst_QKeySequence::translated() { +#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE) QFETCH(QString, transKey); QFETCH(QString, compKey); @@ -775,8 +778,8 @@ void tst_QKeySequence::translated() qApp->removeTranslator(ourTranslator); qApp->removeTranslator(qtTranslator); -} #endif +} void tst_QKeySequence::i18nKeys_data() { From c6b91576a6fbb45449261e48a72ad9a24e41bf3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Tue, 7 Jan 2014 08:17:57 +0100 Subject: [PATCH 03/72] Use custom -I,-D and -L flags when building arch-test Needed for using alternate stdlib implementation like libc++ with clang. Change-Id: I1782f62f5e2ea95e6cff8a1ed646362c0a31645c Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- config.tests/unix/arch.test | 20 +++++++++++++++++++- configure | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/config.tests/unix/arch.test b/config.tests/unix/arch.test index 529ed5e547..7b1c01ce28 100755 --- a/config.tests/unix/arch.test +++ b/config.tests/unix/arch.test @@ -19,6 +19,24 @@ fi LFLAGS="$SYSROOT_FLAG" CXXFLAGS="$SYSROOT_FLAG" +while [ "$#" -gt 0 ]; do + PARAM=$1 + case $PARAM in + -L*|-l*) + LFLAGS="$LFLAGS $PARAM" + ;; + -I*) + INC=`echo $PARAM | sed -e 's/^-I//'` + INCLUDEPATH="$INCLUDEPATH $INC" + ;; + -D*) + CXXFLAGS="$CXXFLAGS $PARAM" + ;; + *) ;; + esac + shift +done + # debuggery [ "$VERBOSE" = "yes" ] && echo "Determining architecture... ($*)" @@ -26,7 +44,7 @@ CXXFLAGS="$SYSROOT_FLAG" test -d "$OUTDIR/config.tests/arch" || mkdir -p "$OUTDIR/config.tests/arch" cd "$OUTDIR/config.tests/arch" [ -f Makefile ] && $MAKE distclean >/dev/null 2>&1 -OUTDIR=$OUTDIR "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "QT_BUILD_TREE=$OUTDIR" "LIBS+=$LFLAGS" "QMAKE_CXXFLAGS+=$CXXFLAGS" "CONFIG-=app_bundle" "$SRCDIR/config.tests/arch/arch$PROSUFFIX.pro" >/dev/null 2>&1 || echo "qmake is broken" >&2 +OUTDIR=$OUTDIR "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "QT_BUILD_TREE=$OUTDIR" "LIBS+=$LFLAGS" "QMAKE_CXXFLAGS+=$CXXFLAGS" "INCLUDEPATH+=$INCLUDEPATH" "CONFIG-=app_bundle" "$SRCDIR/config.tests/arch/arch$PROSUFFIX.pro" >/dev/null 2>&1 || echo "qmake is broken" >&2 ARCH="" diff --git a/configure b/configure index b16b79fa81..aaa59bdf17 100755 --- a/configure +++ b/configure @@ -4153,7 +4153,7 @@ compileTest() # Use config.tests/arch/arch.pro to have the compiler tell us what the target architecture is OUTFILE=$outpath/arch.result -"$unixtests/arch.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "target" +"$unixtests/arch.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "target" $I_FLAGS $D_FLAGS $L_FLAGS if [ $? -eq 0 ]; then eval `cat "$OUTFILE"` else @@ -4166,7 +4166,7 @@ rm -f "$OUTFILE" 2>/dev/null if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then # Do the same test again, using the host compiler - SYSROOT_FLAG= "$unixtests/arch.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "host" + SYSROOT_FLAG= "$unixtests/arch.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "host" $I_FLAGS $D_FLAGS $L_FLAGS if [ $? -eq 0 ]; then eval `cat "$OUTFILE"` else From 2dc04430baf4c38f3ee8b855236bbb1e3d60e946 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Tue, 31 Dec 2013 21:02:50 +0900 Subject: [PATCH 04/72] Make qtbase compile with QT_NO_DOM Change-Id: I98bef84ca9bf86bf7dddd3ca2a3d8210a8e46a16 Reviewed-by: Oswald Buddenhagen --- src/tools/qdoc/qdoc.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/qdoc/qdoc.pro b/src/tools/qdoc/qdoc.pro index b020bfe9a4..7ec4b4f726 100644 --- a/src/tools/qdoc/qdoc.pro +++ b/src/tools/qdoc/qdoc.pro @@ -1,6 +1,7 @@ !force_bootstrap { load(qfeatures) requires(!contains(QT_DISABLED_FEATURES, xmlstreamwriter)) + requires(!contains(QT_DISABLED_FEATURES, dom)) } option(host_build) From 6fd205d579ff53eb846ce5e15e558d4ea0e90823 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 18 Dec 2013 11:22:30 +0100 Subject: [PATCH 05/72] network proxy tests: adapt proxy authentication to new server The tests pass with the new test server image. Once we are using the new test server we can remove the test for the host not found error. Change-Id: Iac8ba6d8ce31b0865b33a003086aac0339afe338 Reviewed-by: Richard J. Moore --- .../auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 1837e8d665..291b368e47 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -6596,9 +6596,8 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); - QEXPECT_FAIL("http+socksauth", "QTBUG-23136 - danted accepts bad authentication but blocks the connection", Continue); - QEXPECT_FAIL("https+socksauth", "QTBUG-23136 - danted accepts bad authentication but blocks the connection", Continue); - + if (reply->error() == QNetworkReply::HostNotFoundError) + QSKIP("skip because of quirk in the old test server"); QCOMPARE(reply->error(), QNetworkReply::ProxyAuthenticationRequiredError); QCOMPARE(authSpy.count(), 0); QVERIFY(proxyAuthSpy.count() > 0); From 263fdd15da120c664de9ab6c43932a70cda9997b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 8 Jan 2014 11:35:30 +0100 Subject: [PATCH 06/72] Don't force create the platform window. This causes all sorts of unintended side effects and is generally a bad idea. Task-number: QTBUG-32988 Change-Id: Iebdae34764be4cfd9ced47aa93789871e0455ab3 Reviewed-by: Gabriel de Dietrich Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 795d1a8149..6facab1785 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -268,11 +268,6 @@ void QCocoaNativeInterface::registerTouchWindow(QWindow *window, bool enable) if (!window) return; - // Make sure the QCocoaWindow is created when enabling. Disabling might - // happen on window destruction, don't (re)create the QCocoaWindow then. - if (enable) - window->create(); - QCocoaWindow *cocoaWindow = static_cast(window->handle()); if (cocoaWindow) cocoaWindow->registerTouch(enable); From f568e43e107ba909eaad300729ee93354b0a1846 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 3 Jan 2014 14:38:12 +0900 Subject: [PATCH 07/72] Make qtbase compile with QT_NO_GESTURES Change-Id: I90f173265e177ff37ce80da3983080651856259d Reviewed-by: Oswald Buddenhagen --- src/gui/kernel/qguiapplication.cpp | 2 ++ src/gui/kernel/qguiapplication_p.h | 3 +++ src/gui/kernel/qwindowsysteminterface_p.h | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 1db252ca61..0711a37edd 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1473,10 +1473,12 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv QGuiApplicationPrivate::processTabletLeaveProximityEvent( static_cast(e)); break; +#ifndef QT_NO_GESTURES case QWindowSystemInterfacePrivate::Gesture: QGuiApplicationPrivate::processGestureEvent( static_cast(e)); break; +#endif case QWindowSystemInterfacePrivate::PlatformPanel: QGuiApplicationPrivate::processPlatformPanelEvent( static_cast(e)); diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 65c6d814e6..218036033e 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -148,7 +148,10 @@ public: static void processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e); static void processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e); static void processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e); + +#ifndef QT_NO_GESTURES static void processGestureEvent(QWindowSystemInterfacePrivate::GestureEvent *e); +#endif static void processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e); #ifndef QT_NO_CONTEXTMENU diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 8cafb8da5c..42dbe7509e 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -91,7 +91,9 @@ public: PlatformPanel = UserInputEvent | 0x17, ContextMenu = UserInputEvent | 0x18, EnterWhatsThisMode = UserInputEvent | 0x19, +#ifndef QT_NO_GESTURES Gesture = UserInputEvent | 0x1a, +#endif ApplicationStateChanged = 0x19, FlushEvents = 0x20, WindowScreenChanged = 0x21 @@ -400,6 +402,7 @@ public: }; #endif +#ifndef QT_NO_GESTURES class GestureEvent : public InputEvent { public: GestureEvent(QWindow *window, ulong time, Qt::NativeGestureType type, QPointF pos, QPointF globalPos) @@ -414,6 +417,7 @@ public: ulong sequenceId; quint64 intValue; }; +#endif class WindowSystemEventList { QList impl; From 67cf8bf9a8e6e583e9da02b153e8fdbe558637cb Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 28 Jun 2013 01:57:10 +0900 Subject: [PATCH 08/72] Make qtbase compile with QT_NO_TEMPORARYFILE Change-Id: I0211ed44513723392e3f50b76be10b95c0bcddd5 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qfile.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 519ac009aa..82aee331c5 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -571,6 +571,8 @@ QFile::rename(const QString &newName) d->setError(QFile::RenameError, tr("Destination file exists")); return false; } +#ifndef QT_NO_TEMPORARYFILE + // This #ifndef disables the workaround it encloses. Therefore, this configuration is not recommended. #ifdef Q_OS_LINUX // rename() on Linux simply does nothing when renaming "foo" to "Foo" on a case-insensitive // FS, such as FAT32. Move the file away and rename in 2 steps to work around. @@ -598,7 +600,8 @@ QFile::rename(const QString &newName) arg(QDir::toNativeSeparators(tempFile.fileName()), tempFile.errorString())); } return false; -#endif +#endif // Q_OS_LINUX +#endif // QT_NO_TEMPORARYFILE } unsetError(); close(); From c28763d83c493a11da90295ec4bde016c53c0d70 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Thu, 10 Oct 2013 11:56:02 +1000 Subject: [PATCH 09/72] update the network configuration list when changes in the networks happen. Task-number: QTBUG-34021 Change-Id: I2bd187e7d04d6876294f18d917c9a384afe5db35 Reviewed-by: Robin Burchell --- src/plugins/bearer/connman/qconnmanengine.cpp | 22 +++++++++++++++++++ src/plugins/bearer/connman/qconnmanengine.h | 1 + .../bearer/connman/qconnmanservice_linux.cpp | 16 ++++++++++++++ .../bearer/connman/qconnmanservice_linux_p.h | 5 +++++ 4 files changed, 44 insertions(+) diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index 6ea34b17f5..be50ba9935 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -65,6 +65,9 @@ QConnmanEngine::QConnmanEngine(QObject *parent) : QBearerEngineImpl(parent), connmanManager(new QConnmanManagerInterface(this)) { + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qRegisterMetaType("ConnmanMapList"); } QConnmanEngine::~QConnmanEngine() @@ -82,6 +85,9 @@ void QConnmanEngine::initialize() connect(connmanManager,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SLOT(propertyChangedContext(QString,QString,QDBusVariant))); + connect(connmanManager,SIGNAL(servicesChanged(ConnmanMapList, QList)), + this, SLOT(updateServices(ConnmanMapList, QList))); + foreach (const QString &techPath, connmanManager->getTechnologies()) { QConnmanTechnologyInterface *tech; tech = new QConnmanTechnologyInterface(techPath, this); @@ -172,6 +178,22 @@ void QConnmanEngine::requestUpdate() QTimer::singleShot(0, this, SLOT(doRequestUpdate())); } +void QConnmanEngine::updateServices(const ConnmanMapList &changed, const QList &removed) +{ + foreach (const QDBusObjectPath &objectPath, removed) { + removeConfiguration(QString::number(qHash(objectPath.path()))); + } + + foreach (const ConnmanMap &connmanMap, changed) { + const QString id = QString::number(qHash(connmanMap.objectPath.path())); + if (accessPointConfigurations.contains(id)) { + configurationChange(id); + } else { + addServiceConfiguration(connmanMap.objectPath.path()); + } + } +} + QString QConnmanEngine::serviceFromId(const QString &id) { QMutexLocker locker(&mutex); diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index 9b6a271011..c2a820997e 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -105,6 +105,7 @@ private Q_SLOTS: void servicePropertyChangedContext(const QString &,const QString &,const QDBusVariant &); void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); void technologyPropertyChangedContext(const QString &,const QString &, const QDBusVariant &); + void updateServices(const ConnmanMapList &changed, const QList &removed); private: QConnmanManagerInterface *connmanManager; diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index 380cf92a24..6d9ee265c6 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -127,8 +127,24 @@ void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal) QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection); } + static const QMetaMethod servicesChangedSignal = QMetaMethod::fromSignal(&QConnmanManagerInterface::servicesChanged); + if (signal == servicesChangedSignal) { + if (!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("ServicesChanged"), + this,SLOT(onServicesChanged(ConnmanMapList, QList)))) { + qWarning() << "servicesChanged not connected"; + } + } } +void QConnmanManagerInterface::onServicesChanged(const ConnmanMapList &changed, const QList &removed) +{ + emit servicesChanged(changed, removed); +} + + void QConnmanManagerInterface::disconnectNotify(const QMetaMethod &signal) { static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanManagerInterface::propertyChanged); diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h index a437c6609c..dd3f847cfd 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -155,11 +155,16 @@ Q_SIGNALS: void propertyChanged(const QString &, const QDBusVariant &value); void stateChanged(const QString &); void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void servicesChanged(const ConnmanMapList&, const QList &); protected: void connectNotify(const QMetaMethod &signal); void disconnectNotify(const QMetaMethod &signal); QVariant getProperty(const QString &); + +private slots: + void onServicesChanged(const ConnmanMapList&, const QList &); + }; class QConnmanProfileInterfacePrivate; From 1db89eb5a4cbe98d8380410de3acc527fc53f911 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 18 Oct 2013 05:29:25 +1000 Subject: [PATCH 10/72] fix connman QNetworkConfiguration Discovered Make Discovered depend on autoconnectable service This stops seemingly automatic use of a non autconnectable service, and allows the connection dialog to popup. Change-Id: Idea9a22eb4bbfb4fefeca7867526a2ddc3954376 Reviewed-by: Robin Burchell --- src/plugins/bearer/connman/qconnmanengine.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index be50ba9935..7633b4f2b8 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -416,21 +416,23 @@ QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QStri QMutexLocker locker(&mutex); QConnmanServiceInterface serv(service); QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; - if( serv.getType() == "cellular") { - if(serv.isSetupRequired()) { + if (serv.getType() == "cellular") { + if (serv.isSetupRequired() || !serv.isAutoConnect()) { flag = ( flag | QNetworkConfiguration::Defined); } else { flag = ( flag | QNetworkConfiguration::Discovered); } } else { - if(serv.isFavorite()) { - flag = ( flag | QNetworkConfiguration::Discovered); + if (serv.isFavorite()) { + if (serv.isAutoConnect()) { + flag = ( flag | QNetworkConfiguration::Discovered); + } } else { flag = QNetworkConfiguration::Undefined; } } - if(serv.getState() == "ready" || serv.getState() == "online") { + if (serv.getState() == "ready" || serv.getState() == "online") { flag = ( flag | QNetworkConfiguration::Active); } From fa7451043e3e41690c292905866e3ddfe029f705 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 20 Nov 2013 06:41:55 +1000 Subject: [PATCH 11/72] make 'AlwaysAsk' if found help determine whether the configuration is Discovered or not. Since bearer has no idea about user interaction, we just do this, and make the roaming/always ask scenario unavailable. Change-Id: Id509a4d3346cdbb9367ddb465364c3500fc62fdf Reviewed-by: Konstantin Ritt Reviewed-by: Robin Burchell --- src/plugins/bearer/connman/qconnmanengine.cpp | 8 +++++++- src/plugins/bearer/connman/qconnmanengine.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index 7633b4f2b8..eac0d2b813 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -417,7 +417,7 @@ QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QStri QConnmanServiceInterface serv(service); QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; if (serv.getType() == "cellular") { - if (serv.isSetupRequired() || !serv.isAutoConnect()) { + if (serv.isSetupRequired() || !serv.isAutoConnect() || (serv.isRoaming() && isAlwaysAskRoaming())) { flag = ( flag | QNetworkConfiguration::Defined); } else { flag = ( flag | QNetworkConfiguration::Discovered); @@ -593,6 +593,12 @@ bool QConnmanEngine::requiresPolling() const return false; } +bool QConnmanEngine::isAlwaysAskRoaming() +{ + QSettings confFile(QStringLiteral("nemomobile"), QStringLiteral("connectionagent")); + confFile.beginGroup(QStringLiteral("Connectionagent")); + return confFile.value(QStringLiteral("askForRoaming")).toBool(); +} QT_END_NAMESPACE #endif // QT_NO_DBUS diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index c2a820997e..49a1a91d29 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -129,6 +129,7 @@ private: QNetworkConfiguration::BearerType ofonoTechToBearerType(const QString &type); bool isRoamingAllowed(const QString &context); + bool isAlwaysAskRoaming(); protected: bool requiresPolling() const; }; From 79b07807832d5595823fc6625061d0d194b5ba23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Wed, 8 Jan 2014 22:40:04 +0000 Subject: [PATCH 12/72] Fix kms build with -qtnamespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6aa3f3bc3c098b96ec0eec369b85a938c552f364 Reviewed-by: Jørgen Lind Reviewed-by: Andrew Knight --- src/plugins/platforms/kms/qkmscursor.h | 5 +++-- src/plugins/platforms/kms/qkmsdevice.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/kms/qkmscursor.h b/src/plugins/platforms/kms/qkmscursor.h index 91ac10aae5..f972604c01 100644 --- a/src/plugins/platforms/kms/qkmscursor.h +++ b/src/plugins/platforms/kms/qkmscursor.h @@ -44,11 +44,12 @@ #include +struct gbm_device; +struct gbm_bo; + QT_BEGIN_NAMESPACE class QKmsScreen; -struct gbm_device; -struct gbm_bo; class QKmsCursor : public QPlatformCursor { diff --git a/src/plugins/platforms/kms/qkmsdevice.h b/src/plugins/platforms/kms/qkmsdevice.h index 906e00aa13..2f8e2da709 100644 --- a/src/plugins/platforms/kms/qkmsdevice.h +++ b/src/plugins/platforms/kms/qkmsdevice.h @@ -51,9 +51,10 @@ extern "C" { #include +struct gbm_device; + QT_BEGIN_NAMESPACE -struct gbm_device; class QKmsIntegration; class QKmsDevice : public QObject From 0caaf9966a8e4ea1e83de866020e61fd5ffaec1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 22:38:13 +0100 Subject: [PATCH 13/72] Cocoa: Add setContentBorderThickness(). Add setContentBorderThickness() to the Cocoa platform plugin. This functions requests that the platform plugin draws a gradient in the unified title and toolbar area and/or the status bar area. The background gradient is drawn before and under the Qt backing store content. It is expected that parts of the backing store will be filled with transparent pixels to allow the gradient to be visible. To facilitate this the backing store image is created with an alpha channel. Task-number: QTBUG-34411 Change-Id: Iadc5e64ee9b9b42e92fb84a615817fdffd7a8802 Reviewed-by: Gabriel de Dietrich --- .../platforms/cocoa/qcocoabackingstore.mm | 3 +- .../platforms/cocoa/qcocoanativeinterface.h | 3 ++ .../platforms/cocoa/qcocoanativeinterface.mm | 12 ++++++ src/plugins/platforms/cocoa/qcocoawindow.h | 6 +++ src/plugins/platforms/cocoa/qcocoawindow.mm | 41 +++++++++++++++++++ src/plugins/platforms/cocoa/qnsview.mm | 6 ++- 6 files changed, 69 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 665b3d4c13..30c15d823a 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -73,7 +73,8 @@ QPaintDevice *QCocoaBackingStore::paintDevice() } #endif - QImage::Format format = window()->format().hasAlpha() + QCocoaWindow *cocoaWindow = static_cast(window()->handle()); + QImage::Format format = (window()->format().hasAlpha() || cocoaWindow->m_drawContentBorderGradient) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; m_qImage = QImage(m_requestedSize * scaleFactor, format); m_qImage.setDevicePixelRatio(scaleFactor); diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index d30b281eb8..5c59c73847 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -132,6 +132,9 @@ private: // touch events, which then will be delivered until the widget // deregisters. static void registerTouchWindow(QWindow *window, bool enable); + + // Request a unified title and toolbar look for the window. + static void setContentBorderThickness(QWindow *window, int topThickness, int bottomThickness); }; #endif // QCOCOANATIVEINTERFACE_H diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 6facab1785..eb520b97c9 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -123,6 +123,8 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerTouchWindow); if (resource.toLower() == "setembeddedinforeignview") return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setEmbeddedInForeignView); + if (resource.toLower() == "setcontentborderthickness") + return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setContentBorderThickness); return 0; } @@ -273,4 +275,14 @@ void QCocoaNativeInterface::registerTouchWindow(QWindow *window, bool enable) cocoaWindow->registerTouch(enable); } +void QCocoaNativeInterface::setContentBorderThickness(QWindow *window, int topThickness, int bottomThickness) +{ + if (!window) + return; + + QCocoaWindow *cocoaWindow = static_cast(window->handle()); + if (cocoaWindow) + cocoaWindow->setContentBorderThickness(topThickness, bottomThickness); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index c7ec315f04..66c3241b3d 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -157,6 +157,8 @@ public: void setWindowCursor(NSCursor *cursor); void registerTouch(bool enable); + void setContentBorderThickness(int topThickness, int bottomThickness); + void applyContentBorderThickness(NSWindow *window); qreal devicePixelRatio() const; bool isWindowExposable(); @@ -214,6 +216,10 @@ public: // for QNSView static const int NoAlertRequest; NSInteger m_alertRequest; id monitor; + + bool m_drawContentBorderGradient; + int m_topContentBorderThickness; + int m_bottomContentBorderThickness; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index ad11a525ad..8e977236fa 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -220,6 +220,9 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_overrideBecomeKey(false) , m_alertRequest(NoAlertRequest) , monitor(nil) + , m_drawContentBorderGradient(false) + , m_topContentBorderThickness(0) + , m_bottomContentBorderThickness(0) { #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG qDebug() << "QCocoaWindow::QCocoaWindow" << this; @@ -502,6 +505,9 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags) } } + if (m_drawContentBorderGradient) + styleMask |= NSTexturedBackgroundWindowMask; + #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG qDebug("windowStyleMask of '%s': flags %X -> styleMask %lX", qPrintable(window()->title()), (int)flags, styleMask); #endif @@ -927,6 +933,9 @@ NSWindow * QCocoaWindow::createNSWindow() } m_windowModality = window()->modality(); + + applyContentBorderThickness(createdWindow); + return createdWindow; } @@ -1069,6 +1078,38 @@ void QCocoaWindow::registerTouch(bool enable) [m_contentView setAcceptsTouchEvents:NO]; } +void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness) +{ + m_topContentBorderThickness = topThickness; + m_bottomContentBorderThickness = bottomThickness; + bool enable = (topThickness > 0 || bottomThickness > 0); + m_drawContentBorderGradient = enable; + + applyContentBorderThickness(m_nsWindow); +} + +void QCocoaWindow::applyContentBorderThickness(NSWindow *window) +{ + if (!window) + return; + + if (m_drawContentBorderGradient) + [window setStyleMask:[window styleMask] | NSTexturedBackgroundWindowMask]; + else + [window setStyleMask:[window styleMask] & ~NSTexturedBackgroundWindowMask]; + + if (m_topContentBorderThickness > 0) { + [window setContentBorderThickness:m_topContentBorderThickness forEdge:NSMaxYEdge]; + [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; + } + + if (m_bottomContentBorderThickness > 0) { + [window setContentBorderThickness:m_topContentBorderThickness forEdge:NSMinYEdge]; + [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge]; + } +} + + qreal QCocoaWindow::devicePixelRatio() const { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index e183f93c6c..f7b129aea1 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -408,6 +408,9 @@ static QTouchDevice *touchDevice = 0; m_shouldSetGLContextinDrawRect = false; } + if (m_platformWindow->m_drawContentBorderGradient) + NSDrawWindowBackground(dirtyRect); + if (!m_backingStore) return; @@ -451,7 +454,8 @@ static QTouchDevice *touchDevice = 0; // Optimization: Copy frame buffer content instead of blending for // top-level windows where Qt fills the entire window content area. - if (m_platformWindow->m_nsWindow) + // (But don't overpaint the title-bar gradient) + if (m_platformWindow->m_nsWindow && !m_platformWindow->m_drawContentBorderGradient) CGContextSetBlendMode(cgContext, kCGBlendModeCopy); CGContextDrawImage(cgContext, dirtyWindowRect, cleanImg); From f2f2e4e53ee679b50878c042ecd64a0cf30c9569 Mon Sep 17 00:00:00 2001 From: Kurt Pattyn Date: Mon, 23 Dec 2013 21:13:30 +0100 Subject: [PATCH 14/72] Fix to comply with Qt coding guidelines Change-Id: Ie6c62d3107d17e64c94fa01380b3b1d80f24d0de Reviewed-by: Giuseppe D'Angelo --- src/tools/qdoc/config.cpp | 51 +++++++++++++++------------------------ 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/src/tools/qdoc/config.cpp b/src/tools/qdoc/config.cpp index 2d8e98d64c..56e7287c40 100644 --- a/src/tools/qdoc/config.cpp +++ b/src/tools/qdoc/config.cpp @@ -196,8 +196,7 @@ void MetaStack::process(QChar ch, const Location& location) if (ch == QLatin1Char('{')) { push(MetaStackEntry()); top().open(); - } - else if (ch == QLatin1Char('}')) { + } else if (ch == QLatin1Char('}')) { if (count() == 1) location.fatal(tr("Unexpected '}'")); @@ -215,12 +214,10 @@ void MetaStack::process(QChar ch, const Location& location) } ++pre; } - } - else if (ch == QLatin1Char(',') && count() > 1) { + } else if (ch == QLatin1Char(',') && count() > 1) { top().close(); top().open(); - } - else { + } else { /* This is where all the processing is done. */ @@ -296,12 +293,10 @@ Config::~Config() void Config::load(const QString& fileName) { load(Location::null, fileName); - if (loc.isEmpty()) { + if (loc.isEmpty()) loc = Location(fileName); - } - else { + else loc.setEtc(true); - } lastLocation_ = Location::null; } @@ -472,9 +467,8 @@ QStringList Config::getCanonicalPathList(const QString& var) const const ConfigVar& cv = configVars[i]; if (!cv.location_.isEmpty()) (Location&) lastLocation_ = cv.location_; - if (!cv.plus_) { + if (!cv.plus_) t.clear(); - } const QString d = cv.currentPath_; const QStringList& sl = cv.values_; if (!sl.isEmpty()) { @@ -786,9 +780,8 @@ QString Config::findFile(const Location& location, QStringList::ConstIterator d = dirs.constBegin(); while (d != dirs.constEnd()) { fileInfo.setFile(QDir(*d), firstComponent); - if (fileInfo.exists()) { + if (fileInfo.exists()) break; - } ++d; } } @@ -808,9 +801,9 @@ QString Config::findFile(const Location& location, QString extracted = extractedDirs[fileInfo.filePath()]; ++c; fileInfo.setFile(QDir(extracted), *c); - } - else + } else { break; + } userFriendlyFilePath += QLatin1Char('?'); } @@ -876,9 +869,8 @@ QString Config::copyFile(const Location& location, char buffer[1024]; int len; - while ((len = inFile.read(buffer, sizeof(buffer))) > 0) { + while ((len = inFile.read(buffer, sizeof(buffer))) > 0) outFile.write(buffer, len); - } return outFileName; } @@ -1002,17 +994,15 @@ void Config::load(Location location, const QString& fileName) QChar c = text.at(0); uint cc = c.unicode(); while (i < (int) text.length()) { - if (cc == 0) + if (cc == 0) { ++i; - else if (c.isSpace()) { + } else if (c.isSpace()) { SKIP_CHAR(); - } - else if (cc == '#') { + } else if (cc == '#') { do { SKIP_CHAR(); } while (cc != '\n'); - } - else if (isMetaKeyChar(c)) { + } else if (isMetaKeyChar(c)) { Location keyLoc = location; bool plus = false; QString stringValue; @@ -1184,15 +1174,13 @@ void Config::load(Location location, const QString& fileName) ++key; } } - } - else { + } else { location.fatal(tr("Unexpected character '%1' at beginning of line").arg(c)); } } popWorkingDir(); - if (!workingDirs_.isEmpty()) { + if (!workingDirs_.isEmpty()) QDir::setCurrent(workingDirs_.top()); - } } QStringList Config::getFilesHere(const QString& uncleanDir, @@ -1219,9 +1207,8 @@ QStringList Config::getFilesHere(const QString& uncleanDir, if (!fn->startsWith(QLatin1Char('~'))) { QString s = dirInfo.filePath(*fn); QString c = QDir::cleanPath(s); - if (!excludedFiles.contains(c)) { + if (!excludedFiles.contains(c)) result.append(c); - } } ++fn; } @@ -1251,9 +1238,9 @@ void Config::pushWorkingDir(const QString& dir) */ QString Config::popWorkingDir() { - if (!workingDirs_.isEmpty()) { + if (!workingDirs_.isEmpty()) return workingDirs_.pop(); - } + qDebug() << "RETURNED EMPTY WORKING DIR"; return QString(); } From 46de0c476589cdc5ba02cb4c439cb4f4b3ba401f Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 6 Jan 2014 14:37:06 +0100 Subject: [PATCH 15/72] QLocale - Check day number is valid Check day number falls in valid range before using as array index. Change-Id: I8d7c203b97988633fe4c345d5e7002bba9c2c68b Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale_win.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index 3a083582c9..c20827a4ae 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -279,6 +279,9 @@ QVariant QSystemLocalePrivate::dateTimeFormat(QLocale::FormatType type) QVariant QSystemLocalePrivate::dayName(int day, QLocale::FormatType type) { + if (day < 1 || day > 7) + return QString(); + static const LCTYPE short_day_map[] = { LOCALE_SABBREVDAYNAME1, LOCALE_SABBREVDAYNAME2, LOCALE_SABBREVDAYNAME3, LOCALE_SABBREVDAYNAME4, LOCALE_SABBREVDAYNAME5, From a41a5f6671616128eed650ad4742842b8e81a6ff Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 6 Jan 2014 19:20:58 +0100 Subject: [PATCH 16/72] QDateTime - Fix isValid() if invalid QTimeZone Explicitly check that the QTimeZone is valid before trying to use it. Change-Id: Iec415a2cb07071502fe71ee5ac92a7657e818f99 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 9 +++++++++ tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 42721c018f..1ab5665893 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2764,6 +2764,15 @@ void QDateTimePrivate::refreshDateTime() return; } +#ifndef QT_BOOTSTRAPPED + // If not valid time zone then is invalid + if (m_spec == Qt::TimeZone && !m_timeZone.isValid()) { + clearValidDateTime(); + m_offsetFromUtc = 0; + return; + } +#endif // QT_BOOTSTRAPPED + // We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating // LocalTime and TimeZone might fall into "missing" DaylightTime transition hour // Calling toEpochMSecs will adjust the returned date/time if it does diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 5d1fe0784f..866f68c99c 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2784,6 +2784,13 @@ void tst_QDateTime::daylightTransitions() const void tst_QDateTime::timeZones() const { + QTimeZone invalidTz = QTimeZone("Vulcan/ShiKahr"); + QCOMPARE(invalidTz.isValid(), false); + QDateTime invalidDateTime = QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0), invalidTz); + QCOMPARE(invalidDateTime.isValid(), false); + QCOMPARE(invalidDateTime.date(), QDate(2000, 1, 1)); + QCOMPARE(invalidDateTime.time(), QTime(0, 0, 0)); + QTimeZone nzTz = QTimeZone("Pacific/Auckland"); // During Standard Time NZ is +12:00 From 684ebc66481eb095bac1aea4db5ae5a41aabd604 Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 6 Jan 2014 20:03:37 +0100 Subject: [PATCH 17/72] QDate - Fix parsing Qt::ISODate Fix parsing of ISO Date from being totally lenient to being semi-strict by requiring the separator positions to be non-numeric. [ChangeLog][Important Behavior Changes] Parsing of Qt::ISODate by QDate::fromString() and QDateTime()::fromString() is not as lenient as before, the date component separators are now required to be non-numeric. This means a string like "2000901901" will no longer be recognized as a valid ISO Date, but "2000/01/01" will still be even though it doesn't strictly meet the ISO format of "2000-01-01". Task-number: QTBUG-34141 Change-Id: I0e481144136c60d4cac61364b9b2c1d2cd1e78fc Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 5 +++++ tests/auto/corelib/tools/qdate/tst_qdate.cpp | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 1ab5665893..5438f00c67 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1281,6 +1281,11 @@ QDate QDate::fromString(const QString& string, Qt::DateFormat format) } #endif // QT_NO_TEXTDATE case Qt::ISODate: { + // Semi-strict parsing, must be long enough and have non-numeric separators + if (string.size() < 10 || string.at(4).isDigit() || string.at(7).isDigit() + || (string.size() > 10 && string.at(10).isDigit())) { + return QDate(); + } const int year = string.mid(0, 4).toInt(); if (year <= 0 || year > 9999) return QDate(); diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp index b91de092e8..807dcf5cbe 100644 --- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp @@ -944,6 +944,13 @@ void tst_QDate::fromStringDateFormat_data() QTest::newRow("iso2") << QDate(1999, 11, 14).toString(Qt::ISODate) << Qt::ISODate << QDate(1999, 11, 14); QTest::newRow("iso3") << QString("0999-01-01") << Qt::ISODate << QDate(999, 1, 1); QTest::newRow("iso3b") << QString("0999-01-01") << Qt::ISODate << QDate(999, 1, 1); + QTest::newRow("iso4") << QString("2000101101") << Qt::ISODate << QDate(); + QTest::newRow("iso5") << QString("2000/01/01") << Qt::ISODate << QDate(2000, 1, 1); + QTest::newRow("iso6") << QString("2000-01-01 blah") << Qt::ISODate << QDate(2000, 1, 1); + QTest::newRow("iso7") << QString("2000-01-011blah") << Qt::ISODate << QDate(); + QTest::newRow("iso8") << QString("2000-01-01blah") << Qt::ISODate << QDate(2000, 1, 1); + QTest::newRow("iso9") << QString("-001-01-01") << Qt::ISODate << QDate(); + QTest::newRow("iso10") << QString("99999-01-01") << Qt::ISODate << QDate(); // Test Qt::RFC2822Date format (RFC 2822). QTest::newRow("RFC 2822") << QString::fromLatin1("13 Feb 1987 13:24:51 +0100") From cd5ae8fb21c2e44083f0b8ba85ef8d620803c934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 22:43:05 +0100 Subject: [PATCH 18/72] Enable window dragging code in QToolBar on Mac Allows moving the window by dragging the unified title and toolbar area. Task-number: QTBUG-34411 Change-Id: Idd85c0031895b5afd7dfdc8616e4452c47935af2 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qtoolbar.cpp | 6 +++--- src/widgets/widgets/qtoolbar_p.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 5f80bbb1ca..096f53de40 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -272,7 +272,7 @@ bool QToolBarPrivate::mousePressEvent(QMouseEvent *event) QStyleOptionToolBar opt; q->initStyleOption(&opt); if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false) { -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX // When using the unified toolbar on Mac OS X, the user can click and // drag between toolbar contents to move the window. Make this work by // implementing the standard mouse-dragging code and then call @@ -306,7 +306,7 @@ bool QToolBarPrivate::mouseReleaseEvent(QMouseEvent*) endDrag(); return true; } else { -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX if (!macWindowDragging) return false; macWindowDragging = false; @@ -322,7 +322,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) Q_Q(QToolBar); if (!state) { -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX if (!macWindowDragging) return false; QWidget *w = q->window(); diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h index 9ff0b9d61c..c9dd0490cd 100644 --- a/src/widgets/widgets/qtoolbar_p.h +++ b/src/widgets/widgets/qtoolbar_p.h @@ -75,7 +75,7 @@ public: allowedAreas(Qt::AllToolBarAreas), orientation(Qt::Horizontal), toolButtonStyle(Qt::ToolButtonIconOnly), layout(0), state(0) -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX , macWindowDragging(false) #endif { } @@ -107,7 +107,7 @@ public: }; DragState *state; -#ifdef Q_WS_MAC +#ifdef Q_OS_OSX bool macWindowDragging; QPoint macWindowDragPressPosition; #endif From 459ad9e018071cdf613d3deb70ea4d96178ca683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 22:49:41 +0100 Subject: [PATCH 19/72] Mac: Update PE_IndicatorToolBarHandle drawing. Smaller, rounder, darker toolbar handles. Works especially well in unified toolbar mode. Task-number: QTBUG-34411 Change-Id: I41eafdf0bb1dbbb4ed96d7bd799eb6f53bccbf7d Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 5db4801c37..93a72980c9 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -3008,23 +3008,19 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai if (opt->state & State_Horizontal) { while (y < opt->rect.height() - RectHeight - 5) { path.moveTo(x, y); - path.addRect(x, y, RectHeight, RectHeight); + path.addEllipse(x, y, RectHeight, RectHeight); y += 6; } } else { while (x < opt->rect.width() - RectHeight - 5) { path.moveTo(x, y); - path.addRect(x, y, RectHeight, RectHeight); + path.addEllipse(x, y, RectHeight, RectHeight); x += 6; } } p->setPen(Qt::NoPen); - QColor dark = opt->palette.dark().color(); - dark.setAlphaF(0.75); - QColor light = opt->palette.light().color(); - light.setAlphaF(0.6); - p->fillPath(path, light); - p->translate(1, 1); + QColor dark = opt->palette.dark().color().darker(); + dark.setAlphaF(0.50); p->fillPath(path, dark); p->restore(); From 055591750aaccab9e764eb7348968d9716dd4f47 Mon Sep 17 00:00:00 2001 From: Thorsten Zachmann Date: Wed, 1 Jan 2014 08:13:02 +0100 Subject: [PATCH 20/72] Fix Use android theme when defined It is possible to define the theme to use for android in the AndroidManifest.xml. If it is defined in the activity qt itself should not overwrite it. The change uses the defined style in case it is given in the AndroidManifest.xml. This seems to fix also QTBUG-35151. Task-number: QTBUG-35050 Change-Id: I8b55c02ca1ecd7baa5f2f9460d154095aacf015f Reviewed-by: BogDan Vatra --- .../qt5/android/bindings/QtActivity.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java index 6762717d91..b2f92c04e9 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java @@ -34,6 +34,7 @@ import java.io.FileOutputStream; import java.io.FileInputStream; import java.io.DataOutputStream; import java.io.DataInputStream; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -816,6 +817,21 @@ public class QtActivity extends Activity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + try { + m_activityInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); + for (Field f : Class.forName("android.R$style").getDeclaredFields()) { + if (f.getInt(null) == m_activityInfo.getThemeResource()) { + QT_ANDROID_THEMES = new String[] {f.getName()}; + QT_ANDROID_DEFAULT_THEME = f.getName(); + } + } + } catch (Exception e) { + e.printStackTrace(); + finish(); + return; + } + try { setTheme(Class.forName("android.R$style").getDeclaredField(QT_ANDROID_DEFAULT_THEME).getInt(null)); } catch (Exception e) { @@ -840,14 +856,6 @@ public class QtActivity extends Activity ENVIRONMENT_VARIABLES += "\tQT_ANDROID_THEME=" + QT_ANDROID_DEFAULT_THEME + "/\tQT_ANDROID_THEME_DISPLAY_DPI=" + getResources().getDisplayMetrics().densityDpi + "\t"; - try { - m_activityInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); - } catch (NameNotFoundException e) { - e.printStackTrace(); - finish(); - return; - } - if (null == getLastNonConfigurationInstance()) { // if splash screen is defined, then show it if (m_activityInfo.metaData.containsKey("android.app.splash_screen") ) From b3d642e71e1b1083e5f17872614da2cbf38e8fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:03:30 +0100 Subject: [PATCH 21/72] Mac: Update unified toolbar drawing code. Fill the toolbar background with transparent pixels to allow the view background to shine through. Draw a separator line using HITheme. Task-number: QTBUG-34411 Change-Id: I57732564a67a5a9d1eb7fd9038382b2b65be50a4 Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 40 ++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 93a72980c9..8c00f06a4f 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -679,6 +679,18 @@ bool qt_macWindowIsTextured(const QWidget *window) return false; } +static bool qt_macWindowMainWindow(const QWidget *window) +{ + if (QWindow *w = window->windowHandle()) { + if (w->handle()) { + if (NSWindow *nswindow = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("nswindow"), w))) { + return [nswindow isMainWindow]; + } + } + } + return false; +} + /***************************************************************************** QMacCGStyle globals *****************************************************************************/ @@ -4438,12 +4450,34 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } break; case CE_ToolBar: { - // For unified tool bars, draw nothing. - if (w) { + const QStyleOptionToolBar *toolBar = qstyleoption_cast(opt); + + // Unified title and toolbar drawing. In this mode the cocoa platform plugin will + // fill the top toolbar area part with a background gradient that "unifies" with + // the title bar. The following code fills the toolBar area with transparent pixels + // to make that gradient visible. + if (w) { if (QMainWindow * mainWindow = qobject_cast(w->window())) { - if (mainWindow->unifiedTitleAndToolBarOnMac()) + if (toolBar && toolBar->toolBarArea == Qt::TopToolBarArea && mainWindow->unifiedTitleAndToolBarOnMac()) { + + // fill with transparent pixels. + p->save(); + p->setCompositionMode(QPainter::CompositionMode_Source); + p->fillRect(opt->rect, Qt::transparent); + p->restore(); + + // drow horizontal sepearator line at toolBar bottom. + SInt32 margin; + GetThemeMetric(kThemeMetricSeparatorSize, &margin); + CGRect separatorRect = CGRectMake(opt->rect.left(), opt->rect.bottom(), opt->rect.width(), margin); + HIThemeSeparatorDrawInfo separatorDrawInfo; + separatorDrawInfo.version = 0; + separatorDrawInfo.state = qt_macWindowMainWindow(mainWindow) ? kThemeStateActive : kThemeStateInactive; + QMacCGContext cg(p); + HIThemeDrawSeparator(&separatorRect, &separatorDrawInfo, cg, kHIThemeOrientationNormal); break; } + } } // draw background gradient From 4a7f27ea536c2010edae05f39c1a9cb6c56205f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:06:35 +0100 Subject: [PATCH 22/72] Mac: remove unified toolbar workarounds. QMainWindow::unifiedTitleAndToolBarOnMac() will again return true, but the new implementation is much more similar to the cross platform one so these workarounds are not needed. Task-number: QTBUG-34411 Change-Id: Ic95f491af94354776385dc984f1a00c64429a3f0 Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 8c00f06a4f..d13339b555 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2437,11 +2437,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW break; case PM_ToolBarFrameWidth: ret = 1; - if (widget) { - if (QMainWindow * mainWindow = qobject_cast(widget->parent())) - if (mainWindow->unifiedTitleAndToolBarOnMac()) - ret = 0; - } break; case PM_ScrollView_ScrollBarOverlap: #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 @@ -3445,14 +3440,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) { needText = true; if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { - QMainWindow *mw = w ? qobject_cast(w->window()) : 0; - if (mw && mw->unifiedTitleAndToolBarOnMac()) { - pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio()); - cr.adjust(0, pr.bottom() + 1, 0, 1); - } else { - pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio() + 6); - cr.adjust(0, pr.bottom(), 0, -3); - } + pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio() + 6); + cr.adjust(0, pr.bottom(), 0, -3); alignment |= Qt::AlignCenter; } else { pr.setWidth(pixmap.width() / pixmap.devicePixelRatio() + 8); @@ -6271,18 +6260,6 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } break; case CT_ToolButton: - if (widget && qobject_cast(widget->parentWidget())) { - if (QMainWindow * mainWindow = qobject_cast(widget->parent())) { - if (mainWindow->unifiedTitleAndToolBarOnMac()) { - sz.rwidth() += 4; - if (sz.height() <= 32) { - // Workaround strange HIToolBar bug when getting constraints. - sz.rheight() += 1; - } - return sz; - } - } - } sz.rwidth() += 10; sz.rheight() += 10; return sz; From 50b36f218118d262d552fc45a7efc9c3ab77cb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Sun, 12 Jan 2014 02:21:22 +0000 Subject: [PATCH 23/72] QNX: Fix compiler warning about unused variable. Change-Id: I16e4aa32647793bf36fee60ed94db69a6ae2d8ea Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemwatcher.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 44bbe55719..d1deae2d7b 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -77,6 +77,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) return QKqueueFileSystemWatcherEngine::create(parent); #else + Q_UNUSED(parent); return 0; #endif } From ba507f66906b4e4b57977fe3661d21912d0aec45 Mon Sep 17 00:00:00 2001 From: Kurt Pattyn Date: Sun, 12 Jan 2014 18:59:44 +0100 Subject: [PATCH 24/72] Fix typos in comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comments contained some typos. Comments have been replaced with the ‘official’ description from http://msdn.microsoft.com/en-us/library/8x5x43k7.aspx. Change-Id: I25dda0911735b4a0d4f306bc95bc984be0080e2f Reviewed-by: Olivier Goffart --- src/corelib/global/qglobal.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 9db48354b3..d8c987d2e0 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -819,18 +819,18 @@ Q_CORE_EXPORT void qFreeAligned(void *ptr); #endif #if defined(QT_NO_WARNINGS) # if defined(Q_CC_MSVC) -# pragma warning(disable: 4251) /* class 'A' needs to have dll interface for to be used by clients of class 'B'. */ -# pragma warning(disable: 4244) /* 'conversion' conversion from 'type1' to 'type2', possible loss of data */ +# pragma warning(disable: 4251) /* class 'type' needs to have dll-interface to be used by clients of class 'type2' */ +# pragma warning(disable: 4244) /* conversion from 'type1' to 'type2', possible loss of data */ # pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */ -# pragma warning(disable: 4514) /* unreferenced inline/local function has been removed */ +# pragma warning(disable: 4514) /* unreferenced inline function has been removed */ # pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */ # pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */ # pragma warning(disable: 4706) /* assignment within conditional expression */ -# pragma warning(disable: 4786) /* truncating debug info after 255 characters */ +# pragma warning(disable: 4786) /* 'identifier' : identifier was truncated to 'number' characters in the debug information */ # pragma warning(disable: 4355) /* 'this' : used in base member initializer list */ -# pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */ +# pragma warning(disable: 4231) /* nonstandard extension used : 'identifier' before template explicit instantiation */ # pragma warning(disable: 4710) /* function not inlined */ -# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */ +# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */ # elif defined(Q_CC_BOR) # pragma option -w-inl # pragma option -w-aus From e1330ecfdccf75c3c3f93734e7950199918e6ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:36:14 +0100 Subject: [PATCH 25/72] Mac: Remove old unified toolbar implementation. This has been dead code in Qt 5 since WS_MAC isn't defined any more. The new implementation is far less intrusive and does not require a separate layout. Task-number: QTBUG-34411 Change-Id: I91bf2294086cb7334a0f56eb1bb97464d8d7b2e3 Reviewed-by: Gabriel de Dietrich --- src/widgets/kernel/qwidget.cpp | 95 +----- src/widgets/kernel/qwidget_p.h | 3 +- .../widgets/qcocoatoolbardelegate_mac.mm | 151 --------- .../widgets/qcocoatoolbardelegate_mac_p.h | 69 ----- src/widgets/widgets/qmainwindowlayout_mac.mm | 292 ------------------ src/widgets/widgets/qtoolbar.cpp | 68 +--- src/widgets/widgets/qtoolbarlayout.cpp | 23 -- src/widgets/widgets/widgets.pri | 9 - 8 files changed, 5 insertions(+), 705 deletions(-) delete mode 100644 src/widgets/widgets/qcocoatoolbardelegate_mac.mm delete mode 100644 src/widgets/widgets/qcocoatoolbardelegate_mac_p.h delete mode 100644 src/widgets/widgets/qmainwindowlayout_mac.mm diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 08e8975f9d..df523e7e21 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5026,16 +5026,6 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP if (rgn.isEmpty()) return; -#ifdef Q_WS_MAC - if (qt_mac_clearDirtyOnWidgetInsideDrawWidget) - dirtyOnWidget = QRegion(); - - // We disable the rendering of QToolBar in the backingStore if - // it's supposed to be in the unified toolbar on Mac OS X. - if (backingStore && isInUnifiedToolbar) - return; -#endif // Q_WS_MAC - const bool asRoot = flags & DrawAsRoot; bool onScreen = paintOnScreen(); @@ -9403,26 +9393,13 @@ QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDe if (children.isEmpty()) return 0; -#ifdef Q_WS_MAC - Q_Q(const QWidget); - // Unified tool bars on the Mac require special handling since they live outside - // QMainWindow's geometry(). See commit: 35667fd45ada49269a5987c235fdedfc43e92bb8 - bool includeFrame = q->isWindow() && qobject_cast(q) - && static_cast(q)->unifiedTitleAndToolBarOnMac(); - if (includeFrame) - return childAtRecursiveHelper(p, ignoreChildrenInDestructor, includeFrame); -#endif - if (!pointInsideRectAndMask(p)) return 0; return childAtRecursiveHelper(p, ignoreChildrenInDestructor); } -QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor, bool includeFrame) const +QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor) const { -#ifndef Q_WS_MAC - Q_UNUSED(includeFrame); -#endif for (int i = children.size() - 1; i >= 0; --i) { QWidget *child = qobject_cast(children.at(i)); if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents) @@ -9432,14 +9409,6 @@ QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChil // Map the point 'p' from parent coordinates to child coordinates. QPoint childPoint = p; -#ifdef Q_WS_MAC - // 'includeFrame' is true if the child's parent is a top-level QMainWindow with an unified tool bar. - // An unified tool bar on the Mac lives outside QMainWindow's geometry(), so a normal - // QWidget::mapFromParent won't do the trick. - if (includeFrame && qobject_cast(child)) - childPoint = qt_mac_nativeMapFromParent(child, p); - else -#endif childPoint -= child->data->crect.topLeft(); // Check if the point hits the child. @@ -9614,13 +9583,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; if (newParent && parent && !desktopWidget) { - if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) -#ifdef Q_WS_MAC - // On Mac, toolbars inside the unified title bar will never overlap with - // siblings in the content view. So we skip enforce native siblings in that case - && !d->isInUnifiedToolbar && parentWidget() && parentWidget()->isWindow() -#endif // Q_WS_MAC - ) + if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) parent->d_func()->enforceNativeChildren(); else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen)) setAttribute(Qt::WA_NativeWindow); @@ -9879,12 +9842,6 @@ void QWidget::repaint(const QRect &rect) return; if (hasBackingStoreSupport()) { -#ifdef Q_WS_MAC - if (qt_widget_private(this)->isInUnifiedToolbar) { - qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); - return; - } -#endif // Q_WS_MAC QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { tlwExtra->inRepaint = true; @@ -9914,12 +9871,6 @@ void QWidget::repaint(const QRegion &rgn) return; if (hasBackingStoreSupport()) { -#ifdef Q_WS_MAC - if (qt_widget_private(this)->isInUnifiedToolbar) { - qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); - return; - } -#endif // Q_WS_MAC QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { tlwExtra->inRepaint = true; @@ -9982,12 +9933,6 @@ void QWidget::update(const QRect &rect) } if (hasBackingStoreSupport()) { -#ifdef Q_WS_MAC - if (qt_widget_private(this)->isInUnifiedToolbar) { - qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); - return; - } -#endif // Q_WS_MAC QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) tlwExtra->backingStoreTracker->markDirty(r, this); @@ -10017,12 +9962,6 @@ void QWidget::update(const QRegion &rgn) } if (hasBackingStoreSupport()) { -#ifdef Q_WS_MAC - if (qt_widget_private(this)->isInUnifiedToolbar) { - qt_widget_private(this)->unifiedSurface->renderToolbar(this, true); - return; - } -#endif // Q_WS_MAC QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) tlwExtra->backingStoreTracker->markDirty(r, this); @@ -10218,13 +10157,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) qApp->inputMethod()->commit(); qApp->inputMethod()->update(Qt::ImEnabled); } - if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget() -#ifdef Q_WS_MAC - // On Mac, toolbars inside the unified title bar will never overlap with - // siblings in the content view. So we skip enforce native siblings in that case - && !d->isInUnifiedToolbar && parentWidget()->isWindow() -#endif // Q_WS_MAC - ) + if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()) parentWidget()->d_func()->enforceNativeChildren(); if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) d->createWinId(); @@ -11544,28 +11477,6 @@ void QWidget::clearMask() setMask(QRegion()); } -#ifdef Q_WS_MAC -void QWidgetPrivate::syncUnifiedMode() { - // The whole purpose of this method is to keep the unifiedToolbar in sync. - // That means making sure we either exchange the drawing methods or we let - // the toolbar know that it does not require to draw the baseline. - Q_Q(QWidget); - // This function makes sense only if this is a top level - if(!q->isWindow()) - return; - OSWindowRef window = qt_mac_window_for(q); - if(changeMethods) { - // Ok, we are in documentMode. - if(originalDrawMethod) - qt_mac_replaceDrawRect(window, this); - } else { - if(!originalDrawMethod) - qt_mac_replaceDrawRectOriginal(window, this); - } -} - -#endif // Q_WS_MAC - QT_END_NAMESPACE #include "moc_qwidget.cpp" diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index df40908c00..943b7057b5 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -495,7 +495,7 @@ public: void setConstraints_sys(); bool pointInsideRectAndMask(const QPoint &) const; QWidget *childAt_helper(const QPoint &, bool) const; - QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const; + QWidget *childAtRecursiveHelper(const QPoint &p, bool) const; void updateGeometry_helper(bool forceUpdate); void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const; @@ -780,7 +780,6 @@ public: void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef); void syncCocoaMask(); void finishCocoaMaskSetup(); - void syncUnifiedMode(); // Did we add the drawRectOriginal method? bool drawRectOriginalAdded; // Is the original drawRect method available? diff --git a/src/widgets/widgets/qcocoatoolbardelegate_mac.mm b/src/widgets/widgets/qcocoatoolbardelegate_mac.mm deleted file mode 100644 index 2ea66b0d40..0000000000 --- a/src/widgets/widgets/qcocoatoolbardelegate_mac.mm +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#import -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -extern QWidgetPrivate *qt_widget_private(QWidget *widget); -QT_END_NAMESPACE - -QT_FORWARD_DECLARE_CLASS(QMainWindowLayout); -QT_FORWARD_DECLARE_CLASS(QToolBar); -QT_FORWARD_DECLARE_CLASS(QCFString); - -@implementation QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) - -- (id)initWithMainWindowLayout:(QMainWindowLayout *)layout -{ - self = [super init]; - if (self) { - mainWindowLayout = layout; - } - return self; -} - -- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar -{ - Q_UNUSED(toolbar); - return [NSArray arrayWithObject:@"org.qt-project.qt.nstoolbar-qtoolbar"]; -} - -- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar -{ - return [self toolbarAllowedItemIdentifiers:toolbar]; -} - -- (void)toolbarDidRemoveItem:(NSNotification *)notification -{ - NSToolbarItem *item = [[notification userInfo] valueForKey:@"item"]; - mainWindowLayout->unifiedToolbarHash.remove(item); - for (int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) { - if (mainWindowLayout->toolbarItemsCopy.at(i) == item) { - // I know about it, so release it. - mainWindowLayout->toolbarItemsCopy.removeAt(i); - mainWindowLayout->qtoolbarsInUnifiedToolbarList.removeAt(i); - [item release]; - break; - } - } -} - -- (NSToolbarItem *)toolbar:(NSToolbar *)nstoolbar itemForItemIdentifier:(NSString *)itemIdentifier - willBeInsertedIntoToolbar:(BOOL)flag -{ - Q_UNUSED(flag); - Q_UNUSED(nstoolbar); - QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value( - QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(itemIdentifier)); - NSToolbarItem *item = nil; - if (tb) { - item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; - mainWindowLayout->unifiedToolbarHash.insert(item, tb); - } - return item; -} - -- (void)toolbarWillAddItem:(NSNotification *)notification -{ - NSToolbarItem *item = [[notification userInfo] valueForKey:@"item"]; - QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value( - QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)([item itemIdentifier])); - if (!tb) - return; // I can't really do anything about this. - [item retain]; - [item setView:QT_PREPEND_NAMESPACE(qt_mac_nativeview_for)(tb)]; - - NSArray *items = [[qt_mac_window_for(mainWindowLayout->layoutState.mainWindow->window()) toolbar] items]; - int someIndex = 0; - for (NSToolbarItem *i in items) { - if (i == item) - break; - ++someIndex; - } - mainWindowLayout->toolbarItemsCopy.insert(someIndex, item); - - // This is synchronization code that was needed in Carbon, but may not be needed anymore here. - QToolBar *toolbar = mainWindowLayout->unifiedToolbarHash.value(item); - if (toolbar) { - int toolbarIndex = mainWindowLayout->qtoolbarsInUnifiedToolbarList.indexOf(toolbar); - if (someIndex != toolbarIndex) { - // Dang, we must be out of sync, rebuild it from the "toolbarItemsCopy" - mainWindowLayout->qtoolbarsInUnifiedToolbarList.clear(); - for (int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) { - // This will either append the correct toolbar or an - // null toolbar. This is fine because this list - // is really only kept to make sure that things are but in the right order. - mainWindowLayout->qtoolbarsInUnifiedToolbarList.append( - mainWindowLayout->unifiedToolbarHash.value(mainWindowLayout-> - toolbarItemsCopy.at(i))); - } - } - toolbar->update(); - } -} - -@end diff --git a/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h b/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h deleted file mode 100644 index f74f608660..0000000000 --- a/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qmacdefines_mac.h" -#import - -QT_BEGIN_NAMESPACE -class QMainWindowLayout; -class QToolBar; -QT_END_NAMESPACE - -@class NSToolbarItem; - -@interface QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) : NSObject { - QT_PREPEND_NAMESPACE(QMainWindowLayout) *mainWindowLayout; - NSToolbarItem *toolbarItem; -} - -- (id)initWithMainWindowLayout:(QT_PREPEND_NAMESPACE(QMainWindowLayout) *)layout; -@end diff --git a/src/widgets/widgets/qmainwindowlayout_mac.mm b/src/widgets/widgets/qmainwindowlayout_mac.mm deleted file mode 100644 index 38605c2e09..0000000000 --- a/src/widgets/widgets/qmainwindowlayout_mac.mm +++ /dev/null @@ -1,292 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -#include -#import - -QT_BEGIN_NAMESPACE -#ifdef QT_NAMESPACE - -// namespace up the stuff -#define SS(x) #x -#define S0(x) SS(x) -#define S "org.qt-project.qt-" S0(QT_NAMESPACE) ".qmainwindow.qtoolbarInHIToolbar" -#define SToolbar "org.qt-project.qt-" S0(QT_NAMESPACE) ".hitoolbar-qtoolbar" -#define SNSToolbar "org.qt-project.qt-" S0(QT_NAMESPACE) ".qtoolbarInNSToolbar" -#define MacToolbar "org.qt-project.qt-" S0(QT_NAMESPACE) ".qmainwindow.mactoolbar" - -static NSString *kQToolBarNSToolbarIdentifier = @SNSToolbar; -static CFStringRef kQMainWindowMacToolbarID = CFSTR(MacToolbar); -#undef SS -#undef S0 -#undef S -#undef SToolbar -#undef SNSToolbar -#undef MacToolbar - -#else -static NSString *kQToolBarNSToolbarIdentifier = @"org.qt-project.qt.qmainwindow.qtoolbarInNSToolbar"; -static CFStringRef kQMainWindowMacToolbarID = CFSTR("org.qt-project.qt.qmainwindow.mactoolbar"); -#endif // QT_NAMESPACE - - -#ifndef kWindowUnifiedTitleAndToolbarAttribute -#define kWindowUnifiedTitleAndToolbarAttribute (1 << 7) -#endif - -void QMainWindowLayout::updateHIToolBarStatus() -{ - bool useMacToolbar = layoutState.mainWindow->unifiedTitleAndToolBarOnMac(); - - layoutState.mainWindow->setUpdatesEnabled(false); // reduces a little bit of flicker, not all though - QMacCocoaAutoReleasePool pool; - NSView *cView = [qt_mac_window_for(layoutState.mainWindow) contentView]; - if (useMacToolbar) { - [cView setPostsFrameChangedNotifications:YES]; - [[NSNotificationCenter defaultCenter] addObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] - selector: @selector(syncContentViewFrame:) - name: NSViewFrameDidChangeNotification - object: cView]; - } - if (!useMacToolbar) { - macWindowToolbarShow(layoutState.mainWindow, false); - // Move everything out of the HIToolbar into the main toolbar. - while (!qtoolbarsInUnifiedToolbarList.isEmpty()) { - // Should shrink the list by one every time. - QToolBar *toolbar = qtoolbarsInUnifiedToolbarList.first(); - unifiedSurface->removeToolbar(toolbar); - layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, toolbar); - } - macWindowToolbarSet(qt_mac_window_for(layoutState.mainWindow), 0); - } else { - QList toolbars = layoutState.mainWindow->findChildren(); - for (int i = 0; i < toolbars.size(); ++i) { - QToolBar *toolbar = toolbars.at(i); - if (toolBarArea(toolbar) == Qt::TopToolBarArea) { - // Do this here, because we are in an in-between state. - removeWidget(toolbar); - layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, toolbar); - } - } - syncUnifiedToolbarVisibility(); - } - if (!useMacToolbar) { - [cView setPostsFrameChangedNotifications:NO]; - [[NSNotificationCenter defaultCenter] removeObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] - name: NSViewFrameDidChangeNotification - object: cView]; - } - layoutState.mainWindow->setUpdatesEnabled(true); -} - -void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar) -{ - // This layering could go on to one more level, but I decided to stop here. - // The HIToolbar and NSToolbar APIs are fairly similar as you will see. - if (toolbar == 0) - return; - - // toolbar will now become native (if not already) since we need - // an nsview for it inside the corresponding NSToolbarItem. - // Setting isInUnifiedToolbar will (among other things) stop alien - // siblings from becoming native when this happends since the toolbar - // will not overlap with other children of the QMainWindow. NB: Switching - // unified toolbar off after this stage is not supported, as this means - // that either the menubar must be alien again, or the sibling must - // be backed by an nsview to protect from overlapping issues: - toolbar->d_func()->isInUnifiedToolbar = true; - - QToolBarLayout *toolbarLayout = static_cast(toolbar->layout()); - toolbarSaveState.insert(toolbar, ToolBarSaveState(toolbar->isMovable(), toolbar->maximumSize())); - - if (toolbarLayout->hasExpandFlag() == false) - toolbar->setMaximumSize(toolbar->sizeHint()); - - toolbar->setMovable(false); - toolbarLayout->setUsePopupMenu(true); - // Make the toolbar a child of the mainwindow to avoid creating a window. - toolbar->setParent(layoutState.mainWindow); - - toolbar->winId(); // Now create the OSViewRef. - layoutState.mainWindow->createWinId(); - - OSWindowRef window = qt_mac_window_for(layoutState.mainWindow); - int beforeIndex = qtoolbarsInUnifiedToolbarList.indexOf(before); - if (beforeIndex == -1) - beforeIndex = qtoolbarsInUnifiedToolbarList.size(); - - int toolbarIndex = qtoolbarsInUnifiedToolbarList.indexOf(toolbar); - - QMacCocoaAutoReleasePool pool; - NSToolbar *macToolbar = [window toolbar]; - if (macToolbar == nil) { - macToolbar = [[NSToolbar alloc] initWithIdentifier:(NSString *)kQMainWindowMacToolbarID]; - [macToolbar setDisplayMode:NSToolbarDisplayModeIconOnly]; - [macToolbar setSizeMode:NSToolbarSizeModeRegular]; - [macToolbar setDelegate:[[QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) alloc] initWithMainWindowLayout:this]]; - [window setToolbar:macToolbar]; - [macToolbar release]; - } - if (toolbarIndex != -1) { - qtoolbarsInUnifiedToolbarList.removeAt(toolbarIndex); - [macToolbar removeItemAtIndex:toolbarIndex]; - } - qtoolbarsInUnifiedToolbarList.insert(beforeIndex, toolbar); - - // Adding to the unified toolbar surface for the raster engine. - if (layoutState.mainWindow->windowSurface()) { - QPoint offset(0, 0); - for (int i = 0; i < beforeIndex; ++i) { - offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i)->size().width()); - } - unifiedSurface->insertToolbar(toolbar, offset); - } - - NSString *toolbarID = kQToolBarNSToolbarIdentifier; - toolbarID = [toolbarID stringByAppendingFormat:@"%p", toolbar]; - cocoaItemIDToToolbarHash.insert(qt_mac_NSStringToQString(toolbarID), toolbar); - [macToolbar insertItemWithItemIdentifier:toolbarID atIndex:beforeIndex]; -} - -void QMainWindowLayout::updateUnifiedToolbarOffset() -{ - QPoint offset(0, 0); - - for (int i = 1; i < qtoolbarsInUnifiedToolbarList.length(); ++i) { - offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i - 1)->size().width()); - qtoolbarsInUnifiedToolbarList.at(i)->d_func()->toolbar_offset = offset; - } -} - - -void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar) -{ - QHash::iterator it = unifiedToolbarHash.begin(); - while (it != unifiedToolbarHash.end()) { - if (it.value() == toolbar) { - // Rescue our HIView and set it on the mainWindow again. - bool saveVisible = !toolbar->isHidden(); - toolbar->setParent(0); - toolbar->setParent(parentWidget()); - toolbar->setVisible(saveVisible); - ToolBarSaveState saveState = toolbarSaveState.value(toolbar); - static_cast(toolbar->layout())->setUsePopupMenu(false); - toolbar->setMovable(saveState.movable); - toolbar->setMaximumSize(saveState.maximumSize); - toolbarSaveState.remove(toolbar); - NSToolbarItem *item = static_cast(it.key()); - [[qt_mac_window_for(layoutState.mainWindow->window()) toolbar] - removeItemAtIndex:toolbarItemsCopy.indexOf(item)]; - unifiedToolbarHash.remove(item); - qtoolbarsInUnifiedToolbarList.removeAll(toolbar); - break; - } - ++it; - } -} - -void QMainWindowLayout::cleanUpMacToolbarItems() -{ - QMacCocoaAutoReleasePool pool; - for (int i = 0; i < toolbarItemsCopy.size(); ++i) { - NSToolbarItem *item = static_cast(toolbarItemsCopy.at(i)); - [item setView:0]; - CFRelease(toolbarItemsCopy.at(i)); - } - toolbarItemsCopy.clear(); - unifiedToolbarHash.clear(); - - OSWindowRef window = qt_mac_window_for(layoutState.mainWindow); - NSToolbar *macToolbar = [window toolbar]; - if (macToolbar) { - [[macToolbar delegate] release]; - [macToolbar setDelegate:nil]; - } -} - -void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const -{ - QHash::const_iterator it = unifiedToolbarHash.constBegin(); - NSToolbarItem *item = nil; - while (it != unifiedToolbarHash.constEnd()) { - if (tb == it.value()) { - item = static_cast(it.key()); - break; - } - ++it; - } - if (item) { - QMacCocoaAutoReleasePool pool; - QWidgetItem layoutItem(tb); - QSize size = layoutItem.maximumSize(); - NSSize nssize = NSMakeSize(size.width(), size.height()); - [item setMaxSize:nssize]; - size = layoutItem.minimumSize(); - nssize.width = size.width(); - nssize.height = size.height(); - [item setMinSize:nssize]; - } -} - -void QMainWindowLayout::syncUnifiedToolbarVisibility() -{ - if (blockVisiblityCheck) - return; - - Q_ASSERT(layoutState.mainWindow->unifiedTitleAndToolBarOnMac()); - bool show = false; - const int ToolBarCount = qtoolbarsInUnifiedToolbarList.count(); - for (int i = 0; i < ToolBarCount; ++i) { - if (qtoolbarsInUnifiedToolbarList.at(i)->isVisible()) { - show = true; - break; - } - } - macWindowToolbarShow(layoutState.mainWindow, show); -} - -QT_END_NAMESPACE diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 096f53de40..5e7eb943ab 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -57,11 +57,6 @@ #include #include #include -#ifdef Q_WS_MAC -#include -#include -#endif - #include #include "qtoolbar_p.h" @@ -74,14 +69,6 @@ QT_BEGIN_NAMESPACE -#ifdef Q_WS_MAC -static void qt_mac_updateToolBarButtonHint(QWidget *parentWidget) -{ - if (!(parentWidget->windowFlags() & Qt::CustomizeWindowHint)) - parentWidget->setWindowFlags(parentWidget->windowFlags() | Qt::MacWindowToolBarButtonHint); -} -#endif - // qmainwindow.cpp extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); @@ -104,17 +91,6 @@ void QToolBarPrivate::init() layout = new QToolBarLayout(q); layout->updateMarginAndSpacing(); -#ifdef Q_WS_MAC - if (q->parentWidget() && q->parentWidget()->isWindow()) { - // Make sure that the window has the "toolbar" button. - QWidget *parentWidget = q->parentWidget(); - qt_mac_updateToolBarButtonHint(parentWidget); - reinterpret_cast(parentWidget)->d_func()->createWinId(); // Please let me create your winId... - extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp - macWindowToolbarShow(q->parentWidget(), true); - } -#endif - toggleViewAction = new QAction(q); toggleViewAction->setCheckable(true); q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q )); @@ -158,12 +134,8 @@ void QToolBarPrivate::updateWindowFlags(bool floating, bool unplug) flags |= Qt::FramelessWindowHint; - if (unplug) { + if (unplug) flags |= Qt::X11BypassWindowManagerHint; -#ifdef Q_WS_MAC - flags |= Qt::WindowStaysOnTopHint; -#endif - } q->setWindowFlags(flags); } @@ -569,16 +541,6 @@ QToolBar::QToolBar(const QString &title, QWidget *parent) */ QToolBar::~QToolBar() { - // Remove the toolbar button if there is nothing left. - QMainWindow *mainwindow = qobject_cast(parentWidget()); - if (mainwindow) { -#ifdef Q_WS_MAC - QMainWindowLayout *mainwin_layout = qt_mainwindow_layout(mainwindow); - if (mainwin_layout && mainwin_layout->layoutState.toolBarAreaLayout.isEmpty() - && mainwindow->testAttribute(Qt::WA_WState_Created)) - macWindowToolbarShow(mainwindow, false); -#endif - } } /*! \property QToolBar::movable @@ -665,12 +627,6 @@ void QToolBar::setAllowedAreas(Qt::ToolBarAreas areas) Qt::ToolBarAreas QToolBar::allowedAreas() const { Q_D(const QToolBar); -#ifdef Q_WS_MAC - if (QMainWindow *window = qobject_cast(parentWidget())) { - if (window->unifiedTitleAndToolBarOnMac()) // Don't allow drags to the top (for now). - return (d->allowedAreas & ~Qt::TopToolBarArea); - } -#endif return d->allowedAreas; } @@ -1083,15 +1039,6 @@ static bool waitForPopup(QToolBar *tb, QWidget *popup) return false; } -#if defined(Q_WS_MAC) -static bool toolbarInUnifiedToolBar(QToolBar *toolbar) -{ - const QMainWindow *mainWindow = qobject_cast(toolbar->parentWidget()); - return mainWindow && mainWindow->unifiedTitleAndToolBarOnMac() - && mainWindow->toolBarArea(toolbar) == Qt::TopToolBarArea; -} -#endif - /*! \reimp */ bool QToolBar::event(QEvent *event) { @@ -1115,22 +1062,9 @@ bool QToolBar::event(QEvent *event) case QEvent::Show: d->toggleViewAction->setChecked(event->type() == QEvent::Show); emit visibilityChanged(event->type() == QEvent::Show); -#if defined(Q_WS_MAC) - if (toolbarInUnifiedToolBar(this)) { - // I can static_cast because I did the qobject_cast in the if above, therefore - // we must have a QMainWindowLayout here. - QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast(parentWidget())); - mwLayout->fixSizeInUnifiedToolbar(this); - mwLayout->syncUnifiedToolbarVisibility(); - } -#endif // Q_WS_MAC break; case QEvent::ParentChange: d->layout->checkUsePopupMenu(); -#if defined(Q_WS_MAC) - if (parentWidget() && parentWidget()->isWindow()) - qt_mac_updateToolBarButtonHint(parentWidget()); -#endif break; case QEvent::MouseButtonPress: { diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index 3c0c84ee2f..fe919feba9 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -332,20 +332,6 @@ void QToolBarLayout::updateGeomArray() const rpick(o, that->hint) += handleExtent; that->hint += QSize(2*margin, 2*margin); - that->dirty = false; -#ifdef Q_WS_MAC - if (QMainWindow *mw = qobject_cast(parentWidget()->parentWidget())) { - if (mw->unifiedTitleAndToolBarOnMac() - && mw->toolBarArea(static_cast(parentWidget())) == Qt::TopToolBarArea) { - if (expandFlag) { - tb->setMaximumSize(0xFFFFFF, 0xFFFFFF); - } else { - tb->setMaximumSize(hint); - } - } - } -#endif - that->dirty = false; } @@ -401,15 +387,6 @@ void QToolBarLayout::setGeometry(const QRect &rect) if (!extension->isHidden()) extension->hide(); } -#ifdef Q_WS_MAC - if (QMainWindow *win = qobject_cast(tb->parentWidget())) { - Qt::ToolBarArea area = win->toolBarArea(tb); - if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) { - qt_mainwindow_layout(win)->fixSizeInUnifiedToolbar(tb); - } - } -#endif - } bool QToolBarLayout::layoutActions(const QSize &size) diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index efe1dd3616..1bae87ebcc 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -155,15 +155,6 @@ macx { widgets/qmaccocoaviewcontainer_mac.mm } -# TODO -false:mac { - OBJECTIVE_HEADERS += widgets/qcocoatoolbardelegate_mac_p.h \ - widgets/qcocoamenu_mac_p.h - OBJECTIVE_SOURCES += widgets/qcocoatoolbardelegate_mac.mm \ - widgets/qmainwindowlayout_mac.mm - -} - wince*: { SOURCES += widgets/qmenu_wince.cpp HEADERS += widgets/qmenu_wince_resource_p.h From 7fab8eb56b9309734d1b34d3d935d6a4cf14ce6e Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 7 Jan 2014 14:43:22 +0100 Subject: [PATCH 26/72] Windows: Do not print test output to both stdout and system debug log Avoid piping the test output to both the Windows system debugger, and stdout. This fixes duplicate output in Qt Creator, which displays messages from both sources. [ChangeLog][QtTestLib] The (default) plain text logger on Windows now logs to either the system debug log (in case no console is open), or stdout, not both. Task-number: QTBUG-34630 Change-Id: I35fe9f4a50cc660d79fad7dffa6d19659b2102ae Reviewed-by: Thiago Macieira Reviewed-by: Friedemann Kleint --- src/corelib/global/qlogging.cpp | 2 +- src/testlib/qplaintestlogger.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index cc20891c76..5b7a674ddb 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -102,7 +102,7 @@ static inline bool hasStdErr() } # endif // !Q_OS_WINCE && !Q_OS_WINRT -bool qWinLogToStderr() +Q_CORE_EXPORT bool qWinLogToStderr() { # if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) static const bool result = hasStdErr(); diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 77be0e423e..3f65dc0a6e 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -197,6 +197,10 @@ namespace QTest { } } +#if defined(Q_OS_WIN) +Q_CORE_EXPORT bool qWinLogToStderr(); // defined in qlogging.cpp +#endif + void QPlainTestLogger::outputMessage(const char *str) { #if defined(Q_OS_WINCE) @@ -209,7 +213,11 @@ void QPlainTestLogger::outputMessage(const char *str) } while (!strUtf16.isEmpty()); if (stream != stdout) #elif defined(Q_OS_WIN) - OutputDebugStringA(str); + // log to system log only if output is not redirected, and no console is attached + if (!qWinLogToStderr() && stream == stdout) { + OutputDebugStringA(str); + return; + } #elif defined(Q_OS_ANDROID) __android_log_write(ANDROID_LOG_INFO, "QTestLib", str); #endif From a761be2fb2191215426f904cb03df0e966214531 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 23 Nov 2013 00:15:30 +0100 Subject: [PATCH 27/72] Correct wordwrapped text handling in QListView icon mode Currently a QListView with wordwrapping activated will wrap the text only to the width of the icon even if the grid size is bigger. With this patch the option rect is now updated to match the grid size if valid and the style uses it to determine the correct size when wrapping [ChangeLog][QtWidgets][QTBUG-4714] Use the grid size for wordwrapping when available in icon mode Task-number: QTBUG-4714 Change-Id: I2cb63809d3ee8bd262f38bc11de91df9ff5cf237 Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qlistview.cpp | 5 +++++ src/widgets/styles/qcommonstyle.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 0cca52daa2..8238e5f6d4 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -915,6 +915,11 @@ QStyleOptionViewItem QListView::viewOptions() const } else { option.decorationPosition = QStyleOptionViewItem::Left; } + + if (d->gridSize().isValid()) { + option.rect.setSize(d->gridSize()); + } + return option; } diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index a9f1c3bbbc..2d7107598f 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -838,7 +838,10 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int break; case QStyleOptionViewItem::Top: case QStyleOptionViewItem::Bottom: - bounds.setWidth(wrapText ? option->decorationSize.width() : QFIXED_MAX); + if (wrapText) + bounds.setWidth(bounds.isValid() ? bounds.width() - 2 * textMargin : option->decorationSize.width()); + else + bounds.setWidth(QFIXED_MAX); break; default: break; From 48caaee17016629b1459041e6d8b2fa7a888b62a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 Jan 2014 15:16:49 -0800 Subject: [PATCH 28/72] Ask qdoc not to parse Q_DECL_UNUSED We have it on function declarations and it gets a bit lost... Change-Id: I19ba2e760f3714c26e78c3d8fd2570af3dcd136e Reviewed-by: Martin Smith Reviewed-by: Frederik Gladhorn --- doc/global/qt-cpp-defines.qdocconf | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/global/qt-cpp-defines.qdocconf b/doc/global/qt-cpp-defines.qdocconf index 528b0cd561..37fa5dbdcf 100644 --- a/doc/global/qt-cpp-defines.qdocconf +++ b/doc/global/qt-cpp-defines.qdocconf @@ -30,6 +30,7 @@ Cpp.ignoretokens += \ Q_DECL_DEPRECATED \ Q_DECL_NOEXCEPT \ Q_DECL_NOTHROW \ + Q_DECL_UNUSED \ Q_DECLARATIVE_EXPORT \ Q_EXPLICIT \ Q_EXPORT \ From f10356ead13e39c9501b84ee5e92efe722a2d2c7 Mon Sep 17 00:00:00 2001 From: lpapuga Date: Wed, 20 Nov 2013 17:09:57 +0100 Subject: [PATCH 29/72] MIPS DSP build system fix and additional optimizations. Changed MIPS DSP portion of the mkspecs/features/simd.prf file in order to fix the corrupted build system for MIPS platforms. List of the additionally optimized functions from file src/gui/painting/qdrawhelper.cpp: - qt_blend_rgb16_on_rgb16 - qt_fetchUntransformed_888 - qt_fetchUntransformed_444 - qt_fetchUntransformed_argb8565 from file src/gui/image/qimage.cpp: - convert_ARGB_to_ARGB_PM_inplace from file src/corelib/qstring.cpp: - ucstrncmp - toLatin1_helper - fromLatin1_helper Change-Id: I5c47a69784917eee29a8dbd2718828a390b27c93 Reviewed-by: Thiago Macieira --- mkspecs/features/simd.prf | 12 +- src/corelib/corelib.pro | 14 + src/corelib/tools/qstring.cpp | 35 ++ src/corelib/tools/qstring_mips_dsp_asm.S | 449 ++++++++++++++ src/corelib/tools/tools.pri | 4 + src/gui/image/image.pri | 2 + src/gui/image/qimage.cpp | 6 + src/gui/image/qimage_mips_dspr2.cpp | 69 +++ src/gui/image/qimage_mips_dspr2_asm.S | 207 +++++++ src/gui/painting/qdrawhelper.cpp | 17 +- src/gui/painting/qdrawhelper_mips_dsp.cpp | 97 ++- src/gui/painting/qdrawhelper_mips_dsp_asm.S | 478 ++++++++++++++- src/gui/painting/qdrawhelper_mips_dsp_p.h | 45 +- src/gui/painting/qdrawhelper_mips_dspr2_asm.S | 550 +++++++++++++++++- src/gui/painting/qt_mips_asm_dsp_p.h | 166 +++++- 15 files changed, 2141 insertions(+), 10 deletions(-) create mode 100644 src/corelib/tools/qstring_mips_dsp_asm.S create mode 100644 src/gui/image/qimage_mips_dspr2.cpp create mode 100644 src/gui/image/qimage_mips_dspr2_asm.S diff --git a/mkspecs/features/simd.prf b/mkspecs/features/simd.prf index a98683d929..ad8c545819 100644 --- a/mkspecs/features/simd.prf +++ b/mkspecs/features/simd.prf @@ -174,10 +174,19 @@ QT_CPU_FEATURES = $$eval(QT_CPU_FEATURES.$$QT_ARCH) mips_dsp_assembler.name = assembling[mips_dsp] ${QMAKE_FILE_IN} silent:mips_dsp_assembler.commands = @echo assembling[mips_dsp] ${QMAKE_FILE_IN} && $$mips_dsp_assembler.commands QMAKE_EXTRA_COMPILERS += mips_dsp_compiler + QMAKE_EXTRA_COMPILERS += mips_dsp_assembler } mips_dspr2 { HEADERS += $$MIPS_DSP_HEADERS + mips_dspr2_compiler.commands = $$QMAKE_CXX -c + mips_dspr2_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} + mips_dspr2_compiler.dependency_type = TYPE_C + mips_dspr2_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)} + mips_dspr2_compiler.input = MIPS_DSPR2_SOURCES + mips_dspr2_compiler.variable_out = OBJECTS + mips_dspr2_compiler.name = compiling[mips_dspr2] ${QMAKE_FILE_IN} + silent:mips_dspr2_compiler.commands = @echo compiling[mips_dspr2] ${QMAKE_FILE_IN} && $$mips_dspr2_compiler.commands mips_dspr2_assembler.commands = $$QMAKE_CC -c mips_dspr2_assembler.commands += $(CFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} mips_dspr2_assembler.dependency_type = TYPE_C @@ -186,6 +195,7 @@ QT_CPU_FEATURES = $$eval(QT_CPU_FEATURES.$$QT_ARCH) mips_dspr2_assembler.variable_out = OBJECTS mips_dspr2_assembler.name = assembling[mips_dspr2] ${QMAKE_FILE_IN} silent:mips_dspr2_assembler.commands = @echo assembling[mips_dspr2] ${QMAKE_FILE_IN} && $$mips_dspr2_assembler.commands + QMAKE_EXTRA_COMPILERS += mips_dspr2_compiler QMAKE_EXTRA_COMPILERS += mips_dspr2_assembler } } else:win32-msvc*|winrt { @@ -297,7 +307,7 @@ QT_CPU_FEATURES = $$eval(QT_CPU_FEATURES.$$QT_ARCH) $$AVX_SOURCES $$AVX2_SOURCES \ $$NEON_SOURCES $$NEON_ASM \ $$IWMMXT_SOURCES \ - $$MIPS_DSP_SOURCES $$MIPS_DSP_ASM $$MIPS_DSPR2_ASM + $$MIPS_DSP_SOURCES $$MIPS_DSPR2_SOURCES $$MIPS_DSP_ASM $$MIPS_DSPR2_ASM # Headers are already done in the above sections. } diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index b513149e7c..df28183fdc 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -111,3 +111,17 @@ ctest_qt5_module_files.files += $$ctest_macros_file.output $$cmake_extras_mkspec ctest_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5Core INSTALLS += ctest_qt5_module_files cmake_qt5_umbrella_module_files + +mips_dsp:*-g++* { + HEADERS += $$MIPS_DSP_HEADERS + + mips_dsp_corelib_assembler.commands = $$QMAKE_CXX -c + mips_dsp_corelib_assembler.commands += $(CXXFLAGS) $(INCPATH) -mips32r2 -mdsp ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} + mips_dsp_corelib_assembler.dependency_type = TYPE_C + mips_dsp_corelib_assembler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)} + mips_dsp_corelib_assembler.input = MIPS_DSP_ASM + mips_dsp_corelib_assembler.variable_out = OBJECTS + mips_dsp_corelib_assembler.name = assembling[mips_dsp] ${QMAKE_FILE_IN} + silent:mips_dsp_corelib_assembler.commands = @echo assembling[mips_dsp] ${QMAKE_FILE_IN} && $$mips_dsp_corelib_assembler.commands + QMAKE_EXTRA_COMPILERS += mips_dsp_corelib_assembler +} diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3976f2cb6f..d682207314 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -188,9 +188,23 @@ static int ucstricmp(const ushort *a, const ushort *ae, const uchar *b, const uc return 1; } +#if defined(__mips_dsp) +// From qstring_mips_dsp_asm.S +extern "C" int qt_ucstrncmp_mips_dsp_asm(const ushort *a, + const ushort *b, + unsigned len); +#endif + // Unicode case-sensitive compare two same-sized strings static int ucstrncmp(const QChar *a, const QChar *b, int l) { +#if defined(__mips_dsp) + if (l >= 8) { + return qt_ucstrncmp_mips_dsp_asm(reinterpret_cast(a), + reinterpret_cast(b), + l); + } +#endif // __mips_dsp while (l-- && *a == *b) a++,b++; if (l==-1) @@ -3937,6 +3951,10 @@ static inline __m128i mergeQuestionMarks(__m128i chunk) } #endif +#if defined(__mips_dsp) +extern "C" void qt_toLatin1_mips_dsp_asm(uchar *dst, const ushort *src, int length); +#endif + static QByteArray toLatin1_helper(const QChar *data, int length) { QByteArray ba; @@ -3989,10 +4007,14 @@ static QByteArray toLatin1_helper(const QChar *data, int length) length = length % 8; } #endif +#if defined(__mips_dsp) + qt_toLatin1_mips_dsp_asm(dst, src, length); +#else while (length--) { *dst++ = (*src>0xff) ? '?' : (uchar) *src; ++src; } +#endif } return ba; } @@ -4104,6 +4126,12 @@ QVector QString::toUcs4() const return v; } +#if defined(__mips_dsp) +// From qstring_mips_dsp_asm.S +extern "C" void qt_fromlatin1_mips_asm_unroll4 (ushort*, const char*, uint); +extern "C" void qt_fromlatin1_mips_asm_unroll8 (ushort*, const char*, uint); +#endif + QString::Data *QString::fromLatin1_helper(const char *str, int size) { Data *d; @@ -4144,8 +4172,15 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size) size = size % 16; } #endif +#if defined(__mips_dsp) + if (size > 20) + qt_fromlatin1_mips_asm_unroll8(dst, str, size); + else + qt_fromlatin1_mips_asm_unroll4(dst, str, size); +#else while (size--) *dst++ = (uchar)*str++; +#endif } return d; } diff --git a/src/corelib/tools/qstring_mips_dsp_asm.S b/src/corelib/tools/qstring_mips_dsp_asm.S new file mode 100644 index 0000000000..aee162c290 --- /dev/null +++ b/src/corelib/tools/qstring_mips_dsp_asm.S @@ -0,0 +1,449 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Imagination Technologies Limited, www.imgtec.com +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../../gui/painting/qt_mips_asm_dsp_p.h" + +.macro EXTRACT_HALVES_x2 src1, src2, hi_1, hi_2 +#if defined(__MIPSEL) && __MIPSEL + srl \hi_1, \src1, 16 + ext \src1, \src1, 0, 16 + srl \hi_2, \src2, 16 + ext \src2, \src2, 0, 16 +#else + ext \hi_1, \src1, 0, 16 + srl \src1, \src1, 16 + ext \hi_2, \src2, 0, 16 + srl \src2, \src2, 16 +#endif +.endm + + +LEAF_MIPS_DSP(qt_ucstrncmp_mips_dsp_asm) +/* + * Arguments: + * a0 - string_a (uint16_t*) + * a1 - string_b (uint16_t*) + * a2 - length (uint32_t) + * + * Register usage: + * t0 - batches + */ + + move v0, zero /* result = 0 */ + andi t0, a0, 0x3 /* t1 = string_a % 4 */ + andi t1, a1, 0x3 /* t0 = string_b % 4 */ + or t2, t0, t1 /* t2 = t0 | t1 */ + + beqz t2, 5f /* both aligned */ + and t2, t0 ,t1 + beqz t2, 6f /* one aligned */ + nop + + /* + * Both strings are unaligned: read 1 halfword from each, + * then fall-off to continue with the both-aligned case. + */ + lhu t0, 0 (a0) + lhu t1, 0 (a1) + addiu a2, a2, -1 /* len-- */ + sub v0, t0, t1 /* v0 = t0-t1 */ + addiu a0, a0, 2 /* string_a++ */ + bnez v0, 0f /* if (t0-t1): return */ + addiu a1, a1, 2 /* string_b++ */ + beqz a2, 0f /* if !len: return */ + /* next instruction (srl) fills delay branch slot */ + +5: /* Both string pointers are aligned */ + srl t0, a2, 3 /* batches = length / 8 */ + beqz t0, 9f /* if !batches: tail */ + andi a2, a2, 0x7 /* length = length % 8 */ + + SAVE_REGS_ON_STACK 0, s0, s1, s2, s3 + +1: lw t1, 0 (a0) /* [a0 a1] */ + lw t3, 4 (a0) /* [a2 a3] */ + lw t5, 8 (a0) /* [a4 a5] */ + lw t7, 12 (a0) /* [a6 a7] */ + + lw t2, 0 (a1) /* [b0 b1] */ + lw t4, 4 (a1) /* [b2 b3] */ + lw t6, 8 (a1) /* [b4 b5] */ + lw t8, 12 (a1) /* [b6 b7] */ + + /* + * Subtract elements one by one, if the result is zero + * both halves of the registers (shorts) are equal. + */ + subq.ph s0, t1, t2 /* [a0-b0 a1-b1] */ + subq.ph s1, t3, t4 /* [a2-b2 a3-b3] */ + + bnez s0, 1f + subq.ph s2, t5, t6 /* [a4-b4 a5-b5] */ + bnez s1, 2f + subq.ph s3, t7, t8 /* [a6-b6 a7-b7] */ + bnez s2, 3f + addiu t0, t0, -1 /* batches-- */ + bnez s3, 4f + addiu a0, a0, 8*2 /* string_a += 8 */ + + bnez t0, 1b /* if batches: loop */ + addiu a1, a1, 8*2 /* string_b += 8 */ + + RESTORE_REGS_FROM_STACK 0, s0, s1, s2, s3 + + bnez a2, 9f /* if length: tail */ + nop + jr ra + nop + + + 1: /* Check t1 [a0 a1] vs. t2 [b0 b1] */ + EXTRACT_HALVES_x2 t1, t2, t3, t4 /* a0, b0, a1, b1 */ + sub v0, t1, t2 + RESTORE_REGS_FROM_STACK 0, s0, s1, s2, s3 + bnez v0, 0f /* if (a0-b0): return */ + nop + jr ra + sub v0, t3, t4 /* return a1-b1 */ + + 2: /* Check t3 [a2 a3] vs. t4 [b2 b3] */ + EXTRACT_HALVES_x2 t3, t4, t1, t2 /* a2, b2, a3, b3 */ + sub v0, t3, t4 + RESTORE_REGS_FROM_STACK 0, s0, s1, s2, s3 + bnez v0, 0f /* if (a2-b2): return */ + nop + jr ra + sub v0, t1, t2 /* return a3-b3 */ + + 3: /* Check t5 [a4 a5] vs. t6 [b4 b5] */ + EXTRACT_HALVES_x2 t5, t6, t1, t2 /* a4, b4, a5, b5 */ + sub v0, t5, t6 + RESTORE_REGS_FROM_STACK 0, s0, s1, s2, s3 + bnez v0, 0f /* if (a4-b4): return */ + nop + jr ra + sub v0, t1, t2 /* return a5-b5 */ + + 4: /* Check t7 [a6 a7] vs. t8 [b6 b7] */ + EXTRACT_HALVES_x2 t7, t8, t1, t2 /* a6, b6, a7, b7 */ + sub v0, t7, t8 + RESTORE_REGS_FROM_STACK 0, s0, s1, s2, s3 + bnez v0, 0f /* if (a6-b6): return */ + nop + jr ra + sub v0, t1, t2 + + + /* Process remaining tail items. */ +9: lhu t1, 0 (a0) /* a */ + lhu t2, 0 (a1) /* b */ + addiu a2, a2, -1 /* length-- */ + sub v0, t1, t2 /* result = (a - b) */ + + bnez v0, 0f /* if (a - b): return */ + addiu a0, a0, 2 /* string_a++ */ + + bnez a2, 9b /* if length: loop */ + addiu a1, a1, 2 /* string_b++ */ + +0: jr ra + nop + + + /* One of the inputs is unaligned, do unrolled half-word loads */ +6: srl t0, a2, 3 /* batches = length / 8 */ + andi a2, a2, 0x7 /* length = length % 8 */ + +1: lhu t1, 0 (a0) + lhu t2, 0 (a1) + lhu t3, 2 (a0) + lhu t4, 2 (a1) + lhu t5, 4 (a0) + lhu t6, 4 (a1) + lhu t7, 6 (a0) + lhu t8, 6 (a1) + + sub v0, t1, t2 + sub t1, t3, t4 + + bnez v0, 0f + sub t2, t5, t6 + bnez t1, 2f + sub t3, t7, t8 + bnez t2, 3f + lhu t1, 8 (a0) + bnez t3, 4f + lhu t2, 8 (a1) + + lhu t3, 10 (a0) + lhu t4, 10 (a1) + lhu t5, 12 (a0) + lhu t6, 12 (a1) + lhu t7, 14 (a0) + lhu t8, 14 (a1) + + sub v0, t1, t2 + sub t1, t3, t4 + + bnez v0, 0f + sub t2, t5, t6 + bnez t1, 2f + sub t3, t7, t8 + bnez t2, 3f + addiu t0, t0, -1 /* batches-- */ + bnez t3, 4f + addiu a0, a0, 8*2 /* string_a += 8 */ + + bnez t0, 1b + addiu a1, a1, 8*2 /* string_b += 8 */ + + bnez a2, 9b /* if length: tail */ + nop + +0: jr ra + nop +2: jr ra + move v0, t1 +3: jr ra + move v0, t2 +4: jr ra + move v0, t3 + +END(qt_ucstrncmp_mips_dsp_asm) + + +#if defined(__mips_dspr2) +LEAF_MIPS_DSPR2(qt_fromlatin1_mips_asm_unroll8) +#else +LEAF_MIPS_DSP(qt_fromlatin1_mips_asm_unroll8) +#endif + + andi t0, a1, 0x3 + beqz t0, 9f /* check that src is aligned */ + nop + +1: lbu t1, 0 (a1) + addiu a1, a1, 1 + addiu a2, a2, -1 + sh t1, 0 (a0) + beqz a2, 0f + andi t0, a1, 0x3 + bnez t0, 1b + addiu a0, a0, 2 + +9: /* source pointer is aligned: do batches of 8 elements */ + andi t0, a0, 3 /* check if dst is aligned */ + bnez t0, 6f + srl t0, a2, 3 /* batches = len / 8 */ + andi a2, a2, 0x7 /* tail = len % 8 */ + + beqz t0, 8f /* if !batches: tail */ + nop + +1: lw t1, 0 (a1) + lw t2, 4 (a1) + + addiu a1, a1, 8*1 + addiu t0, t0, -1 + + preceu.ph.qbl t3, t1 + preceu.ph.qbr t1, t1 + preceu.ph.qbl t4, t2 + preceu.ph.qbr t2, t2 + +#if defined(__MIPSEL) && __MIPSEL + sw t1, 0 (a0) + sw t3, 4 (a0) + sw t2, 8 (a0) + sw t4, 12 (a0) +#else + sw t3, 0 (a0) + sw t1, 4 (a0) + sw t4, 8 (a0) + sw t2, 12 (a0) +#endif + + bnez t0, 1b + addiu a0, a0, 8*2 + +8: /* process tail items */ + beqz a2, 0f + nop + +1: lbu t1, 0 (a1) + addiu a2, a2, -1 + sh t1, 0 (a0) + addiu a1, a1, 1 + bnez a2, 1b + addiu a0, a0, 2 + +0: jr ra + nop + +6: beqz t0, 8b + andi a2, a2, 7 +7: lw t1, 0(a1) + lw t2, 4(a1) + addiu t0, t0, -1 + addiu a1, a1, 8 + andi t3, t1, 0xff +#if defined(__mips_dspr2) + prepend t1, t2, 8 +#else + sll t4, t4, 24 + srl t1, t1, 8 + or t1, t1, t4 +#endif + srl t2, t2, 8 + preceu.ph.qbr t4, t1 + preceu.ph.qbl t1, t1 + preceu.ph.qbr t5, t2 + srl t2, t2, 16 + sh t3, 0(a0) + sw t4, 2(a0) + sw t1, 6(a0) + sw t5, 10(a0) + sh t2, 14(a0) + bnez t0, 7b + addiu a0, a0, 16 + bnez a2, 1b + nop + + jr ra + nop + +END(qt_fromlatin1_mips_asm_unroll8) + + +LEAF_MIPS_DSP(qt_fromlatin1_mips_asm_unroll4) +/* + * Arguments: + * a0 - dst (uint16_t*) + * a1 - src (const char*) + * a2 - len (unsigned int) + */ + + /* + * QString::fromLatin1_helper() already handles the len==0 + * case: assume that len is never zero. + */ + srl t0, a2, 2 + beqz t0, 9f + andi a2, a2, 0x3 + +1: lbu t1, 0(a1) + lbu t2, 1(a1) + lbu t3, 2(a1) + lbu t4, 3(a1) + sh t1, 0(a0) + sh t2, 2(a0) + sh t3, 4(a0) + sh t4, 6(a0) + addiu t0, t0, -1 + addiu a1, a1, 4 + bnez t0, 1b + addiu a0, a0, 8 + +8: beqz a2, 0f + nop + +9: lbu t1, 0(a1) + addiu a2, a2, -1 + addiu a1, a1, 1 + sh t1, 0(a0) + bnez a2, 9b + addiu a0, a0, 2 + +0: jr ra + nop + +END(qt_fromlatin1_mips_asm_unroll4) + + +LEAF_MIPS_DSP(qt_toLatin1_mips_dsp_asm) + /* + * a0 - dst + * a1 - src + * a2 - length + */ + + addiu t9, zero, 0x3f + srl t8, a2, 2 + beqz t8, 2f + andi a2, a2, 3 +1: + lhu t0, 0(a1) + lhu t1, 2(a1) + lhu t2, 4(a1) + lhu t3, 6(a1) + srl t4, t0, 8 + srl t5, t1, 8 + srl t6, t2, 8 + srl t7, t3, 8 + movn t0, t9, t4 + movn t1, t9, t5 + movn t2, t9, t6 + movn t3, t9, t7 + addiu a1, a1, 8 + addiu t8, t8, -1 + sb t0, 0(a0) + sb t1, 1(a0) + sb t2, 2(a0) + sb t3, 3(a0) + bgtz t8, 1b + addiu a0, a0, 4 +2: beqz a2, 4f + nop +3: + lhu t0, 0(a1) + addiu a1, a1, 2 + addiu a2, a2, -1 + srl t1, t0, 8 + movn t0, t9, t1 + sb t0, 0(a0) + bgtz a2, 3b + addiu a0, a0, 1 +4: + jr ra + nop + +END(qt_toLatin1_mips_dsp_asm) + diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index e4a7b02aee..cac596f0bc 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -192,3 +192,7 @@ INCLUDEPATH += ../3rdparty/md5 \ !macx-icc:!vxworks:unix:LIBS_PRIVATE += -lm TR_EXCLUDE += ../3rdparty/* + +# MIPS DSP +MIPS_DSP_ASM += tools/qstring_mips_dsp_asm.S +MIPS_DSP_HEADERS += ../gui/painting/qt_mips_asm_dsp_p.h diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index a80ab4a2fe..bf4b5ddf01 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -78,3 +78,5 @@ NEON_SOURCES += image/qimage_neon.cpp SSE2_SOURCES += image/qimage_sse2.cpp SSSE3_SOURCES += image/qimage_ssse3.cpp AVX_SOURCES += image/qimage_avx.cpp +MIPS_DSPR2_SOURCES += image/qimage_mips_dspr2.cpp +MIPS_DSPR2_ASM += image/qimage_mips_dspr2_asm.S diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 12ab5eaffa..70fe7b783f 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3960,6 +3960,12 @@ void qInitImageConversions() return; } #endif + +#ifdef QT_COMPILER_SUPPORTS_MIPS_DSPR2 + extern bool convert_ARGB_to_ARGB_PM_inplace_mips_dspr2(QImageData *data, Qt::ImageConversionFlags); + inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_mips_dspr2; + return; +#endif } extern const uchar *qt_pow_rgb_gamma(); diff --git a/src/gui/image/qimage_mips_dspr2.cpp b/src/gui/image/qimage_mips_dspr2.cpp new file mode 100644 index 0000000000..a1c40a16df --- /dev/null +++ b/src/gui/image/qimage_mips_dspr2.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Imagination Technologies Limited, www.imgtec.com +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qimage.h" +#include + +QT_BEGIN_NAMESPACE + +// Defined in qimage_mips_dspr2_asm.S +// +extern "C" void premultiply_argb_inplace_mips_asm(void*, unsigned, unsigned, int); + +bool convert_ARGB_to_ARGB_PM_inplace_mips_dspr2(QImageData *data, Qt::ImageConversionFlags) +{ + Q_ASSERT(data->format == QImage::Format_ARGB32); + + if (!data->width || !data->height) + return true; + + Q_ASSERT((data->bytes_per_line - (data->width << 2)) >= 0); + + premultiply_argb_inplace_mips_asm(data->data, + data->height, + data->width, + data->bytes_per_line - (data->width << 2)); + + data->format = QImage::Format_ARGB32_Premultiplied; + return true; +} + +QT_END_NAMESPACE diff --git a/src/gui/image/qimage_mips_dspr2_asm.S b/src/gui/image/qimage_mips_dspr2_asm.S new file mode 100644 index 0000000000..1f03b72dd4 --- /dev/null +++ b/src/gui/image/qimage_mips_dspr2_asm.S @@ -0,0 +1,207 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Imagination Technologies Limited, www.imgtec.com +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../painting/qt_mips_asm_dsp_p.h" + +LEAF_MIPS_DSPR2(premultiply_argb_inplace_mips_asm) + + SAVE_REGS_ON_STACK 0, s0, s1, s2, s3 + +3: srl v1, a2, 3 /* t1 = linelen / 8 */ + addiu a1, a1, -1 /* numlines-- */ + beqz v1, 1f /* if (!(linelen / 8)): tail */ + andi v0, a2, 0x7 /* v0 = linelen % 8 */ + pref 5, 0 (a0) /* cache-hint: store-streamed */ + + /* unrolled loop, handles (v1 = len / 8) batches of 8 pixels */ +2: addiu v1, v1, -1 + pref 5, 0(a0) + pref 5, 32(a0) + + lw t0, 0(a0) + lw t1, 4(a0) + lw t2, 8(a0) + lw t3, 12(a0) + srl t4, t0, 24 /* 00|00|00|A1 */ + replv.ph t5, t4 /* 00|A1|00|A1 */ + srl t6, t1, 24 /* 00|00|00|A2 */ + replv.ph t7, t6 /* 00|A2|00|A2 */ + muleu_s.ph.qbl t8, t0, t5 /* A1*A1|A1*R1 */ + muleu_s.ph.qbr t0, t0, t5 /* A1*G1|A1*B1 */ + muleu_s.ph.qbl t9, t1, t7 /* A2*A2|A2*R2 */ + muleu_s.ph.qbr t1, t1, t7 /* A2*G2|A2*B2 */ + srl t5, t2, 24 /* 00|00|00|A3 */ + replv.ph s0, t5 /* 00|A3|00|A3 */ + srl t7, t3, 24 /* 00|00|00|A4 */ + replv.ph s1, t7 /* 00|A4|00|A4 */ + muleu_s.ph.qbl s2, t2, s0 /* A3*A3|A3*R3 */ + muleu_s.ph.qbr t2, t2, s0 /* A3*G3|A3*B3 */ + muleu_s.ph.qbl s0, t3, s1 /* A4*A4|A4*R4 */ + muleu_s.ph.qbr t3, t3, s1 /* A4*G4|A4*B4 */ + preceu.ph.qbla s1, t8 + preceu.ph.qbla s3, t0 + addu.ph t8, t8, s1 + addu.ph t0, t0, s3 + preceu.ph.qbla s1, t9 + preceu.ph.qbla s3, t1 + addu.ph t9, t9, s1 + addu.ph t1, t1, s3 + preceu.ph.qbla s1, s2 + preceu.ph.qbla s3, t2 + addu.ph s2, s2, s1 + addu.ph t2, t2, s3 + preceu.ph.qbla s1, s0 + preceu.ph.qbla s3, t3 + addu.ph s0, s0, s1 + addu.ph t3, t3, s3 + shra_r.ph t8, t8, 8 /* xxAA1|xxRR1 */ + shra_r.ph t0, t0, 8 /* xxBB1|xxGG1 */ + shra_r.ph t9, t9, 8 + shra_r.ph t1, t1, 8 + shra_r.ph s2, s2, 8 + shra_r.ph t2, t2, 8 + shra_r.ph s0, s0, 8 + shra_r.ph t3, t3, 8 + precr.qb.ph t0, t8, t0 + precr.qb.ph t1, t9, t1 + precr.qb.ph t2, s2, t2 + precr.qb.ph t3, s0, t3 + append t4, t0, 24 + append t6, t1, 24 + append t5, t2, 24 + append t7, t3, 24 + sw t4, 0(a0) + sw t6, 4(a0) + sw t5, 8(a0) + sw t7, 12(a0) + + lw t0, 16(a0) + lw t1, 20(a0) + lw t2, 24(a0) + lw t3, 28(a0) + srl t4, t0, 24 /* 00|00|00|A1 */ + replv.ph t5, t4 /* 00|A1|00|A1 */ + srl t6, t1, 24 /* 00|00|00|A2 */ + replv.ph t7, t6 /* 00|A2|00|A2 */ + muleu_s.ph.qbl t8, t0, t5 /* A1*A1|A1*R1 */ + muleu_s.ph.qbr t0, t0, t5 /* A1*G1|A1*B1 */ + muleu_s.ph.qbl t9, t1, t7 /* A2*A2|A2*R2 */ + muleu_s.ph.qbr t1, t1, t7 /* A2*G2|A2*B2 */ + srl t5, t2, 24 /* 00|00|00|A3 */ + replv.ph s0, t5 /* 00|A3|00|A3 */ + srl t7, t3, 24 /* 00|00|00|A4 */ + replv.ph s1, t7 /* 00|A4|00|A4 */ + muleu_s.ph.qbl s2, t2, s0 /* A3*A3|A3*R3 */ + muleu_s.ph.qbr t2, t2, s0 /* A3*G3|A3*B3 */ + muleu_s.ph.qbl s0, t3, s1 /* A4*A4|A4*R4 */ + muleu_s.ph.qbr t3, t3, s1 /* A4*G4|A4*B4 */ + preceu.ph.qbla s1, t8 + preceu.ph.qbla s3, t0 + addu.ph t8, t8, s1 + addu.ph t0, t0, s3 + preceu.ph.qbla s1, t9 + preceu.ph.qbla s3, t1 + addu.ph t9, t9, s1 + addu.ph t1, t1, s3 + preceu.ph.qbla s1, s2 + preceu.ph.qbla s3, t2 + addu.ph s2, s2, s1 + addu.ph t2, t2, s3 + preceu.ph.qbla s1, s0 + preceu.ph.qbla s3, t3 + addu.ph s0, s0, s1 + addu.ph t3, t3, s3 + shra_r.ph t8, t8, 8 /* xxAA1|xxRR1 */ + shra_r.ph t0, t0, 8 /* xxBB1|xxGG1 */ + shra_r.ph t9, t9, 8 + shra_r.ph t1, t1, 8 + shra_r.ph s2, s2, 8 + shra_r.ph t2, t2, 8 + shra_r.ph s0, s0, 8 + shra_r.ph t3, t3, 8 + precr.qb.ph t0, t8, t0 + precr.qb.ph t1, t9, t1 + precr.qb.ph t2, s2, t2 + precr.qb.ph t3, s0, t3 + append t4, t0, 24 + append t6, t1, 24 + append t5, t2, 24 + append t7, t3, 24 + sw t4, 16(a0) + sw t6, 20(a0) + sw t5, 24(a0) + sw t7, 28(a0) + bgtz v1, 2b /* if (t1): unrolled loop */ + addiu a0, a0, 32 /* data += 8 */ + + beqz v0, 4f /* if (!v0): skip tail loop */ + nop + + /* tail loop, handles (len < 8), one pixel at a time */ +1: lw t1, 0 (a0) + addiu v0, v0, -1 /* len-- */ + srl t2, t1, 24 /* t2 = alpha */ + replv.ph t3, t2 + muleu_s.ph.qbl t4, t1, t3 + muleu_s.ph.qbr t1, t1, t3 + preceu.ph.qbla t3, t4 + preceu.ph.qbla t5, t1 + addu.ph t4, t4, t3 + addu.ph t1, t1, t5 + shra_r.ph t4, t4, 8 + shra_r.ph t1, t1, 8 + precr.qb.ph t1, t4, t1 + append t2, t1, 24 + sw t2, 0(a0) + bgtz v0, 1b + addiu a0, a0, 4 /* src++ */ + +4: bnez a1, 3b /* if (numlines): loop */ + addu a0, a0, a3 /* src += srclineskip */ + +0: /* return */ + RESTORE_REGS_FROM_STACK 0, s0, s1, s2, s3 + + jr ra + nop + +END(premultiply_argb_inplace_mips_asm) + diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index a037545dc2..cc28076b7c 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1790,7 +1790,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper return buffer; } -static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { +static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { // Untransformed { 0, // Invalid @@ -6402,6 +6402,21 @@ void qInitDrawhelperAsm() destStoreProc[QImage::Format_ARGB32] = qt_destStoreARGB32_mips_dsp; + sourceFetch[BlendUntransformed][QImage::Format_RGB888] = qt_fetchUntransformed_888_mips_dsp; + sourceFetch[BlendTiled][QImage::Format_RGB888] = qt_fetchUntransformed_888_mips_dsp; + + sourceFetch[BlendUntransformed][QImage::Format_RGB444] = qt_fetchUntransformed_444_mips_dsp; + sourceFetch[BlendTiled][QImage::Format_RGB444] = qt_fetchUntransformed_444_mips_dsp; + + sourceFetch[BlendUntransformed][QImage::Format_ARGB8565_Premultiplied] = qt_fetchUntransformed_argb8565_premultiplied_mips_dsp; + sourceFetch[BlendTiled][QImage::Format_ARGB8565_Premultiplied] = qt_fetchUntransformed_argb8565_premultiplied_mips_dsp; + +#if defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) + qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dspr2; +#else + qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dsp; +#endif // QT_COMPILER_SUPPORTS_MIPS_DSPR2 + #endif // QT_COMPILER_SUPPORTS_MIPS_DSP if (functionForModeSolidAsm) { const int destinationMode = QPainter::CompositionMode_Destination; diff --git a/src/gui/painting/qdrawhelper_mips_dsp.cpp b/src/gui/painting/qdrawhelper_mips_dsp.cpp index a9b551c226..2202b78ce8 100644 --- a/src/gui/painting/qdrawhelper_mips_dsp.cpp +++ b/src/gui/painting/qdrawhelper_mips_dsp.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2012 MIPS Technologies, www.mips.com, author Damir Tatalovic +** Copyright (C) 2013 Imagination Technologies Limited, www.imgtec.com ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -110,6 +110,78 @@ void qt_blend_rgb32_on_rgb32_mips_dsp(uchar *destPixels, int dbpl, } } +#if defined QT_COMPILER_SUPPORTS_MIPS_DSPR2 +void qt_blend_rgb16_on_rgb16_mips_dspr2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha) +{ + if (const_alpha == 256) { + if (w < 256) { + const quint16 *src = (const quint16*) srcPixels; + quint16 *dst = (quint16*) destPixels; + for (int y = 0; y < h; ++y) { + qt_blend_rgb16_on_rgb16_const_alpha_256_mips_dsp_asm(dst, src, w); + dst = (quint16*) (((uchar*) dst) + dbpl); + src = (quint16*) (((uchar*) src) + sbpl); + } + } + else { + int length = w << 1; + while (h--) { + memcpy(destPixels, srcPixels, length); + destPixels += dbpl; + srcPixels += sbpl; + } + } + } + else if (const_alpha != 0) { + const quint16 *src = (const quint16*) srcPixels; + quint16 *dst = (quint16*) destPixels; + for (int y = 0; y < h; ++y) { + qt_blend_rgb16_on_rgb16_mips_dspr2_asm(dst, src, w, const_alpha); + dst = (quint16*) (((uchar*) dst) + dbpl); + src = (quint16*) (((uchar*) src) + sbpl); + } + } +} +#else +void qt_blend_rgb16_on_rgb16_mips_dsp(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha) +{ + if (const_alpha == 256) { + if (w < 256) { + const quint16 *src = (const quint16*) srcPixels; + quint16 *dst = (quint16*) destPixels; + for (int y = 0; y < h; ++y) { + qt_blend_rgb16_on_rgb16_const_alpha_256_mips_dsp_asm(dst, src, w); + dst = (quint16*) (((uchar*) dst) + dbpl); + src = (quint16*) (((uchar*) src) + sbpl); + } + } + else { + int length = w << 1; + while (h--) { + memcpy(destPixels, srcPixels, length); + destPixels += dbpl; + srcPixels += sbpl; + } + } + } + else if (const_alpha != 0) { + const quint16 *src = (const quint16*) srcPixels; + quint16 *dst = (quint16*) destPixels; + for (int y = 0; y < h; ++y) { + qt_blend_rgb16_on_rgb16_mips_dsp_asm(dst, src, w, const_alpha); + dst = (quint16*) (((uchar*) dst) + dbpl); + src = (quint16*) (((uchar*) src) + sbpl); + } + } +} +#endif + void comp_func_Source_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha) { if (const_alpha == 255) { @@ -422,5 +494,28 @@ void QT_FASTCALL comp_func_SourceOut_mips_dsp(uint *dest, const uint *src, int l comp_func_SourceOut_dsp_asm_x2(dest, src, length, const_alpha); } +const uint * QT_FASTCALL qt_fetchUntransformed_888_mips_dsp (uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length) +{ + uchar *line = (uchar *)data->texture.scanLine(y) + x; + fetchUntransformed_888_asm_mips_dsp(buffer, line, length); + return buffer; +} + +const uint * QT_FASTCALL qt_fetchUntransformed_444_mips_dsp (uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length) +{ + uchar *line = (uchar *)data->texture.scanLine(y) + x; + fetchUntransformed_444_asm_mips_dsp(buffer, line, length); + return buffer; +} + +const uint * QT_FASTCALL qt_fetchUntransformed_argb8565_premultiplied_mips_dsp (uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length) +{ + uchar *line = (uchar *)data->texture.scanLine(y) + x; + fetchUntransformed_argb8565_premultiplied_asm_mips_dsp(buffer, line, length); + return buffer; +} QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper_mips_dsp_asm.S b/src/gui/painting/qdrawhelper_mips_dsp_asm.S index 64fc635970..26b48f9d62 100644 --- a/src/gui/painting/qdrawhelper_mips_dsp_asm.S +++ b/src/gui/painting/qdrawhelper_mips_dsp_asm.S @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2012 MIPS Technologies, www.mips.com, author Damir Tatalovic +** Copyright (C) 2013 Imagination Technologies Limited, www.imgtec.com ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -1601,3 +1601,479 @@ LEAF_MIPS_DSP(qt_blend_argb32_on_argb32_const_alpha_256_mips_dsp_asm) nop END(qt_blend_argb32_on_argb32_const_alpha_256_mips_dsp_asm) + + +#if defined(__MIPSEL) && __MIPSEL +# define PACK(r, s, t) packrl.ph r, s, t +# define SWHI(r, o, b) swl r, o + 1 (b) +# define SWLO(r, o, b) swr r, o + 0 (b) +# define LDHI(r, o, b) lwl r, o + 1 (b) +# define LDLO(r, o, b) lwr r, o + 2 (b) +#else +# define PACK(r, s, t) packrl.ph r, t, s +# define SWHI(r, o, b) swr r, o + 1 (b) +# define SWLO(r, o, b) swl r, o + 0 (b) +# define LDHI(r, o, b) lwr r, o + 1 (b) +# define LDLO(r, o, b) lwl r, o + 2 (b) +#endif + +LEAF_MIPS_DSP(qt_blend_rgb16_on_rgb16_const_alpha_256_mips_dsp_asm) +/* + * a0 - dst (*r5g6b5) + * a1 - src (const *r5g6b5) + * a2 - len (unsigned int) + * + * Register usage: + * t0-3 - Scratch registers + * t4 - Number of iterations to do in unrolled loops + * t5-7 - Auxiliary scratch registers. + * + * Check if base addresses of src/dst are aligned, cases: + * a) Both aligned. + * b) Both unaligned: + * 1. Copy a halfword + * 2. Use aligned case. + * c) dst aligned, src unaligned: + * 1. Read a word from dst, halfword from src. + * 2. Continue reading words from both. + * d) dst unaligned, src aligned: + * 1. Read a word from src, halfword from dst. + * 2. Continue reading words from both. + */ + + beqz a2, 0f /* if (a2:len == 0): return */ + andi t0, a0, 0x3 /* t0 = a0:dst % 4 */ + andi t1, a1, 0x3 /* t1 = a1:dst % 4 */ + or t2, t0, t1 /* t1 = t0 | t1 */ + + beqz t2, 4f /* both aligned */ + nop + beqz t0, 3f /* dst aligned, src unaligned */ + nop + beqz t1, 2f /* src aligned, dst unaligned */ + nop + + /* + * Both src/dst are unaligned: read 1 halfword from each, + * the fall-off to continue with word-aligned copy. + */ + lhu t0, 0 (a1) /* t0 <- ((uint16_t*) src)[0] */ + addiu a1, a1, 2 /* src++ */ + addiu a2, a2,-1 /* len-- */ + sh t0, 0 (a0) /* t1 -> ((uint16_t*) dst)[0] */ + addiu a0, a0, 2 /* dst++ */ + + /* + * Both src/dst pointers are word-aligned, process eight + * items at a time in an unrolled loop. + */ +4: beqz a2, 0f /* if (len == 0): return */ + srl t4, a2, 3 /* t4 = len / 8 */ + + beqz t4, 5f /* if (t4 == 0): tail */ + andi a2, a2, 0x07 /* len = len % 8 */ + +1: lw t0, 0 (a1) + lw t1, 4 (a1) + lw t2, 8 (a1) + lw t3, 12 (a1) + + addiu t4, t4, -1 /* t4-- */ + addiu a1, a1, 16 /* src += 8 */ + + sw t0, 0 (a0) + sw t1, 4 (a0) + sw t2, 8 (a0) + sw t3, 12 (a0) + + bnez t4, 1b + addiu a0, a0, 16 /* dst += 8 */ + + b 5f + nop + + + /* + * dst pointer is unaligned + */ +2: beqz a2, 0f /* if (len == 0): return */ + srl t4, a2, 3 /* t4 = len / 8 */ + beqz t4, 5f /* if (t4 == 0): tail */ + andi a2, a2, 0x07 /* len = len % 8 */ + +1: lw t0, 0 (a1) + lw t1, 4 (a1) + lw t2, 8 (a1) + lw t3, 12 (a1) + + addiu t4, t4, -1 /* t4-- */ + addiu a1, a1, 16 /* src += 8 */ + + SWLO (t0, 0, a0) + PACK (t5, t1, t0) + PACK (t6, t2, t1) + PACK (t7, t3, t2) + SWHI (t3, 14, a0) + sw t5, 2 (a0) + sw t6, 6 (a0) + sw t7, 10 (a0) + + bnez t4, 1b + addiu a0, a0, 16 /* dst += 8 */ + + b 5f + nop + + /* + * src pointer is unaligned + */ +3: beqz a2, 0f /* if (len == 0): return */ + srl t4, a2, 3 /* t4 = len / 8 */ + beqz t4, 5f /* if (t4 == 0): tail */ + andi a2, a2, 0x07 /* len = len % 8 */ + +1: LDHI (t0, 0, a1) + lw t1, 2 (a1) + lw t2, 6 (a1) + lw t3, 10 (a1) + LDLO (t5, 12, a1) + + addiu t4, t4, -1 /* t4-- */ + addiu a1, a1, 16 /* src += 8 */ + + PACK (t0, t1, t0) + PACK (t6, t2, t1) + PACK (t7, t3, t2) + sw t0, 0 (a0) + PACK (t0, t5, t3) + sw t6, 4 (a0) + sw t7, 8 (a0) + sw t0, 12 (a0) + + bnez t4, 1b + addiu a0, a0, 16 /* dst += 8 */ + + +5: /* Process remaining items (a2:len < 4), one at a time */ + beqz a2, 0f + nop + +1: lhu t0, 0 (a1) /* t0 <- ((uint16_t*) src)[0] */ + addiu a2, a2,-1 /* len-- */ + addiu a1, a1, 2 /* src++ */ + sh t0, 0 (a0) /* to -> ((uint16_t*) dst)[0] */ + bnez a2, 1b /* if (len != 0): loop */ + addiu a0, a0, 2 /* dst++ */ + +0: jr ra + nop + +END(qt_blend_rgb16_on_rgb16_const_alpha_256_mips_dsp_asm) + + +#undef LDHI +#undef LDLO +#undef PACK +#undef SWHI +#undef SWLO + + +LEAF_MIPS_DSP(qt_blend_rgb16_on_rgb16_mips_dsp_asm) +/* + * a0 - dst (*r5g6b5) + * a1 - src (const *r5g6b5) + * a2 - len (unsigned int) - batch length + * a3 - alpha (int) + */ + + beqz a2, 2f + li t9, 255 + sll t8, a3, 8 + subu a3, t8, a3 + srl a3, a3, 8 + subu t9, t9, a3 + addiu a3, a3, 1 + srl t4, a3, 2 + addiu t9, t9, 1 + srl t5, t9, 2 +1: + lhu t0, 0(a1) + lhu t1, 0(a0) + addiu a2, a2, -1 + andi t2, t0, 0x07e0 + andi t0, t0, 0xf81f + mul t2, t2, a3 + mul t0, t0, t4 + andi t3, t1, 0x07e0 + andi t1, t1, 0xf81f + mul t3, t3, t9 + mul t1, t1, t5 + addiu a1, a1, 2 + srl t2, t2, 8 + srl t0, t0, 6 + andi t2, t2, 0x07e0 + andi t0, t0, 0xf81f + or t0, t0, t2 + srl t3, t3, 8 + srl t1, t1, 6 + andi t3, t3, 0x07e0 + andi t1, t1, 0xf81f + or t1, t1, t3 + addu t0, t0, t1 + sh t0, 0(a0) + bgtz a2, 1b + addiu a0, a0, 2 +2: + jr ra + nop + +END(qt_blend_rgb16_on_rgb16_mips_dsp_asm) + + +LEAF_MIPS_DSP(fetchUntransformed_888_asm_mips_dsp) +/* + * a0 - dst address (address of 32-bit aRGB value) + * a1 - src address + * a2 - length + */ + + beqz a2, 4f + lui t8, 0xff00 + andi t0, a2, 0x1 + beqz t0, 1f + nop +/* case for one pixel */ + lbu t1, 0(a1) + lbu v1, 2(a1) + lbu t0, 1(a1) + addiu a1, a1, 3 + addiu a2, a2, -1 + sll t1, t1, 0x10 + or v1, v1, t8 + sll t0, t0, 0x8 + or v1, v1, t1 + or v1, v1, t0 + sw v1, 0(a0) + addiu a0, a0, 4 + + beqz a2, 4f /* only one pixel is present (length = 1) */ + nop +1: + andi t0, a1, 0x1 + beqz t0, 3f + nop +2: + lbu t0, 0(a1) /* t0 = | 0 | 0 | 0 | R1 | */ + lhu t1, 1(a1) /* t1 = | 0 | 0 | B1 | G1 | */ + addiu a1, a1, 3 + lhu t2, 0(a1) /* t2 = | 0 | 0 | G2 | R2 | */ + lbu t3, 2(a1) /* t3 = | 0 | 0 | 0 | B2 | */ + + sll t0, t0, 16 + or t0, t0, t8 /* t0 = | ff | R1 | 0 | 0 | */ + shll.ph t4, t1, 8 /* t4 = | 0 | 0 | G1 | 0 | */ + srl t5, t1, 8 + or t4, t4, t5 /* t4 = | 0 | 0 | G1 | B1 | */ + or t0, t0, t4 /* t0 = | ff | R1 | G1 | B1 | */ + + shll.ph t4, t2, 8 /* t4 = | 0 | 0 | R2 | 0 | */ + srl t5, t2, 8 /* t5 = | 0 | 0 | 0 | G2 | */ + or t4, t4, t5 + sll t4, t4, 8 /* t4 = | 0 | R2 | G2 | 0 | */ + or t5, t3, t8 + or t2, t4, t5 /* t2 = | ff | R2 | G2 | B2 | */ + + sw t0, 0(a0) + addiu a1, a1, 3 + sw t2, 4(a0) + addiu a2, a2, -2 + bnez a2, 2b + addiu a0, a0, 8 + b 4f + nop +3: + lhu t0, 0(a1) /* t0 = | 0 | 0 | G1 | R1 | */ + lbu t1, 2(a1) /* t1 = | 0 | 0 | 0 | B1 | */ + addiu a1, a1, 3 + lbu t2, 0(a1) /* t2 = | 0 | 0 | 0 | R2 | */ + lhu t3, 1(a1) /* t3 = | 0 | 0 | B2 | G2 | */ + + srl t4, t0, 8 /* t4 = | 0 | 0 | 0 | G1 | */ + shll.ph t5, t0, 8 /* t5 = | 0 | 0 | R1 | 0 | */ + or t0, t4, t5 + sll t6, t0, 8 /* t6 = | 0 | R1 | G1 | 0 | */ + or t4, t1, t8 /* t4 = | ff | 0 | 0 | B1 | */ + or t0, t6, t4 + + sll t2, t2, 16 + srl t4, t3, 8 + shll.ph t5, t3, 8 + or t3, t4, t5 + or t2, t2, t3 + or t2, t2, t8 + + sw t0, 0(a0) + addiu a1, a1, 3 + sw t2, 4(a0) + addiu a2, a2, -2 + bnez a2, 3b + addiu a0, a0, 8 +4: + jr ra + nop + +END(fetchUntransformed_888_asm_mips_dsp) + + +LEAF_MIPS_DSP(fetchUntransformed_444_asm_mips_dsp) +/* + * a0 - dst address (address of 32-bit aRGB value) + * a1 - src address + * a2 - length + */ + + lui t8, 0xff00 + li t4, 0x1 + + beqz a2, 5f + move v0, a0 /* just return the address of buffer + * for storing returning values */ + andi t0, a2, 0x1 + beqz t0, 2f /* there is more then one pixel + * (check src memory alignment (word)) */ + nop +1: + lhu v0, 0(a1) + addiu a1, a1, 2 + addiu a2, a2, -1 + andi t0, v0, 0xf00 + andi v1, v0, 0xf + andi v0, v0, 0xf0 + sra t3, t0, 0x4 + sra t1, v0, 0x4 + sra t0, t0, 0x8 + sll t2, v1, 0x4 + or t0, t0, t3 + or v0, t1, v0 + lui t1, 0xff00 + or v1, t2, v1 + sll t0, t0, 0x10 + or v1, v1, t1 + sll v0, v0, 0x8 + or v1, v1, t0 + or v0, v1, v0 + sw v0, 0(a0) + addiu a0, a0, 4 + beqz a2, 5f /* no more pixels for processing */ + nop + beq a2, t4, 4f /* only one more pixel remained */ + nop +/* check if src memory address is word aligned */ +2: + andi t0, a1, 0x3 + beqz t0, 3f /* memory is word aligned */ + andi a3, a2, 0x1 /* set the a3 register as the comparation + * for ending the unrolled loop + * (1 if odd, 0 if even) */ + b 1b /* not word aligned, + * go another turn with + * just one pixel processing */ + nop +3: + lw t0, 0(a1) + addiu a2, a2, -2 + preceu.ph.qbr t1, t0 /* t1 = | 0 | aR1 | 0 | G1B1 | */ + preceu.ph.qbl t2, t0 /* t1 = | 0 | aR2 | 0 | G2B2 | */ + shll.qb t3, t1, 4 /* t3 = | 0 | R1 0 | 0 | B1 0 | */ + srl t4, t3, 4 + or t0, t3, t4 /* t0 = | 0 | R1R1 | 0 | B1B1 | */ + andi t3, t1, 0xf0 + sll t3, t3, 8 + srl t4, t3, 4 + or t1, t3, t4 + or t0, t0, t1 /* t0 = | 0 | R1R1 | G1G1 | B1B1 | */ + or t0, t0, t8 /* t0 = | ff | R1R1 | G1G1 | B1B1 | */ + + shll.qb t3, t2, 4 /* t3 = | 0 | R1 0 | 0 | B1 0 | */ + srl t4, t3, 4 + or t7, t3, t4 /* t0 = | 0 | R1R1 | 0 | B1B1 | */ + andi t3, t2, 0xf0 + sll t3, t3, 8 + srl t4, t3, 4 + or t1, t3, t4 + or t2, t7, t1 /* t0 = | 0 | R1R1 | G1G1 | B1B1 | */ + or t2, t2, t8 /* t0 = | ff | R1R1 | G1G1 | B1B1 | */ + + sw t0, 0(a0) + addiu a1, a1, 4 + sw t2, 4(a0) + bne a2, a3, 3b + addiu a0, a0, 8 + beqz a2, 5f /* no more pixels for processing */ + nop +4: +/* one more pixel remained (after loop unrolling process finished) */ + lhu v0, 0(a1) + addiu a1, a1, 2 + addiu a2, a2, -1 + andi t0, v0, 0xf00 + andi v1, v0, 0xf + andi v0, v0, 0xf0 + sra t3, t0, 0x4 + sra t1, v0, 0x4 + sra t0, t0, 0x8 + sll t2, v1, 0x4 + or t0, t0, t3 + or v0, t1, v0 + lui t1, 0xff00 + or v1, t2, v1 + sll t0, t0, 0x10 + or v1, v1, t1 + sll v0, v0, 0x8 + or v1, v1, t0 + or v0, v1, v0 + sw v0, 0(a0) + addiu a0, a0, 4 +5: + jr ra + nop + +END(fetchUntransformed_444_asm_mips_dsp) + + +LEAF_MIPS_DSP(fetchUntransformed_argb8565_premultiplied_asm_mips_dsp) +/* + * a0 - dst address + * a1 - src address + * a2 - length + */ + + beqz a2, 2f + nop + +1: + ulh t1, 0(a1) + lbu t2, 2(a1) + addiu a2, a2, -1 + wsbh t1, t1 + sll t0, t1, 8 /* t0 = 00000000rrrrrggggggbbbbb00000000 */ + ins t0, t1, 3, 16 /* t0 = 00000000rrrrrrrrrrggggggbbbbb000 */ + ins t0, t1, 5, 11 /* t0 = 00000000rrrrrrrrggggggbbbbbbb000 */ + srl t4, t1, 9 /* t4 = 0000000000000000000000000rrrrrgg */ + replv.qb t3, t2 + ins t0, t4, 8, 2 /* t0 = 00000000rrrrrrrrggggggggbbbbb000 */ + ins t0, t1, 3, 5 /* t0 = 00000000rrrrrrrrggggggggbbbbb000 */ + srl t4, t1, 2 /* t4 = 000000000000000000rrrrrggggggbbb */ + ins t0, t4, 0, 3 /* t0 = 00000000rrrrrrrrggggggggbbbbbbbb */ + ins t0, t2, 24, 8 /* t0 =aaaaaaaarrrrrrrrggggggggbbbbbbbb */ + cmpu.lt.qb t3, t0 + pick.qb t0, t3, t0 + addiu a1, a1, 3 + sw t0, 0(a0) + bgtz a2, 1b + addiu a0, a0, 4 +2: + jr ra + nop + +END(fetchUntransformed_argb8565_premultiplied_asm_mips_dsp) diff --git a/src/gui/painting/qdrawhelper_mips_dsp_p.h b/src/gui/painting/qdrawhelper_mips_dsp_p.h index 2df7d4920a..3dceb7793d 100644 --- a/src/gui/painting/qdrawhelper_mips_dsp_p.h +++ b/src/gui/painting/qdrawhelper_mips_dsp_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2012 MIPS Technologies, www.mips.com, author Damir Tatalovic +** Copyright (C) 2013 Imagination Technologies Limited, www.imgtec.com ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -101,19 +101,34 @@ extern "C" void qt_blend_argb32_on_argb32_mips_dsp_asm_x2(uint *dest, const uint extern "C" void qt_blend_argb32_on_argb32_const_alpha_256_mips_dsp_asm(uint *dest, const uint *src, int length); +extern "C" void qt_blend_rgb16_on_rgb16_const_alpha_256_mips_dsp_asm(quint16 *dest, const quint16 *src, int length); + +extern "C" void qt_blend_rgb16_on_rgb16_mips_dsp_asm(quint16 *dest, const quint16 *src, int length, uint const_alpha); + extern "C" uint * destfetchARGB32_asm_mips_dsp(uint *buffer, const uint *data, int length); extern "C" uint * qt_destStoreARGB32_asm_mips_dsp(uint *buffer, const uint *data, int length); +extern "C" uint * fetchUntransformed_888_asm_mips_dsp(uint *buffer, const uchar *line, int length); + +extern "C" uint * fetchUntransformed_444_asm_mips_dsp(uint *buffer, const uchar *line, int length); + +extern "C" uint * fetchUntransformed_argb8565_premultiplied_asm_mips_dsp(uint *buffer, const uchar *line, int length); + void qt_blend_argb32_on_argb32_mips_dsp(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha); void qt_blend_rgb32_on_rgb32_mips_dsp(uchar *destPixels, int dbpl, - const uchar *srcPixels, int sbpl, - int w, int h, - int const_alpha); + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + +void qt_blend_rgb16_on_rgb16_mips_dsp(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); void comp_func_Source_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha); @@ -164,6 +179,21 @@ void QT_FASTCALL comp_func_SourceOut_mips_dsp(uint *dest, const uint *src, int l void QT_FASTCALL comp_func_XOR_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha); +const uint * QT_FASTCALL qt_fetchUntransformed_888_mips_dsp (uint *buffer, + const Operator *, + const QSpanData *data, + int y, int x, int length); + +const uint * QT_FASTCALL qt_fetchUntransformed_444_mips_dsp (uint *buffer, + const Operator *, + const QSpanData *data, + int y, int x, int length); + +const uint * QT_FASTCALL qt_fetchUntransformed_argb8565_premultiplied_mips_dsp (uint *buffer, + const Operator *, + const QSpanData *data, + int y, int x, int length); + #endif // QT_COMPILER_SUPPORTS_MIPS_DSP @@ -171,6 +201,13 @@ void QT_FASTCALL comp_func_XOR_mips_dsp(uint *dest, const uint *src, int length, extern "C" void qConvertRgb16To32_asm_mips_dspr2(quint32 *dest, const quint16 *src, int length); +extern "C" void qt_blend_rgb16_on_rgb16_mips_dspr2_asm(quint16 *dest, const quint16 *src, int length, uint const_alpha); + +void qt_blend_rgb16_on_rgb16_mips_dspr2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + #endif // QT_COMPILER_SUPPORTS_MIPS_DSPR2 QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper_mips_dspr2_asm.S b/src/gui/painting/qdrawhelper_mips_dspr2_asm.S index ec220732be..c7a603eebe 100644 --- a/src/gui/painting/qdrawhelper_mips_dspr2_asm.S +++ b/src/gui/painting/qdrawhelper_mips_dspr2_asm.S @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2012 MIPS Technologies, www.mips.com, author Damir Tatalovic +** Copyright (C) 2013 Imagination Technologies Limited, www.imgtec.com ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -122,3 +122,551 @@ LEAF_MIPS_DSPR2(qConvertRgb16To32_asm_mips_dspr2) nop END(qConvertRgb16To32_asm_mips_dspr2) + + +#if defined(__MIPSEL) && __MIPSEL +# define PACK(r, s, t) packrl.ph r, s, t +# define LDHI(r, o, b) lwl r, o + 1 (b) +# define LDLO(r, o, b) lwr r, o + 2 (b) +#else +# define PACK(r, s, t) packrl.ph r, t, s +# define LDHI(r, o, b) lwr r, o + 1 (b) +# define LDLO(r, o, b) lwl r, o + 2 (b) +#endif + + +LEAF_MIPS_DSPR2(qt_blend_rgb16_on_rgb16_mips_dspr2_asm) +/* ++ * a0 - dst (*r5g6b5) + * a1 - src (const *r5g6b5) + * a2 - len (unsigned int) - batch length + * a3 - alpha (int) + * + * Register usage: + * t0-3 - Scratch registers + * t4 - Number of iterations to do in unrolled loops + * t5 - Inverse alpha + * t6 - Alpha >> 2 + * t7 - Inverse alpha >> 2 + * t8 - magic1 (0x07e007e0) + * t9 - magic2 (0xf81ff81f) + * + * NOTE: + * Cannot use DSP instructions for the multiplication of two + * 16-bit values: overflow would be always rounded or saturated. + */ + + beqz a2, 0f + andi t0, a0, 0x3 + andi t1, a1, 0x3 + /* Adjust alpha value, and calculate inverse alpha value */ + li t5, 255 + or t2, t0, t1 /* t0 = (dst & 0x3) | (src & 0x3) */ + sll t8, a3, 8 + subu a3, t8, a3 + li t8, 0x07e007e0 /* magic1 */ + srl a3, a3, 8 /* alpha >>= 8 */ + li t9, 0xf81ff81f /* magic2 */ + subu t5, t5, a3 /* ialpha = 255 - alpha */ + addiu a3, a3, 1 /* alpha++ */ + addiu t5, t5, 1 /* ialpha++ */ + srl t6, a3, 2 /* ashift = alpha >> 2 */ + + beqz t2, 4f /* both aligned */ + srl t7, t5, 2 /* iashift = ialpha >> 2 */ + + beqz t1, 2f /* src aligned, dst unaligned */ + nop + + beqz t0, 3f /* dst aligned, src unaligned */ + nop + + /* + * Both src/dst are unaligned: read 1 halfword from each, then + * fall-off to continue with word-aligned operation. + */ + lhu t1, 0 (a1) + lhu t0, 0 (a0) + addiu a2, a2, -1 /* len-- */ + andi t2, t1, 0x07e0 + andi t1, t1, 0xf81f + mul t2, t2, a3 + mul t1, t1, t6 + andi t3, t0, 0x07e0 + andi t0, t0, 0xf81f + mul t3, t3, t5 + mul t0, t0, t7 + addiu a1, a1, 2 /* src++ */ + srl t2, t2, 8 + srl t1, t1, 6 + andi t2, t2, 0x07e0 + andi t1, t1, 0xf81f + or t1, t1, t2 + srl t3, t3, 8 + srl t0, t0, 6 + andi t3, t3, 0x07e0 + andi t0, t0, 0xf81f + or t0, t0, t3 + addu t0, t0, t1 /* src * alpha + dst * ialpha */ + sh t0, 0 (a0) + addiu a0, a0, 2 /* dst++ */ + + /* + * Both src/dst pointers are word-aligned, process eight + * items at a time in an unrolled loop. + */ +4: beqz a2, 0f + srl t4, a2, 3 /* t4 = len / 8 */ + beqz t4, 5f + andi a2, a2, 0x7 /* len = len % 8 */ + SAVE_REGS_ON_STACK 12, s0, s1, s2, s3, s4, v0, v1 + +1: lw t1, 0 (a1) /* [s0, s1] */ + lw v1, 4 (a1) /* [s2, s3] */ + lw s1, 8 (a1) /* [s4, s5] */ + lw s3, 12 (a1) /* [s6, s7] */ + + lw t0, 0 (a0) /* [d0, d1] */ + lw v0, 4 (a0) /* [d2, d3] */ + lw s0, 8 (a0) /* [d4, d5] */ + lw s2, 12 (a0) /* [d6, d7] */ + + pref 4, 16 (a1) + pref 5, 16 (a0) + + and t2, t1, t8 + ext t3, t2, 0, 16 + srl t2, t2, 16 + mul t3, t3, a3 + mul t2, t2, a3 + and t1, t1, t9 + ext s4, t1, 0, 16 + mul s4, s4, t6 + srl t1, t1, 16 + mul t1, t1, t6 + srl t3, t3, 8 + srl t2, t2, 8 + append t2, t3, 16 + and t2, t2, t8 + srl s4, s4, 6 + and t3, v1, t8 + srl t1, t1, 6 + append t1, s4, 16 + and t1, t1, t9 + or t1, t1, t2 + ext t2, t3, 0, 16 + srl t3, t3, 16 + mul t2, t2, a3 + mul t3, t3, a3 + and v1, v1, t9 + ext s4, v1, 0, 16 + mul s4, s4, t6 + srl v1, v1, 16 + mul v1, v1, t6 + srl t2, t2, 8 + srl t3, t3, 8 + append t3, t2, 16 + and t3, t3, t8 + srl s4, s4, 6 + and t2, s1, t8 + srl v1, v1, 6 + append v1, s4, 16 + and v1, v1, t9 + or v1, v1, t3 + ext t3, t2, 0, 16 + srl t2, t2, 16 + mul t3, t3, a3 + mul t2, t2, a3 + and s1, s1, t9 + ext s4, s1, 0, 16 + mul s4, s4, t6 + srl s1, s1, 16 + mul s1, s1, t6 + srl t3, t3, 8 + srl t2, t2, 8 + append t2, t3, 16 + and t2, t2, t8 + srl s4, s4, 6 + and t3, s3, t8 + srl s1, s1, 6 + append s1, s4, 16 + and s1, s1, t9 + or s1, s1, t2 + ext t2, t3, 0, 16 + srl t3, t3, 16 + mul t2, t2, a3 + mul t3, t3, a3 + and s3, s3, t9 + ext s4, s3, 0, 16 + mul s4, s4, t6 + srl s3, s3, 16 + mul s3, s3, t6 + srl t2, t2, 8 + srl t3, t3, 8 + append t3, t2, 16 + and t3, t3, t8 + srl s4, s4, 6 + and t2, t0, t8 + srl s3, s3, 6 + append s3, s4, 16 + and s3, s3, t9 + or s3, s3, t3 + ext t3, t2, 0, 16 + srl t2, t2, 16 + mul t3, t3, t5 + mul t2, t2, t5 + and t0, t0, t9 + ext s4, t0, 0, 16 + mul s4, s4, t7 + srl t0, t0, 16 + mul t0, t0, t7 + srl t3, t3, 8 + srl t2, t2, 8 + append t2, t3, 16 + and t2, t2, t8 + srl s4, s4, 6 + and t3, v0, t8 + srl t0, t0, 6 + append t0, s4, 16 + and t0, t0, t9 + or t0, t0, t2 + ext t2, t3, 0, 16 + srl t3, t3, 16 + mul t2, t2, t5 + mul t3, t3, t5 + and v0, v0, t9 + ext s4, v0, 0, 16 + mul s4, s4, t7 + srl v0, v0, 16 + mul v0, v0, t7 + srl t2, t2, 8 + srl t3, t3, 8 + append t3, t2, 16 + and t3, t3, t8 + srl s4, s4, 6 + and t2, s0, t8 + srl v0, v0, 6 + append v0, s4, 16 + and v0, v0, t9 + or v0, v0, t3 + ext t3, t2, 0, 16 + srl t2, t2, 16 + mul t3, t3, t5 + mul t2, t2, t5 + and s0, s0, t9 + ext s4, s0, 0, 16 + mul s4, s4, t7 + srl s0, s0, 16 + mul s0, s0, t7 + srl t3, t3, 8 + srl t2, t2, 8 + append t2, t3, 16 + and t2, t2, t8 + srl s4, s4, 6 + and t3, s2, t8 + srl s0, s0, 6 + append s0, s4, 16 + and s0, s0, t9 + or s0, s0, t2 + ext t2, t3, 0, 16 + srl t3, t3, 16 + mul t2, t2, t5 + mul t3, t3, t5 + and s2, s2, t9 + ext s4, s2, 0, 16 + mul s4, s4, t7 + srl s2, s2, 16 + mul s2, s2, t7 + srl t2, t2, 8 + srl t3, t3, 8 + append t3, t2, 16 + and t3, t3, t8 + srl s4, s4, 6 + addu.ph t0, t0, t1 + srl s2, s2, 6 + append s2, s4, 16 + and s2, s2, t9 + or s2, s2, t3 + addu.ph v0, v0, v1 /* v0 = [S2 + D2, S3 + D3] */ + addu.ph s0, s0, s1 /* s0 = [S4 + D4, S5 + D5] */ + addu.ph s2, s2, s3 /* s2 = [S6 + D6, S7 + D7] */ + + sw t0, 0 (a0) /* [SS0, SS1] */ + sw v0, 4 (a0) /* [SS2, SS3] */ + sw s0, 8 (a0) /* [SS4, SS5] */ + sw s2, 12 (a0) /* [SS6, SS7] */ + + addiu t4, t4, -1 /* t4-- */ + addiu a1, a1, 16 /* src += 8 */ + + bnez t4, 1b + addiu a0, a0, 16 /* dst += 8 */ + + RESTORE_REGS_FROM_STACK 12, s0, s1, s2, s3, s4, v0, v1 + b 5f + nop + + + /* dst unaligned: do one item and fall down to the src unaligned case */ +2: lhu t1, 0 (a1) + lhu t0, 0 (a0) + addiu a2, a2, -1 /* len-- */ + andi t2, t1, 0x07e0 + andi t1, t1, 0xf81f + mul t2, t2, a3 + mul t1, t1, t6 + andi t3, t0, 0x07e0 + andi t0, t0, 0xf81f + mul t3, t3, t5 + mul t0, t0, t7 + addiu a1, a1, 2 /* src++ */ + srl t2, t2, 8 + srl t1, t1, 6 + andi t2, t2, 0x07e0 + andi t1, t1, 0xf81f + or t1, t1, t2 + srl t3, t3, 8 + srl t0, t0, 6 + andi t3, t3, 0x07e0 + andi t0, t0, 0xf81f + or t0, t0, t3 + addu t0, t0, t1 /* src * alpha + dst * ialpha */ + sh t0, 0 (a0) + addiu a0, a0, 2 /* dst++ */ + + /* src unaligned */ +3: beqz a2, 0f + srl t4, a2, 3 /* t4 = len / 8 */ + beqz t4, 5f + andi a2, a2, 0x7 /* len = len % 8 */ + SAVE_REGS_ON_STACK 12, s0, s1, s2, s3, s4, v0, v1 + +1: lw t0, 0 (a0) /* [d0, d1] */ + lw v0, 4 (a0) /* [d2, d3] */ + lw s0, 8 (a0) /* [d4, d5] */ + lw s2, 12 (a0) /* [d6, d7] */ + + LDHI (t1, 0, a1) /* [s0, __] */ + lw v1, 2 (a1) /* [s1, s2] */ + lw s1, 6 (a1) /* [s3, s4] */ + lw s3, 10 (a1) /* [s5, s6] */ + LDLO (s4, 12, a1) /* [__, s7] */ + + pref 4, 14 (a1) + pref 5, 16 (a0) + + PACK (t1, v1, t1) /* [s0, s1] */ + PACK (v1, s1, v1) /* [s2, s3] */ + PACK (s1, s3, s1) /* [s4, s5] */ + PACK (s3, s4, s3) /* [s6, s7] */ + + and t2, t1, t8 + ext t3, t2, 0, 16 + srl t2, t2, 16 + mul t3, t3, a3 + mul t2, t2, a3 + and t1, t1, t9 + ext s4, t1, 0, 16 + mul s4, s4, t6 + srl t1, t1, 16 + mul t1, t1, t6 + srl t3, t3, 8 + srl t2, t2, 8 + append t2, t3, 16 + and t2, t2, t8 + srl s4, s4, 6 + and t3, v1, t8 + srl t1, t1, 6 + append t1, s4, 16 + and t1, t1, t9 + or t1, t1, t2 + ext t2, t3, 0, 16 + srl t3, t3, 16 + mul t2, t2, a3 + mul t3, t3, a3 + and v1, v1, t9 + ext s4, v1, 0, 16 + mul s4, s4, t6 + srl v1, v1, 16 + mul v1, v1, t6 + srl t2, t2, 8 + srl t3, t3, 8 + append t3, t2, 16 + and t3, t3, t8 + srl s4, s4, 6 + and t2, s1, t8 + srl v1, v1, 6 + append v1, s4, 16 + and v1, v1, t9 + or v1, v1, t3 + ext t3, t2, 0, 16 + srl t2, t2, 16 + mul t3, t3, a3 + mul t2, t2, a3 + and s1, s1, t9 + ext s4, s1, 0, 16 + mul s4, s4, t6 + srl s1, s1, 16 + mul s1, s1, t6 + srl t3, t3, 8 + srl t2, t2, 8 + append t2, t3, 16 + and t2, t2, t8 + srl s4, s4, 6 + and t3, s3, t8 + srl s1, s1, 6 + append s1, s4, 16 + and s1, s1, t9 + or s1, s1, t2 + ext t2, t3, 0, 16 + srl t3, t3, 16 + mul t2, t2, a3 + mul t3, t3, a3 + and s3, s3, t9 + ext s4, s3, 0, 16 + mul s4, s4, t6 + srl s3, s3, 16 + mul s3, s3, t6 + srl t2, t2, 8 + srl t3, t3, 8 + append t3, t2, 16 + and t3, t3, t8 + srl s4, s4, 6 + and t2, t0, t8 + srl s3, s3, 6 + append s3, s4, 16 + and s3, s3, t9 + or s3, s3, t3 + ext t3, t2, 0, 16 + srl t2, t2, 16 + mul t3, t3, t5 + mul t2, t2, t5 + and t0, t0, t9 + ext s4, t0, 0, 16 + mul s4, s4, t7 + srl t0, t0, 16 + mul t0, t0, t7 + srl t3, t3, 8 + srl t2, t2, 8 + append t2, t3, 16 + and t2, t2, t8 + srl s4, s4, 6 + and t3, v0, t8 + srl t0, t0, 6 + append t0, s4, 16 + and t0, t0, t9 + or t0, t0, t2 + ext t2, t3, 0, 16 + srl t3, t3, 16 + mul t2, t2, t5 + mul t3, t3, t5 + and v0, v0, t9 + ext s4, v0, 0, 16 + mul s4, s4, t7 + srl v0, v0, 16 + mul v0, v0, t7 + srl t2, t2, 8 + srl t3, t3, 8 + append t3, t2, 16 + and t3, t3, t8 + srl s4, s4, 6 + and t2, s0, t8 + srl v0, v0, 6 + append v0, s4, 16 + and v0, v0, t9 + or v0, v0, t3 + ext t3, t2, 0, 16 + srl t2, t2, 16 + mul t3, t3, t5 + mul t2, t2, t5 + and s0, s0, t9 + ext s4, s0, 0, 16 + mul s4, s4, t7 + srl s0, s0, 16 + mul s0, s0, t7 + srl t3, t3, 8 + srl t2, t2, 8 + append t2, t3, 16 + and t2, t2, t8 + srl s4, s4, 6 + and t3, s2, t8 + srl s0, s0, 6 + append s0, s4, 16 + and s0, s0, t9 + or s0, s0, t2 + ext t2, t3, 0, 16 + srl t3, t3, 16 + mul t2, t2, t5 + mul t3, t3, t5 + and s2, s2, t9 + ext s4, s2, 0, 16 + mul s4, s4, t7 + srl s2, s2, 16 + mul s2, s2, t7 + srl t2, t2, 8 + srl t3, t3, 8 + append t3, t2, 16 + and t3, t3, t8 + srl s4, s4, 6 + addu.ph t0, t0, t1 + srl s2, s2, 6 + append s2, s4, 16 + and s2, s2, t9 + or s2, s2, t3 + addu.ph v0, v0, v1 /* v0 = [S2 + D2, S3 + D3] */ + addu.ph s0, s0, s1 /* s0 = [S4 + D4, S5 + D5] */ + addu.ph s2, s2, s3 /* s2 = [S6 + D6, S7 + D7] */ + + sw t0, 0 (a0) /* [SS0, SS1] */ + sw v0, 4 (a0) /* [SS2, SS3] */ + sw s0, 8 (a0) /* [SS4, SS5] */ + sw s2, 12 (a0) /* [SS6, SS7] */ + + addiu t4, t4, -1 /* t4-- */ + addiu a1, a1, 16 /* src += 8 */ + + bnez t4, 1b + addiu a0, a0, 16 /* dst += 8 */ + + RESTORE_REGS_FROM_STACK 12, s0, s1, s2, s3, s4, v0, v1 + +5: /* Process remaining items (len < 8), one at a time */ + beqz a2, 0f + nop + +1: lhu t1, 0 (a1) + lhu t0, 0 (a0) + addiu a1, a1, 2 /* src++ */ + andi t2, t1, 0x07e0 + andi t1, t1, 0xf81f + mul t2, t2, a3 + mul t1, t1, t6 + andi t3, t0, 0x07e0 + andi t0, t0, 0xf81f + mul t3, t3, t5 + mul t0, t0, t7 + addiu a2, a2, -1 /* len-- */ + srl t2, t2, 8 + srl t1, t1, 6 + andi t2, t2, 0x07e0 + andi t1, t1, 0xf81f + or t1, t1, t2 + srl t3, t3, 8 + srl t0, t0, 6 + andi t3, t3, 0x07e0 + andi t0, t0, 0xf81f + or t0, t0, t3 + + addu t0, t0, t1 /* src*alpha + dst*ialpha */ + sh t0, 0 (a0) + bnez a2, 1b + addiu a0, a0, 2 /* dst++ */ + +0: jr ra + nop + +END(qt_blend_rgb16_on_rgb16_mips_dspr2_asm) + +#undef PACK +#undef LDHI +#undef LDLO diff --git a/src/gui/painting/qt_mips_asm_dsp_p.h b/src/gui/painting/qt_mips_asm_dsp_p.h index 1b78eaf52c..54fcfab206 100644 --- a/src/gui/painting/qt_mips_asm_dsp_p.h +++ b/src/gui/painting/qt_mips_asm_dsp_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2012 MIPS Technologies, www.mips.com, author Damir Tatalovic +** Copyright (C) 2013 Imagination Technologies Limited, www.imgtec.com ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -261,4 +261,168 @@ LEAF_MIPS32R2(symbol) \ or \out_1, \scratch1, \scratch3 .endm +/* + * Checks if stack offset is big enough for storing/restoring regs_num + * number of register to/from stack. Stack offset must be greater than + * or equal to the number of bytes needed for storing registers (regs_num*4). + * Since MIPS ABI allows usage of first 16 bytes of stack frame (this is + * preserved for input arguments of the functions, already stored in a0-a3), + * stack size can be further optimized by utilizing this space. + */ +.macro CHECK_STACK_OFFSET regs_num, stack_offset +.if \stack_offset < \regs_num * 4 - 16 +.error "Stack offset too small." +.endif +.endm + +/* + * Saves set of registers on stack. Maximum number of registers that + * can be saved on stack is limitted to 14 (a0-a3, v0-v1 and s0-s7). + * Stack offset is number of bytes that are added to stack pointer (sp) + * before registers are pushed in order to provide enough space on stack + * (offset must be multiple of 4, and must be big enough, as described by + * CHECK_STACK_OFFSET macro). This macro is intended to be used in + * combination with RESTORE_REGS_FROM_STACK macro. Example: + * SAVE_REGS_ON_STACK 4, v0, v1, s0, s1 + * RESTORE_REGS_FROM_STACK 4, v0, v1, s0, s1 + */ +.macro SAVE_REGS_ON_STACK stack_offset = 0, r1, \ + r2 = 0, r3 = 0, r4 = 0, \ + r5 = 0, r6 = 0, r7 = 0, \ + r8 = 0, r9 = 0, r10 = 0, \ + r11 = 0, r12 = 0, r13 = 0, \ + r14 = 0 + .if (\stack_offset < 0) || (\stack_offset - (\stack_offset / 4) * 4) + .error "Stack offset must be positive and multiple of 4." + .endif + .if \stack_offset != 0 + addiu sp, sp, -\stack_offset + .endif + sw \r1, 0(sp) + .if \r2 != 0 + sw \r2, 4(sp) + .endif + .if \r3 != 0 + sw \r3, 8(sp) + .endif + .if \r4 != 0 + sw \r4, 12(sp) + .endif + .if \r5 != 0 + CHECK_STACK_OFFSET 5, \stack_offset + sw \r5, 16(sp) + .endif + .if \r6 != 0 + CHECK_STACK_OFFSET 6, \stack_offset + sw \r6, 20(sp) + .endif + .if \r7 != 0 + CHECK_STACK_OFFSET 7, \stack_offset + sw \r7, 24(sp) + .endif + .if \r8 != 0 + CHECK_STACK_OFFSET 8, \stack_offset + sw \r8, 28(sp) + .endif + .if \r9 != 0 + CHECK_STACK_OFFSET 9, \stack_offset + sw \r9, 32(sp) + .endif + .if \r10 != 0 + CHECK_STACK_OFFSET 10, \stack_offset + sw \r10, 36(sp) + .endif + .if \r11 != 0 + CHECK_STACK_OFFSET 11, \stack_offset + sw \r11, 40(sp) + .endif + .if \r12 != 0 + CHECK_STACK_OFFSET 12, \stack_offset + sw \r12, 44(sp) + .endif + .if \r13 != 0 + CHECK_STACK_OFFSET 13, \stack_offset + sw \r13, 48(sp) + .endif + .if \r14 != 0 + CHECK_STACK_OFFSET 14, \stack_offset + sw \r14, 52(sp) + .endif +.endm + +/* + * Restores set of registers from stack. Maximum number of registers that + * can be restored from stack is limitted to 14 (a0-a3, v0-v1 and s0-s7). + * Stack offset is number of bytes that are added to stack pointer (sp) + * after registers are restored (offset must be multiple of 4, and must + * be big enough, as described by CHECK_STACK_OFFSET macro). This macro is + * intended to be used in combination with RESTORE_REGS_FROM_STACK macro. + * Example: + * SAVE_REGS_ON_STACK 4, v0, v1, s0, s1 + * RESTORE_REGS_FROM_STACK 4, v0, v1, s0, s1 + */ +.macro RESTORE_REGS_FROM_STACK stack_offset = 0, r1, \ + r2 = 0, r3 = 0, r4 = 0, \ + r5 = 0, r6 = 0, r7 = 0, \ + r8 = 0, r9 = 0, r10 = 0, \ + r11 = 0, r12 = 0, r13 = 0, \ + r14 = 0 + .if (\stack_offset < 0) || (\stack_offset - (\stack_offset/4)*4) + .error "Stack offset must be pozitive and multiple of 4." + .endif + lw \r1, 0(sp) + .if \r2 != 0 + lw \r2, 4(sp) + .endif + .if \r3 != 0 + lw \r3, 8(sp) + .endif + .if \r4 != 0 + lw \r4, 12(sp) + .endif + .if \r5 != 0 + CHECK_STACK_OFFSET 5, \stack_offset + lw \r5, 16(sp) + .endif + .if \r6 != 0 + CHECK_STACK_OFFSET 6, \stack_offset + lw \r6, 20(sp) + .endif + .if \r7 != 0 + CHECK_STACK_OFFSET 7, \stack_offset + lw \r7, 24(sp) + .endif + .if \r8 != 0 + CHECK_STACK_OFFSET 8, \stack_offset + lw \r8, 28(sp) + .endif + .if \r9 != 0 + CHECK_STACK_OFFSET 9, \stack_offset + lw \r9, 32(sp) + .endif + .if \r10 != 0 + CHECK_STACK_OFFSET 10, \stack_offset + lw \r10, 36(sp) + .endif + .if \r11 != 0 + CHECK_STACK_OFFSET 11, \stack_offset + lw \r11, 40(sp) + .endif + .if \r12 != 0 + CHECK_STACK_OFFSET 12, \stack_offset + lw \r12, 44(sp) + .endif + .if \r13 != 0 + CHECK_STACK_OFFSET 13, \stack_offset + lw \r13, 48(sp) + .endif + .if \r14 != 0 + CHECK_STACK_OFFSET 14, \stack_offset + lw \r14, 52(sp) + .endif + .if \stack_offset != 0 + addiu sp, sp, \stack_offset + .endif +.endm + #endif // QT_MIPS_ASM_DSP_H From 122ae7142b2dfd7ec0e03820c1d7f4317d1ce267 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 13 Jan 2014 16:55:22 +0100 Subject: [PATCH 30/72] Stabilize tst_scrollbar. - Use a separate widget for each test. - Replace hard-coded timeouts by qWaitForWindowExposed. - Center windows on screen. Change-Id: I45ae306fd23348ee5dec3849e64ec98843e8bf32 Reviewed-by: Frederik Gladhorn --- .../widgets/qscrollbar/tst_qscrollbar.cpp | 93 +++++++++++-------- 1 file changed, 52 insertions(+), 41 deletions(-) diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index baa3022919..51dd0852ee 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -44,68 +44,72 @@ #include #include #include +#include + +static inline void centerOnScreen(QWidget *w, const QSize &size) +{ + const QPoint offset = QPoint(size.width() / 2, size.height() / 2); + w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); +} + +static inline void centerOnScreen(QWidget *w) +{ + centerOnScreen(w, w->geometry().size()); +} class tst_QScrollBar : public QObject { Q_OBJECT -public slots: - void initTestCase(); - void cleanupTestCase(); - void hideAndShow(int action); - private slots: void scrollSingleStep(); void task_209492(); #ifndef QT_NO_WHEELEVENT void QTBUG_27308(); #endif - -private: - QScrollBar *testWidget; }; -void tst_QScrollBar::initTestCase() -{ - testWidget = new QScrollBar(Qt::Horizontal); - testWidget->resize(100, testWidget->height()); - testWidget->show(); -} +class SingleStepTestScrollBar : public QScrollBar { + Q_OBJECT +public: + explicit SingleStepTestScrollBar(Qt::Orientation o, QWidget *parent = 0) : QScrollBar(o, parent) {} -void tst_QScrollBar::cleanupTestCase() -{ - delete testWidget; - testWidget = 0; -} - -void tst_QScrollBar::hideAndShow(int) -{ - testWidget->hide(); - testWidget->show(); -} +public slots: + void hideAndShow() + { + hide(); + show(); + } +}; // Check that the scrollbar doesn't scroll after calling hide and show // from a slot connected to the scrollbar's actionTriggered signal. void tst_QScrollBar::scrollSingleStep() { - testWidget->setValue(testWidget->minimum()); - QCOMPARE(testWidget->value(), testWidget->minimum()); - connect(testWidget, SIGNAL(actionTriggered(int)), this, SLOT(hideAndShow(int))); + SingleStepTestScrollBar testWidget(Qt::Horizontal); + connect(&testWidget, &QAbstractSlider::actionTriggered, &testWidget, &SingleStepTestScrollBar::hideAndShow); + testWidget.resize(100, testWidget.height()); + centerOnScreen(&testWidget); + testWidget.show(); + QTest::qWaitForWindowExposed(&testWidget); + + testWidget.setValue(testWidget.minimum()); + QCOMPARE(testWidget.value(), testWidget.minimum()); // Get rect for the area to click on - const QStyleOptionSlider opt = qt_qscrollbarStyleOption(testWidget); - QRect sr = testWidget->style()->subControlRect(QStyle::CC_ScrollBar, &opt, - QStyle::SC_ScrollBarAddLine, testWidget); + const QStyleOptionSlider opt = qt_qscrollbarStyleOption(&testWidget); + QRect sr = testWidget.style()->subControlRect(QStyle::CC_ScrollBar, &opt, + QStyle::SC_ScrollBarAddLine, &testWidget); if (!sr.isValid()) QSKIP("SC_ScrollBarAddLine not valid"); - QTest::mouseClick(testWidget, Qt::LeftButton, Qt::NoModifier, QPoint(sr.x(), sr.y())); + QTest::mouseClick(&testWidget, Qt::LeftButton, Qt::NoModifier, QPoint(sr.x(), sr.y())); QTest::qWait(510); // initial delay is 500 for setRepeatAction - disconnect(testWidget, SIGNAL(actionTriggered(int)), 0, 0); + disconnect(&testWidget, &QAbstractSlider::actionTriggered, &testWidget, &SingleStepTestScrollBar::hideAndShow); #ifdef Q_OS_MAC QEXPECT_FAIL("", "This test fails on Mac OS X, see QTBUG-25272", Abort); #endif - QCOMPARE(testWidget->value(), testWidget->singleStep()); + QCOMPARE(testWidget.value(), testWidget.singleStep()); } void tst_QScrollBar::task_209492() @@ -123,8 +127,9 @@ void tst_QScrollBar::task_209492() MyScrollArea scrollArea; QScrollBar *verticalScrollBar = scrollArea.verticalScrollBar(); verticalScrollBar->setRange(0, 1000); + centerOnScreen(&scrollArea); scrollArea.show(); - QTest::qWait(300); + QTest::qWaitForWindowExposed(&scrollArea); QSignalSpy spy(verticalScrollBar, SIGNAL(actionTriggered(int))); QCOMPARE(scrollArea.scrollCount, 0); @@ -153,12 +158,18 @@ void tst_QScrollBar::QTBUG_27308() // https://bugreports.qt-project.org/browse/QTBUG-27308 // Check that a disabled scrollbar doesn't react on wheel events anymore - testWidget->setValue(testWidget->minimum()); - testWidget->setEnabled(false); - QWheelEvent event(testWidget->rect().center(), - -WHEEL_DELTA, Qt::NoButton, Qt::NoModifier, testWidget->orientation()); - qApp->sendEvent(testWidget, &event); - QCOMPARE(testWidget->value(), testWidget->minimum()); + QScrollBar testWidget(Qt::Horizontal); + testWidget.resize(100, testWidget.height()); + centerOnScreen(&testWidget); + testWidget.show(); + QTest::qWaitForWindowExposed(&testWidget); + + testWidget.setValue(testWidget.minimum()); + testWidget.setEnabled(false); + QWheelEvent event(testWidget.rect().center(), + -WHEEL_DELTA, Qt::NoButton, Qt::NoModifier, testWidget.orientation()); + qApp->sendEvent(&testWidget, &event); + QCOMPARE(testWidget.value(), testWidget.minimum()); } #endif From 73a98ccc4677056416f5de8797c91097e1000a0c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Jan 2014 16:05:15 +0100 Subject: [PATCH 31/72] Windows: Use focusWindow() as native dialog parent when 0 is passed. A parent is required, otherwise the application gets deactivated when the dialog closes. The same is done in Qt 4. Task-number: QTBUG-36039 Change-Id: I56688b3259f1d207edd1bec499afd1365ae511dc Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 497d0975af..8ebfd018d0 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -572,6 +572,8 @@ bool QWindowsDialogHelperBase::show(Qt::WindowFlags, QWindow *parent) { const bool modal = (windowModality != Qt::NonModal); + if (!parent) + parent = QGuiApplication::focusWindow(); // Need a parent window, else the application loses activation when closed. if (parent) { m_ownerWindow = QWindowsWindow::handleOf(parent); } else { From 6233f006df24495587fbb784c33478f034ac2df0 Mon Sep 17 00:00:00 2001 From: Cyril Oblikov Date: Mon, 13 Jan 2014 01:18:25 +0300 Subject: [PATCH 32/72] Saving physical size changes of screen on Windows On windows (tested on win7) physicalSizeMM is changed after changing screen resolution. We need to save new size. Change-Id: I1b38d9ba2af9679812a973737a724c9a9c5395da Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 530ebc38b7..1fc1be53c7 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -306,6 +306,8 @@ QList QWindowsScreen::virtualSiblings() const void QWindowsScreen::handleChanges(const QWindowsScreenData &newData) { + m_data.physicalSizeMM = newData.physicalSizeMM; + if (m_data.geometry != newData.geometry) { m_data.geometry = newData.geometry; QWindowSystemInterface::handleScreenGeometryChange(screen(), From 7c11e7ec195955f6b66cdcd19110f6daf303e023 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sun, 12 Jan 2014 19:44:32 +0800 Subject: [PATCH 33/72] qdocconf: Remove nonexistent dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I9d2f36102691a2bd8ab0697d20f6eac59d59a84f Reviewed-by: Topi Reiniö --- qmake/doc/qmake.qdocconf | 1 - src/tools/qdoc/doc/config/qdoc.qdocconf | 1 - 2 files changed, 2 deletions(-) diff --git a/qmake/doc/qmake.qdocconf b/qmake/doc/qmake.qdocconf index a5bd089a5d..d8f970048c 100644 --- a/qmake/doc/qmake.qdocconf +++ b/qmake/doc/qmake.qdocconf @@ -65,7 +65,6 @@ depends += \ qtsvg \ qtsysteminfo \ qttestlib \ - qttools \ qtuitools \ qtversit \ qtwebkit \ diff --git a/src/tools/qdoc/doc/config/qdoc.qdocconf b/src/tools/qdoc/doc/config/qdoc.qdocconf index 992cec65dc..0f4ad07711 100644 --- a/src/tools/qdoc/doc/config/qdoc.qdocconf +++ b/src/tools/qdoc/doc/config/qdoc.qdocconf @@ -62,7 +62,6 @@ depends += \ qtsql \ qtsvg \ qttestlib \ - qttools \ qtuitools \ qtversit \ qtwidgets \ From 3169863ace045d53edda46b1840e76e1822b94e1 Mon Sep 17 00:00:00 2001 From: Kurt Pattyn Date: Sat, 7 Dec 2013 14:53:43 +0100 Subject: [PATCH 34/72] Clear read- and write buffers Added calls to clear the write and read buffers when - setSocketDescriptor is called - abort is called Removed clears the read and write buffers from the documentation of resetSocketLayer. Added documentation to setSocketDescriptor describing that read and write buffers are cleared. Task-number: QTBUG-28914 Change-Id: I25a4b679708bdea0b259c50f1d10a3e9271dabb9 Reviewed-by: Peter Hartmann --- src/network/socket/qabstractsocket.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 47fec38283..e0e13205fd 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -578,8 +578,7 @@ QAbstractSocketPrivate::~QAbstractSocketPrivate() /*! \internal - Resets the socket layer, clears the read and write buffers and - deletes any socket notifiers. + Resets the socket layer and deletes any socket notifiers. */ void QAbstractSocketPrivate::resetSocketLayer() { @@ -1821,6 +1820,7 @@ qintptr QAbstractSocket::socketDescriptor() const as a valid socket descriptor; otherwise returns \c false. The socket is opened in the mode specified by \a openMode, and enters the socket state specified by \a socketState. + Read and write buffers are cleared, discarding any pending data. \b{Note:} It is not possible to initialize two abstract sockets with the same native socket descriptor. @@ -1833,6 +1833,8 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState Q_D(QAbstractSocket); d->resetSocketLayer(); + d->writeBuffer.clear(); + d->buffer.clear(); d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this); if (!d->socketEngine) { d->socketError = UnsupportedSocketOperationError; @@ -2281,6 +2283,7 @@ void QAbstractSocket::abort() #if defined (QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocket::abort()"); #endif + d->writeBuffer.clear(); if (d->state == UnconnectedState) return; #ifndef QT_NO_SSL @@ -2295,7 +2298,6 @@ void QAbstractSocket::abort() d->connectTimer = 0; } - d->writeBuffer.clear(); d->abortCalled = true; close(); } From a6c79344f74a1cb2c2831bc9ebec4f927d49df9b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 14 Jan 2014 09:33:50 +0100 Subject: [PATCH 35/72] Fix typo in QTextEdit documentation Task-number: QTBUG-36077 Change-Id: I5cd9ad3fe309e5dd2e5e5d67d6c7561182e65c25 Reviewed-by: Mitch Curtis Reviewed-by: Giuseppe D'Angelo Reviewed-by: Jerome Pasion --- src/widgets/widgets/qtextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 49e05e8e14..e47abace4d 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -2042,7 +2042,7 @@ QList QTextEdit::extraSelections() const This function returns a new MIME data object to represent the contents of the text edit's current selection. It is called when the selection needs to be encapsulated into a new QMimeData object; for example, when a drag - and drop operation is started, or when data is copyied to the clipboard. + and drop operation is started, or when data is copied to the clipboard. If you reimplement this function, note that the ownership of the returned QMimeData object is passed to the caller. The selection can be retrieved From 3558c0cd743bbd61e4d108671e2da5d4910256c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Wed, 15 Jan 2014 15:48:26 +0100 Subject: [PATCH 36/72] Minor optimization use QString midRef instead of mid. It doesn't create a temporary string. Change-Id: If5c540422f69e573107d1f5a886ac7174ae99853 Reviewed-by: Friedemann Kleint --- src/sql/drivers/sqlite/qsql_sqlite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index c98d6438fc..0b0731399e 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -609,7 +609,7 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c foreach (const QString &option, opts) { if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) { bool ok; - const int nt = option.mid(21).toInt(&ok); + const int nt = option.midRef(21).toInt(&ok); if (ok) timeOut = nt; } else if (option == QLatin1String("QSQLITE_OPEN_READONLY")) { From a695edef569671068dfa30f301e34f0883128c6b Mon Sep 17 00:00:00 2001 From: Kurt Pattyn Date: Sun, 12 Jan 2014 15:18:43 +0100 Subject: [PATCH 37/72] Fix some typos Change-Id: I673ad09e458438b921fa093190bd983e8f9749b4 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 44077132d4..d526d40398 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -251,7 +251,7 @@ # if defined(__EDG__) # define Q_CC_EDG # endif -/* Compaq have disabled EDG's _BOOL macro and use _BOOL_EXISTS instead +/* Compaq has disabled EDG's _BOOL macro and uses _BOOL_EXISTS instead - 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) @@ -722,13 +722,13 @@ # define Q_COMPILER_DECLTYPE # define Q_COMPILER_RVALUE_REFS # define Q_COMPILER_STATIC_ASSERT -// MSVC's library has std::initilizer_list, but the compiler does not support the braces initialization +// MSVC's library has std::initializer_list, but the compiler does not support the braces initialization //# define Q_COMPILER_INITIALIZER_LISTS //# define Q_COMPILER_UNIFORM_INIT # endif # if _MSC_VER >= 1700 /* C++11 features supported in VC11 = VC2012: */ -# undef Q_DECL_OVERRIDE /* undo 2005/2098 settings... */ +# undef Q_DECL_OVERRIDE /* undo 2005/2008 settings... */ # undef Q_DECL_FINAL /* undo 2005/2008 settings... */ # define Q_COMPILER_EXPLICIT_OVERRIDES /* ...and use std C++11 now */ # define Q_COMPILER_RANGE_FOR From 110d36fee82aabfc951bbd50549e809ca3649aa3 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 8 Jan 2014 12:24:50 +0100 Subject: [PATCH 38/72] REG: Fix make install on library projects on Android This is a partial revert of 39e04b022227c52c9e6aac1942919f68247e1394. The original change moved the special make install target path logic into the logic for the app template to make it possible to remove the condition that excluded builds inside the Qt directory. This was to make it possible to build examples in the Qt directory for Android without moving them. However, this broke user library projects, specifically when they were part of a subdirs project and should have been automatically installed into the Android package. This patch brings back the logic but only enables it for library projects, meaning that the only examples inside Qt which cannot be built correctly are library projects (which didn't work anyway). [ChangeLog][Android] Fixed regression in "make install" on library projects on Android so they can be used inside subdirs projects again. Task-number: QTBUG-34781 Change-Id: Iabf53ed68845b2ddd4ae66656e1372c96185660e Reviewed-by: Oswald Buddenhagen Reviewed-by: Paul Olav Tvete --- mkspecs/features/android/android.prf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkspecs/features/android/android.prf b/mkspecs/features/android/android.prf index 5e21f0b845..9e86110da6 100644 --- a/mkspecs/features/android/android.prf +++ b/mkspecs/features/android/android.prf @@ -8,4 +8,7 @@ contains(TEMPLATE, ".*app") { INSTALLS *= target } } +} else: contains(TEMPLATE, "lib"):!QTDIR_build:android_install { + target.path = /libs/$$ANDROID_TARGET_ARCH/ + INSTALLS *= target } From fd37c9a9d1fb142b2f3f365234e841514bae29b7 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 14 Jan 2014 17:18:53 +0100 Subject: [PATCH 39/72] Document QAbstractItemModels::roleNames() better. List all of the default role names, and mention that the function must be overridden if the model is used within QML. Change-Id: I6ced5ac74143dcb97c527da2a6a23aa9d21f70e5 Reviewed-by: J-P Nurmi Reviewed-by: Stephen Kelly --- src/corelib/itemmodels/qabstractitemmodel.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index ab257a996d..4241fe08ca 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -2334,6 +2334,31 @@ void QAbstractItemModel::doSetRoleNames(const QHash &roleNames) Returns the model's role names. + The default role names set by Qt are: + + \table + \header + \li Qt Role + \li QML Role Name + \row + \li Qt::DisplayRole + \li display + \row + \li Qt::DecorationRole + \li decoration + \row + \li Qt::EditRole + \li edit + \row + \li Qt::ToolTipRole + \li toolTip + \row + \li Qt::StatusTipRole + \li statusTip + \row + \li Qt::WhatsThisRole + \li whatsThis + \endtable */ QHash QAbstractItemModel::roleNames() const { @@ -3378,6 +3403,9 @@ Qt::ItemFlags QAbstractTableModel::flags(const QModelIndex &index) const of the rowCount() and data() functions. Well behaved models also provide a headerData() implementation. + If your model is used within QML and requires roles other than the + default ones provided by the roleNames() function, you must override it. + For editable list models, you must also provide an implementation of setData(), implement the flags() function so that it returns a value containing \l{Qt::ItemFlags}{Qt::ItemIsEditable}. From f15d73058903eee77daa0a3f6deb8554aa01ea93 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Wed, 15 Jan 2014 14:01:08 +0100 Subject: [PATCH 40/72] test: tst_qhostinfo requires `private_tests' set Otherwise you get: undefined reference to `qt_qhostinfo_clear_cache()' Change-Id: I32313f290b9e4236440ae01afe12285d4539be60 Reviewed-by: Peter Hartmann --- tests/auto/network/kernel/qhostinfo/qhostinfo.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro index c21e73ccee..b6f5c2badb 100644 --- a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro +++ b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro @@ -3,6 +3,7 @@ TARGET = tst_qhostinfo SOURCES += tst_qhostinfo.cpp +requires(contains(QT_CONFIG,private_tests)) QT = core-private network-private testlib wince*: { From fa907401e90364797b3e60223618b94b4b8776e5 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Wed, 15 Jan 2014 14:10:16 +0100 Subject: [PATCH 41/72] test: tst_qhttpsocketengine requires `private_tests' set Otherwise you get: undefined reference to `vtable for QAbstractSocketEngine' when -developer-build is not used. Change-Id: I444140736a6bf736894dc12a20f6a4d48af2678e Reviewed-by: Peter Hartmann --- .../auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro index 414486f82b..009d151e29 100644 --- a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro +++ b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro @@ -7,6 +7,7 @@ include(../platformsocketengine/platformsocketengine.pri) MOC_DIR=tmp +requires(contains(QT_CONFIG,private_tests)) QT = core-private network-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 From d94830035bba0efd411478d96268e43d927cc27a Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 14 Jan 2014 10:42:15 +0100 Subject: [PATCH 42/72] Run non-xcb X tests also with -no-xcb Passing -no-xcb disables xcb and related configuration tests completely so for example QT_NO_XRENDER is not defined. This results in linker errors in glxconvenience with -no-xcb since the XRender calls are compiled in without linking to the library. The XRender, XInput and such tests are not strictly xcb related and may be used from elsewhere, for example glxconvenience which has nothing to do with xcb. Therefore these tests are moved in configure so that they are run even when xcb is disabled. Task-number: QTBUG-35644 Change-Id: I77871612ea5f6711ecafd8ca53aac6c516c19e2e Reviewed-by: Oswald Buddenhagen --- configure | 72 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/configure b/configure index aaa59bdf17..23ffd43ca9 100755 --- a/configure +++ b/configure @@ -5120,6 +5120,42 @@ if compileTest x11/xlib "XLib"; then QT_CONFIG="$QT_CONFIG xlib" fi +# auto-detect Xrender support +if [ "$CFG_XRENDER" != "no" ]; then + if compileTest x11/xrender "Xrender"; then + CFG_XRENDER=yes + QT_CONFIG="$QT_CONFIG xrender" + else + if [ "$CFG_XRENDER" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then + echo "Xrender support cannot be enabled due to functionality tests!" + echo " Turn on verbose messaging (-v) to $0 to see the final report." + echo " If you believe this message is in error you may use the continue" + echo " switch (-continue) to $0 to continue." + exit 101 + else + CFG_XRENDER=no + fi + fi +fi + +# auto-detect XInput2 support +if [ "$CFG_XINPUT2" != "no" ]; then + if compileTest x11/xinput2 "XInput2"; then + CFG_XINPUT2=yes + CFG_XINPUT=no + else + if [ "$CFG_XINPUT2" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then + echo "XInput2 support cannot be enabled due to functionality tests!" + echo " Turn on verbose messaging (-v) to $0 to see the final report." + echo " If you believe this message is in error you may use the continue" + echo " switch (-continue) to $0 to continue." + exit 101 + else + CFG_XINPUT2=no + fi + fi +fi + if [ "$CFG_XCB" != "no" ]; then if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "xcb >= 1.5" 2>/dev/null; then QMAKE_CFLAGS_XCB="`$PKG_CONFIG --cflags xcb 2>/dev/null`" @@ -5179,42 +5215,6 @@ if [ "$CFG_XCB" != "no" ]; then QT_CONFIG="$QT_CONFIG xcb-sm" fi fi - - # auto-detect Xrender support - if [ "$CFG_XRENDER" != "no" ]; then - if compileTest x11/xrender "Xrender"; then - CFG_XRENDER=yes - QT_CONFIG="$QT_CONFIG xrender" - else - if [ "$CFG_XRENDER" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then - echo "Xrender support cannot be enabled due to functionality tests!" - echo " Turn on verbose messaging (-v) to $0 to see the final report." - echo " If you believe this message is in error you may use the continue" - echo " switch (-continue) to $0 to continue." - exit 101 - else - CFG_XRENDER=no - fi - fi - fi - - # auto-detect XInput2 support. Needed by xcb too. - if [ "$CFG_XINPUT2" != "no" ]; then - if compileTest x11/xinput2 "XInput2"; then - CFG_XINPUT2=yes - CFG_XINPUT=no - else - if [ "$CFG_XINPUT2" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then - echo "XInput2 support cannot be enabled due to functionality tests!" - echo " Turn on verbose messaging (-v) to $0 to see the final report." - echo " If you believe this message is in error you may use the continue" - echo " switch (-continue) to $0 to continue." - exit 101 - else - CFG_XINPUT2=no - fi - fi - fi else if [ "$CFG_XCB" != "auto" ]; then echo "The test for linking against libxcb failed!" From e746aa6e93dff5819aeee8460edbe09e2258f791 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 11 Apr 2013 12:20:12 +0200 Subject: [PATCH 43/72] network tests: add manual test for uploading images to Facebook ... to have a real world test case for uploading via SSL, QHttpMultiPart (+ resetting) etc. Change-Id: I004dd6f2507776b2fb8ebe1f02625b40abff6261 Reviewed-by: Richard J. Moore --- tests/manual/qnetworkreply/main.cpp | 107 ++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/tests/manual/qnetworkreply/main.cpp b/tests/manual/qnetworkreply/main.cpp index 2f47985261..fe667e92a0 100644 --- a/tests/manual/qnetworkreply/main.cpp +++ b/tests/manual/qnetworkreply/main.cpp @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include "../../auto/network-settings.h" #if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) @@ -65,6 +67,9 @@ private slots: void limiting(); void setSslConfiguration_data(); void setSslConfiguration(); + void uploadToFacebook(); +private: + QHttpMultiPart *createFacebookMultiPart(const QByteArray &accessToken); }; QNetworkReply *reply; @@ -177,6 +182,108 @@ void tst_qnetworkreply::setSslConfiguration() #endif // QT_NO_SSL } +QHttpMultiPart *tst_qnetworkreply::createFacebookMultiPart(const QByteArray &accessToken) +{ + QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); + QHttpPart accessTokenPart; + accessTokenPart.setHeader(QNetworkRequest::ContentDispositionHeader, + QVariant("form-data; name=\"access_token\"")); + accessTokenPart.setBody(accessToken); + multiPart->append(accessTokenPart); + + QHttpPart batchPart; + batchPart.setHeader(QNetworkRequest::ContentDispositionHeader, + QVariant("form-data; name=\"batch\"")); + batchPart.setBody("[" +" {" +" \"attached_files\" : \"image1\"," +" \"body\" : \"message=&published=0\"," +" \"method\" : \"POST\"," +" \"relative_url\" : \"me/photos\"" +" }," +" {" +" \"attached_files\" : \"image2\"," +" \"body\" : \"message=&published=0\"," +" \"method\" : \"POST\"," +" \"relative_url\" : \"me/photos\"" +" }," +" {" +" \"attached_files\" : \"image3\"," +" \"body\" : \"message=&published=0\"," +" \"method\" : \"POST\"," +" \"relative_url\" : \"me/photos\"" +" }" +"]"); + multiPart->append(batchPart); + + QHttpPart imagePart1; + imagePart1.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpg")); + imagePart1.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image1\"; filename=\"image1.jpg\"")); + QFile *file1 = new QFile(QFINDTESTDATA("../../auto/network/access/qnetworkreply/image1.jpg")); + file1->open(QIODevice::ReadOnly); + imagePart1.setBodyDevice(file1); + file1->setParent(multiPart); + + multiPart->append(imagePart1); + + QHttpPart imagePart2; + imagePart2.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpg")); + imagePart2.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image2\"; filename=\"image2.jpg\"")); + QFile *file2 = new QFile(QFINDTESTDATA("../../auto/network/access/qnetworkreply/image2.jpg")); + file2->open(QIODevice::ReadOnly); + imagePart2.setBodyDevice(file2); + file2->setParent(multiPart); + + multiPart->append(imagePart2); + + QHttpPart imagePart3; + imagePart3.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpg")); + imagePart3.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image3\"; filename=\"image3.jpg\"")); + QFile *file3 = new QFile(QFINDTESTDATA("../../auto/network/access/qnetworkreply/image3.jpg")); + file3->open(QIODevice::ReadOnly); + imagePart3.setBodyDevice(file3); + file3->setParent(multiPart); + + multiPart->append(imagePart3); + return multiPart; +} + +void tst_qnetworkreply::uploadToFacebook() +{ + QByteArray accessToken = qgetenv("QT_FACEBOOK_ACCESS_TOKEN"); + if (accessToken.isEmpty()) + QSKIP("This test requires the QT_FACEBOOK_ACCESS_TOKEN environment variable to be set. " + "Do something like 'export QT_FACEBOOK_ACCESS_TOKEN=MyAccessToken'"); + + QElapsedTimer timer; + QNetworkAccessManager manager; + QNetworkRequest request(QUrl("https://graph.facebook.com/me/photos")); + QHttpMultiPart *multiPart = createFacebookMultiPart(accessToken); + timer.start(); + + QNetworkReply *reply = manager.post(request, multiPart); + multiPart->setParent(reply); + QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(120); + qint64 elapsed = timer.elapsed(); + QVERIFY(!QTestEventLoop::instance().timeout()); + qDebug() << "reply finished after" << elapsed / 1000.0 << "seconds"; + QCOMPARE(reply->error(), QNetworkReply::NoError); + + QByteArray content = reply->readAll(); + QJsonDocument jsonDocument = QJsonDocument::fromJson(content); + QVERIFY(jsonDocument.isArray()); + QJsonArray uploadStatuses = jsonDocument.array(); + QVERIFY(uploadStatuses.size() > 0); + for (int a = 0; a < uploadStatuses.size(); a++) { + QJsonValue currentUploadStatus = uploadStatuses.at(a); + QVERIFY(currentUploadStatus.isObject()); + QJsonObject statusObject = currentUploadStatus.toObject(); + QJsonValue statusCode = statusObject.value(QLatin1String("code")); + QCOMPARE(statusCode.toVariant().toInt(), 200); // 200 OK + } +} + QTEST_MAIN(tst_qnetworkreply) #include "main.moc" From 7b82406569c236b5adc6127b0e6d736236784a15 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Wed, 15 Jan 2014 16:20:44 +0100 Subject: [PATCH 44/72] Bump Qt version to 5.2.2 Change-Id: Ia7dd68e0a280d12eba28932b4c5edb9948310a1e Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qglobal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index d8c987d2e0..9bba21210c 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -45,11 +45,11 @@ #include -#define QT_VERSION_STR "5.2.1" +#define QT_VERSION_STR "5.2.2" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x050201 +#define QT_VERSION 0x050202 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ From bd57e8638866e4f74922dd7a644c6bc0c212a585 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 5 Dec 2013 19:44:09 +0100 Subject: [PATCH 45/72] consistently use single quotes to quote sed & tr arguments ... except where they actually contain variable expansions. unescaped backslashes in double quoted strings aren't nice, and apparently actually break with old solaris shells. Task-number: QTBUG-14167 Change-Id: I703694b6ac7ab71d9293c049d77212e20dd5bcb0 Reviewed-by: Thiago Macieira --- configure | 56 +++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/configure b/configure index 23ffd43ca9..9646fd31e5 100755 --- a/configure +++ b/configure @@ -95,7 +95,7 @@ if [ x"$1" = x"-top-level" ]; then fi # later cache the command line in config.status -OPT_CMDLINE=`echo $@ | sed "s,-v ,,g; s,-v$,,g"` +OPT_CMDLINE=`echo $@ | sed 's,-v ,,g; s,-v$,,g'` # initialize global variables QMAKE_SWITCHES= @@ -170,7 +170,7 @@ expandQMakeConf() { while read line; do case "$line" in include*) - inc_file=`echo "$line" | sed -n -e "/^include.*(.*)/s/include.*(\(.*\)).*$/\1/p"` + inc_file=`echo "$line" | sed -n -e '/^include.*(.*)/s/include.*(\(.*\)).*$/\1/p'` current_dir=`dirname "$1"` conf_file="$current_dir/$inc_file" if [ ! -f "$conf_file" ]; then @@ -450,7 +450,7 @@ resolveDeviceMkspec() match_count=$(echo "$result" | wc -w) if [ "$match_count" -gt 1 ]; then echo >&2 "Error: Multiple matches for device '$1'. Candidates are:" - tabbed_result=$(echo "$result" | sed "s,^, ,") + tabbed_result=$(echo "$result" | sed 's,^, ,') echo >&2 "$tabbed_result" echo "undefined" elif [ "$match_count" -eq 0 ]; then @@ -828,33 +828,33 @@ while [ "$#" -gt 0 ]; do case "$1" in #Autoconf style options --enable-*) - VAR=`echo $1 | sed "s,^--enable-\(.*\),\1,"` + VAR=`echo $1 | sed 's,^--enable-\(.*\),\1,'` VAL=yes ;; --disable-*) - VAR=`echo $1 | sed "s,^--disable-\(.*\),\1,"` + VAR=`echo $1 | sed 's,^--disable-\(.*\),\1,'` VAL=no ;; --*=*) - VAR=`echo $1 | sed "s,^--\(.*\)=.*,\1,"` - VAL=`echo $1 | sed "s,^--.*=\(.*\),\1,"` + VAR=`echo $1 | sed 's,^--\(.*\)=.*,\1,'` + VAL=`echo $1 | sed 's,^--.*=\(.*\),\1,'` ;; --no-*) - VAR=`echo $1 | sed "s,^--no-\(.*\),\1,"` + VAR=`echo $1 | sed 's,^--no-\(.*\),\1,'` VAL=no ;; --*) - VAR=`echo $1 | sed "s,^--\(.*\),\1,"` + VAR=`echo $1 | sed 's,^--\(.*\),\1,'` VAL=yes ;; #Qt plugin options -no-*-*|-plugin-*-*|-qt-*-*) - VAR=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"` - VAL=`echo $1 | sed "s,^-\([^-]*\).*,\1,"` + VAR=`echo $1 | sed 's,^-[^-]*-\(.*\),\1,'` + VAL=`echo $1 | sed 's,^-\([^-]*\).*,\1,'` ;; #Qt style no options -no-*) - VAR=`echo $1 | sed "s,^-no-\(.*\),\1,"` + VAR=`echo $1 | sed 's,^-no-\(.*\),\1,'` VAL=no ;; #Qt style options that pass an argument @@ -899,14 +899,14 @@ while [ "$#" -gt 0 ]; do -android-ndk-host| \ -android-arch| \ -android-toolchain-version) - VAR=`echo $1 | sed "s,^-\(.*\),\1,"` + VAR=`echo $1 | sed 's,^-\(.*\),\1,'` shift VAL="$1" ;; #Qt style complex options in one command -enable-*|-disable-*) - VAR=`echo $1 | sed "s,^-\([^-]*\)-.*,\1,"` - VAL=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"` + VAR=`echo $1 | sed 's,^-\([^-]*\)-.*,\1,'` + VAL=`echo $1 | sed 's,^-[^-]*-\(.*\),\1,'` ;; -system-proxies) VAR=system-proxies @@ -918,8 +918,8 @@ while [ "$#" -gt 0 ]; do ;; #Qt Builtin/System style options -no-*|-system-*|-qt-*) - VAR=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"` - VAL=`echo $1 | sed "s,^-\([^-]*\)-.*,\1,"` + VAR=`echo $1 | sed 's,^-[^-]*-\(.*\),\1,'` + VAL=`echo $1 | sed 's,^-\([^-]*\)-.*,\1,'` ;; #Options that cannot be generalized -k|-continue) @@ -947,7 +947,7 @@ while [ "$#" -gt 0 ]; do fi ;; -hostprefix) - VAR=`echo $1 | sed "s,^-\(.*\),\1,"` + VAR=`echo $1 | sed 's,^-\(.*\),\1,'` # this option may or may not be followed by an argument if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then VAL=$outpath @@ -1037,7 +1037,7 @@ while [ "$#" -gt 0 ]; do ;; #General options, including Qt style yes options -*) - VAR=`echo $1 | sed "s,^-\(.*\),\1,"` + VAR=`echo $1 | sed 's,^-\(.*\),\1,'` VAL="yes" ;; *) @@ -1395,7 +1395,7 @@ while [ "$#" -gt 0 ]; do fi ;; feature-*) - FEATURE=`echo $VAR | sed "s,^[^-]*-\([^-]*\),\1," | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` + FEATURE=`echo $VAR | sed 's,^[^-]*-\([^-]*\),\1,' | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` if [ "$VAL" = "no" ]; then QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_$FEATURE" elif [ "$VAL" = "yes" ] || [ "$VAL" = "unknown" ]; then @@ -1907,8 +1907,8 @@ while [ "$#" -gt 0 ]; do fi # now $VAL is "no", "qt", or "plugin" OPT="$VAL" - VAL=`echo $VAR | sed "s,^[^-]*-\([^-]*\).*,\1,"` - VAR=`echo $VAR | sed "s,^\([^-]*\).*,\1,"` + VAL=`echo $VAR | sed 's,^[^-]*-\([^-]*\).*,\1,'` + VAR=`echo $VAR | sed 's,^\([^-]*\).*,\1,'` # Grab the available values case "$VAR" in @@ -1974,7 +1974,7 @@ while [ "$#" -gt 0 ]; do fi elif [ "$VAL" = "no" ]; then if [ "$OPT_VERBOSE" = "$VAL" ] && echo "$QMAKE_SWITCHES" | grep ' -d' >/dev/null 2>&1; then - QMAKE_SWITCHES=`echo $QMAKE_SWITCHES | sed "s, -d,,"` + QMAKE_SWITCHES=`echo $QMAKE_SWITCHES | sed 's, -d,,'` else OPT_VERBOSE=no fi @@ -3044,7 +3044,7 @@ elif [ "$Edition" = "Preview" ]; then done elif [ "$Edition" != "OpenSource" ]; then if [ -n "$ExpiryDate" ]; then - ExpiryDate=`echo $ExpiryDate | sed -e "s,-,,g" | tr -d "\n\r"` + ExpiryDate=`echo $ExpiryDate | sed -e 's,-,,g' | tr -d '\n\r'` [ -z "$ExpiryDate" ] && ExpiryDate="0" Today=`date +%Y%m%d` if [ "$Today" -gt "$ExpiryDate" ]; then @@ -3564,7 +3564,7 @@ if [ -z "$CFG_BUILD_PARTS" ]; then # don't build tools by default when cross-compiling if [ "$PLATFORM" != "$XPLATFORM" ]; then - CFG_BUILD_PARTS=`echo "$CFG_BUILD_PARTS" | sed "s, tools,,g"` + CFG_BUILD_PARTS=`echo "$CFG_BUILD_PARTS" | sed 's, tools,,g'` fi fi for nobuild in $CFG_NOBUILD_PARTS; do @@ -4015,7 +4015,7 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ]; if "$WHICH" makedepend >/dev/null 2>&1 && grep 'depend:' "$mkfile" >/dev/null 2>&1; then (cd "$outpath/qmake" && "$MAKE" -f "$mkfile" depend) >/dev/null 2>&1 - sed "s,^.*/\([^/]*.o\):,\1:,g" "$mkfile" >"$mkfile.tmp" + sed 's,^.*/\([^/]*.o\):,\1:,g' "$mkfile" >"$mkfile.tmp" sed "s,$outpath,$adjoutpath,g" "$mkfile.tmp" >"$mkfile" rm "$mkfile.tmp" fi @@ -6322,10 +6322,10 @@ EOF cfgdNeg= if [ true ] && echo "$cfgd" | grep 'QT_NO_' >/dev/null 2>&1; then # QT_NO_option can be forcefully turned on by QT_option - cfgdNeg=`echo $cfgd | sed "s,QT_NO_,QT_,"` + cfgdNeg=`echo $cfgd | sed 's,QT_NO_,QT_,'` elif [ true ] && echo "$cfgd" | grep 'QT_' >/dev/null 2>&1; then # QT_option can be forcefully turned off by QT_NO_option - cfgdNeg=`echo $cfgd | sed "s,QT_,QT_NO_,"` + cfgdNeg=`echo $cfgd | sed 's,QT_,QT_NO_,'` fi if [ -z $cfgdNeg ]; then From ca02462f0251fa420700f57b488f5b426dd00839 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 15 Nov 2013 14:36:02 +0100 Subject: [PATCH 46/72] set QMAKE_INTERNAL_INCLUDED_FILES even without PROEVALUATOR_FULL some qt prfs use this variable, so better set it it to avoid some noise. Change-Id: I606c88dd7664b1cd8b490d60badd5c6bf80fd1c9 Reviewed-by: Daniel Teske Reviewed-by: Oswald Buddenhagen (cherry picked from qtcreator/e64cc71194cbe283dfe9bd2cd688f01fcdcadf34) Reviewed-by: Joerg Bornemann --- qmake/library/qmakeevaluator.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index e17ac16e96..fe7b29ceec 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -1850,14 +1850,12 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFile( VisitReturn ok = visitProFile(pro, type, flags); m_current = m_locationStack.pop(); pro->deref(); -#ifdef PROEVALUATOR_FULL if (ok == ReturnTrue && !(flags & LoadHidden)) { ProStringList &iif = m_valuemapStack.first()[ProKey("QMAKE_INTERNAL_INCLUDED_FILES")]; ProString ifn(fileName); if (!iif.contains(ifn)) iif << ifn; } -#endif return ok; } else { return ReturnFalse; @@ -1970,13 +1968,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFileInto( if (ret != ReturnTrue) return ret; *values = visitor.m_valuemapStack.top(); -#ifdef PROEVALUATOR_FULL ProKey qiif("QMAKE_INTERNAL_INCLUDED_FILES"); ProStringList &iif = m_valuemapStack.first()[qiif]; foreach (const ProString &ifn, values->value(qiif)) if (!iif.contains(ifn)) iif << ifn; -#endif return ReturnTrue; } From ee35954122f5fa413b7164901e63cbef4c49d9d5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 15 Nov 2013 19:28:50 +0100 Subject: [PATCH 47/72] don't turn = into += in cumulative mode it leads to pathological cases where the number of loop iterations may go way beyond the reasonable. this means that users need to avoid using the = operator in alternative branches that lead to different sources/subdirectories being included into the project. this is a bit of a corner case anyway, as people usually add directly to SOURCES/SUBDIRS. Task-number: QTCREATORBUG-1595 Change-Id: I7783e318fbc2790f6a853ba4e3f4a12db881feb5 Reviewed-by: Daniel Teske (cherry picked from qtcreator/30bd7fcce1aef974f6af9eaa6532aa1f2b6192d2) Reviewed-by: Joerg Bornemann --- qmake/library/qmakeevaluator.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index fe7b29ceec..2ea5ffd45e 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -889,30 +889,9 @@ void QMakeEvaluator::visitProVariable( default: // whatever - cannot happen case TokAssign: // = zipEmpty(&varVal); - if (!m_cumulative) { - // FIXME: add check+warning about accidental value removal. - // This may be a bit too noisy, though. - m_valuemapStack.top()[varName] = varVal; - } else { - if (!varVal.isEmpty()) { - // We are greedy for values. But avoid exponential growth. - ProStringList &v = valuesRef(varName); - if (v.isEmpty()) { - v = varVal; - } else { - ProStringList old = v; - v = varVal; - QSet has; - has.reserve(v.size()); - foreach (const ProString &s, v) - has.insert(s); - v.reserve(v.size() + old.size()); - foreach (const ProString &s, old) - if (!has.contains(s)) - v << s; - } - } - } + // FIXME: add check+warning about accidental value removal. + // This may be a bit too noisy, though. + m_valuemapStack.top()[varName] = varVal; debugMsg(2, "assigning"); break; case TokAppendUnique: // *= @@ -928,7 +907,7 @@ void QMakeEvaluator::visitProVariable( if (!m_cumulative) { removeEach(&valuesRef(varName), varVal); } else { - // We are stingy with our values, too. + // We are stingy with our values. } debugMsg(2, "removing"); break; From 65defa516d35697df5c3babe5b110c24327a1df9 Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Tue, 17 Dec 2013 11:43:12 +1100 Subject: [PATCH 48/72] Doc: Fix suggest parentheses GCC warning Change-Id: I96cb76da7d260d08133830de72b0ff6e6a5099be Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp index 338817ea74..70e3090cde 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp @@ -44,7 +44,7 @@ w->setWindowState(w->windowState() ^ Qt::WindowFullScreen); //! [1] -w->setWindowState(w->windowState() & ~Qt::WindowMinimized | Qt::WindowActive); +w->setWindowState((w->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); //! [1] From b765a0b19d8b5d31c9d05924300bed7eda2da62b Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Sat, 14 Dec 2013 17:17:45 +1100 Subject: [PATCH 49/72] Doc: Fix typo in Fade Message Effect Example documentation Change-Id: I3a64f296d01f2b0147f87b406163ff25c4d12ada Reviewed-by: Eskil Abrahamsen Blomfeldt --- examples/widgets/doc/src/fademessage.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/widgets/doc/src/fademessage.qdoc b/examples/widgets/doc/src/fademessage.qdoc index 2a88c80ff2..d3c2494556 100644 --- a/examples/widgets/doc/src/fademessage.qdoc +++ b/examples/widgets/doc/src/fademessage.qdoc @@ -29,7 +29,7 @@ \example effects/fademessage \title Fade Message Effect Example \ingroup examples-graphicsview-graphicseffects - \brief Demonstrates how to appliy effects on items in the view + \brief Demonstrates how to apply effects on items in the view \div { style="text-align: left"} \inlineimage fademessageeffect-example.png From fd22e89593002a4fd155e5da1aabbaefb72433db Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 3 Jan 2014 14:23:52 -0200 Subject: [PATCH 50/72] Fix unused-function warning in qdrawhelper.cpp storePixel would have been called by storePixels but that function has an overload that uses memcpy instead. So it's really unused. Found by Clang 3.4. Change-Id: I661804e273486d3469221fdd362a24cd77cfb8a7 Reviewed-by: Gunnar Sletta --- src/gui/painting/qdrawhelper.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index cc28076b7c..d3e5b645c4 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -374,12 +374,6 @@ inline void QT_FASTCALL storePixel(uchar *dest, int index, reinterpret_cast(dest)[index] = quint24(pixel); } -template <> -inline void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel) -{ - reinterpret_cast(dest)[index] = pixel; -} - template inline void QT_FASTCALL storePixels(uchar *dest, const uint *src, int index, int count) { From 48db373ce3cadab3a54cd443f9136d1e5d74ca50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Wed, 8 Jan 2014 14:06:38 +0100 Subject: [PATCH 51/72] Android: Add convenience function to get the API level. It's common to check the Android API level at runtime to determine what functionality is available. This change provides a convenient way to get the Android SDK version (API level) from c++. Change-Id: I88f65ae87e0fa8ac0affefffbd1b1bba855c9f46 Reviewed-by: BogDan Vatra --- src/corelib/kernel/qjnihelpers.cpp | 21 +++++++++++++++++++++ src/corelib/kernel/qjnihelpers_p.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp index 9ec491f6a9..74eb6f5b27 100644 --- a/src/corelib/kernel/qjnihelpers.cpp +++ b/src/corelib/kernel/qjnihelpers.cpp @@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE static JavaVM *g_javaVM = Q_NULLPTR; static jobject g_jActivity = Q_NULLPTR; static jobject g_jClassLoader = Q_NULLPTR; +static jint g_androidSdkVersion = 0; static inline bool exceptionCheck(JNIEnv *env) { @@ -60,6 +61,19 @@ static inline bool exceptionCheck(JNIEnv *env) return false; } +static void setAndroidSdkVersion(JNIEnv *env) +{ + jclass androidVersionClass = env->FindClass("android/os/Build$VERSION"); + if (exceptionCheck(env)) + return; + + jfieldID androidSDKFieldID = env->GetStaticFieldID(androidVersionClass, "SDK_INT", "I"); + if (exceptionCheck(env)) + return; + + g_androidSdkVersion = env->GetStaticIntField(androidVersionClass, androidSDKFieldID); +} + jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env) { jclass jQtNative = env->FindClass("org/qtproject/qt5/android/QtNative"); @@ -93,6 +107,8 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env) if (exceptionCheck(env)) return JNI_ERR; + setAndroidSdkVersion(env); + g_jClassLoader = env->NewGlobalRef(classLoader); env->DeleteLocalRef(classLoader); g_jActivity = env->NewGlobalRef(activity); @@ -118,4 +134,9 @@ jobject QtAndroidPrivate::classLoader() return g_jClassLoader; } +jint QtAndroidPrivate::androidSdkVersion() +{ + return g_androidSdkVersion; +} + QT_END_NAMESPACE diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h index 39059db215..c92dbdde7f 100644 --- a/src/corelib/kernel/qjnihelpers_p.h +++ b/src/corelib/kernel/qjnihelpers_p.h @@ -64,6 +64,7 @@ namespace QtAndroidPrivate Q_CORE_EXPORT JavaVM *javaVM(); Q_CORE_EXPORT jint initJNI(JavaVM *vm, JNIEnv *env); jobject classLoader(); + jint androidSdkVersion(); } QT_END_NAMESPACE From aa7ec3cdf5d423b7abb7d0bb5ff7772602d41962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 18 Jun 2013 13:56:29 +0200 Subject: [PATCH 52/72] Android: QStandardPaths implementation Adds standard paths implementation for Android. [ChangeLog][QtCore][QStandardPaths] Added QStandardPaths implementation for Android. Task-number: QTBUG-34631 Change-Id: I38673204a521a990438470c4e165105a2b02b7ad Reviewed-by: BogDan Vatra Reviewed-by: Shawn Rutledge --- src/corelib/io/io.pri | 2 + src/corelib/io/qstandardpaths_android.cpp | 331 ++++++++++++++++++ .../io/qstandardpaths/tst_qstandardpaths.cpp | 6 +- 3 files changed, 336 insertions(+), 3 deletions(-) create mode 100644 src/corelib/io/qstandardpaths_android.cpp diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index f06bf61b09..649493f8b7 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -142,6 +142,8 @@ win32 { } } else:blackberry { SOURCES += io/qstandardpaths_blackberry.cpp + } else:android { + SOURCES += io/qstandardpaths_android.cpp } else { SOURCES += io/qstandardpaths_unix.cpp } diff --git a/src/corelib/io/qstandardpaths_android.cpp b/src/corelib/io/qstandardpaths_android.cpp new file mode 100644 index 0000000000..60b285a3d6 --- /dev/null +++ b/src/corelib/io/qstandardpaths_android.cpp @@ -0,0 +1,331 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qstandardpaths.h" + +#ifndef QT_NO_STANDARDPATHS + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +typedef QMap AndroidDirCache; +Q_GLOBAL_STATIC(AndroidDirCache, androidDirCache) + +static QString testDir() +{ + return QStandardPaths::isTestModeEnabled() ? QLatin1String("/qttest") + : QLatin1String(""); +} + +static QJNIObjectPrivate applicationContext() +{ + static QJNIObjectPrivate appCtx; + if (appCtx.isValid()) + return appCtx; + + QJNIObjectPrivate activity = QtAndroidPrivate::activity(); + if (!activity.isValid()) + return appCtx; + + appCtx = activity.callObjectMethod("getApplicationContext", + "()Landroid/content/Context;"); + return appCtx; +} + +static inline QString getAbsolutePath(const QJNIObjectPrivate &file) +{ + QJNIObjectPrivate path = file.callObjectMethod("getAbsolutePath", + "()Ljava/lang/String;"); + if (!path.isValid()) + return QString(); + + return path.toString(); +} + +/* + * The root of the external storage + * + */ +static QString getExternalStorageDirectory() +{ + QString &path = (*androidDirCache)[QStringLiteral("EXT_ROOT")]; + if (!path.isEmpty()) + return path; + + QJNIObjectPrivate file = QJNIObjectPrivate::callStaticObjectMethod("android/os/Environment", + "getExternalStorageDirectory", + "()Ljava/io/File;"); + if (!file.isValid()) + return QString(); + + return (path = getAbsolutePath(file)); +} + +/* + * Locations where applications can place user files (public). + * E.g., /storage/Music + */ +static QString getExternalStoragePublicDirectory(const char *directoryField) +{ + QString &path = (*androidDirCache)[QLatin1String(directoryField)]; + if (!path.isEmpty()) + return path; + + QJNIObjectPrivate dirField = QJNIObjectPrivate::getStaticObjectField("android/os/Environment", + directoryField, + "Ljava/lang/String;"); + if (!dirField.isValid()) + return QString(); + + QJNIObjectPrivate file = QJNIObjectPrivate::callStaticObjectMethod("android/os/Environment", + "getExternalStoragePublicDirectory", + "(Ljava/lang/String;)Ljava/io/File;", + dirField.object()); + if (!file.isValid()) + return QString(); + + return (path = getAbsolutePath(file)); +} + +/* + * Locations where applications can place persistent files it owns. + * E.g., /storage/org.app/Music + */ +static QString getExternalFilesDir(const char *directoryField = 0) +{ + QString &path = (*androidDirCache)[QString(QLatin1String("APPNAME_%1")).arg(QLatin1String(directoryField))]; + if (!path.isEmpty()) + return path; + + QJNIObjectPrivate activity = QtAndroidPrivate::activity(); + if (!activity.isValid()) + return QString(); + + QJNIObjectPrivate appCtx = applicationContext(); + if (!appCtx.isValid()) + return QString(); + + QJNIObjectPrivate dirField = QJNIObjectPrivate::fromString(QLatin1String("")); + if (directoryField) { + dirField = QJNIObjectPrivate::getStaticObjectField("android/os/Environment", + directoryField, + "Ljava/lang/String;"); + if (!dirField.isValid()) + return QString(); + } + + QJNIObjectPrivate file = appCtx.callObjectMethod("getExternalFilesDir", + "(Ljava/lang/String;)Ljava/io/File;", + dirField.object()); + + if (!file.isValid()) + return QString(); + + return (path = getAbsolutePath(file)); +} + +/* + * Directory where applications can store cache files it owns (public). + * E.g., /storage/org.app/ + */ +static QString getExternalCacheDir() +{ + QString &path = (*androidDirCache)[QStringLiteral("APPNAME_CACHE")]; + if (!path.isEmpty()) + return path; + + QJNIObjectPrivate appCtx = applicationContext(); + if (!appCtx.isValid()) + return QString(); + + QJNIObjectPrivate file = appCtx.callObjectMethod("getExternalCacheDir", + "()Ljava/io/File;"); + + if (!file.isValid()) + return QString(); + + return (path = getAbsolutePath(file)); +} + +/* + * Directory where applications can store cache files it owns (private). + */ +static QString getCacheDir() +{ + QString &path = (*androidDirCache)[QStringLiteral("APPROOT_CACHE")]; + if (!path.isEmpty()) + return path; + + QJNIObjectPrivate appCtx = applicationContext(); + if (!appCtx.isValid()) + return QString(); + + QJNIObjectPrivate file = appCtx.callObjectMethod("getCacheDir", + "()Ljava/io/File;"); + if (!file.isValid()) + return QString(); + + return (path = getAbsolutePath(file)); +} + +/* + * Directory where applications can store files it owns (private). + * (Same location as $HOME) + */ +static QString getFilesDir() +{ + QString &path = (*androidDirCache)[QStringLiteral("APPROOT_FILES")]; + if (!path.isEmpty()) + return path; + + return (path = QDir::homePath()); +} + +QString QStandardPaths::writableLocation(StandardLocation type) +{ + switch (type) { + case QStandardPaths::MusicLocation: + return getExternalStoragePublicDirectory("DIRECTORY_MUSIC"); + case QStandardPaths::MoviesLocation: + return getExternalStoragePublicDirectory("DIRECTORY_MOVIES"); + case QStandardPaths::PicturesLocation: + return getExternalStoragePublicDirectory("DIRECTORY_PICTURES"); + case QStandardPaths::DocumentsLocation: + if (QtAndroidPrivate::androidSdkVersion() > 18) + return getExternalStoragePublicDirectory("DIRECTORY_DOCUMENTS"); + else + return getExternalStorageDirectory() + QLatin1String("/Documents"); + case QStandardPaths::DownloadLocation: + return getExternalStoragePublicDirectory("DIRECTORY_DOWNLOADS"); + case QStandardPaths::GenericConfigLocation: + case QStandardPaths::ConfigLocation: + return getFilesDir() + testDir() + QLatin1String("/settings"); + case QStandardPaths::GenericDataLocation: + return getExternalStorageDirectory() + testDir(); + case QStandardPaths::DataLocation: + return getFilesDir() + testDir(); + case QStandardPaths::GenericCacheLocation: + case QStandardPaths::RuntimeLocation: + case QStandardPaths::TempLocation: + case QStandardPaths::CacheLocation: + return getCacheDir() + testDir(); + case QStandardPaths::DesktopLocation: + case QStandardPaths::HomeLocation: + return getFilesDir(); + case QStandardPaths::ApplicationsLocation: + case QStandardPaths::FontsLocation: + default: + break; + } + + return QString(); +} + +QStringList QStandardPaths::standardLocations(StandardLocation type) +{ + if (type == MusicLocation) { + return QStringList() << writableLocation(type) + << getExternalFilesDir("DIRECTORY_MUSIC") + << getExternalStoragePublicDirectory("DIRECTORY_PODCASTS") + << getExternalFilesDir("DIRECTORY_PODCASTS") + << getExternalStoragePublicDirectory("DIRECTORY_NOTIFICATIONS") + << getExternalFilesDir("DIRECTORY_NOTIFICATIONS") + << getExternalStoragePublicDirectory("DIRECTORY_ALARMS") + << getExternalFilesDir("DIRECTORY_ALARMS"); + } + + if (type == MoviesLocation) { + return QStringList() << writableLocation(type) + << getExternalFilesDir("DIRECTORY_MOVIES"); + } + + if (type == PicturesLocation) { + return QStringList() << writableLocation(type) + << getExternalFilesDir("DIRECTORY_PICTURES"); + } + + if (type == DocumentsLocation) { + if (QtAndroidPrivate::androidSdkVersion() > 18) { + return QStringList() << writableLocation(type) + << getExternalFilesDir("DIRECTORY_DOCUMENTS"); + } else { + return QStringList() << writableLocation(type) + << getExternalFilesDir() + QLatin1String("/Documents"); + } + } + + if (type == DownloadLocation) { + return QStringList() << writableLocation(type) + << getExternalFilesDir("DIRECTORY_DOWNLOADS"); + } + + if (type == DataLocation) { + return QStringList() << writableLocation(type) + << getExternalFilesDir(); + } + + if (type == CacheLocation) { + return QStringList() << writableLocation(type) + << getExternalCacheDir(); + } + + if (type == FontsLocation) { + QString &fontLocation = (*androidDirCache)[QStringLiteral("FONT_LOCATION")]; + if (!fontLocation.isEmpty()) + return QStringList(fontLocation); + + const QByteArray ba = qgetenv("QT_ANDROID_FONT_LOCATION"); + if (!ba.isEmpty()) + return QStringList((fontLocation = QDir::cleanPath(QString::fromLocal8Bit(ba)))); + + return QStringList((fontLocation = QLatin1String("/system/fonts"))); + } + + return QStringList(writableLocation(type)); +} + +QT_END_NAMESPACE + +#endif // QT_NO_STANDARDPATHS diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 35a59401b7..21dfa5a962 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -52,7 +52,7 @@ #include #endif -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_BLACKBERRY) +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_ANDROID) #define Q_XDG_PLATFORM #endif @@ -289,9 +289,9 @@ void tst_qstandardpaths::testDataLocation() { // On all platforms, DataLocation should be GenericDataLocation / organization name / app name // This allows one app to access the data of another app. - // Blackberry OS is an exception to this case, owing to the fact that + // Blackberry OS and Android are exceptions to this case, owing to the fact that // applications are sandboxed. -#ifndef Q_OS_BLACKBERRY +#if !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_ANDROID) const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/tst_qstandardpaths"); QCoreApplication::instance()->setOrganizationName("Qt"); From 894ce8aaab8d3319a704deb73cb5109d092df0aa Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 13 Jan 2014 14:19:49 +0100 Subject: [PATCH 53/72] Android: Don't register main thread on loading library When building with debug, all SLOT or SIGNAL macros will expand to a function call, and then function will call QThreadData::current(), which will set QCoreApplication::theMainThread if it has not already been done. Since Qt Widgets has these macros in the static initialization of the library, we would register the Android main thread as the main thread of Qt, which would mean that the actual application object was created on a different thread than the main thread. This caused warnings to appear, and also triggered a race condition which caused widget applications to sometimes show a black screen instead of content on startup when run with the OpenGL plugin. Task-number: QTBUG-35048 Change-Id: Ie8979f5e7cd5662f8d7dd276de9f94f27cc120b5 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 4 +++- src/corelib/thread/qthread_p.h | 2 +- src/corelib/thread/qthread_unix.cpp | 4 ++-- src/corelib/thread/qthread_win.cpp | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index f1351f5a07..5819443d3c 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2086,7 +2086,9 @@ void QObject::deleteLater() const char *qFlagLocation(const char *method) { - QThreadData::current()->flaggedSignatures.store(method); + QThreadData *currentThreadData = QThreadData::current(false); + if (currentThreadData != 0) + currentThreadData->flaggedSignatures.store(method); return method; } diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 8429e41433..fce84e881b 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -223,7 +223,7 @@ public: QThreadData(int initialRefCount = 1); ~QThreadData(); - static QThreadData *current(); + static QThreadData *current(bool createIfNecessary = true); static void clearCurrentThreadData(); static QThreadData *get2(QThread *thread) { Q_ASSERT_X(thread != 0, "QThread", "internal error"); return thread->d_func()->data; } diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 15558cb148..b838cb4b28 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -215,10 +215,10 @@ void QThreadData::clearCurrentThreadData() clear_thread_data(); } -QThreadData *QThreadData::current() +QThreadData *QThreadData::current(bool createIfNecessary) { QThreadData *data = get_thread_data(); - if (!data) { + if (!data && createIfNecessary) { data = new QThreadData; QT_TRY { set_thread_data(data); diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 037343c996..865b1e6af5 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -101,11 +101,11 @@ void QThreadData::clearCurrentThreadData() TlsSetValue(qt_current_thread_data_tls_index, 0); } -QThreadData *QThreadData::current() +QThreadData *QThreadData::current(bool createIfNecessary) { qt_create_tls(); QThreadData *threadData = reinterpret_cast(TlsGetValue(qt_current_thread_data_tls_index)); - if (!threadData) { + if (!threadData && createIfNecessary) { threadData = new QThreadData; // This needs to be called prior to new AdoptedThread() to // avoid recursion. From 87d2fa5f849b0877b75d29113ec7dd3613827904 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 16 Jan 2014 14:01:04 +0100 Subject: [PATCH 54/72] eglfs: Allow using a different framebuffer device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right now /dev/fb0 is hardcoded. This is not ideal. Therefore QT_QPA_EGLFS_FB is introduced. This environment variable can be set to a different framebuffer device. Once it is set, eglfs will use the specific device. This is similar to linuxfb's fb=... plugin parameter. The actual behavior depends on the board-specific implementations. For now only iMX6 has real support. It extracts the index from the device name as bind the EGL display to the corresponding framebuffer using the vendor-specific fbGetDisplayByIndex(). Other hooks can follow suit later on. With this patch eglfs is at least on par with linuxfb, meaning that, if the board supports it, different apps can run on different screens. Task-number: QTBUG-36113 Change-Id: Ia3c88bd06e108bc668433e3c5c3fce34a5a0e73d Reviewed-by: Jørgen Lind --- .../linux-imx6-g++/qeglfshooks_imx6.cpp | 2 +- src/plugins/platforms/eglfs/qeglfshooks.h | 3 ++- .../platforms/eglfs/qeglfshooks_stub.cpp | 26 ++++++++++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp b/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp index c351e3dbc4..91c29b5ea9 100644 --- a/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp +++ b/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp @@ -72,7 +72,7 @@ QEglFSImx6Hooks::QEglFSImx6Hooks() qputenv("FB_MULTI_BUFFER", "2"); } - mNativeDisplay = fbGetDisplayByIndex(0); + mNativeDisplay = fbGetDisplayByIndex(framebufferIndex()); fbGetDisplayGeometry(mNativeDisplay, &width, &height); mScreenSize.setHeight(height); mScreenSize.setWidth(width); diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h index 1cd1380994..0251e27f96 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks.h +++ b/src/plugins/platforms/eglfs/qeglfshooks.h @@ -77,7 +77,8 @@ public: virtual bool filterConfig(EGLDisplay display, EGLConfig config) const; virtual void waitForVSync() const; - virtual const char *fbDeviceName() const; + virtual QByteArray fbDeviceName() const; + virtual int framebufferIndex() const; static QEglFSHooks *hooks() { diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp index 4dc0783d43..4368f37e50 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp @@ -41,6 +41,7 @@ #include "qeglfshooks.h" #include "qeglfscursor.h" +#include #include #include @@ -56,17 +57,34 @@ QT_BEGIN_NAMESPACE // this is a global static to keep the QEglFSHooks interface as clean as possible static int framebuffer = -1; -const char *QEglFSHooks::fbDeviceName() const +QByteArray QEglFSHooks::fbDeviceName() const { - return "/dev/fb0"; + QByteArray fbDev = qgetenv("QT_QPA_EGLFS_FB"); + if (fbDev.isEmpty()) + fbDev = QByteArrayLiteral("/dev/fb0"); + + return fbDev; +} + +int QEglFSHooks::framebufferIndex() const +{ + int fbIndex = 0; + QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)")); + QRegularExpressionMatch match = fbIndexRx.match(fbDeviceName()); + if (match.hasMatch()) + fbIndex = match.captured(1).toInt(); + + return fbIndex; } void QEglFSHooks::platformInit() { - framebuffer = qt_safe_open(fbDeviceName(), O_RDONLY); + QByteArray fbDev = fbDeviceName(); + + framebuffer = qt_safe_open(fbDev, O_RDONLY); if (framebuffer == -1) - qWarning("EGLFS: Failed to open %s", fbDeviceName()); + qWarning("EGLFS: Failed to open %s", qPrintable(fbDev)); } void QEglFSHooks::platformDestroy() From 9132dbb6592c3357585d5c589b48d814497f1cc5 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Thu, 16 Jan 2014 11:31:51 +0100 Subject: [PATCH 55/72] Do not consider a signal to be connected if only a signal spy is installed. This fixes QtQuick key handling not propagating key events beyond the specific onXPressed handlers, due to erroneously thinking those exist, when signal spy callbacks are present. Considering signal spies for isSignalConnected() goes back to 87239ef6 in Qt4, and seems to be there just due to this code being based on activate(), where this check obviously makes sense. Change-Id: Iad41e42a8d3ee2a16a55be7d1a7cdc51484981ce Reviewed-by: Olivier Goffart --- src/corelib/kernel/qobject.cpp | 5 ++++- src/corelib/kernel/qobject_p.h | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 5819443d3c..43b88d21b5 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3453,8 +3453,11 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i { int signal_index = signalOffset + local_signal_index; - if (!sender->d_func()->isSignalConnected(signal_index)) + if (!sender->d_func()->isSignalConnected(signal_index) + && !qt_signal_spy_callback_set.signal_begin_callback + && !qt_signal_spy_callback_set.signal_end_callback) { return; // nothing connected to these signals, and no spy + } if (sender->d_func()->blockSig) return; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 011e140e3b..8cbb244451 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -248,7 +248,7 @@ public: Returns \c true if the signal with index \a signal_index from object \a sender is connected. Signals with indices above a certain range are always considered connected (see connectedSignals - in QObjectPrivate). If a signal spy is installed, all signals are considered connected. + in QObjectPrivate). \a signal_index must be the index returned by QObjectPrivate::signalIndex; */ @@ -257,9 +257,7 @@ inline bool QObjectPrivate::isSignalConnected(uint signal_index) const return signal_index >= sizeof(connectedSignals) * 8 || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f)) || (declarativeData && QAbstractDeclarativeData::isSignalConnected - && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index)) - || qt_signal_spy_callback_set.signal_begin_callback - || qt_signal_spy_callback_set.signal_end_callback); + && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index))); } inline QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver, From 73b5a5cdd534044573d49fac53666b8490d54c79 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Thu, 16 Jan 2014 12:48:08 +0100 Subject: [PATCH 56/72] test: Don't build qmimedatabase-cache for QNX update-mime-database does not exist, so there is no point in trying to build this test. Change-Id: Id60f2f8fc3af33d3f7ae2fb4f1042356b60f6596 Reviewed-by: David Faure Reviewed-by: Wolfgang Bremer --- tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase.pro b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase.pro index 1ff5546e5c..536a6b64de 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase.pro +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs SUBDIRS = qmimedatabase-xml -unix:!mac: SUBDIRS += qmimedatabase-cache +unix:!mac:!qnx: SUBDIRS += qmimedatabase-cache From 3575ebfd9ddcef90aee107ce76ec181fa9a10735 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jan 2014 08:57:06 -0800 Subject: [PATCH 57/72] Add linux/kd.h to the config test for evdev This header is used by qevdevmousehandler.cpp, so it's not a bad idea to check that it exists as early as here. Apparently, FreeBSD's Linux support has linux/input.h, so the "evdev" test was passing and then the build would fail later. Task-number: QTBUG-36205 Change-Id: Iab9788350a9f4c90d355524769a7a396679fd218 Reviewed-by: Allan Sandfeld Jensen --- config.tests/unix/evdev/evdev.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/config.tests/unix/evdev/evdev.cpp b/config.tests/unix/evdev/evdev.cpp index 475c54a363..3fbce565ce 100644 --- a/config.tests/unix/evdev/evdev.cpp +++ b/config.tests/unix/evdev/evdev.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include enum { e1 = ABS_PRESSURE, From 3a2631391914e002769d0e3f6a934d241fa1d389 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 Jan 2014 17:00:28 -0800 Subject: [PATCH 58/72] Make QCommandLineParser not crash if passed a bad QCommandLineOption This otherwise crashed: QCommandLineOotion opt("with=equals"); parser.isSet(opt); Can't write a unit test because it produces a warning. Change-Id: Ifc67f20bb4b16b96d93dffbe4e82e6cc8a17584d Reviewed-by: David Faure --- src/corelib/tools/qcommandlineparser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index db4c2961f0..c860b4d155 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -720,7 +720,8 @@ QStringList QCommandLineParser::values(const QString &optionName) const */ bool QCommandLineParser::isSet(const QCommandLineOption &option) const { - return isSet(option.names().first()); + // option.names() might be empty if the constructor failed + return !option.names().isEmpty() && isSet(option.names().first()); } /*! From 7c8131763de9e70ca56f16635716e7e00559b5d1 Mon Sep 17 00:00:00 2001 From: "Richard J. Moore" Date: Sun, 12 Jan 2014 16:59:27 +0000 Subject: [PATCH 59/72] Prevent spurious SSL errors from local certificates. Qt since approximately 4.4 has set the verify callback on both the SSL store and the SSL context. Only the latter is actually needed. This is normally not a problem, but openssl prior to 1.0.2 uses the verify code to find the intermediate certificates for any local certificate that has been set which can lead to verification errors for the local certificate to be emitted. Task-number: QTBUG-33228 Task-number: QTBUG-7200 Task-number: QTBUG-24234 Change-Id: Ie4115e7f7faa1267ea9b807c01b1ed6604c4a16c Reviewed-by: Peter Hartmann Reviewed-by: Thiago Macieira --- src/network/ssl/qsslcontext.cpp | 3 --- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/network/ssl/qsslcontext.cpp b/src/network/ssl/qsslcontext.cpp index 037ee8c672..adf42fb79a 100644 --- a/src/network/ssl/qsslcontext.cpp +++ b/src/network/ssl/qsslcontext.cpp @@ -189,9 +189,6 @@ init_context: q_SSL_CTX_load_verify_locations(sslContext->ctx, 0, unixDirs.at(a).constData()); } - // Register a custom callback to get all verification errors. - X509_STORE_set_verify_cb_func(sslContext->ctx->cert_store, q_X509Callback); - if (!sslContext->sslConfiguration.localCertificate().isNull()) { // Require a private key as well. if (sslContext->sslConfiguration.privateKey().isNull()) { diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index a15daf660a..d19e08178a 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1924,9 +1924,6 @@ void tst_QSslSocket::verifyMode() loop.exec(); QVERIFY(clientSocket.isEncrypted()); -#if (defined(UBUNTU_ONEIRIC) && defined(__x86_64__)) || defined(Q_OS_WIN) || defined(Q_OS_MAC) - QEXPECT_FAIL("", "QTBUG-24234", Abort); -#endif QVERIFY(server.socket->sslErrors().isEmpty()); } From 39262323d32306fb8f3bd0f5543b406a786c088e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Thu, 12 Sep 2013 12:18:45 +0000 Subject: [PATCH 60/72] Optimize QDateTime string parsing The patch reduces amount of allocations during string parsing by using QStringRef. The operation is safe as neither QDate nor QTime uses QString as a storage type Change-Id: Ib9f40d86e8e420653ac4fe8ba883d554331ffc32 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 42 ++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 5438f00c67..33a8ffa04c 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1902,7 +1902,7 @@ int QTime::msecsTo(const QTime &t) const #ifndef QT_NO_DATESTRING -static QTime fromIsoTimeString(const QString &string, Qt::DateFormat format, bool *isMidnight24) +static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, bool *isMidnight24) { if (isMidnight24) *isMidnight24 = false; @@ -1935,9 +1935,13 @@ static QTime fromIsoTimeString(const QString &string, Qt::DateFormat format, boo // the maximum amount of millisecond digits it will expand to once converted to // seconds is 4. E.g. 12:34,99999 will expand to 12:34:59.9994. The milliseconds // will then be rounded up AND clamped to 999. - const float minuteFraction = QString::fromUtf8("0.%1").arg(string.mid(6, 5)).toFloat(&ok); + + const QStringRef minuteFractionStr = string.mid(6, 5); + const long minuteFractionInt = minuteFractionStr.toLong(&ok); if (!ok) return QTime(); + const float minuteFraction = double(minuteFractionInt) / (pow(double(10), minuteFractionStr.count())); + const float secondWithMs = minuteFraction * 60; const float secondNoMs = std::floor(secondWithMs); const float secondFraction = secondWithMs - secondNoMs; @@ -1949,9 +1953,11 @@ static QTime fromIsoTimeString(const QString &string, Qt::DateFormat format, boo if (!ok) return QTime(); if (size > 8 && (string.at(8) == QLatin1Char(',') || string.at(8) == QLatin1Char('.'))) { - const double secondFraction = QString::fromUtf8("0.%1").arg(string.mid(9, 4)).toDouble(&ok); + const QStringRef msecStr(string.mid(9, 4)); + int msecInt = msecStr.isEmpty() ? 0 : msecStr.toInt(&ok); if (!ok) return QTime(); + const double secondFraction(msecInt / (pow(double(10), msecStr.count()))); msec = qMin(qRound(secondFraction * 1000.0), 999); } } @@ -2001,7 +2007,7 @@ QTime QTime::fromString(const QString& string, Qt::DateFormat format) case Qt::ISODate: case Qt::TextDate: default: - return fromIsoTimeString(string, format, 0); + return fromIsoTimeString(&string, format, 0); } } @@ -4383,26 +4389,40 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format) if (size < 10) return QDateTime(); - QString isoString = string; + QStringRef isoString(&string); Qt::TimeSpec spec = Qt::LocalTime; - QDate date = QDate::fromString(isoString.left(10), Qt::ISODate); + QDate date = QDate::fromString(string.left(10), Qt::ISODate); if (!date.isValid()) return QDateTime(); if (size == 10) return QDateTime(date); - isoString.remove(0, 11); + isoString = isoString.right(11); int offset = 0; // Check end of string for Time Zone definition, either Z for UTC or [+-]HH:MM for Offset if (isoString.endsWith(QLatin1Char('Z'))) { spec = Qt::UTC; - isoString.chop(1); + isoString = isoString.left(isoString.size() - 1); } else { - const int signIndex = isoString.indexOf(QRegExp(QStringLiteral("[+-]"))); - if (signIndex >= 0) { + // the loop below is faster but functionally equal to: + // const int signIndex = isoString.indexOf(QRegExp(QStringLiteral("[+-]"))); + const int sizeOfTimeZoneString = 4; + int signIndex = isoString.size() - sizeOfTimeZoneString - 1; + bool found = false; + { + const QChar plus = QLatin1Char('+'); + const QChar minus = QLatin1Char('-'); + do { + QChar character(isoString.at(signIndex)); + found = character == plus || character == minus; + } while (--signIndex >= 0 && !found); + ++signIndex; + } + + if (found) { bool ok; - offset = fromOffsetString(isoString.mid(signIndex), &ok); + offset = fromOffsetString(isoString.mid(signIndex).toString(), &ok); if (!ok) return QDateTime(); isoString = isoString.left(signIndex); From 55659fb5a4efd3fee813627350287c0b45a6dc9c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 25 Sep 2013 21:36:15 +0200 Subject: [PATCH 61/72] moc: Fix parsing of complex defines defined via command line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since now in Qt5 the moc does full macro substitution, it needs to handle the defines passed is command argument, even if they span over multiple tokens, or if they do not have any token. Example: moc '-DCOMPLEX=QVector' '-DEMPTY=' foo.h [ChangeLog][moc] Fixed passing -D of a macro defined to something more complex than a single identifier. Task-number: QTBUG-33668 Change-Id: Ie8131de215f1659a24af4778d52ee40cda19759f Reviewed-by: Oswald Buddenhagen Reviewed-by: Jędrzej Nowacki --- src/tools/moc/main.cpp | 3 ++- src/tools/moc/preprocessor.cpp | 3 +-- src/tools/moc/preprocessor.h | 2 ++ tests/auto/tools/moc/moc.pro | 3 +++ tests/auto/tools/moc/parse-defines.h | 12 +++++++++++- tests/auto/tools/moc/tst_moc.cpp | 3 +++ 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 3ae6445093..0a5f6ec241 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -343,7 +343,8 @@ int runMoc(int argc, char **argv) parser.showHelp(1); } Macro macro; - macro.symbols += Symbol(0, PP_IDENTIFIER, value); + macro.symbols = Preprocessor::tokenize(value, 1, Preprocessor::TokenizeDefine); + macro.symbols.removeLast(); // remove the EOF symbol pp.macros.insert(name, macro); } foreach (const QString &arg, parser.values(undefineOption)) { diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 3615262b67..2de495f010 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -158,8 +158,7 @@ bool Preprocessor::skipBranch() } -enum TokenizeMode { TokenizeCpp, TokenizePreprocessor, PreparePreprocessorStatement, TokenizePreprocessorStatement, TokenizeInclude, PrepareDefine, TokenizeDefine }; -static Symbols tokenize(const QByteArray &input, int lineNum = 1, TokenizeMode mode = TokenizeCpp) +Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocessor::TokenizeMode mode) { Symbols symbols; const char *begin = input.constData(); diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h index dc7c98de85..6403955c1b 100644 --- a/src/tools/moc/preprocessor.h +++ b/src/tools/moc/preprocessor.h @@ -89,6 +89,8 @@ public: int evaluateCondition(); + enum TokenizeMode { TokenizeCpp, TokenizePreprocessor, PreparePreprocessorStatement, TokenizePreprocessorStatement, TokenizeInclude, PrepareDefine, TokenizeDefine }; + static Symbols tokenize(const QByteArray &input, int lineNum = 1, TokenizeMode mode = TokenizeCpp); private: void until(Token); diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index 779e992881..9a3fee38f0 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -42,3 +42,6 @@ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 # Ensure that plugin_metadata.h are moc-ed with some extra -M arguments: QMAKE_MOC_OPTIONS += -Muri=com.company.app -Muri=com.company.app.private +# Define macro on the command lines used in parse-defines.h +QMAKE_MOC_OPTIONS += "-DDEFINE_CMDLINE_EMPTY=" "\"-DDEFINE_CMDLINE_SIGNAL=void cmdlineSignal(const QMap &i)\"" + diff --git a/tests/auto/tools/moc/parse-defines.h b/tests/auto/tools/moc/parse-defines.h index aaadcef601..35934853f0 100644 --- a/tests/auto/tools/moc/parse-defines.h +++ b/tests/auto/tools/moc/parse-defines.h @@ -79,9 +79,16 @@ #define PD_ADD_SUFFIX(x) PD_DEFINE1(x,_SUFFIX) #define PD_DEFINE_ITSELF PD_ADD_SUFFIX(PD_DEFINE_ITSELF) +#ifndef Q_MOC_RUN +// macro defined on the command line (in tst_moc.pro) +#define DEFINE_CMDLINE_EMPTY +#define DEFINE_CMDLINE_SIGNAL void cmdlineSignal(const QMap &i) +#endif + PD_BEGIN_NAMESPACE -class PD_CLASSNAME : public QObject +class DEFINE_CMDLINE_EMPTY PD_CLASSNAME DEFINE_CMDLINE_EMPTY + : public DEFINE_CMDLINE_EMPTY QObject DEFINE_CMDLINE_EMPTY { Q_OBJECT Q_CLASSINFO("TestString", PD_STRINGIFY(PD_CLASSNAME)) @@ -140,6 +147,9 @@ public slots: void PD_DEFINE_ITSELF(int) {} +signals: + DEFINE_CMDLINE_SIGNAL; + }; #undef QString diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 7fae29e5ca..8ce55cbdf5 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -3037,6 +3037,9 @@ void tst_Moc::parseDefines() index = mo->indexOfSlot("PD_DEFINE_ITSELF_SUFFIX(int)"); QVERIFY(index != -1); + + index = mo->indexOfSignal("cmdlineSignal(QMap)"); + QVERIFY(index != -1); } void tst_Moc::preprocessorOnly() From cc2079c85032f51e7bb0ac5a296d25777fb652c0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 3 Jan 2014 14:31:31 -0200 Subject: [PATCH 62/72] Fix QtTest function-unused warnings found by Clang 3.4 The front-end functions in the QTest namespace are declared static inline, so the compiler can complain. Make it not do so. Change-Id: I4036c85010e02ef22a8071ed05e49173dfc64729 Reviewed-by: Jason McDonald --- src/testlib/qtestkeyboard.h | 12 ++++++------ src/testlib/qtestsystem.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h index 878806737e..d693d66db4 100644 --- a/src/testlib/qtestkeyboard.h +++ b/src/testlib/qtestkeyboard.h @@ -151,17 +151,17 @@ namespace QTest Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) { sendKeyEvent(action, window, key, keyToAscii(key), modifier, delay); } - inline static void keyClick(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + Q_DECL_UNUSED inline static void keyClick(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) { keyEvent(Click, window, key, modifier, delay); } - inline static void keyClick(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + Q_DECL_UNUSED inline static void keyClick(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) { keyEvent(Click, window, key, modifier, delay); } - inline static void keyRelease(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + Q_DECL_UNUSED inline static void keyRelease(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) { keyEvent(Release, window, key, modifier, delay); } - inline static void keyRelease(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + Q_DECL_UNUSED inline static void keyRelease(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) { keyEvent(Release, window, key, modifier, delay); } - inline static void keyPress(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + Q_DECL_UNUSED inline static void keyPress(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) { keyEvent(Press, window, key, modifier, delay); } - inline static void keyPress(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + Q_DECL_UNUSED inline static void keyPress(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) { keyEvent(Press, window, key, modifier, delay); } #ifdef QT_WIDGETS_LIB diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index 2a719e96f1..f859ff164d 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE namespace QTest { - inline static void qWait(int ms) + Q_DECL_UNUSED inline static void qWait(int ms) { Q_ASSERT(QCoreApplication::instance()); From e4d6488ffa46fb3505376d656835470675a59fef Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 21 Nov 2013 17:21:57 +0100 Subject: [PATCH 63/72] QCocoaTheme: Fix size of pixmap returned by fileIconPixmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code assumed that CGImageForProposedRect would return a sensible sized image, but that can return basically any size (depending on the NSImage's image representations). In the case of the bug report this is a 1024x1024 pixmap when requesting a pixmap of size 64x64 and larger. Make sure that we return a pixmap of the exact requested size. For this, themeHint must also return sizes in device coordinates. Task-number: QTBUG-35009 Change-Id: Iaae11023bab6d4122815ca4010aab6967dfb18a0 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoatheme.mm | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 1484ae2ba3..d863861288 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -258,13 +258,17 @@ QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &siz NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo.canonicalFilePath())]; if (!iconImage) return QPixmap(); - - NSRect iconRect = NSMakeRect(0, 0, size.width(), size.height()); - NSGraphicsContext *gc = [NSGraphicsContext currentContext]; - CGImageRef cgImage = [iconImage CGImageForProposedRect:&iconRect - context:([gc graphicsPort] ? gc : nil) - hints:nil]; - QPixmap pixmap = QPixmap::fromImage(qt_mac_toQImage(cgImage)); + NSSize pixmapSize = NSMakeSize(size.width(), size.height()); + QPixmap pixmap(pixmapSize.width, pixmapSize.height); + pixmap.fill(Qt::transparent); + [iconImage setSize:pixmapSize]; + NSRect iconRect = NSMakeRect(0, 0, pixmapSize.width, pixmapSize.height); + CGContextRef ctx = qt_mac_cg_context(&pixmap); + NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES]; + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:gc]; + [iconImage drawInRect:iconRect fromRect:iconRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil]; + [NSGraphicsContext restoreGraphicsState]; return pixmap; } @@ -280,8 +284,12 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const case TabAllWidgets: return QVariant(bool([[NSApplication sharedApplication] isFullKeyboardAccessEnabled])); case IconPixmapSizes: { + qreal devicePixelRatio = qGuiApp->devicePixelRatio(); QList sizes; - sizes << 16 << 32 << 64 << 128; + sizes << 16 * devicePixelRatio + << 32 * devicePixelRatio + << 64 * devicePixelRatio + << 128 * devicePixelRatio; return QVariant::fromValue(sizes); } case QPlatformTheme::PasswordMaskCharacter: From e0484dca75de97c11f2aaad6df33e4de8aa733c0 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Fri, 17 Jan 2014 17:27:26 +0100 Subject: [PATCH 64/72] QNX: Fix compilation of qdatetime.cpp Adding std:: to pow() to make it compile for BlackBerry 10. Change-Id: I9ab3cc626eb2ba872c09df33cdb820b50d075428 Reviewed-by: Wolfgang Bremer Reviewed-by: Fabian Bumberger Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 33a8ffa04c..6177012e4b 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1940,7 +1940,7 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, const long minuteFractionInt = minuteFractionStr.toLong(&ok); if (!ok) return QTime(); - const float minuteFraction = double(minuteFractionInt) / (pow(double(10), minuteFractionStr.count())); + const float minuteFraction = double(minuteFractionInt) / (std::pow(double(10), minuteFractionStr.count())); const float secondWithMs = minuteFraction * 60; const float secondNoMs = std::floor(secondWithMs); @@ -1957,7 +1957,7 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, int msecInt = msecStr.isEmpty() ? 0 : msecStr.toInt(&ok); if (!ok) return QTime(); - const double secondFraction(msecInt / (pow(double(10), msecStr.count()))); + const double secondFraction(msecInt / (std::pow(double(10), msecStr.count()))); msec = qMin(qRound(secondFraction * 1000.0), 999); } } From eae8abbc188db559bb1509dbcab6807252edc32e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 14 Jan 2014 15:30:35 +0100 Subject: [PATCH 65/72] Fix detecting the system path The normalize function don't do well it's job. Given a path like that, the regexp "/[^/]+/.." will match 3 times /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../include/c++/4.8.2 [ ][ ][ ] The second match is wrong as it will remove /../.. Use sub instead of gsub which only remove one match at the time. Change-Id: I0657bc603e521c9e53b9f50d2481dce184b64bad Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 9646fd31e5..90c349cfc7 100755 --- a/configure +++ b/configure @@ -3508,7 +3508,7 @@ function normalize(dir) { do { odir = dir - gsub(/\/[^\/]+\/\.\./, "", dir) + sub(/\/[^\/]+\/\.\./, "", dir) } while (dir != odir); do { odir = dir From ec77f93b389d0a69af54f278a8bf7c4919fd696c Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Fri, 17 Jan 2014 13:28:37 +0100 Subject: [PATCH 66/72] Fix crash when constructing a QVector with an empty initializer list. Data::allocate(0) returns a pointer to read-only memory, updating d->size will segfault. The safety check for this exists in all other QVector ctors already. Change-Id: Ida0fe4182de56ee62c7f91e8652cfafbfd7b8410 Reviewed-by: Thiago Macieira --- src/corelib/tools/qvector.h | 14 +++++++++----- tests/auto/corelib/tools/qvector/tst_qvector.cpp | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index f56511edbf..505e1a32e4 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -438,11 +438,15 @@ QVector::QVector(int asize, const T &t) template QVector::QVector(std::initializer_list args) { - d = Data::allocate(args.size()); - // std::initializer_list::iterator is guaranteed to be - // const T* ([support.initlist]/1), so can be memcpy'ed away from by copyConstruct - copyConstruct(args.begin(), args.end(), d->begin()); - d->size = int(args.size()); + if (args.size() > 0) { + d = Data::allocate(args.size()); + // std::initializer_list::iterator is guaranteed to be + // const T* ([support.initlist]/1), so can be memcpy'ed away from by copyConstruct + copyConstruct(args.begin(), args.end(), d->begin()); + d->size = int(args.size()); + } else { + d = Data::sharedNull(); + } } #endif diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 53caec4a64..59956e33cf 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -2042,6 +2042,9 @@ void tst_QVector::initializeList() QVector> v3; v3 << v1 << (QVector() << val4) << QVector() << v1; QCOMPARE(v3, v2); + + QVector v4({}); + QCOMPARE(v4.size(), 0); #endif } From b095479d1418d7dc83a5b15f1d8118b39f768b16 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 17 Jan 2014 09:57:24 +0100 Subject: [PATCH 67/72] Fix typos in QUrl::toAce() documentation. Change-Id: I6b101c57c537523fb48e57985e1d69c4327a67aa Reviewed-by: Jerome Pasion --- src/corelib/io/qurl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 77aa3c4821..eac5a0b738 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3437,7 +3437,7 @@ QString QUrl::fromAce(const QByteArray &domain) (like \c "example.com") to be written using international characters. - This function return an empty QByteArra if \a domain is not a valid + This function returns an empty QByteArray if \a domain is not a valid hostname. Note, in particular, that IPv6 literals are not valid domain names. */ From 446f9f2812e9f351caca11750792dadbd4e53662 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 13 Dec 2013 20:20:09 +0100 Subject: [PATCH 68/72] Fix QPixmap and OpenGL threading warnings when painting If the QPA supports threaded pixmaps, don't print out a message warning the user about painting a pixmap in the non-main thread. Likewise, if the QPA supports threaded OpenGL, don't print out a warning when the user is about to paint on OpenGL from a non-main thread. Change-Id: I5b4928ee49b1d6c1b638b036fade12dc794258df Reviewed-by: Albert Astals Cid Reviewed-by: Laszlo Agocs --- src/gui/painting/qpainter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 424ed554a2..41a2e39fc9 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -62,6 +62,7 @@ #include "qglyphrun.h" #include +#include #include #include @@ -155,7 +156,9 @@ static bool qt_painter_thread_test(int devType, const char *what) // can be drawn onto these devices safely from any thread break; default: - if (QThread::currentThread() != qApp->thread()) { + if (QThread::currentThread() != qApp->thread() + && (devType!=QInternal::Pixmap || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) + && (devType!=QInternal::OpenGL || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL))) { qWarning("QPainter: It is not safe to use %s outside the GUI thread", what); return false; } From 7ffce3fb0bb0bd42aa359467d66691ef8a4762df Mon Sep 17 00:00:00 2001 From: Bartosz Brachaczek Date: Sun, 29 Dec 2013 04:01:27 +0100 Subject: [PATCH 69/72] Fix cd(), cdUp() QDir member functions docs regarding nonreadable dirs The documentation implies that cd() and cdUp() functions return false if the new directory is not readable, but that is not the case. It is an obvious mistake in the documentation, because cd'ing into a nonreadable directory is perfectly valid. Provided also with a test to verify that cd() actually returns true with nonreadable directories. Change-Id: I4aa3e859b35c64266df510a203574e3701aea77c Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/io/qdir.cpp | 4 ++-- tests/auto/corelib/io/qdir/tst_qdir.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 43db2ec1fe..015f4cfe14 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -855,7 +855,7 @@ QString QDir::fromNativeSeparators(const QString &pathName) /*! Changes the QDir's directory to \a dirName. - Returns \c true if the new directory exists and is readable; + Returns \c true if the new directory exists; otherwise returns \c false. Note that the logical cd() operation is not performed if the new directory does not exist. @@ -923,7 +923,7 @@ bool QDir::cd(const QString &dirName) Changes directory by moving one directory up from the QDir's current directory. - Returns \c true if the new directory exists and is readable; + Returns \c true if the new directory exists; otherwise returns \c false. Note that the logical cdUp() operation is not performed if the new directory does not exist. diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index fbb21e4e9a..96be5065d6 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -193,6 +193,8 @@ private slots: void isReadable(); + void cdNonreadable(); + void cdBelowRoot(); private: @@ -1990,6 +1992,23 @@ void tst_QDir::isReadable() #endif } +void tst_QDir::cdNonreadable() +{ +#ifdef Q_OS_UNIX + if (::getuid() == 0) + QSKIP("Running this test as root doesn't make sense"); + + QDir dir; + QVERIFY(dir.mkdir("nonreadabledir2")); + QVERIFY(0 == ::chmod("nonreadabledir2", S_IWUSR | S_IXUSR)); + QVERIFY(dir.cd("nonreadabledir2")); + QVERIFY(!dir.isReadable()); + QVERIFY(dir.cd("..")); + QVERIFY(0 == ::chmod("nonreadabledir2", S_IRUSR | S_IWUSR | S_IXUSR)); + QVERIFY(dir.rmdir("nonreadabledir2")); +#endif +} + void tst_QDir::cdBelowRoot() { #if defined (Q_OS_UNIX) From f2d76cb524884491cca29a6f60861fb49121be11 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 6 Jan 2014 18:23:19 +0100 Subject: [PATCH 70/72] clear OBJECTIVE_SOURCES as well the newly added mac examples use it, so it needs to be grounded. a more generic solution would be clearing out QMAKE_EXTRA_COMPILERS, but many prf files will be loaded after us, possibly nullifying our effort. Task-number: QTBUG-35680 Change-Id: I3aba7595898baac14bd41e9fae2ff24507187c6a Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_example_installs.prf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/features/qt_example_installs.prf b/mkspecs/features/qt_example_installs.prf index 2db752c1e4..ff842ca754 100644 --- a/mkspecs/features/qt_example_installs.prf +++ b/mkspecs/features/qt_example_installs.prf @@ -97,6 +97,7 @@ probase = $$relative_path($$_PRO_FILE_PWD_, $$dirname(_QMAKE_CONF_)/examples) TEMPLATE = aux CONFIG -= have_target qt staticlib dll SOURCES = + OBJECTIVE_SOURCES = INSTALLS -= target } } From bbee8ca485acc6bad7021f4e1cb3e5b8cd32e8fc Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 14 Jan 2014 10:44:24 +0100 Subject: [PATCH 71/72] Fix warning in QVariant test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Values from different enums were compared. Change-Id: I2faf73976e4b24abbdc915e8445256fe7a5be5bd Reviewed-by: Stephen Kelly Reviewed-by: Jędrzej Nowacki --- tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 42570751fc..7512829e09 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -640,7 +640,7 @@ void tst_QGuiVariant::writeToReadFromOldDataStream() dataFileStream.setVersion(QDataStream::Qt_4_9); QVariant readVariant; dataFileStream >> readVariant; - QVERIFY(readVariant.type() == QMetaType::QPolygonF); + QVERIFY(readVariant.userType() == QMetaType::QPolygonF); QCOMPARE(testVariant, readVariant); file.close(); } From 03b6a2f0f98b70b24c0cce645d6d58c084111f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 6 Jan 2014 12:21:21 +0100 Subject: [PATCH 72/72] Mac: Improve transformed QGraphicsProxyWidgets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restore Mac code paths from Qt 4. Task-number: QTBUG-29139 Change-Id: I2893ddf6015e2bda92d4a16980dbe2c9021eeef7 Reviewed-by: Morten Johan Sørvig --- src/widgets/graphicsview/qgraphicswidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index ccc51120a9..40d32ea1d5 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -2274,7 +2274,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap const QPointF styleOrigin = this->windowFrameRect().topLeft(); painter->translate(styleOrigin); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC const QSize pixmapSize = windowFrameRect.size(); if (pixmapSize.width() <= 0 || pixmapSize.height() <= 0) return; @@ -2342,7 +2342,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap frameOptions.midLineWidth = 1; style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC realPainter->drawPixmap(QPoint(), pm); delete painter; #endif