From ec68f67ee55944e1f05bdbe1362832ee2ab156c7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 20 Sep 2014 18:08:16 +0200 Subject: [PATCH 001/102] XCB: silence warnings about possibly undefined shifts The code shifts "1" by a uint32 number. If that number is >= 32, we're triggering undefined behavior, and Coverity rightfully complains about that. Add some asserts to silence those warnings. Change-Id: Ib91085a279b0a2b7ad37afad05ec1d764c0496b1 Reviewed-by: Uli Schlachter Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index a873ba97d7..9bf4f90c20 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -865,6 +865,10 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const xkb_mod_index_t altMod = xkb_keymap_mod_get_index(xkb_keymap, "Alt"); xkb_mod_index_t controlMod = xkb_keymap_mod_get_index(xkb_keymap, "Control"); + Q_ASSERT(shiftMod < 32); + Q_ASSERT(altMod < 32); + Q_ASSERT(controlMod < 32); + xkb_mod_mask_t depressed; struct xkb_keymap *fallback_keymap = 0; int qtKey = 0; From 8d8000b5feb35fd284d11118891d9d72fafef3cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Mon, 22 Sep 2014 16:03:00 +0200 Subject: [PATCH 002/102] Android: Don't call requestLayout() when changing the geometry. requestLayout() is already called when setLayoutParams() is called, so calling it again is extremely wasteful. Change-Id: Iddfb488830a6b7277a653a84ffacabf966baf0b5 Reviewed-by: BogDan Vatra --- .../jar/src/org/qtproject/qt5/android/QtActivityDelegate.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index 6dad8888ce..ed5be81d80 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -1090,8 +1090,6 @@ public class QtActivityDelegate Log.e(QtNative.QtTAG, "Surface " + id +" not found!"); return; } - - m_layout.requestLayout(); } public void destroySurface(int id) { From 7755b4af417e6b6da3dac0617eb2ce3a37b9a53c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 8 Oct 2014 09:51:10 +0200 Subject: [PATCH 003/102] Android: null pointer check Task-number: QTBUG-41680 Change-Id: I740fb2a6df5613a8ee724b59dab08674a3337236 Reviewed-by: Kai Uwe Broulik Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../jar/src/org/qtproject/qt5/android/QtInputConnection.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java b/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java index 6de66fe512..80028e1b02 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java @@ -174,6 +174,9 @@ public class QtInputConnection extends BaseInputConnection QtExtractedText qExtractedText = QtNativeInputConnection.getExtractedText(request.hintMaxChars, request.hintMaxLines, flags); + if (qExtractedText == null) + return null; + ExtractedText extractedText = new ExtractedText(); extractedText.partialEndOffset = qExtractedText.partialEndOffset; extractedText.partialStartOffset = qExtractedText.partialStartOffset; From c712ec4543bb9a3db469ffd909e01d97c48ff697 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 22 Sep 2014 14:22:53 +0200 Subject: [PATCH 004/102] Android: Thread fix/optimization Do the cheap test before sending an expensive query that might use a mutex. Task-number: QTBUG-41369 Change-Id: I78f03c84e5bbf0492f1b7ea18d1baa752a1beff2 Reviewed-by: Christian Stromme --- src/plugins/platforms/android/qandroidinputcontext.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index a23d05520c..ca9d1e69c9 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -642,13 +642,13 @@ jboolean QAndroidInputContext::deleteSurroundingText(jint leftLength, jint right // Android docs say the cursor must not move jboolean QAndroidInputContext::finishComposingText() { + if (m_composingText.isEmpty()) + return JNI_TRUE; // not composing + QSharedPointer query = focusObjectInputMethodQueryThreadSafe(); if (query.isNull()) return JNI_FALSE; - if (m_composingText.isEmpty()) - return JNI_TRUE; // not composing - const int blockPos = getBlockPosition(query); const int localCursorPos = m_composingCursor - blockPos; From e31a7e46eaeb7c3590f3099a08ed085edb21c906 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Oct 2014 12:42:13 +0200 Subject: [PATCH 005/102] Android: Support QClipboard::clear() QClipboard::clear() is implemented by calling QPlatformClipboard::setMimeData() with a null pointer. Since we would do nothing in this case on Android, then the clear() function would have no effect. [ChangeLog][Android] Added support for QClipboard::clear() Task-number: QTBUG-41854 Change-Id: Id569b102f2e561e46967b52f89d9b54031d92456 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/android/qandroidplatformclipboard.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.cpp b/src/plugins/platforms/android/qandroidplatformclipboard.cpp index 86fd152bff..70bdbad11f 100644 --- a/src/plugins/platforms/android/qandroidplatformclipboard.cpp +++ b/src/plugins/platforms/android/qandroidplatformclipboard.cpp @@ -53,10 +53,8 @@ QMimeData *QAndroidPlatformClipboard::mimeData(QClipboard::Mode mode) void QAndroidPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) { - if (!data || !data->hasText() || QClipboard::Clipboard != mode) - return; - - QtAndroidClipboard::setClipboardText(data->text()); + Q_ASSERT(supportsMode(mode)); + QtAndroidClipboard::setClipboardText(data != 0 && data->hasText() ? data->text() : QString()); } bool QAndroidPlatformClipboard::supportsMode(QClipboard::Mode mode) const From 5f1f955524d003af4714e43c19062fa07c1d58f8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Oct 2014 12:43:57 +0200 Subject: [PATCH 006/102] Android: Fix memory leak in QClipboard::setMimeData() The ownership of the object passed into QClipboard::setMimeData() is documented to be transferred to the clipboard, but we never deleted it, thus all these objects would leak. [ChangeLog][Android] Fixed memory leak in QClipboard::setMimeData() Change-Id: I43e6bad1071be5f56c219cb9341584edba54d2bd Task-number: QTBUG-41852 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidplatformclipboard.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.cpp b/src/plugins/platforms/android/qandroidplatformclipboard.cpp index 70bdbad11f..3515be436d 100644 --- a/src/plugins/platforms/android/qandroidplatformclipboard.cpp +++ b/src/plugins/platforms/android/qandroidplatformclipboard.cpp @@ -55,6 +55,7 @@ void QAndroidPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mo { Q_ASSERT(supportsMode(mode)); QtAndroidClipboard::setClipboardText(data != 0 && data->hasText() ? data->text() : QString()); + delete data; } bool QAndroidPlatformClipboard::supportsMode(QClipboard::Mode mode) const From 9ddf2fb3768e87cc1f6dbb181261d68f266f4327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Siedlarek?= Date: Sat, 4 Oct 2014 10:58:09 +0200 Subject: [PATCH 007/102] Prevent parsing of SSL certificates from 0-size buffers. When QSslCertificatePrivate::certificatesFromDer() was passed count == -1 to extract unlimied number of certificates from buffer, it also tried to parse the 0-sized fragment after the last certificate. This has caused d2i_X509() to report an error on latest OpenSSL. Task-number: QTBUG-41774 Change-Id: Ifa36b7ac5b4236bd2fb53b9d7fe53c5db3cb078c Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcertificate_openssl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/ssl/qsslcertificate_openssl.cpp b/src/network/ssl/qsslcertificate_openssl.cpp index 664f5eba08..850654835d 100644 --- a/src/network/ssl/qsslcertificate_openssl.cpp +++ b/src/network/ssl/qsslcertificate_openssl.cpp @@ -683,7 +683,7 @@ QList QSslCertificatePrivate::certificatesFromDer(const QByteAr #endif int size = der.size(); - while (count == -1 || certificates.size() < count) { + while (size > 0 && (count == -1 || certificates.size() < count)) { if (X509 *x509 = q_d2i_X509(0, &data, size)) { certificates << QSslCertificate_from_X509(x509); q_X509_free(x509); From 8fc34e42a88835c4f1ceda1a23b9bbefcfb9039e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Siedlarek?= Date: Sat, 4 Oct 2014 11:44:18 +0200 Subject: [PATCH 008/102] Add information about unsupported SSL protocol when creating context. When creating SSL context failed due to unsupported protocol being demanded, no explanation was given. It's because QSslContext::fromConfiguration() extracted explanation for error message from OpenSSL, which at that point hasn't even been called yet. This patch adds explicit message informing that an unsupported protocol was chosen. Task-number: QTBUG-41775 Change-Id: I9d2710da4ba314a16837a90afcdc5d9256179bef Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcontext_openssl.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp index 1f787b0da3..6daddebba3 100644 --- a/src/network/ssl/qsslcontext_openssl.cpp +++ b/src/network/ssl/qsslcontext_openssl.cpp @@ -124,13 +124,16 @@ QSslContext* QSslContext::fromConfiguration(QSslSocket::SslMode mode, const QSsl bool client = (mode == QSslSocket::SslClientMode); bool reinitialized = false; + bool unsupportedProtocol = false; init_context: switch (sslContext->sslConfiguration.protocol()) { case QSsl::SslV2: #ifndef OPENSSL_NO_SSL2 sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv2_client_method() : q_SSLv2_server_method()); #else - sslContext->ctx = 0; // SSL 2 not supported by the system, but chosen deliberately -> error + // SSL 2 not supported by the system, but chosen deliberately -> error + sslContext->ctx = 0; + unsupportedProtocol = true; #endif break; case QSsl::SslV3: @@ -149,14 +152,18 @@ init_context: #if OPENSSL_VERSION_NUMBER >= 0x10001000L sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_1_client_method() : q_TLSv1_1_server_method()); #else - sslContext->ctx = 0; // TLS 1.1 not supported by the system, but chosen deliberately -> error + // TLS 1.1 not supported by the system, but chosen deliberately -> error + sslContext->ctx = 0; + unsupportedProtocol = true; #endif break; case QSsl::TlsV1_2: #if OPENSSL_VERSION_NUMBER >= 0x10001000L sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_2_client_method() : q_TLSv1_2_server_method()); #else - sslContext->ctx = 0; // TLS 1.2 not supported by the system, but chosen deliberately -> error + // TLS 1.2 not supported by the system, but chosen deliberately -> error + sslContext->ctx = 0; + unsupportedProtocol = true; #endif break; } @@ -169,7 +176,9 @@ init_context: goto init_context; } - sslContext->errorStr = QSslSocket::tr("Error creating SSL context (%1)").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl()); + sslContext->errorStr = QSslSocket::tr("Error creating SSL context (%1)").arg( + unsupportedProtocol ? QSslSocket::tr("unsupported protocol") : QSslSocketBackendPrivate::getErrorsFromOpenSsl() + ); sslContext->errorCode = QSslError::UnspecifiedError; return sslContext; } From 26c104d120aff93f9da24dfeba3b64864d9f6a37 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 9 Oct 2014 16:38:38 +0200 Subject: [PATCH 009/102] Add a warning when using QOpenGLWidget as a native child Just like it is done for QQuickWidget. Task-number: QTBUG-41779 Change-Id: I1b27c2ed34ecb2520edf82843b675dbf6b0eab8e Reviewed-by: Michael Bruning Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qopenglwidget.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 543f59d7d1..7782c4c1d4 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -506,6 +506,12 @@ void QOpenGLWidgetPaintDevice::ensureActiveTarget() GLuint QOpenGLWidgetPrivate::textureId() const { + Q_Q(const QOpenGLWidget); + if (!q->isWindow() && q->internalWinId()) { + qWarning() << "QOpenGLWidget cannot be used as a native child widget." + << "Consider setting Qt::AA_DontCreateNativeWidgetAncestors and Siblings."; + return 0; + } return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0); } From f813a3e8ad65f6a38da866dff7683650abff334d Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Fri, 10 Oct 2014 12:16:36 +0200 Subject: [PATCH 010/102] Print warning when unable to query physical screen size This warning was removed when re-factoring code in: 328f2f9c35f3cc5e7049a060a608c3f72876484a Change-Id: I5a9d7fbbf2b78e6e80a79478f4e9fb08ccaec431 Reviewed-by: Laszlo Agocs --- src/platformsupport/eglconvenience/qeglconvenience.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index b7ce6dfaf3..1fdeec3adb 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -487,6 +487,11 @@ QSizeF q_physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize size.setWidth(w <= 0 ? screenResolution.width() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w)); size.setHeight(h <= 0 ? screenResolution.height() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h)); + + if (w <= 0 || h <= 0) + qWarning("Unable to query physical screen size, defaulting to %d dpi.\n" + "To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH " + "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi); } return size; From bf73ab490de127d1a22cb31acb2e251b1daef328 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 9 Oct 2014 08:25:41 +0200 Subject: [PATCH 011/102] Disable tst_qhostinfo on OS X. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-41847 Change-Id: Idfb4058a50a0baecce1b3e430629ec6b2867550b Reviewed-by: Morten Johan Sørvig --- tests/auto/network/kernel/kernel.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/network/kernel/kernel.pro b/tests/auto/network/kernel/kernel.pro index 8594ad5932..bb13c7dd7d 100644 --- a/tests/auto/network/kernel/kernel.pro +++ b/tests/auto/network/kernel/kernel.pro @@ -14,6 +14,9 @@ winrt: SUBDIRS -= \ qnetworkproxy \ qnetworkproxyfactory \ +osx: SUBDIRS -= \ # QTBUG-41847 + qhostinfo \ + !contains(QT_CONFIG, private_tests): SUBDIRS -= \ qauthenticator \ qhostinfo \ From eaf04207bddd778380cae178db1bf3cce7d6b9df Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 8 Oct 2014 16:57:07 +0200 Subject: [PATCH 012/102] Improve threadedqopenglwidget example. Retrieve vendor/renderer name similar to context info and exclude renderers that do not support threaded Open GL (ANGLE/noveau). Change-Id: I690c2fc277538bf28bf1f6032c2e017ede15e434 Reviewed-by: Laszlo Agocs --- .../opengl/threadedqopenglwidget/glwidget.h | 2 +- .../opengl/threadedqopenglwidget/main.cpp | 47 +++++++++++++++---- .../threadedqopenglwidget/mainwindow.cpp | 1 + 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/examples/opengl/threadedqopenglwidget/glwidget.h b/examples/opengl/threadedqopenglwidget/glwidget.h index 8319faf322..c063e846dc 100644 --- a/examples/opengl/threadedqopenglwidget/glwidget.h +++ b/examples/opengl/threadedqopenglwidget/glwidget.h @@ -100,7 +100,7 @@ class GLWidget : public QOpenGLWidget { Q_OBJECT public: - GLWidget(QWidget *parent); + explicit GLWidget(QWidget *parent = 0); ~GLWidget(); protected: diff --git a/examples/opengl/threadedqopenglwidget/main.cpp b/examples/opengl/threadedqopenglwidget/main.cpp index 75b7f5e46f..2c94469b7c 100644 --- a/examples/opengl/threadedqopenglwidget/main.cpp +++ b/examples/opengl/threadedqopenglwidget/main.cpp @@ -40,10 +40,19 @@ #include #include +#include #include +#include #include "mainwindow.h" #include "glwidget.h" +static QString getGlString(QOpenGLFunctions *functions, GLenum name) +{ + if (const GLubyte *p = functions->glGetString(name)) + return QString::fromLatin1(reinterpret_cast(p)); + return QString(); +} + int main( int argc, char ** argv ) { QApplication a( argc, argv ); @@ -54,20 +63,38 @@ int main( int argc, char ** argv ) // Two top-level windows with two QOpenGLWidget children in each. // The rendering for the four QOpenGLWidgets happens on four separate threads. - MainWindow mw1; - mw1.setMinimumSize(800, 400); - mw1.show(); + GLWidget topLevelGlWidget; + QPoint pos = QApplication::desktop()->availableGeometry(&topLevelGlWidget).topLeft() + QPoint(200, 200); + topLevelGlWidget.setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example top level")); + topLevelGlWidget.resize(200, 200); + topLevelGlWidget.move(pos); + topLevelGlWidget.show(); + + const QString glInfo = getGlString(topLevelGlWidget.context()->functions(), GL_VENDOR) + + QLatin1Char('/') + getGlString(topLevelGlWidget.context()->functions(), GL_RENDERER); + + const bool supportsThreading = !glInfo.contains(QLatin1String("nouveau"), Qt::CaseInsensitive) + && !glInfo.contains(QLatin1String("ANGLE"), Qt::CaseInsensitive); + + const QString toolTip = supportsThreading ? glInfo : glInfo + QStringLiteral("\ndoes not support threaded OpenGL."); + topLevelGlWidget.setToolTip(toolTip); + + QScopedPointer mw1; QScopedPointer mw2; - if (!QApplication::arguments().contains(QStringLiteral("--single"))) { + if (supportsThreading && !QApplication::arguments().contains(QStringLiteral("--single"))) { + pos += QPoint(100, 100); + mw1.reset(new MainWindow); + mw1->setToolTip(toolTip); + mw1->move(pos); + mw1->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #1")); + mw1->show(); + pos += QPoint(100, 100); mw2.reset(new MainWindow); - mw2->setMinimumSize(800, 400); + mw2->setToolTip(toolTip); + mw2->move(pos); + mw2->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #2")); mw2->show(); - - // And a top-level. - GLWidget *bonus = new GLWidget(0); - bonus->resize(200, 200); - bonus->show(); } return a.exec(); diff --git a/examples/opengl/threadedqopenglwidget/mainwindow.cpp b/examples/opengl/threadedqopenglwidget/mainwindow.cpp index 29c59573cf..de866f5615 100644 --- a/examples/opengl/threadedqopenglwidget/mainwindow.cpp +++ b/examples/opengl/threadedqopenglwidget/mainwindow.cpp @@ -43,6 +43,7 @@ MainWindow::MainWindow() { + setMinimumSize(800, 400); GLWidget *glwidget1 = new GLWidget(this); glwidget1->resize(400, 400); From 8ddaf5c74150d18f2639aeca495ec40efd8e8add Mon Sep 17 00:00:00 2001 From: Tomasz Olszak Date: Fri, 3 Oct 2014 16:48:06 +0200 Subject: [PATCH 013/102] Gcc 4.5.* build fix. Q_COMPILER_DEFAULT_MEMBERS and Q_COMPILER_DELETE_MEMBERS are now set starting from gcc 4.6. Pre-4.6 compilers implement a non-final snapshot of N2346, hence default and delete functions are supported only if they are public. Starting from 4.6, GCC handles final version - the access modifier is not relevant. Compiler error: qsharedpointer_impl.h:717:31: error: 'QEnableSharedFromThis::QEnableSharedFromThis()' declared with non-public access cannot be defaulted in the class body Change-Id: If1d3d4696f91912a09ca72bd4aa1fb07f491a0cb Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 7 +++++-- tests/auto/other/compiler/tst_compiler.cpp | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index ac60d47c7e..8e52c50322 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -730,8 +730,6 @@ /* C++11 features supported in GCC 4.4: */ # define Q_COMPILER_AUTO_FUNCTION # define Q_COMPILER_AUTO_TYPE -# define Q_COMPILER_DEFAULT_MEMBERS -# define Q_COMPILER_DELETE_MEMBERS # define Q_COMPILER_EXTERN_TEMPLATES # define Q_COMPILER_UNIFORM_INIT # define Q_COMPILER_UNICODE_STRINGS @@ -748,6 +746,11 @@ # define Q_COMPILER_CLASS_ENUM # endif # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 + /* Pre-4.6 compilers implement a non-final snapshot of N2346, hence default and delete + * functions are supported only if they are public. Starting from 4.6, GCC handles + * final version - the access modifier is not relevant. */ +# define Q_COMPILER_DEFAULT_MEMBERS +# define Q_COMPILER_DELETE_MEMBERS /* C++11 features supported in GCC 4.6: */ # define Q_COMPILER_CONSTEXPR # define Q_COMPILER_NULLPTR diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index 47345bfc43..8253a283f5 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -784,12 +784,19 @@ void tst_Compiler::cxx11_default_members() #ifndef Q_COMPILER_DEFAULT_MEMBERS QSKIP("Compiler does not support C++11 feature"); #else - struct DefaultMembers + class DefaultMembers { + protected: DefaultMembers() = default; + public: DefaultMembers(int) {} }; - DefaultMembers dm; + class DefaultMembersChild: public DefaultMembers + { + public: + DefaultMembersChild():DefaultMembers() {}; + }; + DefaultMembersChild dm; Q_UNUSED(dm); #endif } @@ -799,9 +806,11 @@ void tst_Compiler::cxx11_delete_members() #ifndef Q_COMPILER_DELETE_MEMBERS QSKIP("Compiler does not support C++11 feature"); #else - struct DeleteMembers + class DeleteMembers { + protected: DeleteMembers() = delete; + public: DeleteMembers(const DeleteMembers &) = delete; ~DeleteMembers() = delete; }; From aa0002057835065d6ddb2be4d3c4deeda3276785 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Oct 2014 11:40:04 +0200 Subject: [PATCH 014/102] Android: Support QSysInfo::productVersion() Gets the user-readable string for the current running Android version. Task-number: QTBUG-41764 Change-Id: Iefea4a4f5291bfddc99bbf901676ccd33fbc23d6 Reviewed-by: Thiago Macieira Reviewed-by: J-P Nurmi --- src/corelib/global/qglobal.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 2696df9e39..ae3e86629e 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2519,7 +2519,9 @@ QString QSysInfo::productVersion() // fall through // Android and Blackberry should not fall through to the Unix code -#elif defined(Q_OS_ANDROID) +#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + return QJNIObjectPrivate::getStaticObjectField("android/os/Build$VERSION", "RELEASE", "Ljava/lang/String;").toString(); +#elif defined(Q_OS_ANDROID) // Q_OS_ANDROID_NO_SDK // TBD #elif defined(Q_OS_BLACKBERRY) deviceinfo_details_t *deviceInfo; From 9685c72e37d618cf44aa15c892375b3c8d27e578 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Oct 2014 12:37:56 +0200 Subject: [PATCH 015/102] Android: Return empty mime data instead of 0 from empty clipboard This is consistent with other platforms such as iOS and XCB, which return a QMimeData with an empty text when the clipboard is empty. [ChangeLog][Android] QClipboard::mimeData() now returns an empty object instead of null pointer from QClipboard when clipboard is empty for consistency with other platforms. Change-Id: I17068f0afcb63690cf11048ffa60e19dc9b08691 Task-number: QTBUG-41817 Reviewed-by: Paul Olav Tvete --- .../platforms/android/qandroidplatformclipboard.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.cpp b/src/plugins/platforms/android/qandroidplatformclipboard.cpp index 3515be436d..a975f4a852 100644 --- a/src/plugins/platforms/android/qandroidplatformclipboard.cpp +++ b/src/plugins/platforms/android/qandroidplatformclipboard.cpp @@ -44,10 +44,10 @@ QAndroidPlatformClipboard::QAndroidPlatformClipboard() QMimeData *QAndroidPlatformClipboard::mimeData(QClipboard::Mode mode) { - if (QClipboard::Clipboard != mode || !QtAndroidClipboard::hasClipboardText()) - return 0; - - m_mimeData.setText(QtAndroidClipboard::clipboardText()); + Q_ASSERT(supportsMode(mode)); + m_mimeData.setText(QtAndroidClipboard::hasClipboardText() + ? QtAndroidClipboard::clipboardText() + : QString()); return &m_mimeData; } From 74a20b77a67ec4d5a8be0f59302075d34151dc05 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Oct 2014 12:46:04 +0200 Subject: [PATCH 016/102] Fix memory leak in QClipboard::setMimeData() The setMimeData() function is documented to take ownership of the object passed in, but in the case where the platform plugin did not support the requested mode, we would simply return without deleting the object nor telling the application, so it would cause a potential memory leak. We need to honor the contract, even when we fail to set the mime data. Test was updated to avoid verifying the leak in cases where the platform does not support all modes. [ChangeLog][QtGui][Clipboard] Fixed a memory leak in setMimeData() when the platform plugin did not support the requested mode. Task-number: QTBUG-41852 Change-Id: I2112da1613199fe1b56724e7ccf097b9e912c117 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qclipboard.cpp | 11 ++++++++--- .../gui/kernel/qclipboard/tst_qclipboard.cpp | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index ec9a8fdcf0..5be9f19b3e 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -463,9 +463,14 @@ const QMimeData* QClipboard::mimeData(Mode mode) const void QClipboard::setMimeData(QMimeData* src, Mode mode) { QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); - if (!clipboard->supportsMode(mode)) return; - - clipboard->setMimeData(src,mode); + if (!clipboard->supportsMode(mode)) { + if (src != 0) { + qWarning("Data set on unsupported clipboard mode. QMimeData object will be deleted."); + src->deleteLater(); + } + } else { + clipboard->setMimeData(src,mode); + } } /*! diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 167e4b41bc..a88f41f7b8 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -340,8 +340,10 @@ void tst_QClipboard::setMimeData() data->setText("foo"); QGuiApplication::clipboard()->setMimeData(data, QClipboard::Clipboard); - QGuiApplication::clipboard()->setMimeData(data, QClipboard::Selection); - QGuiApplication::clipboard()->setMimeData(data, QClipboard::FindBuffer); + if (QGuiApplication::clipboard()->supportsSelection()) + QGuiApplication::clipboard()->setMimeData(data, QClipboard::Selection); + if (QGuiApplication::clipboard()->supportsFindBuffer()) + QGuiApplication::clipboard()->setMimeData(data, QClipboard::FindBuffer); QSignalSpy spySelection(QGuiApplication::clipboard(), SIGNAL(selectionChanged())); QSignalSpy spyData(QGuiApplication::clipboard(), SIGNAL(dataChanged())); @@ -373,8 +375,10 @@ void tst_QClipboard::setMimeData() data->setText("foo"); QGuiApplication::clipboard()->setMimeData(data, QClipboard::Clipboard); - QGuiApplication::clipboard()->setMimeData(data, QClipboard::Selection); - QGuiApplication::clipboard()->setMimeData(data, QClipboard::FindBuffer); + if (QGuiApplication::clipboard()->supportsSelection()) + QGuiApplication::clipboard()->setMimeData(data, QClipboard::Selection); + if (QGuiApplication::clipboard()->supportsFindBuffer()) + QGuiApplication::clipboard()->setMimeData(data, QClipboard::FindBuffer); QMimeData *newData = new QMimeData; newData->setText("bar"); @@ -385,8 +389,10 @@ void tst_QClipboard::setMimeData() spyFindBuffer.clear(); QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Clipboard); - QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Selection); // used to crash on X11 - QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer); + if (QGuiApplication::clipboard()->supportsSelection()) + QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Selection); // used to crash on X11 + if (QGuiApplication::clipboard()->supportsFindBuffer()) + QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer); if (QGuiApplication::clipboard()->supportsSelection()) QCOMPARE(spySelection.count(), 1); From 0647f24c7ddd73b1c4e273a71497f852573b4911 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 9 Oct 2014 14:10:04 +0200 Subject: [PATCH 017/102] QMenu: ensure that a menu item's icon can be removed dynamically Task-number: QTBUG-41348 Change-Id: Iad3b7f000ebce51530f5e196868aefffad2e1eab Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qmenu.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index f2aefe6ea9..0fd645a4d3 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -2980,6 +2980,8 @@ static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* i QStyleOption opt; item->setIconSize(qApp->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0)); } + } else { + item->setIcon(QIcon()); } item->setVisible(action->isVisible()); item->setShortcut(action->shortcut()); From 01f5ba006eb8b7910b36909727c7b1a0b053ea09 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 29 Sep 2014 15:30:08 +0200 Subject: [PATCH 018/102] Fix patching of installation date Marking qt_eval_expiry_date alone as volatile apparently didn't stop the compiler from optimizing away the calculation of the expiry date. Task-number: QTBUG-41612 Change-Id: Ia51fb83f03250346952a76c8a1a641096b4ff9e7 Reviewed-by: Oswald Buddenhagen Reviewed-by: Friedemann Kleint Reviewed-by: Kalle Viironen Reviewed-by: Iikka Eklund --- src/corelib/kernel/qtcore_eval.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp index c0f8897b3b..eb1019534c 100644 --- a/src/corelib/kernel/qtcore_eval.cpp +++ b/src/corelib/kernel/qtcore_eval.cpp @@ -111,10 +111,11 @@ static EvaluationStatus qt_eval_is_supported() static int qt_eval_days_left() { - const char *expiry_date = const_cast(qt_eval_expiry_date + 12); + const volatile char *const expiry_date = qt_eval_expiry_date + 12; QDate today = QDate::currentDate(); - QDate lastday = QDate::fromString(QString::fromLatin1(expiry_date), Qt::ISODate); + QDate lastday = QDate::fromString( + QString::fromLatin1(const_cast(expiry_date)), Qt::ISODate); return today.daysTo(lastday); } From e4493c41b641273e76558b568196a4629a7c4ea6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Oct 2014 10:46:26 +0200 Subject: [PATCH 019/102] DPI-scale PM_SubMenuOverlap after all This actually isn't a magic value and needs to be scaled. This partially reverts commit be1635e2d6a4e42f3f828e7831e5dbf867ba161d. Task-number: QTBUG-41864 Change-Id: Ie03c96c8b5343386f55c3ae9b988e79f943f334e Reviewed-by: Alessandro Portale --- src/widgets/styles/qfusionstyle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 8d7ca42934..c1d6d879a8 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -3098,7 +3098,8 @@ int QFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, co val = 2; break; case PM_SubMenuOverlap: - return -1; // Do not dpi-scale because the value is magic + val = -1; + break; case PM_DockWidgetHandleExtent: case PM_SplitterWidth: val = 4; From 9bbf08fcf3ad141b92dda3af2103dac28ff40f00 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 10 Oct 2014 14:31:47 +0200 Subject: [PATCH 020/102] Android: Make memory handling in QClipboard consistent with iOS On iOS we do deleteLater() on the mime data instead of deleting it directly, in case the application should happen to use the pointer again directly after setting it on the clipboard. Technically it would be a bug in the application, but using deleteLater() is safer and it's better to be consistent with iOS so that a buggy application crashes in the same places in both. Change-Id: I2996d6c7816a2f83615a43609f5be207aaa72c86 Task-number: QTBUG-41853 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidplatformclipboard.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.cpp b/src/plugins/platforms/android/qandroidplatformclipboard.cpp index a975f4a852..fb73db8455 100644 --- a/src/plugins/platforms/android/qandroidplatformclipboard.cpp +++ b/src/plugins/platforms/android/qandroidplatformclipboard.cpp @@ -55,7 +55,8 @@ void QAndroidPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mo { Q_ASSERT(supportsMode(mode)); QtAndroidClipboard::setClipboardText(data != 0 && data->hasText() ? data->text() : QString()); - delete data; + if (data != 0) + data->deleteLater(); } bool QAndroidPlatformClipboard::supportsMode(QClipboard::Mode mode) const From 8c538d10da618add00aba1acbc8d8dc2f24445b4 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 10 Oct 2014 14:00:44 +0200 Subject: [PATCH 021/102] OS X: rename special menu items instead of duplicating Two-part fix: QCocoaMenu::syncMenuItem, when selecting the "old" menu, if an item was merged, 'applicationMenu' was always selected, but this is wrong for any item with a role >= CutRole (such an item still can be "merged", but it's not in the application menu). QCocoaMenuItem::sync - item can be merged with itself: after item's role detected, the search for an item to merge with can find exactly the same item we've just detected the role for (since a data-member is modified) - try to avoid this. Task-number: QTBUG-39934 Change-Id: Ibe1df9e92973380652101143067e14922afdfb9e Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qcocoamenu.mm | 9 +++++++-- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 11 +++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 736e02a3ca..d849389907 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -366,9 +366,14 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) } bool wasMerged = cocoaItem->isMerged(); - NSMenu *oldMenu = wasMerged ? [getMenuLoader() applicationMenu] : m_nativeMenu; - NSMenuItem *oldItem = [oldMenu itemWithTag:(NSInteger) cocoaItem]; + NSMenu *oldMenu = m_nativeMenu; + if (wasMerged) { + QPlatformMenuItem::MenuRole role = cocoaItem->effectiveRole(); + if (role >= QPlatformMenuItem::ApplicationSpecificRole && role < QPlatformMenuItem::CutRole) + oldMenu = [getMenuLoader() applicationMenu]; + } + NSMenuItem *oldItem = [oldMenu itemWithTag:(NSInteger) cocoaItem]; if (cocoaItem->sync() != oldItem) { // native item was changed for some reason if (oldItem) { diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 3d3b6bf598..791b0805d0 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -256,8 +256,8 @@ NSMenuItem *QCocoaMenuItem::sync() if (depth == 3 || !menubar) break; // Menu item too deep in the hierarchy, or not connected to any menubar - m_detectedRole = detectMenuRole(m_text); - switch (m_detectedRole) { + MenuRole newDetectedRole = detectMenuRole(m_text); + switch (newDetectedRole) { case QPlatformMenuItem::AboutRole: if (m_text.indexOf(QRegExp(QString::fromLatin1("qt$"), Qt::CaseInsensitive)) == -1) mergeItem = [loader aboutMenuItem]; @@ -271,12 +271,15 @@ NSMenuItem *QCocoaMenuItem::sync() mergeItem = [loader quitMenuItem]; break; default: - if (m_detectedRole >= CutRole && m_detectedRole < RoleCount && menubar) - mergeItem = menubar->itemForRole(m_detectedRole); + if (newDetectedRole >= CutRole && newDetectedRole < RoleCount && menubar) + mergeItem = menubar->itemForRole(newDetectedRole); if (!m_text.isEmpty()) m_textSynced = true; break; } + + m_detectedRole = newDetectedRole; + break; } From 7c90778487fee7c53e27766ac895c620ad566049 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 10 Oct 2014 12:04:17 +0200 Subject: [PATCH 022/102] Account for the country/language settings when checking for duplicates When a file has the same alias but a different country or language setting then it should not warn about it being a potential duplicate. Task-number: QTBUG-19286 Change-Id: I60a9c422ff02214399bdea3791374a65c9f6c604 Reviewed-by: hjk --- src/tools/rcc/rcc.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 6d4cc12d5c..11a99d136d 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -610,11 +610,18 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file) const QString filename = nodes.at(nodes.size()-1); RCCFileInfo *s = new RCCFileInfo(file); s->m_parent = parent; - if (parent->m_children.contains(filename)) { - foreach (const QString &fileName, m_fileNames) - qWarning("%s: Warning: potential duplicate alias detected: '%s'", - qPrintable(fileName), qPrintable(filename)); + typedef QHash::const_iterator ChildConstIterator; + const ChildConstIterator cbegin = parent->m_children.constFind(filename); + const ChildConstIterator cend = parent->m_children.constEnd(); + for (ChildConstIterator it = cbegin; it != cend; ++it) { + if (it.key() == filename && it.value()->m_language == s->m_language && + it.value()->m_country == s->m_country) { + foreach (const QString &name, m_fileNames) + qWarning("%s: Warning: potential duplicate alias detected: '%s'", + qPrintable(name), qPrintable(filename)); + break; } + } parent->m_children.insertMulti(filename, s); return true; } From 65c542bc87bd40da90c63e322d1275045de19bff Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 10 Oct 2014 09:57:31 +0200 Subject: [PATCH 023/102] qiosclipboard: take ownership over mime data QClipboard is documented to take ownership over the mime data set with "setMimeData" and the value returned by "mimeData". So we need to implement this to avoid memory leaks. Change-Id: Ieb3a17368ed3a698c29a7f92c8ee87a0cca86b46 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/ios/qiosclipboard.h | 4 ++++ src/plugins/platforms/ios/qiosclipboard.mm | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/ios/qiosclipboard.h b/src/plugins/platforms/ios/qiosclipboard.h index 7d758e3a56..f532eba3de 100644 --- a/src/plugins/platforms/ios/qiosclipboard.h +++ b/src/plugins/platforms/ios/qiosclipboard.h @@ -36,6 +36,7 @@ #import +#include #include @class QUIClipboard; @@ -46,6 +47,8 @@ class QIOSClipboard : public QPlatformClipboard { public: QIOSClipboard(); + ~QIOSClipboard(); + QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) Q_DECL_OVERRIDE; void setMimeData(QMimeData *mimeData, QClipboard::Mode mode = QClipboard::Clipboard) Q_DECL_OVERRIDE; bool supportsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE; @@ -53,6 +56,7 @@ public: private: QUIClipboard *m_clipboard; + QMap m_mimeData; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosclipboard.mm b/src/plugins/platforms/ios/qiosclipboard.mm index e18ad53b2c..5ed6d3be62 100644 --- a/src/plugins/platforms/ios/qiosclipboard.mm +++ b/src/plugins/platforms/ios/qiosclipboard.mm @@ -194,10 +194,17 @@ QIOSClipboard::QIOSClipboard() { } +QIOSClipboard::~QIOSClipboard() +{ + qDeleteAll(m_mimeData); +} + QMimeData *QIOSClipboard::mimeData(QClipboard::Mode mode) { Q_ASSERT(supportsMode(mode)); - return new QIOSMimeData(mode); + if (!m_mimeData.contains(mode)) + return *m_mimeData.insert(mode, new QIOSMimeData(mode)); + return m_mimeData[mode]; } void QIOSClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) @@ -209,6 +216,8 @@ void QIOSClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) pb.items = [NSArray array]; return; } + + mimeData->deleteLater(); NSMutableDictionary *pbItem = [NSMutableDictionary dictionaryWithCapacity:mimeData->formats().size()]; foreach (const QString &mimeType, mimeData->formats()) { From d16f76cde3a78287b565215e6d6906f54616b756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Thu, 9 Oct 2014 08:40:18 +0200 Subject: [PATCH 024/102] Remove duplicate of clang + libc++ mkspec The same funcionality is already supported, so we avoid confusion. The corresponding mkspec is name "linux-clang-libc++" Change-Id: Ib087595298b48c73ad5da8d92cca2d1bac89f2be Reviewed-by: Joerg Bornemann --- .../unsupported/linux-libc++-clang/qmake.conf | 20 ---- .../linux-libc++-clang/qplatformdefs.h | 92 ------------------- 2 files changed, 112 deletions(-) delete mode 100644 mkspecs/unsupported/linux-libc++-clang/qmake.conf delete mode 100644 mkspecs/unsupported/linux-libc++-clang/qplatformdefs.h diff --git a/mkspecs/unsupported/linux-libc++-clang/qmake.conf b/mkspecs/unsupported/linux-libc++-clang/qmake.conf deleted file mode 100644 index bf0abb2a54..0000000000 --- a/mkspecs/unsupported/linux-libc++-clang/qmake.conf +++ /dev/null @@ -1,20 +0,0 @@ -# -# qmake configuration for linux-clang -# - -MAKEFILE_GENERATOR = UNIX -CONFIG += incremental - -QMAKE_INCREMENTAL_STYLE = sublib - -include(../../common/linux.conf) -include(../../common/gcc-base-unix.conf) -include(../../common/clang.conf) - -QMAKE_CFLAGS_RELEASE = -Os -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE - -QMAKE_CXXFLAGS_CXX11 += -std=c++11 -stdlib=libc++ -QMAKE_LFLAGS_CXX11 += -stdlib=libc++ -lc++abi - -load(qt_config) diff --git a/mkspecs/unsupported/linux-libc++-clang/qplatformdefs.h b/mkspecs/unsupported/linux-libc++-clang/qplatformdefs.h deleted file mode 100644 index 0f0c60b148..0000000000 --- a/mkspecs/unsupported/linux-libc++-clang/qplatformdefs.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the qmake spec of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** 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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** 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. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H - -// Get Qt defines/settings - -#include "qglobal.h" - -// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs - -// 1) need to reset default environment if _BSD_SOURCE is defined -// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0 -// 3) it seems older glibc need this to include the X/Open stuff -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include - - -// We are hot - unistd.h should have turned on the specific APIs we requested - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_IPV6IFNAME -#include -#endif - -#define QT_USE_XOPEN_LFS_EXTENSIONS -#include "../../common/posix/qplatformdefs.h" - -#undef QT_SOCKLEN_T - -#if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t -#else -#define QT_SOCKLEN_T int -#endif - -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf -#endif - -#endif // QPLATFORMDEFS_H From 38c39341b3394f5c9223a96bd65b52984308740c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 Oct 2014 12:44:30 +0200 Subject: [PATCH 025/102] Use :- instead of - for empty environment variables We set the variables to empty when we start processing, so ${FOO-foo} will never print "foo". We need to use ${FOO:-foo}. Change-Id: I00c28edb10d8eaa09df689905a302b576b246806 Reviewed-by: Oswald Buddenhagen --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 6597262053..7d6ba9f4d6 100755 --- a/configure +++ b/configure @@ -6492,10 +6492,10 @@ echo " Configure summary" echo if [ "$XPLATFORM" = "$PLATFORM" ]; then # the missing space before $CFG_FEATURES is intentional - echo "Build type: $PLATFORM ($CFG_ARCH, CPU features:${CFG_CPUFEATURES- none detected})" + echo "Build type: $PLATFORM ($CFG_ARCH, CPU features:${CFG_CPUFEATURES:- none detected})" else - echo "Building on: $PLATFORM ($CFG_HOST_ARCH, CPU features:${CFG_HOST_CPUFEATURES- none detected})" - echo "Building for: $XPLATFORM ($CFG_ARCH, CPU features:${CFG_CPUFEATURES- none detected})" + echo "Building on: $PLATFORM ($CFG_HOST_ARCH, CPU features:${CFG_HOST_CPUFEATURES:- none detected})" + echo "Building for: $XPLATFORM ($CFG_ARCH, CPU features:${CFG_CPUFEATURES:- none detected})" fi From 955c9562bdb07927069f281a8635ce20405051c3 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 23 Sep 2014 23:33:40 +0200 Subject: [PATCH 026/102] QSettings: undo unintentional change of config dir on non-XDG platforms. c99dfd8f631289 only meant to be able to switch to the test mode of QStandardPaths, not to move the default dir on OS X, iOS, BB10 and Android. So this commit restores it to the previous behavior, to avoid migration issues. The use of XDG_CONFIG_HOME, defaulting to ~/.config, on OS X, is even documented in the current QSettings documentation, even though these paths are non-standard on OS X (granted, the use of ini-style config files isn't either). Task-number: QTBUG-41461 Change-Id: I5eb610ff7ccbdaf6f955ef7f8f7c2658cbecbb86 Reviewed-by: Eike Ziller Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/io/qsettings.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index f6cd5aa7c9..fd35ae33dc 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -100,6 +100,10 @@ using namespace ABI::Windows::Storage; #define CSIDL_APPDATA 0x001a // \Application Data #endif +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_ANDROID) +#define Q_XDG_PLATFORM +#endif + // ************************************************************************ // QConfFile @@ -1041,7 +1045,9 @@ static void initDefaultPaths(QMutexLocker *locker) windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator()); #else -#ifdef QT_NO_STANDARDPATHS +#if defined(QT_NO_STANDARDPATHS) || !defined(Q_XDG_PLATFORM) + // Non XDG platforms (OS X, iOS, Blackberry, Android...) have used this code path erroneously + // for some time now. Moving away from that would require migrating existing settings. QString userPath; char *env = getenv("XDG_CONFIG_HOME"); if (env == 0) { @@ -1056,6 +1062,9 @@ static void initDefaultPaths(QMutexLocker *locker) userPath += QFile::decodeName(env); } #else + // When using a proper XDG platform, use QStandardPaths rather than the above hand-written code; + // it makes the use of test mode from unit tests possible. + // Ideally all platforms should use this, but see above for the migration issue. QString userPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); #endif userPath += QLatin1Char('/'); From 1910454fe00cce8b815b1abc0a18a04d3d387ccf Mon Sep 17 00:00:00 2001 From: Tom Hirst Date: Fri, 10 Oct 2014 17:02:17 +0100 Subject: [PATCH 027/102] prevent if_nametoindex being called with empty string Calling if_nametoindex with an empty string will always return 0, but on ARM linux platforms this call seems to be very expensive (~30ms), adding a large overhead to calls such as QUdpSocket::writeDatagram() Task-number: QTBUG-37092 Change-Id: Iad00867585d9534af1ddaee936dd4e4dc5e03611 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira --- .../socket/qnativesocketengine_unix.cpp | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 60f971a2fb..ad170e187c 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -384,12 +384,15 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16 sockAddrIPv6.sin6_port = htons(port); QString scopeid = addr.scopeId(); - bool ok; - sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok); + + if (!scopeid.isEmpty()) { + bool ok; + sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok); #ifndef QT_NO_IPV6IFNAME - if (!ok) - sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1()); + if (!ok) + sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1()); #endif + } Q_IPV6ADDR ip6 = addr.toIPv6Address(); memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &ip6, sizeof(ip6)); @@ -498,11 +501,16 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16 memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6)); sockAddrIPv6.sin6_family = AF_INET6; sockAddrIPv6.sin6_port = htons(port); + QString scopeid = address.scopeId(); + + if (!scopeid.isEmpty()) { + bool ok; + sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok); #ifndef QT_NO_IPV6IFNAME - sockAddrIPv6.sin6_scope_id = ::if_nametoindex(address.scopeId().toLatin1().data()); -#else - sockAddrIPv6.sin6_scope_id = address.scopeId().toInt(); + if (!ok) + sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1()); #endif + } Q_IPV6ADDR tmp = address.toIPv6Address(); memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &tmp, sizeof(tmp)); sockAddrSize = sizeof(sockAddrIPv6); @@ -917,12 +925,15 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l Q_IPV6ADDR tmp = host.toIPv6Address(); memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &tmp, sizeof(tmp)); QString scopeid = host.scopeId(); - bool ok; - sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok); + + if (!scopeid.isEmpty()) { + bool ok; + sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok); #ifndef QT_NO_IPV6IFNAME - if (!ok) - sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1()); + if (!ok) + sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1()); #endif + } sockAddrSize = sizeof(sockAddrIPv6); sockAddrPtr = (struct sockaddr *)&sockAddrIPv6; } else if (host.protocol() == QAbstractSocket::IPv4Protocol) { From e3bfd9bea65cc7a9e1742b0cb7ca9af22c42f730 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 3 Oct 2014 13:50:30 +0200 Subject: [PATCH 028/102] QMacStyle: Use NSRect instead of CGRect in drawNSViewInRect() Change-Id: I90fd62dea377dfa9569d1730a67136c7a5dc6f82 Reviewed-by: Timur Pocheptsov Reviewed-by: Andy Shaw --- src/widgets/styles/qmacstyle_mac.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 82718eea7f..9347a6ea90 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1897,11 +1897,11 @@ void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPain [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES]]; - CGRect rect = CGRectMake(qtRect.x() + 1, qtRect.y(), qtRect.width(), qtRect.height()); + NSRect rect = NSMakeRect(qtRect.x() + 1, qtRect.y(), qtRect.width(), qtRect.height()); [backingStoreNSView addSubview:view]; - view.frame = NSRectFromCGRect(rect); - [view drawRect:NSRectFromCGRect(rect)]; + view.frame = rect; + [view drawRect:rect]; [view removeFromSuperviewWithoutNeedingDisplay]; [NSGraphicsContext restoreGraphicsState]; From 8304c8087d269b5b48621cc18d3ebe2bd369ebf4 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Thu, 9 Jan 2014 15:29:28 +0100 Subject: [PATCH 029/102] Doc: Update description of QKeyEvent class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the description on how to use the QKeyEvent pointer passed to key event handlers, and remove an outdated note about multimedia key events. Change-Id: I67a3f0054e28b84d5a0e367c02a329f4670221c7 Task-number: QTBUG-35155 Reviewed-by: Topi Reiniö --- src/gui/kernel/qevent.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f99f28d6e0..a8539e8013 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -897,12 +897,11 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, when keys are pressed or released. A key event contains a special accept flag that indicates whether - the receiver will handle the key event. You should call ignore() - if the key press or release event is not handled by your widget. - A key event is propagated up the parent widget chain until a - widget accepts it with accept() or an event filter consumes it. - Key events for multimedia keys are ignored by default. You should - call accept() if your widget handles those events. + the receiver will handle the key event. This flag is set by default, + so there is no need to call accept() when acting on a key event. + Calling ignore() on a key event will propagate it to the parent widget. + The event is propagated up the parent widget chain until a widget + accepts it or an event filter consumes it. The QWidget::setEnable() function can be used to enable or disable mouse and keyboard events for a widget. From df2afcad2fc58effc73797402176a67d0964637a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 9 Oct 2014 22:42:50 +0200 Subject: [PATCH 030/102] QTableGenerator: replace a call to a member function with direct element access Saves one copy of a vector. Change-Id: I3a14c46e306c3d44a64c6e0d8cd2f120b2c208d7 Reviewed-by: Thiago Macieira Reviewed-by: Friedemann Kleint --- .../platforminputcontexts/compose/generator/qtablegenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp index c0aaed2525..4e90f61876 100644 --- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp +++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp @@ -442,7 +442,7 @@ void TableGenerator::parseKeySequence(char *line) void TableGenerator::printComposeTable() const { #ifdef DEBUG_GENERATOR - if (composeTable().isEmpty()) + if (m_composeTable.isEmpty()) return; QString output; From 26fbeecfa55ee3250c81da6d2e14567ec2051e23 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 20 Sep 2014 17:23:31 +0200 Subject: [PATCH 031/102] Initialize QFileSystemMetaData::size_ data member There's a code path which reads that member before it got anything assigned to it, triggering undefined behavior. The code path goes as follows: 1. an instance is created in QFSFileEngineIterator::advance 2. the instance is passed to QFileSystemIterator::advance, which fills in only some members (not size_) 3. the instance is passed to QFileInfoPrivate which does a deep copy, reading an uninitialized size_ Change-Id: I6835ee701a83b63ca4bad6235feeb6a23566fcd3 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemmetadata_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index de79ec32d3..27e2dac2e4 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -74,7 +74,8 @@ class QFileSystemMetaData { public: QFileSystemMetaData() - : knownFlagsMask(0) + : knownFlagsMask(0), + size_(-1) { } From 2b4cda3852cf92fdff3ce4956f8752a99e44cf56 Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Thu, 9 Oct 2014 15:25:07 -0700 Subject: [PATCH 032/102] QMacStyle: save context state before changing to avoid crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qt_drawFocusRingOnPath was saving the graphics state after setting a new context. This leads to zombie NSBitmapGraphicsContext access with QFileDialog. Task-number: QTBUG-41879 Change-Id: I7fc7d959d2b0f01cb3491d639023083f1b46d175 Reviewed-by: Gabriel de Dietrich Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 70daafc88c..db971eba1b 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1102,9 +1102,9 @@ static QAquaWidgetSize qt_aqua_guess_size(const QWidget *widg, QSize large, QSiz static void qt_drawFocusRingOnPath(CGContextRef cg, NSBezierPath *focusRingPath) { CGContextSaveGState(cg); + [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:(CGContextRef)cg flipped:NO]]; - [NSGraphicsContext saveGraphicsState]; NSSetFocusRingStyle(NSFocusRingOnly); [focusRingPath setClip]; // Clear clip path to avoid artifacts when rendering the cursor at zero pos [focusRingPath fill]; From 4cbb99c5e23cb56633b78636bdb7113cd9914a61 Mon Sep 17 00:00:00 2001 From: Maximilian Hrabowski Date: Wed, 8 Oct 2014 20:07:31 +0200 Subject: [PATCH 033/102] QAbstractItemView: fix CTRL+A select all behavior The check for Qt::Key_A to handle selectAll was changed to directly compare to QKeySequence::SelectAll as this will only match Ctrl. The former implementation also triggered when e.g. Shift was pressed. Added a check that selectAll is only called when selection is not disabled, i.e. selectionMode=NoSelection. Added a unit test for selectAll(). Task-number: QTBUG-26687 Change-Id: I721e7ab590b55d7d754b3b74ef01756fa5aa1315 Reviewed-by: Olivier Goffart --- src/widgets/itemviews/qabstractitemview.cpp | 5 +- .../itemviews/qtableview/tst_qtableview.cpp | 159 ++++++++++++++++++ 2 files changed, 161 insertions(+), 3 deletions(-) diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index a77448cbc4..34e0a8faa0 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -2409,12 +2409,11 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) } break; #endif - case Qt::Key_A: - if (event->modifiers() & Qt::ControlModifier) { + default: { + if (event == QKeySequence::SelectAll && selectionMode() != NoSelection) { selectAll(); break; } - default: { #ifdef Q_WS_MAC if (event->key() == Qt::Key_O && event->modifiers() & Qt::ControlModifier && currentIndex().isValid()) { emit activated(currentIndex()); diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 38367fb4ee..826c2acb78 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -125,6 +125,9 @@ private slots: void selectColumn_data(); void selectColumn(); + void selectall_data(); + void selectall(); + void visualRect_data(); void visualRect(); @@ -1890,6 +1893,162 @@ void tst_QTableView::selectColumn() QCOMPARE(view.selectionModel()->selectedIndexes().at(i).column(), column); } +void tst_QTableView::selectall_data() +{ + QTest::addColumn("rowCount"); + QTest::addColumn("columnCount"); + QTest::addColumn("row"); + QTest::addColumn("column"); + QTest::addColumn("rowSpan"); + QTest::addColumn("columnSpan"); + QTest::addColumn("hideRow"); + QTest::addColumn("hideColumn"); + QTest::addColumn("moveRowFrom"); + QTest::addColumn("moveRowTo"); + QTest::addColumn("moveColumnFrom"); + QTest::addColumn("moveColumnTo"); + QTest::addColumn("rowHeight"); + QTest::addColumn("columnWidth"); + QTest::addColumn("selectedCount"); // ### make this more detailed + + QTest::newRow("no span, no hidden, no moved") + << 10 << 10 // dim + << -1 << -1 // pos + << 1 << 1 // span + << -1 << -1 // hide + << -1 << -1 // move row + << -1 << -1 // move col + << 40 << 40 // cell size + << 100; // selected count + + QTest::newRow("row span, no hidden, no moved") + << 10 << 10 // dim + << 1 << 1 // pos + << 2 << 1 // span + << -1 << -1 // hide + << -1 << -1 // move row + << -1 << -1 // move col + << 40 << 40 // cell size + << 99; // selected count + + QTest::newRow("col span, no hidden, no moved") + << 10 << 10 // dim + << 1 << 1 // pos + << 1 << 2 // span + << -1 << -1 // hide + << -1 << -1 // move row + << -1 << -1 // move col + << 40 << 40 // cell size + << 99; // selected count + + QTest::newRow("no span, row hidden, no moved") + << 10 << 10 // dim + << -1 << -1 // pos + << 1 << 1 // span + << 1 << -1 // hide + << -1 << -1 // move row + << -1 << -1 // move col + << 40 << 40 // cell size + << 90; // selected count + + QTest::newRow("no span, col hidden, no moved") + << 10 << 10 // dim + << -1 << -1 // pos + << 1 << 1 // span + << -1 << 1 // hide + << -1 << -1 // move row + << -1 << -1 // move col + << 40 << 40 // cell size + << 90; // selected count + + QTest::newRow("no span, no hidden, row moved") + << 10 << 10 // dim + << -1 << -1 // pos + << 1 << 1 // span + << -1 << -1 // hide + << 1 << 3 // move row + << -1 << -1 // move col + << 40 << 40 // cell size + << 100; // selected count + + QTest::newRow("no span, no hidden, col moved") + << 10 << 10 // dim + << -1 << -1 // pos + << 1 << 1 // span + << -1 << -1 // hide + << -1 << -1 // move row + << 1 << 3 // move col + << 40 << 40 // cell size + << 100; // selected count +} + +void QTest__keySequence(QWidget* widget, QKeySequence ks) +{ + for (int i=0; imoveSection(moveRowFrom, moveRowTo); + view.horizontalHeader()->moveSection(moveColumnFrom, moveColumnTo); + + for (int r = 0; r < rowCount; ++r) + view.setRowHeight(r, rowHeight); + for (int c = 0; c < columnCount; ++c) + view.setColumnWidth(c, columnWidth); + + // try slot first + view.clearSelection(); + QCOMPARE(view.selectedIndexes().count(), 0); + view.selectAll(); + QCOMPARE(view.selectedIndexes().count(), selectedCount); + + // try by key sequence + view.clearSelection(); + QCOMPARE(view.selectedIndexes().count(), 0); + QTest__keySequence(&view, QKeySequence(QKeySequence::SelectAll)); + QCOMPARE(view.selectedIndexes().count(), selectedCount); + + // check again with no selection mode + view.clearSelection(); + view.setSelectionMode(QAbstractItemView::NoSelection); + QCOMPARE(view.selectedIndexes().count(), 0); + QTest__keySequence(&view, QKeySequence(QKeySequence::SelectAll)); + QCOMPARE(view.selectedIndexes().count(), 0); +} + void tst_QTableView::visualRect_data() { QTest::addColumn("rowCount"); From b380bcc7e244f07d5f2c1f64fc34b6c780f9b781 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 26 Sep 2014 18:55:42 +0200 Subject: [PATCH 034/102] QMacStyle: Fix QPushButton with menu appearance on 10.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As usual, this includes small and mini control sizes. Flat and oversized buttons will fall back to the HITheme rendering for now. Task-number: QTBUG-40833 Change-Id: I08d67c48b2e72681af4dc4a37ea498f7aac1dca0 Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qmacstyle_mac.mm | 55 +++++++++++++++++++------- src/widgets/styles/qmacstyle_mac_p_p.h | 1 + 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index db971eba1b..bad436f846 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1800,7 +1800,8 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons NSView *bv = cocoaControls[widget]; if (!bv) { - if (widget.first == QCocoaPopupButton) + if (widget.first == QCocoaPopupButton + || widget.first == QCocoaPullDownButton) bv = [[NSPopUpButton alloc] init]; else if (widget.first == QCocoaComboBox) bv = [[NSComboBox alloc] init]; @@ -1830,6 +1831,11 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons bc.bezelStyle = NSRoundedBezelStyle; break; } + case QCocoaPullDownButton: { + NSPopUpButton *bc = (NSPopUpButton *)bv; + bc.pullsDown = YES; + break; + } default: break; } @@ -1872,6 +1878,12 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons *offset = QPoint(7, 5); else if (widget == QCocoaWidget(QCocoaPopupButton, QAquaSizeMini)) *offset = QPoint(2, -1); + else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeLarge)) + *offset = QPoint(3, -1); + else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeSmall)) + *offset = QPoint(2, 1); + else if (widget == QCocoaWidget(QCocoaPullDownButton, QAquaSizeMini)) + *offset = QPoint(5, 0); } return bv; @@ -3802,21 +3814,24 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter else if (d->pressedButton == opt->styleObject) d->pressedButton = 0; + bool hasMenu = btn->features & QStyleOptionButton::HasMenu; HIThemeButtonDrawInfo bdi; d->initHIThemePushButton(btn, w, tds, &bdi); if (yosemiteOrLater) { - // HITheme is not drawing a nice focus frame around buttons. - // We'll do it ourselves further down. - bdi.adornment &= ~kThemeAdornmentFocus; + if (!hasMenu) { + // HITheme is not drawing a nice focus frame around buttons. + // We'll do it ourselves further down. + bdi.adornment &= ~kThemeAdornmentFocus; - // We can't rely on an animation existing to test for the default look. That means a bit - // more logic (notice that the logic is slightly different for the bevel and the label). - if (tds == kThemeStateActive - && (btn->features & QStyleOptionButton::DefaultButton - || (btn->features & QStyleOptionButton::AutoDefaultButton - && d->autoDefaultButton == btn->styleObject))) - bdi.adornment |= kThemeAdornmentDefault; + // We can't rely on an animation existing to test for the default look. That means a bit + // more logic (notice that the logic is slightly different for the bevel and the label). + if (tds == kThemeStateActive + && (btn->features & QStyleOptionButton::DefaultButton + || (btn->features & QStyleOptionButton::AutoDefaultButton + && d->autoDefaultButton == btn->styleObject))) + bdi.adornment |= kThemeAdornmentDefault; + } } else { // the default button animation is paused meanwhile any button // is pressed or an auto-default button is animated instead @@ -3856,8 +3871,18 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter newRect.size.width -= QMacStylePrivate::PushButtonRightOffset - 4; } - bool hasMenu = btn->features & QStyleOptionButton::HasMenu; - if (hasMenu && bdi.state == kThemeStatePressed && QSysInfo::macVersion() > QSysInfo::MV_10_6) + if (hasMenu && yosemiteOrLater && bdi.kind != kThemeBevelButton) { + QCocoaWidget w = cocoaWidgetFromHIThemeButtonKind(bdi.kind); + QPoint offset; + NSPopUpButton *pdb = (NSPopUpButton *)d->cocoaControl(QCocoaWidget(QCocoaPullDownButton, w.second), &offset); + [pdb highlight:(bdi.state == kThemeStatePressed)]; + pdb.enabled = bdi.state != kThemeStateUnavailable && bdi.state != kThemeStateUnavailableInactive; + QRect rect = opt->rect; + rect.adjust(0, 0, w.second == QAquaSizeSmall ? -4 : w.second == QAquaSizeMini ? -9 : -6, 0); + p->translate(offset); + d->drawNSViewInRect(pdb, rect, p); + p->translate(-offset); + } else if (hasMenu && bdi.state == kThemeStatePressed && QSysInfo::macVersion() > QSysInfo::MV_10_6) d->drawColorlessButton(newRect, &bdi, p, opt); else HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0); @@ -3893,7 +3918,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath); } - if (hasMenu) { + if (hasMenu && (!yosemiteOrLater || bdi.kind == kThemeBevelButton)) { int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w); QRect ir = btn->rect; int arrowXOffset = 0; @@ -3947,7 +3972,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter bool hasIcon = !btn.icon.isNull(); bool hasText = !btn.text.isEmpty(); - if (QSysInfo::QSysInfo::MacintoshVersion > QSysInfo::MV_10_9) { + if (!hasMenu && QSysInfo::QSysInfo::MacintoshVersion > QSysInfo::MV_10_9) { if (tds == kThemeStatePressed || (tds == kThemeStateActive && ((btn.features & QStyleOptionButton::DefaultButton && !d->autoDefaultButton) diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 8fdeab9163..d8ce9b9250 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -134,6 +134,7 @@ enum QCocoaWidgetKind { QCocoaCheckBox, QCocoaComboBox, // Editable QComboBox QCocoaPopupButton, // Non-editable QComboBox + QCocoaPullDownButton, // QPushButton with menu QCocoaPushButton, QCocoaRadioButton }; From d0a6fcd925dc2a1553e2086e85f59ba76db85bef Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 8 Oct 2014 09:11:30 +1000 Subject: [PATCH 035/102] Fix QtBearer connman backend report correctly on lte network Task-number: QTBUG-41813 Change-Id: I977facc2ee59571d24e60ac9d5d41e957403b344 Reviewed-by: Richard J. Moore --- src/plugins/bearer/connman/qconnmanengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index ee219f00ac..d55db05b1b 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -435,7 +435,7 @@ QNetworkConfiguration::BearerType QConnmanEngine::ofonoTechToBearerType(const QS } else if (currentTechnology == QLatin1String("hspa")) { return QNetworkConfiguration::BearerHSPA; } else if (currentTechnology == QLatin1String("lte")) { - return QNetworkConfiguration::BearerWiMAX; //not exact + return QNetworkConfiguration::BearerLTE; } } return QNetworkConfiguration::BearerUnknown; From d92a9ca2d33ae737b4b4362561209324ade3c95b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 13 Oct 2014 11:57:13 +0200 Subject: [PATCH 036/102] Update QOffscreenSurface docs regarding threads Change-Id: Ic2e3230835aa7fc1b1c3ac0530a65cd478e1ec5f Reviewed-by: Gunnar Sletta --- src/gui/kernel/qoffscreensurface.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index 56c4fbbf8b..5cf77de5d8 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -64,6 +64,12 @@ QT_BEGIN_NAMESPACE typically use a pixel buffer (pbuffer). If the platform doesn't implement or support offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally. + \note Due to the fact that QOffscreenSurface is backed by a QWindow on some platforms, + cross-platform applications must ensure that create() is only called on the main (GUI) + thread. The QOffscreenSurface is then safe to be used with + \l{QOpenGLContext::makeCurrent()}{makeCurrent()} on other threads, but the + initialization and destruction must always happen on the main (GUI) thread. + \note In order to create an offscreen surface that is guaranteed to be compatible with a given context and window, make sure to set the format to the context's or the window's actual format, that is, the QSurfaceFormat returned from @@ -152,6 +158,8 @@ QOffscreenSurface::SurfaceType QOffscreenSurface::surfaceType() const Call destroy() to free the platform resources if necessary. + \note Some platforms require this function to be called on the main (GUI) thread. + \sa destroy() */ void QOffscreenSurface::create() From afefc89d0ff5ad562706b5513662c112e08e1b41 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 13 Oct 2014 10:02:02 +0200 Subject: [PATCH 037/102] osx: let qcombobox specify target rect when showing popup Let qcombobox use the new API for showing a native popup menu (introduced with 1a47595). Change-Id: Id08ef9e59fdd47b2c1df84fa72e3a2c69fe187b0 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qcombobox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 2fa197b2c8..44e22555db 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2439,7 +2439,7 @@ bool QComboBoxPrivate::showNativePopup() offset = QPoint(-1, 7); else if (q->testAttribute(Qt::WA_MacMiniSize)) offset = QPoint(-2, 6); - menu->showPopup(tlw, tlw->mapFromGlobal(q->mapToGlobal(offset)), currentItem); + menu->showPopup(tlw, QRect(tlw->mapFromGlobal(q->mapToGlobal(offset)), QSize()), currentItem); menu->deleteLater(); Q_FOREACH (QPlatformMenuItem *item, items) item->deleteLater(); From 5d9dcac0f2dc8da1a1ac79dbdd309654d6deabac Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 30 Sep 2014 10:42:43 +0200 Subject: [PATCH 038/102] qplatformmenu: remove unused and deprecated function Now that all platforms use the popup function that takes a target rect, lets remove the deprecated one. This is sort of important, since QtQuick controls now uses the new version. So if a (new) platform ends up only implementing the old version, that can end up not working correctly. Change-Id: I34814b3de5ea4954cf21b161e8a834e39e5534c8 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qplatformmenu.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h index c832de0be6..0093ef1538 100644 --- a/src/gui/kernel/qplatformmenu.h +++ b/src/gui/kernel/qplatformmenu.h @@ -108,11 +108,6 @@ public: virtual void setFont(const QFont &font) { Q_UNUSED(font); } virtual void setMenuType(MenuType type) { Q_UNUSED(type); } - virtual void showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item) - { - showPopup(parentWindow, QRect(pos, QSize()), item); - } - virtual void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) { Q_UNUSED(parentWindow); From 4bf0660ae4e695ceb79f585b92dedf00d7757f31 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 13 Oct 2014 08:49:16 +0200 Subject: [PATCH 039/102] Make QStringRef::right() consistent with QString::right() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The implementation was inconsistent with QString::right(), and did not return the N rightmost characters but actually did the same as QString::mid(N) (returning the rightmost size - N characters.) Since this function is fairly recent (Qt 5.2), is documented to behave the same as QString::right(), and since these APIs are meant to be interchangeable, this needs to be fixed, even though it changes behavior. [ChangeLog][Important Behavior Changes] Changed QStringRef::right() to be consistent with QString::right(). The function now returns the N right-most characters, like the documentation already claimed. Change-Id: I2d1cd6d958dfa9354aa09f16bd27b1ed209c2d11 Task-number: QTBUG-41858 Reviewed-by: Thiago Macieira Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qdatetime.cpp | 2 +- src/corelib/tools/qstring.cpp | 2 +- tests/auto/corelib/tools/qstringref/tst_qstringref.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 75f2a93e45..f0f6a56755 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -4419,7 +4419,7 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format) if (size == 10) return QDateTime(date); - isoString = isoString.right(11); + isoString = isoString.right(isoString.length() - 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'))) { diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b805ec792e..48f251e3f4 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -9020,7 +9020,7 @@ QStringRef QStringRef::right(int n) const { if (uint(n) >= uint(m_size)) return *this; - return QStringRef(m_string, n + m_position, m_size - n); + return QStringRef(m_string, m_size - n + m_position, n); } /*! diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp index a38707ef08..3ba901061c 100644 --- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp @@ -1870,9 +1870,9 @@ void tst_QStringRef::right() QStringRef ref = originalString.rightRef(originalString.size() - 1); QCOMPARE(ref.toString(), QLatin1String("OrginalString")); - QCOMPARE(ref.right(ref.size() - 6).toString(), QLatin1String("String")); + QCOMPARE(ref.right(6).toString(), QLatin1String("String")); QCOMPARE(ref.right(ref.size()).toString(), QLatin1String("OrginalString")); - QCOMPARE(ref.right(0).toString(), QLatin1String("OrginalString")); + QCOMPARE(ref.right(0).toString(), QLatin1String("")); QStringRef nullRef; QVERIFY(nullRef.isNull()); From ebc835c2aa02f0b3dc6e4806bde03f33513d3556 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 14 Oct 2014 12:07:41 +0200 Subject: [PATCH 040/102] Fix QOpenGLWidget on Cocoa when used as viewport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having a QOpenGLWidget as a graphics view viewport was not functioning on OS X: it was showing incomplete content due to accessing the texture attached to the framebuffer object before the rendering is complete. On the normal path, when rendering is done via paintGL(), the flush was there. When used as a viewport however, this path is not used. The missing flush is now added for the other case too. For performance reasons, we will not flush on every paint engine end(). Instead, the flush is deferred until composition starts. QGLWidget also featured a weird on-by-default autoFillBackground concept. To maintain compatibility with apps that used QGLWidget as the viewport for QGraphicsView, we will now do the same for QOpenGLWidget, but only when it is used as a viewport. For regular QOpenGLWidgets autoFillBackground defaults to false, like for any other widget. The docs are extended with a small section about differences between QGLWidget and QOpenGLWidget. Task-number: QTBUG-41046 Change-Id: I42c2033fdd2ef5815783fd640fe11373761061e0 Reviewed-by: Jørgen Lind --- src/gui/opengl/qopenglpaintdevice.cpp | 27 +++++++- src/gui/opengl/qopenglpaintdevice.h | 2 + src/gui/opengl/qopenglpaintengine.cpp | 4 ++ src/widgets/kernel/qopenglwidget.cpp | 70 +++++++++++++++++++-- src/widgets/kernel/qwidget_p.h | 2 + src/widgets/widgets/qabstractscrollarea.cpp | 3 + 6 files changed, 103 insertions(+), 5 deletions(-) diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index 59bca6efdf..c2f3295bc3 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -350,15 +350,40 @@ bool QOpenGLPaintDevice::paintFlipped() const return d_ptr->flipped; } +/*! + This virtual method is called when starting to paint. + + The default implementation does nothing. + + \sa endPaint() + */ +void QOpenGLPaintDevice::beginPaint() +{ +} + /*! This virtual method is provided as a callback to allow re-binding a target frame buffer object or context when different QOpenGLPaintDevice instances are issuing draw calls alternately. - QPainter::beginNativePainting will also trigger this method. + \l{QPainter::beginNativePainting()}{beginNativePainting()} will also trigger + this method. + + The default implementation does nothing. */ void QOpenGLPaintDevice::ensureActiveTarget() { } +/*! + This virtual method is called when the painting has finished. + + The default implementation does nothing. + + \sa beginPaint() +*/ +void QOpenGLPaintDevice::endPaint() +{ +} + QT_END_NAMESPACE diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h index e1be9b525d..d88992d6db 100644 --- a/src/gui/opengl/qopenglpaintdevice.h +++ b/src/gui/opengl/qopenglpaintdevice.h @@ -73,7 +73,9 @@ public: void setPaintFlipped(bool flipped); bool paintFlipped() const; + virtual void beginPaint(); virtual void ensureActiveTarget(); + virtual void endPaint(); protected: int metric(QPaintDevice::PaintDeviceMetric metric) const; diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 21bc4a95e8..40c836b2bb 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1994,6 +1994,8 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev) d->ctx = QOpenGLContext::currentContext(); d->ctx->d_func()->active_engine = this; + d->device->beginPaint(); + d->funcs.initializeOpenGLFunctions(); for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) @@ -2044,6 +2046,8 @@ bool QOpenGL2PaintEngineEx::end() { Q_D(QOpenGL2PaintEngineEx); + d->device->endPaint(); + QOpenGLContext *ctx = d->ctx; d->funcs.glUseProgram(0); d->transferMode(BrushDrawingMode); diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 7782c4c1d4..dd8dd64470 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -239,6 +239,28 @@ QT_BEGIN_NAMESPACE \note Avoid calling winId() on a QOpenGLWidget. This function triggers the creation of a native window, resulting in reduced performance and possibly rendering glitches. + \section1 Differences to QGLWidget + + Besides the main conceptual difference of being backed by a framebuffer object, there + are a number of smaller, internal differences between QOpenGLWidget and the older + QGLWidget: + + \list + + \li OpenGL state when invoking paintGL(). QOpenGLWidget sets up the viewport via + glViewport(). It does not perform any clearing. + + \li Clearing when starting to paint via QPainter. Unlike regular widgets, QGLWidget + defaulted to a value of \c true for + \l{QWidget::autoFillBackground()}{autoFillBackground}. It then performed clearing to the + palette's background color every time QPainter::begin() was used. QOpenGLWidget does not + follow this: \l{QWidget::autoFillBackground()}{autoFillBackground} defaults to false, + like for any other widget. The only exception is when being used as a viewport for other + widgets like QGraphicsView. In such a case autoFillBackground will be automatically set + to true to ensure compatibility with QGLWidget-based viewports. + + \endlist + \section1 Multisampling To enable multisampling, set the number of requested samples on the @@ -436,6 +458,7 @@ class QOpenGLWidgetPaintDevice : public QOpenGLPaintDevice { public: QOpenGLWidgetPaintDevice(QOpenGLWidget *widget) : w(widget) { } + void beginPaint() Q_DECL_OVERRIDE; void ensureActiveTarget() Q_DECL_OVERRIDE; private: @@ -454,7 +477,8 @@ public: initialized(false), fakeHidden(false), paintDevice(0), - inBackingStorePaint(false) + inBackingStorePaint(false), + flushPending(false) { requestedFormat = QSurfaceFormat::defaultFormat(); } @@ -478,6 +502,7 @@ public: void endBackingStorePainting() Q_DECL_OVERRIDE { inBackingStorePaint = false; } void beginCompose() Q_DECL_OVERRIDE; void endCompose() Q_DECL_OVERRIDE; + void initializeViewportFramebuffer() Q_DECL_OVERRIDE; void resizeViewportFramebuffer() Q_DECL_OVERRIDE; void resolveSamples() Q_DECL_OVERRIDE; @@ -490,8 +515,28 @@ public: QOpenGLPaintDevice *paintDevice; bool inBackingStorePaint; QSurfaceFormat requestedFormat; + bool flushPending; }; +void QOpenGLWidgetPaintDevice::beginPaint() +{ + // NB! autoFillBackground is and must be false by default. Otherwise we would clear on + // every QPainter begin() which is not desirable. This is only for legacy use cases, + // like using QOpenGLWidget as the viewport of a graphics view, that expect clearing + // with the palette's background color. + if (w->autoFillBackground()) { + QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + if (w->testAttribute(Qt::WA_TranslucentBackground)) { + f->glClearColor(0, 0, 0, 0); + } else { + QColor c = w->palette().brush(w->backgroundRole()).color(); + float alpha = c.alphaF(); + f->glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); + } + f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + } +} + void QOpenGLWidgetPaintDevice::ensureActiveTarget() { QOpenGLWidgetPrivate *d = static_cast(QWidgetPrivate::get(w)); @@ -502,6 +547,11 @@ void QOpenGLWidgetPaintDevice::ensureActiveTarget() w->makeCurrent(); else d->fbo->bind(); + + // When used as a viewport, drawing is done via opening a QPainter on the widget + // without going through paintEvent(). We will have to make sure a glFlush() is done + // before the texture is accessed also in this case. + d->flushPending = true; } GLuint QOpenGLWidgetPrivate::textureId() const @@ -572,6 +622,11 @@ void QOpenGLWidgetPrivate::recreateFbo() void QOpenGLWidgetPrivate::beginCompose() { Q_Q(QOpenGLWidget); + if (flushPending) { + flushPending = false; + q->makeCurrent(); + context->functions()->glFlush(); + } emit q->aboutToCompose(); } @@ -653,9 +708,10 @@ void QOpenGLWidgetPrivate::invokeUserPaint() { Q_Q(QOpenGLWidget); QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); - f->glViewport(0, 0, q->width() * q->devicePixelRatio(), q->height() * q->devicePixelRatio()); + f->glViewport(0, 0, q->width() * q->devicePixelRatio(), q->height() * q->devicePixelRatio()); q->paintGL(); + f->glFlush(); } void QOpenGLWidgetPrivate::render() @@ -667,7 +723,6 @@ void QOpenGLWidgetPrivate::render() q->makeCurrent(); invokeUserPaint(); - context->functions()->glFlush(); } extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); @@ -686,6 +741,14 @@ QImage QOpenGLWidgetPrivate::grabFramebuffer() return res; } +void QOpenGLWidgetPrivate::initializeViewportFramebuffer() +{ + Q_Q(QOpenGLWidget); + // Legacy behavior for compatibility with QGLWidget when used as a graphics view + // viewport: enable clearing on each painter begin. + q->setAutoFillBackground(true); +} + void QOpenGLWidgetPrivate::resizeViewportFramebuffer() { Q_Q(QOpenGLWidget); @@ -929,7 +992,6 @@ void QOpenGLWidget::resizeEvent(QResizeEvent *e) d->recreateFbo(); resizeGL(width(), height()); d->invokeUserPaint(); - d->context->functions()->glFlush(); d->resolveSamples(); } diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index e80447c477..bbdbabc14b 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -641,6 +641,8 @@ public: } } static void sendComposeStatus(QWidget *w, bool end); + // Called on setViewport(). + virtual void initializeViewportFramebuffer() { } // When using a QOpenGLWidget as viewport with QAbstractScrollArea, resize events are // filtered away from the widget. This is fine for QGLWidget but bad for QOpenGLWidget // since the fbo must be resized. We need an alternative way to notify. diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 3b75591998..4cafeafcec 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -609,6 +609,9 @@ void QAbstractScrollArea::setViewport(QWidget *widget) #endif #endif d->layoutChildren(); +#ifndef QT_NO_OPENGL + QWidgetPrivate::get(d->viewport)->initializeViewportFramebuffer(); +#endif if (isVisible()) d->viewport->show(); setupViewport(widget); From f5cf06f4afc48198780e3c3d0d1a52afce425507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 9 Oct 2014 20:13:40 +0200 Subject: [PATCH 041/102] Cocoa: Send obscure events on OcclusionStateHidden This disables animations for windows that are completely obscured by other windows. On examples/quick/animation, obscured CPU usage goes from 10% to 1%. Change-Id: I9945431e6387e406e2064c08d5aa01d5d96ef602 Reviewed-by: Laszlo Agocs Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 10a92667c1..06680228bc 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -420,12 +420,10 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; #pragma clang diagnostic ignored "-Wobjc-method-access" enum { NSWindowOcclusionStateVisible = 1UL << 1 }; #endif - // Older versions managed in -[QNSView viewDidMoveToWindow]. - // Support QWidgetAction in NSMenu. Mavericks only sends this notification. - // Ideally we should support this in Qt as well, in order to disable animations - // when the window is occluded. if ((NSUInteger)[self.window occlusionState] & NSWindowOcclusionStateVisible) m_platformWindow->exposeWindow(); + else + m_platformWindow->obscureWindow(); #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 #pragma clang diagnostic pop #endif From 3edce263fb92ca96f6d7b5f90baf000bb2e0d74a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 13 Oct 2014 13:57:35 +0200 Subject: [PATCH 042/102] Prevent 'recursive' update events when calling QToolButton::setMenu() Commit bb3d2ca9f18 (QToolButton: properly reset the size hint when a menu is set on it) didn't take the case of re-setting the same menu into account, and the result was that we would unconditionally cause an update, resulting in the following backtrace again and again, as each posted update event was processed by the event loop: frame #0: QToolButton::setMenu(this=0x7af59500, menu=0x00000000) frame #1: QToolBarLayout::setUsePopupMenu(this=0x7ae65a30, set=false) frame #2: QToolBarLayout::checkUsePopupMenu(this=0x7ae65a30) frame #3: QToolBarAreaLayoutLine::fitLayout(this=0x78e5f870) frame #4: QToolBarAreaLayoutInfo::fitLayout(this=0x790be278) ... Besides consuming needless CPU time this also uncovered a case on iOS where Qt would starve native events and animations from being processed, preventing eg. rotation animations from running. Change-Id: Ib6bd4ba21d8e84ca73fb0a75b598016dbd9ae0fd Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qtoolbutton.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index 3d3f42605e..bb3f2d74a8 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -636,6 +636,9 @@ void QToolButton::setMenu(QMenu* menu) { Q_D(QToolButton); + if (d->menuAction == (menu ? menu->menuAction() : 0)) + return; + if (d->menuAction) removeAction(d->menuAction); From 29ad07d0a486dd234267fce9a0310ad89683b7d1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 29 Sep 2014 14:55:12 +0200 Subject: [PATCH 043/102] Avoid sleeping 100ms in QProcessPrivate::drainOutputPipes() There is no point in waiting 100 milliseconds after each iteration, as all data that we may possibly read will be already in the pipe. We only need to give the notifier thread a chance to inform us, which is best achieved with a yield. Task-number: QTBUG-41282 Change-Id: Id654b688246508494a5549c11900f9ad2957f192 Reviewed-by: Alessandro Portale Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 980fb58865..ee6b7e13f4 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -634,7 +634,7 @@ bool QProcessPrivate::drainOutputPipes() someReadyReadEmitted |= readyReadEmitted; if (!readOperationActive || !readyReadEmitted) break; - Sleep(100); + QThread::yieldCurrentThread(); } return someReadyReadEmitted; From 648623ff235c36e2482ad64a0578a4f7c36ad15a Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 2 Oct 2014 10:20:28 +0200 Subject: [PATCH 044/102] Consolidate how contentDescription is calculated. Previously, the behavior was different depending on if the contentDescription was calculated as a result of an event, or if it was calculated as a result of hierarchy traversal. Refactor the functionality into one single function that will be used in both scenarios. 'contentDescription' will now receive its value from one of the following sources, listed in prioritised order (QAI == QAccessibleInterface): 1. QAI::text(QAccessible::Name) 2. QAI::text(QAccessible::Description) 3. QAI::text(QAccessible::Value) 4. QAI::valueInterface()->currentValue() Change-Id: I2e4958a1e95b5f20d01da37c23ecbc09842360bc Reviewed-by: Frederik Gladhorn --- .../android/androidjniaccessibility.cpp | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp index 7229fd7af5..5c927da9c5 100644 --- a/src/plugins/platforms/android/androidjniaccessibility.cpp +++ b/src/plugins/platforms/android/androidjniaccessibility.cpp @@ -187,18 +187,30 @@ if (!clazz) { \ //__android_log_print(ANDROID_LOG_FATAL, m_qtTag, m_methodErrorMsg, METHOD_NAME, METHOD_SIGNATURE); - static jstring descriptionForAccessibleObject(JNIEnv *env, jobject /*thiz*/, jint objectId) + + static jstring descriptionForAccessibleObject_helper(JNIEnv *env, QAccessibleInterface *iface) { QString desc; - QAccessibleInterface *iface = interfaceFromId(objectId); if (iface && iface->isValid()) { desc = iface->text(QAccessible::Name); if (desc.isEmpty()) desc = iface->text(QAccessible::Description); + if (desc.isEmpty()) { + desc = iface->text(QAccessible::Value); + if (desc.isEmpty()) { + if (QAccessibleValueInterface *valueIface = iface->valueInterface()) { + desc= valueIface->currentValue().toString(); + } + } + } } + return env->NewString((jchar*) desc.constData(), (jsize) desc.size()); + } - jstring jdesc = env->NewString((jchar*) desc.constData(), (jsize) desc.size()); - return jdesc; + static jstring descriptionForAccessibleObject(JNIEnv *env, jobject /*thiz*/, jint objectId) + { + QAccessibleInterface *iface = interfaceFromId(objectId); + return descriptionForAccessibleObject_helper(env, iface); } static bool populateNode(JNIEnv *env, jobject /*thiz*/, jint objectId, jobject node) @@ -216,11 +228,8 @@ if (!clazz) { \ const bool hasDecreaseAction = actions.contains(QAccessibleActionInterface::decreaseAction()); // try to fill in the text property, this is what the screen reader reads - QString desc = iface->text(QAccessible::Value); - if (desc.isEmpty()) - desc = iface->text(QAccessible::Name); - if (desc.isEmpty()) - desc = iface->text(QAccessible::Description); + jstring jdesc = descriptionForAccessibleObject_helper(env, iface); + if (QAccessibleTextInterface *textIface = iface->textInterface()) { if (m_setTextSelectionMethodID && textIface->selectionCount() > 0) { int startSelection; @@ -252,7 +261,6 @@ if (!clazz) { \ env->CallVoidMethod(node, m_addActionMethodID, (int)8192); // ACTION_SCROLL_BACKWARD defined in AccessibilityNodeInfo - jstring jdesc = env->NewString((jchar*) desc.constData(), (jsize) desc.size()); //CALL_METHOD(node, "setText", "(Ljava/lang/CharSequence;)V", jdesc) env->CallVoidMethod(node, m_setContentDescriptionMethodID, jdesc); From 65b563fe57e1fe6dcaa2165ed5030b2ce0999011 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 14 Oct 2014 12:16:44 +0200 Subject: [PATCH 045/102] qdoc: Fixed recursion of \sincelist command handling QDoc uses a recursive method of resolving all the classes, QML types, properties, functions etc. added since a specified Qt version. The code entered the next level of recursion only if its parent had set a \since version, which was not always the case. Task-number: QTBUG-41862 Change-Id: I3803ed9ffa472165754358f3906955430a893de1 Reviewed-by: Martin Smith --- src/tools/qdoc/qdocdatabase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/qdoc/qdocdatabase.cpp b/src/tools/qdoc/qdocdatabase.cpp index fff78b1cbc..36dd05bb92 100644 --- a/src/tools/qdoc/qdocdatabase.cpp +++ b/src/tools/qdoc/qdocdatabase.cpp @@ -1253,11 +1253,11 @@ void QDocDatabase::findAllSince(InnerNode* node) nsmap.value().insert(name,(*child)); } } - // Recursively find child nodes with since commands. - if ((*child)->isInnerNode()) { - findAllSince(static_cast(*child)); - } } + // Recursively find child nodes with since commands. + if ((*child)->isInnerNode()) + findAllSince(static_cast(*child)); + ++child; } } From 7095cdabc9e5465a33adb9d68782b4541853d964 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Oct 2014 11:45:36 +0200 Subject: [PATCH 046/102] QTestLib: Remove valgrind version check. Version 3.3 is now assumed to be widely available. Task-number: QTBUG-41453 Change-Id: I453ce26d170b2bbb8179ddf4b91155ddd3e6379a Reviewed-by: Kai Koehne Reviewed-by: Jason McDonald --- src/testlib/qbenchmarkvalgrind.cpp | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/testlib/qbenchmarkvalgrind.cpp b/src/testlib/qbenchmarkvalgrind.cpp index c480753675..f107645ab5 100644 --- a/src/testlib/qbenchmarkvalgrind.cpp +++ b/src/testlib/qbenchmarkvalgrind.cpp @@ -45,33 +45,15 @@ QT_BEGIN_NAMESPACE -// Returns \c true iff a sufficiently recent valgrind is available. +// Returns \c true if valgrind is available. bool QBenchmarkValgrindUtils::haveValgrind() { #ifdef NVALGRIND return false; #else QProcess process; - QStringList args; - args << QLatin1String("--version"); - process.start(QLatin1String("valgrind"), args); - if (!process.waitForFinished(-1)) - return false; - const QByteArray out = process.readAllStandardOutput(); - QRegExp rx(QLatin1String("^valgrind-([0-9]+).([0-9]+).[0-9]+")); - if (rx.indexIn(QLatin1String(out.data())) == -1) - return false; - bool ok; - const int major = rx.cap(1).toInt(&ok); - if (!ok) - return false; - const int minor = rx.cap(2).toInt(&ok); - if (!ok) - return false; -// return (major > 3 || (major == 3 && minor >= 3)); // v >= 3.3 for --callgrind-out-file option - Q_UNUSED(major); - Q_UNUSED(minor); - return true; // skip version restriction for now + process.start(QLatin1String("valgrind"), QStringList(QLatin1String("--version"))); + return process.waitForStarted() && process.waitForFinished(-1); #endif } From a4ac4b326318ed9034466305222280ed8d1651b5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Oct 2014 14:39:06 +0200 Subject: [PATCH 047/102] QWindowsGuiEventDispatcher: Register timers in constructor. Port change 3716a76704273fdbe5ad4ec978438daeda606c26 (Qt 4) to Qt 5. Enforce the creation of the internal window and registering of timers in the event dispatcher constructor for GUI applications instead of delaying it to processEvents() is called. Move the call to virtual wakeUp() out of createInternalHwnd(). Task-number: QTBUG-40881 Change-Id: I82a4748897da140a39feff882c75ad5ac6155148 Reviewed-by: Joerg Bornemann --- src/corelib/kernel/qeventdispatcher_win.cpp | 8 +++----- src/corelib/kernel/qeventdispatcher_win_p.h | 2 +- .../platforms/windows/qwindowsguieventdispatcher.cpp | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 7816edd3f9..a3d00faf31 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -639,7 +639,6 @@ void QEventDispatcherWin32::createInternalHwnd() { Q_D(QEventDispatcherWin32); - Q_ASSERT(!d->internalHwnd); if (d->internalHwnd) return; d->internalHwnd = qt_create_internal_window(this); @@ -664,9 +663,6 @@ void QEventDispatcherWin32::createInternalHwnd() // start all normal timers for (int i = 0; i < d->timerVec.count(); ++i) d->registerTimer(d->timerVec.at(i)); - - // trigger a call to sendPostedEvents() - wakeUp(); } QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent) @@ -686,8 +682,10 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QEventDispatcherWin32); - if (!d->internalHwnd) + if (!d->internalHwnd) { createInternalHwnd(); + wakeUp(); // trigger a call to sendPostedEvents() + } d->interrupt = false; emit awake(); diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index f9bb06a5c5..369c276615 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -65,8 +65,8 @@ class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher Q_OBJECT Q_DECLARE_PRIVATE(QEventDispatcherWin32) +protected: void createInternalHwnd(); - friend class QGuiEventDispatcherWin32; public: explicit QEventDispatcherWin32(QObject *parent = 0); diff --git a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp index 73988b6db5..593b5eac7a 100644 --- a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp +++ b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp @@ -62,6 +62,7 @@ QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) : QEventDispatcherWin32(parent), m_flags(0) { setObjectName(QStringLiteral("QWindowsGuiEventDispatcher")); + createInternalHwnd(); // QTBUG-40881: Do not delay registering timers, etc. for QtMfc. } bool QWindowsGuiEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) From 6d1c4c8862161fd4aaffe307c7267ceeb408d8d8 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 14 Oct 2014 12:07:41 +0200 Subject: [PATCH 048/102] Avoid breaking BC with new virtuals in QOpenGLPaintDevice Task-number: QTBUG-41046 Change-Id: Iab628d2d6811d528e2cc513b6f8a74baa628541d Reviewed-by: Gunnar Sletta --- src/gui/opengl/opengl.pri | 1 + src/gui/opengl/qopenglpaintdevice.cpp | 48 +++------------- src/gui/opengl/qopenglpaintdevice.h | 4 +- src/gui/opengl/qopenglpaintdevice_p.h | 81 +++++++++++++++++++++++++++ src/gui/opengl/qopenglpaintengine.cpp | 5 +- src/widgets/kernel/qopenglwidget.cpp | 35 ++++++++---- 6 files changed, 118 insertions(+), 56 deletions(-) create mode 100644 src/gui/opengl/qopenglpaintdevice_p.h diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index f82401c973..adf5428c49 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -11,6 +11,7 @@ contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) { opengl/qopenglframebufferobject.h \ opengl/qopenglframebufferobject_p.h \ opengl/qopenglpaintdevice.h \ + opengl/qopenglpaintdevice_p.h \ opengl/qopenglbuffer.h \ opengl/qopenglshaderprogram.h \ opengl/qopenglextensions_p.h \ diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index c2f3295bc3..e908fd8e91 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -98,23 +99,6 @@ QT_BEGIN_NAMESPACE */ -class QOpenGLPaintDevicePrivate -{ -public: - QOpenGLPaintDevicePrivate(const QSize &size); - - QSize size; - QOpenGLContext *ctx; - - qreal dpmx; - qreal dpmy; - qreal devicePixelRatio; - - bool flipped; - - QPaintEngine *engine; -}; - /*! Constructs a QOpenGLPaintDevice. @@ -151,6 +135,14 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height) { } +/*! + \internal + */ +QOpenGLPaintDevice::QOpenGLPaintDevice(QOpenGLPaintDevicePrivate *dd) + : d_ptr(dd) +{ +} + /*! Destroys the QOpenGLPaintDevice. */ @@ -350,17 +342,6 @@ bool QOpenGLPaintDevice::paintFlipped() const return d_ptr->flipped; } -/*! - This virtual method is called when starting to paint. - - The default implementation does nothing. - - \sa endPaint() - */ -void QOpenGLPaintDevice::beginPaint() -{ -} - /*! This virtual method is provided as a callback to allow re-binding a target frame buffer object or context when different QOpenGLPaintDevice instances @@ -375,15 +356,4 @@ void QOpenGLPaintDevice::ensureActiveTarget() { } -/*! - This virtual method is called when the painting has finished. - - The default implementation does nothing. - - \sa beginPaint() -*/ -void QOpenGLPaintDevice::endPaint() -{ -} - QT_END_NAMESPACE diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h index d88992d6db..dda3bfe43f 100644 --- a/src/gui/opengl/qopenglpaintdevice.h +++ b/src/gui/opengl/qopenglpaintdevice.h @@ -44,7 +44,6 @@ QT_BEGIN_NAMESPACE - class QOpenGLPaintDevicePrivate; class Q_GUI_EXPORT QOpenGLPaintDevice : public QPaintDevice @@ -54,6 +53,7 @@ public: QOpenGLPaintDevice(); explicit QOpenGLPaintDevice(const QSize &size); QOpenGLPaintDevice(int width, int height); + QOpenGLPaintDevice(QOpenGLPaintDevicePrivate *dd); virtual ~QOpenGLPaintDevice(); int devType() const { return QInternal::OpenGL; } @@ -73,9 +73,7 @@ public: void setPaintFlipped(bool flipped); bool paintFlipped() const; - virtual void beginPaint(); virtual void ensureActiveTarget(); - virtual void endPaint(); protected: int metric(QPaintDevice::PaintDeviceMetric metric) const; diff --git a/src/gui/opengl/qopenglpaintdevice_p.h b/src/gui/opengl/qopenglpaintdevice_p.h new file mode 100644 index 0000000000..0b01129a84 --- /dev/null +++ b/src/gui/opengl/qopenglpaintdevice_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENGL_PAINTDEVICE_P_H +#define QOPENGL_PAINTDEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Qt OpenGL classes. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QOpenGLContext; +class QPaintEngine; + +class Q_GUI_EXPORT QOpenGLPaintDevicePrivate +{ +public: + QOpenGLPaintDevicePrivate(const QSize &size); + virtual ~QOpenGLPaintDevicePrivate() { } + + static QOpenGLPaintDevicePrivate *get(QOpenGLPaintDevice *dev) { return dev->d_func(); } + + virtual void beginPaint() { } + virtual void endPaint() { } + +public: + QSize size; + QOpenGLContext *ctx; + + qreal dpmx; + qreal dpmy; + qreal devicePixelRatio; + + bool flipped; + + QPaintEngine *engine; +}; + +QT_END_NAMESPACE + +#endif // QOPENGL_PAINTDEVICE_P_H diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 40c836b2bb..c490726359 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -59,6 +59,7 @@ #include "qopenglgradientcache_p.h" #include "qopengltexturecache_p.h" #include "qopenglpaintengine_p.h" +#include "qopenglpaintdevice_p.h" #include //for memcpy #include @@ -1994,7 +1995,7 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev) d->ctx = QOpenGLContext::currentContext(); d->ctx->d_func()->active_engine = this; - d->device->beginPaint(); + QOpenGLPaintDevicePrivate::get(d->device)->beginPaint(); d->funcs.initializeOpenGLFunctions(); @@ -2046,7 +2047,7 @@ bool QOpenGL2PaintEngineEx::end() { Q_D(QOpenGL2PaintEngineEx); - d->device->endPaint(); + QOpenGLPaintDevicePrivate::get(d->device)->endPaint(); QOpenGLContext *ctx = d->ctx; d->funcs.glUseProgram(0); diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index dd8dd64470..8a4e0c8ffd 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -454,15 +455,24 @@ QT_BEGIN_NAMESPACE due to resizing the widget. */ +class QOpenGLWidgetPaintDevicePrivate : public QOpenGLPaintDevicePrivate +{ +public: + QOpenGLWidgetPaintDevicePrivate(QOpenGLWidget *widget) + : QOpenGLPaintDevicePrivate(QSize()), + w(widget) { } + + void beginPaint() Q_DECL_OVERRIDE; + + QOpenGLWidget *w; +}; + class QOpenGLWidgetPaintDevice : public QOpenGLPaintDevice { public: - QOpenGLWidgetPaintDevice(QOpenGLWidget *widget) : w(widget) { } - void beginPaint() Q_DECL_OVERRIDE; + QOpenGLWidgetPaintDevice(QOpenGLWidget *widget) + : QOpenGLPaintDevice(new QOpenGLWidgetPaintDevicePrivate(widget)) { } void ensureActiveTarget() Q_DECL_OVERRIDE; - -private: - QOpenGLWidget *w; }; class QOpenGLWidgetPrivate : public QWidgetPrivate @@ -518,7 +528,7 @@ public: bool flushPending; }; -void QOpenGLWidgetPaintDevice::beginPaint() +void QOpenGLWidgetPaintDevicePrivate::beginPaint() { // NB! autoFillBackground is and must be false by default. Otherwise we would clear on // every QPainter begin() which is not desirable. This is only for legacy use cases, @@ -539,19 +549,20 @@ void QOpenGLWidgetPaintDevice::beginPaint() void QOpenGLWidgetPaintDevice::ensureActiveTarget() { - QOpenGLWidgetPrivate *d = static_cast(QWidgetPrivate::get(w)); - if (!d->initialized) + QOpenGLWidgetPaintDevicePrivate *d = static_cast(d_ptr.data()); + QOpenGLWidgetPrivate *wd = static_cast(QWidgetPrivate::get(d->w)); + if (!wd->initialized) return; - if (QOpenGLContext::currentContext() != d->context) - w->makeCurrent(); + if (QOpenGLContext::currentContext() != wd->context) + d->w->makeCurrent(); else - d->fbo->bind(); + wd->fbo->bind(); // When used as a viewport, drawing is done via opening a QPainter on the widget // without going through paintEvent(). We will have to make sure a glFlush() is done // before the texture is accessed also in this case. - d->flushPending = true; + wd->flushPending = true; } GLuint QOpenGLWidgetPrivate::textureId() const From d904533acba1267431ca2c5f0d3e85cc59a20a26 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 6 Oct 2014 19:22:00 +0400 Subject: [PATCH 049/102] xcb: Don't return 0 as a possible key for a shortcut QXcbKeyboard::keysymToQtKey() may return a value of 0 for keysyms that are not supported by Qt (e.g. for XK_ISO_Next_Group). It is then translated to an empty QKeySequence which in turn is detected as a partial match for any shortcut. The behavior of QShortcutMap::nextState() becomes broken because it sets current state to QKeySequence::PartialMatch while there is no match at all. Task-number: QTCREATORBUG-9589 Change-Id: I1e2a4511a876dfa418db9906d10382255a2e4d62 Reviewed-by: Gatis Paeglis Reviewed-by: Sergey Belyashov --- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 7e70e7258d..8c12b29a99 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -903,7 +903,7 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const Qt::KeyboardModifiers mods = modifiers & ~neededMods; qtKey = keysymToQtKey(sym, mods, lookupString(kb_state, event->nativeScanCode())); - if (qtKey == baseQtKey) + if (qtKey == baseQtKey || qtKey == 0) continue; result += (qtKey + mods); From e8e1616cf2f4346995cbb222010173ef0850a53d Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 2 Oct 2014 17:36:41 +0400 Subject: [PATCH 050/102] Reduce code duplication in QFontconfigDatabase Extract common part from fontEngine() methods to setupFontEngine(). Change-Id: Id4aee43b2a477f9fd40dc564d96a2335bfde9e22 Reviewed-by: Allan Sandfeld Jensen --- .../fontconfig/qfontconfigdatabase.cpp | 238 +++++++----------- .../fontconfig/qfontconfigdatabase_p.h | 5 + 2 files changed, 97 insertions(+), 146 deletions(-) diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 62dc9a9c6b..1aac0791cd 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -587,92 +587,18 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) { if (!usrPtr) return 0; - QFontDef fontDef = f; - QFontEngineFT *engine; FontFile *fontfile = static_cast (usrPtr); QFontEngine::FaceId fid; fid.filename = QFile::encodeName(fontfile->fileName); fid.index = fontfile->indexValue; - bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias); - bool forcedAntialiasSetting = !antialias; - engine = new QFontEngineFT(fontDef); + QFontEngineFT *engine = new QFontEngineFT(f); + engine->face_id = fid; - const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); - bool useXftConf = (services && (services->desktopEnvironment() == "GNOME" || services->desktopEnvironment() == "UNITY")); - if (useXftConf) { - void *antialiasResource = - QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled", - QGuiApplication::primaryScreen()); - int antialiasingEnabled = int(reinterpret_cast(antialiasResource)); - if (antialiasingEnabled > 0) { - antialias = antialiasingEnabled - 1; - forcedAntialiasSetting = true; - } - } + setupFontEngine(engine, f); - QFontEngine::GlyphFormat format; - // try and get the pattern - FcPattern *pattern = FcPatternCreate(); - - FcValue value; - value.type = FcTypeString; - QByteArray cs = fontDef.family.toUtf8(); - value.u.s = (const FcChar8 *)cs.data(); - FcPatternAdd(pattern,FC_FAMILY,value,true); - - value.u.s = (const FcChar8 *)fid.filename.data(); - FcPatternAdd(pattern,FC_FILE,value,true); - - value.type = FcTypeInteger; - value.u.i = fid.index; - FcPatternAdd(pattern,FC_INDEX,value,true); - - FcResult result; - - FcConfigSubstitute(0, pattern, FcMatchPattern); - FcDefaultSubstitute(pattern); - - FcPattern *match = FcFontMatch(0, pattern, &result); - if (match) { - engine->setDefaultHintStyle(defaultHintStyleFromMatch((QFont::HintingPreference)f.hintingPreference, match, useXftConf)); - - FcBool fc_autohint; - if (FcPatternGetBool(match, FC_AUTOHINT,0, &fc_autohint) == FcResultMatch) - engine->forceAutoHint = fc_autohint; - -#if defined(FT_LCD_FILTER_H) - int lcdFilter; - if (FcPatternGetInteger(match, FC_LCD_FILTER, 0, &lcdFilter) == FcResultMatch) - engine->lcdFilterType = lcdFilter; -#endif - - if (!forcedAntialiasSetting) { - FcBool fc_antialias; - if (FcPatternGetBool(match, FC_ANTIALIAS,0, &fc_antialias) == FcResultMatch) - antialias = fc_antialias; - } - - if (antialias) { - QFontEngine::SubpixelAntialiasingType subpixelType = QFontEngine::Subpixel_None; - if (!(f.styleStrategy & QFont::NoSubpixelAntialias)) - subpixelType = subpixelTypeFromMatch(match, useXftConf); - engine->subpixelType = subpixelType; - - format = (subpixelType == QFontEngine::Subpixel_None) - ? QFontEngine::Format_A8 - : QFontEngine::Format_A32; - } else - format = QFontEngine::Format_Mono; - - FcPatternDestroy(match); - } else - format = antialias ? QFontEngine::Format_A8 : QFontEngine::Format_Mono; - - FcPatternDestroy(pattern); - - if (!engine->init(fid, antialias, format) || engine->invalid()) { + if (!engine->init(fid, engine->antialias, engine->defaultFormat) || engine->invalid()) { delete engine; engine = 0; } @@ -686,74 +612,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QByteArray &fontData, qreal p if (engine == 0) return 0; - QFontDef fontDef = engine->fontDef; - - bool forcedAntialiasSetting = false; - const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); - bool useXftConf = (services && (services->desktopEnvironment() == "GNOME" || services->desktopEnvironment() == "UNITY")); - if (useXftConf) { - void *antialiasResource = - QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled", - QGuiApplication::primaryScreen()); - int antialiasingEnabled = int(reinterpret_cast(antialiasResource)); - if (antialiasingEnabled > 0) { - engine->antialias = antialiasingEnabled - 1; - forcedAntialiasSetting = true; - } - } - - QFontEngine::GlyphFormat format; - // try and get the pattern - FcPattern *pattern = FcPatternCreate(); - - FcValue value; - value.type = FcTypeString; - QByteArray cs = fontDef.family.toUtf8(); - value.u.s = (const FcChar8 *)cs.data(); - FcPatternAdd(pattern,FC_FAMILY,value,true); - - FcResult result; - - FcConfigSubstitute(0, pattern, FcMatchPattern); - FcDefaultSubstitute(pattern); - - FcPattern *match = FcFontMatch(0, pattern, &result); - if (match) { - engine->setDefaultHintStyle(defaultHintStyleFromMatch(hintingPreference, match, useXftConf)); - - FcBool fc_autohint; - if (FcPatternGetBool(match, FC_AUTOHINT,0, &fc_autohint) == FcResultMatch) - engine->forceAutoHint = fc_autohint; - -#if defined(FT_LCD_FILTER_H) - int lcdFilter; - if (FcPatternGetInteger(match, FC_LCD_FILTER, 0, &lcdFilter) == FcResultMatch) - engine->lcdFilterType = lcdFilter; -#endif - - if (!forcedAntialiasSetting) { - FcBool fc_antialias; - if (FcPatternGetBool(match, FC_ANTIALIAS,0, &fc_antialias) == FcResultMatch) - engine->antialias = fc_antialias; - } - - if (engine->antialias) { - QFontEngine::SubpixelAntialiasingType subpixelType = subpixelTypeFromMatch(match, useXftConf); - engine->subpixelType = subpixelType; - - format = subpixelType == QFontEngine::Subpixel_None - ? QFontEngine::Format_A8 - : QFontEngine::Format_A32; - } else - format = QFontEngine::Format_Mono; - FcPatternDestroy(match); - } else - format = QFontEngine::Format_A8; - - FcPatternDestroy(pattern); - - engine->defaultFormat = format; - engine->glyphFormat = format; + setupFontEngine(engine, engine->fontDef); return engine; } @@ -947,4 +806,91 @@ QFont QFontconfigDatabase::defaultFont() const return QFont(resolved); } +void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef &fontDef) const +{ + bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias); + bool forcedAntialiasSetting = !antialias; + + const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); + bool useXftConf = (services && (services->desktopEnvironment() == "GNOME" || services->desktopEnvironment() == "UNITY")); + if (useXftConf) { + void *antialiasResource = + QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled", + QGuiApplication::primaryScreen()); + int antialiasingEnabled = int(reinterpret_cast(antialiasResource)); + if (antialiasingEnabled > 0) { + antialias = antialiasingEnabled - 1; + forcedAntialiasSetting = true; + } + } + + QFontEngine::GlyphFormat format; + // try and get the pattern + FcPattern *pattern = FcPatternCreate(); + + FcValue value; + value.type = FcTypeString; + QByteArray cs = fontDef.family.toUtf8(); + value.u.s = (const FcChar8 *)cs.data(); + FcPatternAdd(pattern,FC_FAMILY,value,true); + + QFontEngine::FaceId fid = engine->faceId(); + + if (!fid.filename.isEmpty()) { + value.u.s = (const FcChar8 *)fid.filename.data(); + FcPatternAdd(pattern,FC_FILE,value,true); + + value.type = FcTypeInteger; + value.u.i = fid.index; + FcPatternAdd(pattern,FC_INDEX,value,true); + } + + FcResult result; + + FcConfigSubstitute(0, pattern, FcMatchPattern); + FcDefaultSubstitute(pattern); + + FcPattern *match = FcFontMatch(0, pattern, &result); + if (match) { + engine->setDefaultHintStyle(defaultHintStyleFromMatch((QFont::HintingPreference)fontDef.hintingPreference, match, useXftConf)); + + FcBool fc_autohint; + if (FcPatternGetBool(match, FC_AUTOHINT,0, &fc_autohint) == FcResultMatch) + engine->forceAutoHint = fc_autohint; + +#if defined(FT_LCD_FILTER_H) + int lcdFilter; + if (FcPatternGetInteger(match, FC_LCD_FILTER, 0, &lcdFilter) == FcResultMatch) + engine->lcdFilterType = lcdFilter; +#endif + + if (!forcedAntialiasSetting) { + FcBool fc_antialias; + if (FcPatternGetBool(match, FC_ANTIALIAS,0, &fc_antialias) == FcResultMatch) + antialias = fc_antialias; + } + + if (antialias) { + QFontEngine::SubpixelAntialiasingType subpixelType = QFontEngine::Subpixel_None; + if (!(fontDef.styleStrategy & QFont::NoSubpixelAntialias)) + subpixelType = subpixelTypeFromMatch(match, useXftConf); + engine->subpixelType = subpixelType; + + format = (subpixelType == QFontEngine::Subpixel_None) + ? QFontEngine::Format_A8 + : QFontEngine::Format_A32; + } else + format = QFontEngine::Format_Mono; + + FcPatternDestroy(match); + } else + format = antialias ? QFontEngine::Format_A8 : QFontEngine::Format_Mono; + + FcPatternDestroy(pattern); + + engine->antialias = antialias; + engine->defaultFormat = format; + engine->glyphFormat = format; +} + QT_END_NAMESPACE diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h index 91ecb52e7b..745d12b825 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +class QFontEngineFT; + class QFontconfigDatabase : public QBasicFontDatabase { public: @@ -61,6 +63,9 @@ public: QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); QString resolveFontFamilyAlias(const QString &family) const; QFont defaultFont() const; + +private: + void setupFontEngine(QFontEngineFT *engine, const QFontDef &fontDef) const; }; QT_END_NAMESPACE From 50398708cd70121b8864f4a82bca5412bde11415 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 24 Sep 2014 13:41:21 +0400 Subject: [PATCH 051/102] Accessibility Linux: Make a full copy of a key event Otherwise native values (scan code, modifiers, virtual key) of the key event will be lost if an event listener is registered. Change-Id: I5eebb1f91ad7de6801f7efb0bf0891c4430f9cf5 Reviewed-by: Frederik Gladhorn --- src/platformsupport/linuxaccessibility/application.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platformsupport/linuxaccessibility/application.cpp b/src/platformsupport/linuxaccessibility/application.cpp index dcf17143fa..2ee6b0a203 100644 --- a/src/platformsupport/linuxaccessibility/application.cpp +++ b/src/platformsupport/linuxaccessibility/application.cpp @@ -196,7 +196,9 @@ bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event) QKeyEvent* QSpiApplicationAdaptor::copyKeyEvent(QKeyEvent* old) { - return new QKeyEvent(old->type(), old->key(), old->modifiers(), old->text(), old->isAutoRepeat(), old->count()); + return new QKeyEvent(old->type(), old->key(), old->modifiers(), + old->nativeScanCode(), old->nativeVirtualKey(), old->nativeModifiers(), + old->text(), old->isAutoRepeat(), old->count()); } void QSpiApplicationAdaptor::notifyKeyboardListenerCallback(const QDBusMessage& message) From 1b8c5f450ba7dc3be04149020ec788a8ca03e47f Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 6 Oct 2014 19:03:35 +0400 Subject: [PATCH 052/102] xcb: Fix a type of variables for xkb modifiers masks Change-Id: I05c7c6a649a55fc0648b1cb84e1c402160c9d998 Reviewed-by: Friedemann Kleint Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 8c12b29a99..d956d6abd3 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -841,8 +841,8 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const xkb_layout_index_t baseLayout = xkb_state_serialize_layout(xkb_state, XKB_STATE_LAYOUT_DEPRESSED); xkb_layout_index_t latchedLayout = xkb_state_serialize_layout(xkb_state, XKB_STATE_LAYOUT_LATCHED); xkb_layout_index_t lockedLayout = xkb_state_serialize_layout(xkb_state, XKB_STATE_LAYOUT_LOCKED); - xkb_mod_index_t latchedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED); - xkb_mod_index_t lockedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED); + xkb_mod_mask_t latchedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED); + xkb_mod_mask_t lockedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED); xkb_state_update_mask(kb_state, 0, latchedMods, lockedMods, baseLayout, latchedLayout, lockedLayout); From 0368b24a7f53c945b582097cc8ad22a053856d22 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 9 Oct 2014 09:43:23 +0200 Subject: [PATCH 053/102] QSettings: Prevent assert when passing empty keys. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][Important behavior changes][QSettings] QSettings::value() now returns an invalid QVariant when passing an empty key. The code path ran into an assert, which was only noticeable in debug builds. Task-number: QTBUG-41812 Change-Id: I5cc32be3aa267a132e9d6639ecd6cb0bbafc15b0 Reviewed-by: Stéphane Fabry, Cutesoft Reviewed-by: Thiago Macieira --- src/corelib/io/qsettings.cpp | 8 ++++++++ tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index fd35ae33dc..d896da176a 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -3121,6 +3121,10 @@ bool QSettings::isWritable() const void QSettings::setValue(const QString &key, const QVariant &value) { Q_D(QSettings); + if (key.isEmpty()) { + qWarning("QSettings::setValue: Empty key passed"); + return; + } QString k = d->actualKey(key); d->set(k, value); d->requestUpdate(); @@ -3253,6 +3257,10 @@ bool QSettings::event(QEvent *event) QVariant QSettings::value(const QString &key, const QVariant &defaultValue) const { Q_D(const QSettings); + if (key.isEmpty()) { + qWarning("QSettings::value: Empty key passed"); + return QVariant(); + } QVariant result = defaultValue; QString k = d->actualKey(key); d->get(k, &result); diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 77a60997a6..3e68e4859f 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -118,6 +118,7 @@ private slots: void testUpdateRequestEvent(); void testThreadSafety(); void testEmptyData(); + void testEmptyKey(); void testResourceFiles(); void testRegistryShortRootNames(); void trailingWhitespace(); @@ -2025,6 +2026,16 @@ void tst_QSettings::testEmptyData() QFile::remove(filename); } +void tst_QSettings::testEmptyKey() +{ + QSettings settings; + QTest::ignoreMessage(QtWarningMsg, "QSettings::value: Empty key passed"); + const QVariant value = settings.value(QString()); + QCOMPARE(value, QVariant()); + QTest::ignoreMessage(QtWarningMsg, "QSettings::setValue: Empty key passed"); + settings.setValue(QString(), value); +} + void tst_QSettings::testResourceFiles() { QSettings settings(":/resourcefile.ini", QSettings::IniFormat); From 16df1ad322689190f9b8107b010d74c92bb19e8b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 13 Oct 2014 11:57:02 +0200 Subject: [PATCH 054/102] Export QFSFileEngine symbols Although it's private API the symbols are used e.g. in the Qt Installer Framework. Change-Id: I557d3b86dbf87cb1b712bae09c3e8fecf6f15e67 Reviewed-by: hjk --- src/corelib/io/qfsfileengine_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 5d5a29243e..3963a9cb11 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE class QFSFileEnginePrivate; -class Q_AUTOTEST_EXPORT QFSFileEngine : public QAbstractFileEngine +class Q_CORE_EXPORT QFSFileEngine : public QAbstractFileEngine { Q_DECLARE_PRIVATE(QFSFileEngine) public: From db069e7f3009075937a772e780df40c63a871999 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 1 Oct 2014 14:48:29 +0200 Subject: [PATCH 055/102] XCB: Always set X window attributes in QXcbWindow::setWindowFlags(). QDockWidget and QToolBar set the Qt::BypassWindowManagerHint window flag when unplugging and clear it in the endDrag() methods. This does not have any effect since the attribute is not taken into account in QXcbWindow::setWindowFlags(). Change the method to always set the attributes, which should also make it possible to set/clear Qt::WindowTransparentForInput. Task-number: QTBUG-41189 Task-number: QTBUG-38964 Change-Id: Id9eddc642489d18f44c7597f8fc1a1df71971306 Reviewed-by: Andy Shaw Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbwindow.cpp | 51 ++++++++++++++---------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index c4cf3b4416..0c2e9d047c 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -251,6 +251,27 @@ QXcbWindow::QXcbWindow(QWindow *window) m_window = window->winId(); } +#ifdef Q_COMPILER_CLASS_ENUM +enum : quint32 { +#else +enum { +#endif + baseEventMask + = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY + | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_FOCUS_CHANGE, + + defaultEventMask = baseEventMask + | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE + | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE + | XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW + | XCB_EVENT_MASK_POINTER_MOTION, + + transparentForInputEventMask = baseEventMask + | XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_RESIZE_REDIRECT + | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT + | XCB_EVENT_MASK_COLOR_MAP_CHANGE | XCB_EVENT_MASK_OWNER_GRAB_BUTTON +}; + void QXcbWindow::create() { destroy(); @@ -285,18 +306,7 @@ void QXcbWindow::create() // XCB_CW_SAVE_UNDER type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, // XCB_CW_EVENT_MASK - XCB_EVENT_MASK_EXPOSURE - | XCB_EVENT_MASK_STRUCTURE_NOTIFY - | XCB_EVENT_MASK_KEY_PRESS - | XCB_EVENT_MASK_KEY_RELEASE - | XCB_EVENT_MASK_BUTTON_PRESS - | XCB_EVENT_MASK_BUTTON_RELEASE - | XCB_EVENT_MASK_BUTTON_MOTION - | XCB_EVENT_MASK_ENTER_WINDOW - | XCB_EVENT_MASK_LEAVE_WINDOW - | XCB_EVENT_MASK_POINTER_MOTION - | XCB_EVENT_MASK_PROPERTY_CHANGE - | XCB_EVENT_MASK_FOCUS_CHANGE + defaultEventMask }; // Parameters to XCreateWindow() are frame corner + inner size. @@ -985,14 +995,15 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags) if (type == Qt::Popup) flags |= Qt::X11BypassWindowManagerHint; - if (flags & Qt::WindowTransparentForInput) { - uint32_t mask = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_VISIBILITY_CHANGE - | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_RESIZE_REDIRECT - | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT - | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE - | XCB_EVENT_MASK_COLOR_MAP_CHANGE | XCB_EVENT_MASK_OWNER_GRAB_BUTTON; - xcb_change_window_attributes(xcb_connection(), xcb_window(), XCB_CW_EVENT_MASK, &mask); - } + const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; + const quint32 values[] = { + // XCB_CW_OVERRIDE_REDIRECT + (flags & Qt::BypassWindowManagerHint) ? 1u : 0, + // XCB_CW_EVENT_MASK + (flags & Qt::WindowTransparentForInput) ? transparentForInputEventMask : defaultEventMask + }; + + xcb_change_window_attributes(xcb_connection(), xcb_window(), mask, values); setNetWmWindowFlags(flags); setMotifWindowFlags(flags); From 45485d9eb47d3129b8a74c2e9d854c07673161cd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 16 Oct 2014 10:39:44 +0200 Subject: [PATCH 056/102] Fix undefined behavior in QLoggingRegistry::defaultCategoryFilter() Report by asan: READ of size 2 at 0x00000041dd40 thread T0 #0 0x2af097b84da6 in QLoggingRegistry::defaultCategoryFilter(QLoggingCategory*) (lib/libQt5Core.so.5+0x566da6) #1 0x2af097b8387b in QLoggingRegistry::registerCategory(QLoggingCategory*, QtMsgType) (lib/libQt5Core.so.5+0x56587b) #2 0x4067f7 in tst_QLogging::QLoggingCategory_categoryName() tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp:238 0x00000041dd41 is located 0 bytes to the right of global variable '*.LC115' defined in 'tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp' (0x41dd40) of size 1 '*.LC115' is ascii string '' At face value, memcmp("", "qt", 2) should not return 0, but since the code invokes undefined behavior, the compiler can do whatever it wants, including returning 0 here, further proving the fact that there are *no* benign cases of undefined behavior. Change-Id: I0c38622c47d1dcea450ea549370be1673b47b18d Reviewed-by: Kai Koehne Reviewed-by: Olivier Goffart --- src/corelib/io/qloggingregistry.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index e9ee8d9458..8af1487834 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -398,9 +398,11 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat) // hard-wired implementation of // qt.*.debug=false // qt.debug=false - char c; - if (!memcmp(cat->categoryName(), "qt", 2) && (!(c = cat->categoryName()[2]) || c == '.')) - debug = false; + if (const char *categoryName = cat->categoryName()) { + // == "qt" or startsWith("qt.") + if (strcmp(categoryName, "qt") == 0 || strncmp(categoryName, "qt.", 3) == 0) + debug = false; + } QString categoryName = QLatin1String(cat->categoryName()); foreach (const QLoggingRule &item, reg->rules) { From cf8f369f8575dcb9ca4d5116f3afc7cff4a080af Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 15 Oct 2014 13:50:27 +0200 Subject: [PATCH 057/102] Move Qt Core examples under a common subdirectory Qt Core examples were scattered into several subdirectories under qtbase/examples. This caused an issue with the example manifest file generated by QDoc; it expects to find all examples under a common directory in order to produde correct paths to the example .pro files. Qt Creator will not find the examples without a valid manifest file. This change moves the examples and edits the documentation files accordingly. Task-number: QTBUG-41963 Change-Id: I51d86782e0ba21c5c9bae5f15401ec774abe5cf8 Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen Reviewed-by: Leena Miettinen --- doc/global/manifest-meta.qdocconf | 7 +- examples/corelib/corelib.pro | 8 +++ examples/{ => corelib}/ipc/README | 0 .../doc/images/localfortuneclient-example.png | Bin .../doc/images/localfortuneserver-example.png | Bin .../ipc/doc/images/sharedmemory-example_1.png | Bin .../ipc/doc/images/sharedmemory-example_2.png | Bin .../ipc/doc/src/localfortuneclient.qdoc | 2 +- .../ipc/doc/src/localfortuneserver.qdoc | 2 +- .../ipc/doc/src/sharedmemory.qdoc | 14 ++-- examples/{ => corelib}/ipc/ipc.pro | 0 .../ipc/localfortuneclient/client.cpp | 0 .../ipc/localfortuneclient/client.h | 0 .../localfortuneclient/localfortuneclient.pro | 2 +- .../ipc/localfortuneclient/main.cpp | 0 .../localfortuneserver/localfortuneserver.pro | 2 +- .../ipc/localfortuneserver/main.cpp | 0 .../ipc/localfortuneserver/server.cpp | 0 .../ipc/localfortuneserver/server.h | 0 .../{ => corelib}/ipc/sharedmemory/dialog.cpp | 0 .../{ => corelib}/ipc/sharedmemory/dialog.h | 0 .../{ => corelib}/ipc/sharedmemory/dialog.ui | 0 .../{ => corelib}/ipc/sharedmemory/image.png | Bin .../{ => corelib}/ipc/sharedmemory/main.cpp | 0 .../{ => corelib}/ipc/sharedmemory/qt.png | Bin .../ipc/sharedmemory/sharedmemory.pro | 2 +- examples/{ => corelib}/json/json.pro | 0 .../{ => corelib}/json/savegame/character.cpp | 0 .../{ => corelib}/json/savegame/character.h | 0 .../json/savegame/doc/src/savegame.qdoc | 30 ++++---- examples/{ => corelib}/json/savegame/game.cpp | 0 examples/{ => corelib}/json/savegame/game.h | 0 .../{ => corelib}/json/savegame/level.cpp | 0 examples/{ => corelib}/json/savegame/level.h | 0 examples/{ => corelib}/json/savegame/main.cpp | 0 .../{ => corelib}/json/savegame/savegame.pro | 2 +- examples/{ => corelib}/threads/README | 0 .../threads/doc/images/mandelbrot-example.png | Bin .../threads/doc/images/mandelbrot_scroll1.png | Bin .../threads/doc/images/mandelbrot_scroll2.png | Bin .../threads/doc/images/mandelbrot_scroll3.png | Bin .../threads/doc/images/mandelbrot_zoom1.png | Bin .../threads/doc/images/mandelbrot_zoom2.png | Bin .../threads/doc/images/mandelbrot_zoom3.png | Bin .../doc/images/queuedcustomtype-example.png | Bin .../threads/doc/src/mandelbrot.qdoc | 68 +++++++++--------- .../threads/doc/src/queuedcustomtype.qdoc | 24 +++---- .../threads/doc/src/semaphores.qdoc | 16 ++--- .../threads/doc/src/waitconditions.qdoc | 16 ++--- .../{ => corelib}/threads/mandelbrot/main.cpp | 0 .../threads/mandelbrot/mandelbrot.pro | 2 +- .../threads/mandelbrot/mandelbrotwidget.cpp | 0 .../threads/mandelbrot/mandelbrotwidget.h | 0 .../threads/mandelbrot/renderthread.cpp | 0 .../threads/mandelbrot/renderthread.h | 0 .../threads/queuedcustomtype/block.cpp | 0 .../threads/queuedcustomtype/block.h | 0 .../threads/queuedcustomtype/main.cpp | 0 .../queuedcustomtype/queuedcustomtype.pro | 2 +- .../threads/queuedcustomtype/renderthread.cpp | 0 .../threads/queuedcustomtype/renderthread.h | 0 .../threads/queuedcustomtype/window.cpp | 0 .../threads/queuedcustomtype/window.h | 0 .../threads/semaphores/semaphores.cpp | 0 .../threads/semaphores/semaphores.pro | 2 +- examples/{ => corelib}/threads/threads.pro | 0 .../threads/waitconditions/waitconditions.cpp | 0 .../threads/waitconditions/waitconditions.pro | 2 +- examples/{ => corelib}/tools/README | 0 .../tools/contiguouscache/contiguouscache.pro | 2 +- .../tools/contiguouscache/main.cpp | 0 .../tools/contiguouscache/randomlistmodel.cpp | 0 .../tools/contiguouscache/randomlistmodel.h | 0 .../tools/customtype/customtype.pro | 2 +- .../{ => corelib}/tools/customtype/main.cpp | 0 .../tools/customtype/message.cpp | 0 .../{ => corelib}/tools/customtype/message.h | 0 .../customtypesending/customtypesending.pro | 2 +- .../tools/customtypesending/main.cpp | 0 .../tools/customtypesending/message.cpp | 0 .../tools/customtypesending/message.h | 0 .../tools/customtypesending/window.cpp | 0 .../tools/customtypesending/window.h | 0 .../tools/doc/src}/contiguouscache.qdoc | 6 +- .../tools/doc/src/customtype.qdoc | 20 +++--- examples/{ => corelib}/tools/tools.pro | 0 examples/examples.pro | 5 +- src/corelib/doc/qtcore.qdocconf | 7 +- src/corelib/doc/src/custom-types.qdoc | 22 +++--- 89 files changed, 138 insertions(+), 131 deletions(-) create mode 100644 examples/corelib/corelib.pro rename examples/{ => corelib}/ipc/README (100%) rename examples/{ => corelib}/ipc/doc/images/localfortuneclient-example.png (100%) rename examples/{ => corelib}/ipc/doc/images/localfortuneserver-example.png (100%) rename examples/{ => corelib}/ipc/doc/images/sharedmemory-example_1.png (100%) rename examples/{ => corelib}/ipc/doc/images/sharedmemory-example_2.png (100%) rename examples/{ => corelib}/ipc/doc/src/localfortuneclient.qdoc (97%) rename examples/{ => corelib}/ipc/doc/src/localfortuneserver.qdoc (97%) rename examples/{ => corelib}/ipc/doc/src/sharedmemory.qdoc (95%) rename examples/{ => corelib}/ipc/ipc.pro (100%) rename examples/{ => corelib}/ipc/localfortuneclient/client.cpp (100%) rename examples/{ => corelib}/ipc/localfortuneclient/client.h (100%) rename examples/{ => corelib}/ipc/localfortuneclient/localfortuneclient.pro (67%) rename examples/{ => corelib}/ipc/localfortuneclient/main.cpp (100%) rename examples/{ => corelib}/ipc/localfortuneserver/localfortuneserver.pro (67%) rename examples/{ => corelib}/ipc/localfortuneserver/main.cpp (100%) rename examples/{ => corelib}/ipc/localfortuneserver/server.cpp (100%) rename examples/{ => corelib}/ipc/localfortuneserver/server.h (100%) rename examples/{ => corelib}/ipc/sharedmemory/dialog.cpp (100%) rename examples/{ => corelib}/ipc/sharedmemory/dialog.h (100%) rename examples/{ => corelib}/ipc/sharedmemory/dialog.ui (100%) rename examples/{ => corelib}/ipc/sharedmemory/image.png (100%) rename examples/{ => corelib}/ipc/sharedmemory/main.cpp (100%) rename examples/{ => corelib}/ipc/sharedmemory/qt.png (100%) rename examples/{ => corelib}/ipc/sharedmemory/sharedmemory.pro (73%) rename examples/{ => corelib}/json/json.pro (100%) rename examples/{ => corelib}/json/savegame/character.cpp (100%) rename examples/{ => corelib}/json/savegame/character.h (100%) rename examples/{ => corelib}/json/savegame/doc/src/savegame.qdoc (92%) rename examples/{ => corelib}/json/savegame/game.cpp (100%) rename examples/{ => corelib}/json/savegame/game.h (100%) rename examples/{ => corelib}/json/savegame/level.cpp (100%) rename examples/{ => corelib}/json/savegame/level.h (100%) rename examples/{ => corelib}/json/savegame/main.cpp (100%) rename examples/{ => corelib}/json/savegame/savegame.pro (80%) rename examples/{ => corelib}/threads/README (100%) rename examples/{ => corelib}/threads/doc/images/mandelbrot-example.png (100%) rename examples/{ => corelib}/threads/doc/images/mandelbrot_scroll1.png (100%) rename examples/{ => corelib}/threads/doc/images/mandelbrot_scroll2.png (100%) rename examples/{ => corelib}/threads/doc/images/mandelbrot_scroll3.png (100%) rename examples/{ => corelib}/threads/doc/images/mandelbrot_zoom1.png (100%) rename examples/{ => corelib}/threads/doc/images/mandelbrot_zoom2.png (100%) rename examples/{ => corelib}/threads/doc/images/mandelbrot_zoom3.png (100%) rename examples/{ => corelib}/threads/doc/images/queuedcustomtype-example.png (100%) rename examples/{ => corelib}/threads/doc/src/mandelbrot.qdoc (88%) rename examples/{ => corelib}/threads/doc/src/queuedcustomtype.qdoc (87%) rename examples/{ => corelib}/threads/doc/src/semaphores.qdoc (94%) rename examples/{ => corelib}/threads/doc/src/waitconditions.qdoc (93%) rename examples/{ => corelib}/threads/mandelbrot/main.cpp (100%) rename examples/{ => corelib}/threads/mandelbrot/mandelbrot.pro (79%) rename examples/{ => corelib}/threads/mandelbrot/mandelbrotwidget.cpp (100%) rename examples/{ => corelib}/threads/mandelbrot/mandelbrotwidget.h (100%) rename examples/{ => corelib}/threads/mandelbrot/renderthread.cpp (100%) rename examples/{ => corelib}/threads/mandelbrot/renderthread.h (100%) rename examples/{ => corelib}/threads/queuedcustomtype/block.cpp (100%) rename examples/{ => corelib}/threads/queuedcustomtype/block.h (100%) rename examples/{ => corelib}/threads/queuedcustomtype/main.cpp (100%) rename examples/{ => corelib}/threads/queuedcustomtype/queuedcustomtype.pro (77%) rename examples/{ => corelib}/threads/queuedcustomtype/renderthread.cpp (100%) rename examples/{ => corelib}/threads/queuedcustomtype/renderthread.h (100%) rename examples/{ => corelib}/threads/queuedcustomtype/window.cpp (100%) rename examples/{ => corelib}/threads/queuedcustomtype/window.h (100%) rename examples/{ => corelib}/threads/semaphores/semaphores.cpp (100%) rename examples/{ => corelib}/threads/semaphores/semaphores.pro (61%) rename examples/{ => corelib}/threads/threads.pro (100%) rename examples/{ => corelib}/threads/waitconditions/waitconditions.cpp (100%) rename examples/{ => corelib}/threads/waitconditions/waitconditions.pro (62%) rename examples/{ => corelib}/tools/README (100%) rename examples/{ => corelib}/tools/contiguouscache/contiguouscache.pro (67%) rename examples/{ => corelib}/tools/contiguouscache/main.cpp (100%) rename examples/{ => corelib}/tools/contiguouscache/randomlistmodel.cpp (100%) rename examples/{ => corelib}/tools/contiguouscache/randomlistmodel.h (100%) rename examples/{ => corelib}/tools/customtype/customtype.pro (62%) rename examples/{ => corelib}/tools/customtype/main.cpp (100%) rename examples/{ => corelib}/tools/customtype/message.cpp (100%) rename examples/{ => corelib}/tools/customtype/message.h (100%) rename examples/{ => corelib}/tools/customtypesending/customtypesending.pro (70%) rename examples/{ => corelib}/tools/customtypesending/main.cpp (100%) rename examples/{ => corelib}/tools/customtypesending/message.cpp (100%) rename examples/{ => corelib}/tools/customtypesending/message.h (100%) rename examples/{ => corelib}/tools/customtypesending/window.cpp (100%) rename examples/{ => corelib}/tools/customtypesending/window.h (100%) rename examples/{tools/doc => corelib/tools/doc/src}/contiguouscache.qdoc (96%) rename examples/{ => corelib}/tools/doc/src/customtype.qdoc (89%) rename examples/{ => corelib}/tools/tools.pro (100%) diff --git a/doc/global/manifest-meta.qdocconf b/doc/global/manifest-meta.qdocconf index f5a4422601..01950e650c 100644 --- a/doc/global/manifest-meta.qdocconf +++ b/doc/global/manifest-meta.qdocconf @@ -255,7 +255,12 @@ manifestmeta.ios.tags = ios # add a generic thumbnail image to examples that do not have any images in their documentation manifestmeta.thumbnail.attributes = "imageUrl:qthelp\://org.qt-project.qtdoc.$QT_VERSION_TAG/qtdoc/images/qt-codesample.png" -manifestmeta.thumbnail.names = "QtConcurrent/Map Example" \ +manifestmeta.thumbnail.names = "QtCore/Contiguous Cache Example" \ + "QtCore/Custom Type Example" \ + "QtCore/JSON Save Game Example" \ + "QtCore/Semaphores Example" \ + "QtCore/Wait Conditions Example" \ + "QtConcurrent/Map Example" \ "QtConcurrent/QtConcurrent Word Count Example" \ "QtConcurrent/Run Function Example" \ "QtGui/Raster Window Example" \ diff --git a/examples/corelib/corelib.pro b/examples/corelib/corelib.pro new file mode 100644 index 0000000000..ec6e19c2b5 --- /dev/null +++ b/examples/corelib/corelib.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +CONFIG += no_docs_target + +SUBDIRS = \ + ipc \ + json \ + threads \ + tools diff --git a/examples/ipc/README b/examples/corelib/ipc/README similarity index 100% rename from examples/ipc/README rename to examples/corelib/ipc/README diff --git a/examples/ipc/doc/images/localfortuneclient-example.png b/examples/corelib/ipc/doc/images/localfortuneclient-example.png similarity index 100% rename from examples/ipc/doc/images/localfortuneclient-example.png rename to examples/corelib/ipc/doc/images/localfortuneclient-example.png diff --git a/examples/ipc/doc/images/localfortuneserver-example.png b/examples/corelib/ipc/doc/images/localfortuneserver-example.png similarity index 100% rename from examples/ipc/doc/images/localfortuneserver-example.png rename to examples/corelib/ipc/doc/images/localfortuneserver-example.png diff --git a/examples/ipc/doc/images/sharedmemory-example_1.png b/examples/corelib/ipc/doc/images/sharedmemory-example_1.png similarity index 100% rename from examples/ipc/doc/images/sharedmemory-example_1.png rename to examples/corelib/ipc/doc/images/sharedmemory-example_1.png diff --git a/examples/ipc/doc/images/sharedmemory-example_2.png b/examples/corelib/ipc/doc/images/sharedmemory-example_2.png similarity index 100% rename from examples/ipc/doc/images/sharedmemory-example_2.png rename to examples/corelib/ipc/doc/images/sharedmemory-example_2.png diff --git a/examples/ipc/doc/src/localfortuneclient.qdoc b/examples/corelib/ipc/doc/src/localfortuneclient.qdoc similarity index 97% rename from examples/ipc/doc/src/localfortuneclient.qdoc rename to examples/corelib/ipc/doc/src/localfortuneclient.qdoc index a68f4bad0c..d7a90fd946 100644 --- a/examples/ipc/doc/src/localfortuneclient.qdoc +++ b/examples/corelib/ipc/doc/src/localfortuneclient.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example localfortuneclient + \example ipc/localfortuneclient \title Local Fortune Client Example \ingroup examples-ipc \brief Demonstrates using QLocalSocket for a simple local service client. diff --git a/examples/ipc/doc/src/localfortuneserver.qdoc b/examples/corelib/ipc/doc/src/localfortuneserver.qdoc similarity index 97% rename from examples/ipc/doc/src/localfortuneserver.qdoc rename to examples/corelib/ipc/doc/src/localfortuneserver.qdoc index 13f7f3ca74..47c28e0eb0 100644 --- a/examples/ipc/doc/src/localfortuneserver.qdoc +++ b/examples/corelib/ipc/doc/src/localfortuneserver.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example localfortuneserver + \example ipc/localfortuneserver \title Local Fortune Server Example \ingroup examples-ipc \brief Demonstrates using QLocalServer and QLocalSocket for serving a simple local service. diff --git a/examples/ipc/doc/src/sharedmemory.qdoc b/examples/corelib/ipc/doc/src/sharedmemory.qdoc similarity index 95% rename from examples/ipc/doc/src/sharedmemory.qdoc rename to examples/corelib/ipc/doc/src/sharedmemory.qdoc index b9f0c86d44..60b949df2d 100644 --- a/examples/ipc/doc/src/sharedmemory.qdoc +++ b/examples/corelib/ipc/doc/src/sharedmemory.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example sharedmemory + \example ipc/sharedmemory \title Shared Memory Example \ingroup examples-ipc \brief Demonstrates doing inter-process communication using shared memory with @@ -40,7 +40,7 @@ dialog is displayed and then control is passed to the application in the standard way. - \snippet sharedmemory/main.cpp 0 + \snippet ipc/sharedmemory/main.cpp 0 Two instances of class Dialog appear. @@ -51,12 +51,12 @@ loadFromFile() and loadFromMemory() that correspond to the two buttons on the dialog. - \snippet sharedmemory/dialog.h 0 + \snippet ipc/sharedmemory/dialog.h 0 The constructor builds the user interface widgets and connects the clicked() signal of each button to the corresponding slot function. - \snippet sharedmemory/dialog.cpp 0 + \snippet ipc/sharedmemory/dialog.cpp 0 Note that "QSharedMemoryExample" is passed to the \l {QSharedMemory} {QSharedMemory()} constructor to be used as the key. This will be @@ -69,7 +69,7 @@ that segment is detached from the process, so we can be assured of starting off the example correctly. - \snippet sharedmemory/dialog.cpp 1 + \snippet ipc/sharedmemory/dialog.cpp 1 The user is then asked to select an image file using QFileDialog::getOpenFileName(). The selected file is loaded into a @@ -85,7 +85,7 @@ to the image data, which we then use to do a memcopy() from the QBuffer into the shared memory segment. - \snippet sharedmemory/dialog.cpp 2 + \snippet ipc/sharedmemory/dialog.cpp 2 Note that we \l {QSharedMemory::} {lock()} the shared memory segment before we copy into it, and we \l {QSharedMemory::} {unlock()} it @@ -117,7 +117,7 @@ then streams the data into a QImage and \l {QSharedMemory::unlock()} {unlocks} the segment. - \snippet sharedmemory/dialog.cpp 3 + \snippet ipc/sharedmemory/dialog.cpp 3 In this case, the function does \l {QSharedMemory::} {detach()} from the segment, because now we are effectively finished using diff --git a/examples/ipc/ipc.pro b/examples/corelib/ipc/ipc.pro similarity index 100% rename from examples/ipc/ipc.pro rename to examples/corelib/ipc/ipc.pro diff --git a/examples/ipc/localfortuneclient/client.cpp b/examples/corelib/ipc/localfortuneclient/client.cpp similarity index 100% rename from examples/ipc/localfortuneclient/client.cpp rename to examples/corelib/ipc/localfortuneclient/client.cpp diff --git a/examples/ipc/localfortuneclient/client.h b/examples/corelib/ipc/localfortuneclient/client.h similarity index 100% rename from examples/ipc/localfortuneclient/client.h rename to examples/corelib/ipc/localfortuneclient/client.h diff --git a/examples/ipc/localfortuneclient/localfortuneclient.pro b/examples/corelib/ipc/localfortuneclient/localfortuneclient.pro similarity index 67% rename from examples/ipc/localfortuneclient/localfortuneclient.pro rename to examples/corelib/ipc/localfortuneclient/localfortuneclient.pro index c52a173ed5..912c0f3b8e 100644 --- a/examples/ipc/localfortuneclient/localfortuneclient.pro +++ b/examples/corelib/ipc/localfortuneclient/localfortuneclient.pro @@ -4,5 +4,5 @@ SOURCES = client.cpp \ QT += network widgets # install -target.path = $$[QT_INSTALL_EXAMPLES]/ipc/localfortuneclient +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/ipc/localfortuneclient INSTALLS += target diff --git a/examples/ipc/localfortuneclient/main.cpp b/examples/corelib/ipc/localfortuneclient/main.cpp similarity index 100% rename from examples/ipc/localfortuneclient/main.cpp rename to examples/corelib/ipc/localfortuneclient/main.cpp diff --git a/examples/ipc/localfortuneserver/localfortuneserver.pro b/examples/corelib/ipc/localfortuneserver/localfortuneserver.pro similarity index 67% rename from examples/ipc/localfortuneserver/localfortuneserver.pro rename to examples/corelib/ipc/localfortuneserver/localfortuneserver.pro index 9eed28ef74..88190c45bd 100644 --- a/examples/ipc/localfortuneserver/localfortuneserver.pro +++ b/examples/corelib/ipc/localfortuneserver/localfortuneserver.pro @@ -4,5 +4,5 @@ SOURCES = server.cpp \ QT += network widgets # install -target.path = $$[QT_INSTALL_EXAMPLES]/ipc/localfortuneserver +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/ipc/localfortuneserver INSTALLS += target diff --git a/examples/ipc/localfortuneserver/main.cpp b/examples/corelib/ipc/localfortuneserver/main.cpp similarity index 100% rename from examples/ipc/localfortuneserver/main.cpp rename to examples/corelib/ipc/localfortuneserver/main.cpp diff --git a/examples/ipc/localfortuneserver/server.cpp b/examples/corelib/ipc/localfortuneserver/server.cpp similarity index 100% rename from examples/ipc/localfortuneserver/server.cpp rename to examples/corelib/ipc/localfortuneserver/server.cpp diff --git a/examples/ipc/localfortuneserver/server.h b/examples/corelib/ipc/localfortuneserver/server.h similarity index 100% rename from examples/ipc/localfortuneserver/server.h rename to examples/corelib/ipc/localfortuneserver/server.h diff --git a/examples/ipc/sharedmemory/dialog.cpp b/examples/corelib/ipc/sharedmemory/dialog.cpp similarity index 100% rename from examples/ipc/sharedmemory/dialog.cpp rename to examples/corelib/ipc/sharedmemory/dialog.cpp diff --git a/examples/ipc/sharedmemory/dialog.h b/examples/corelib/ipc/sharedmemory/dialog.h similarity index 100% rename from examples/ipc/sharedmemory/dialog.h rename to examples/corelib/ipc/sharedmemory/dialog.h diff --git a/examples/ipc/sharedmemory/dialog.ui b/examples/corelib/ipc/sharedmemory/dialog.ui similarity index 100% rename from examples/ipc/sharedmemory/dialog.ui rename to examples/corelib/ipc/sharedmemory/dialog.ui diff --git a/examples/ipc/sharedmemory/image.png b/examples/corelib/ipc/sharedmemory/image.png similarity index 100% rename from examples/ipc/sharedmemory/image.png rename to examples/corelib/ipc/sharedmemory/image.png diff --git a/examples/ipc/sharedmemory/main.cpp b/examples/corelib/ipc/sharedmemory/main.cpp similarity index 100% rename from examples/ipc/sharedmemory/main.cpp rename to examples/corelib/ipc/sharedmemory/main.cpp diff --git a/examples/ipc/sharedmemory/qt.png b/examples/corelib/ipc/sharedmemory/qt.png similarity index 100% rename from examples/ipc/sharedmemory/qt.png rename to examples/corelib/ipc/sharedmemory/qt.png diff --git a/examples/ipc/sharedmemory/sharedmemory.pro b/examples/corelib/ipc/sharedmemory/sharedmemory.pro similarity index 73% rename from examples/ipc/sharedmemory/sharedmemory.pro rename to examples/corelib/ipc/sharedmemory/sharedmemory.pro index a392f9542d..c1b634732e 100644 --- a/examples/ipc/sharedmemory/sharedmemory.pro +++ b/examples/corelib/ipc/sharedmemory/sharedmemory.pro @@ -11,5 +11,5 @@ FORMS += dialog.ui EXAMPLE_FILES = *.png # install -target.path = $$[QT_INSTALL_EXAMPLES]/ipc/sharedmemory +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/ipc/sharedmemory INSTALLS += target diff --git a/examples/json/json.pro b/examples/corelib/json/json.pro similarity index 100% rename from examples/json/json.pro rename to examples/corelib/json/json.pro diff --git a/examples/json/savegame/character.cpp b/examples/corelib/json/savegame/character.cpp similarity index 100% rename from examples/json/savegame/character.cpp rename to examples/corelib/json/savegame/character.cpp diff --git a/examples/json/savegame/character.h b/examples/corelib/json/savegame/character.h similarity index 100% rename from examples/json/savegame/character.h rename to examples/corelib/json/savegame/character.h diff --git a/examples/json/savegame/doc/src/savegame.qdoc b/examples/corelib/json/savegame/doc/src/savegame.qdoc similarity index 92% rename from examples/json/savegame/doc/src/savegame.qdoc rename to examples/corelib/json/savegame/doc/src/savegame.qdoc index 872f2faf42..1de12c38b9 100644 --- a/examples/json/savegame/doc/src/savegame.qdoc +++ b/examples/corelib/json/savegame/doc/src/savegame.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example savegame + \example json/savegame \title JSON Save Game Example \brief The JSON Save Game example demonstrates how to save and load a @@ -50,12 +50,12 @@ It provides read() and write() functions to serialise its member variables. - \snippet savegame/character.h 0 + \snippet json/savegame/character.h 0 Of particular interest to us are the read and write function implementations: - \snippet savegame/character.cpp 0 + \snippet json/savegame/character.cpp 0 In the read() function, we assign Character's members values from the QJsonObject argument. You can use either \l QJsonObject::operator[]() or @@ -64,7 +64,7 @@ could check if the keys are valid before attempting to read them with QJsonObject::contains(), but we assume that they are. - \snippet savegame/character.cpp 1 + \snippet json/savegame/character.cpp 1 In the write() function, we do the reverse of the read() function; assign values from the Character object to the JSON object. As with accessing @@ -74,13 +74,13 @@ Next up is the Level class: - \snippet savegame/level.h 0 + \snippet json/savegame/level.h 0 We want to have several levels in our game, each with several NPCs, so we keep a QList of Character objects. We also provide the familiar read() and write() functions. - \snippet savegame/level.cpp 0 + \snippet json/savegame/level.cpp 0 Containers can be written and read to and from JSON using QJsonArray. In our case, we construct a QJsonArray from the value associated with the key @@ -94,7 +94,7 @@ element is used as the key to construct the container when reading it back in. - \snippet savegame/level.cpp 1 + \snippet json/savegame/level.cpp 1 Again, the write() function is similar to the read() function, except reversed. @@ -102,7 +102,7 @@ Having established the Character and Level classes, we can move on to the Game class: - \snippet savegame/game.h 0 + \snippet json/savegame/game.h 0 First of all, we define the \c SaveFormat enum. This will allow us to specify the format in which the game should be saved: \c Json or \c Binary. @@ -112,12 +112,12 @@ The read() and write() functions are used by saveGame() and loadGame(). - \snippet savegame/game.cpp 0 + \snippet json/savegame/game.cpp 0 To setup a new game, we create the player and populate the levels and their NPCs. - \snippet savegame/game.cpp 1 + \snippet json/savegame/game.cpp 1 The first thing we do in the read() function is tell the player to read itself. We then clear the levels list so that calling loadGame() on the same @@ -125,11 +125,11 @@ We then populate the level list by reading each Level from a QJsonArray. - \snippet savegame/game.cpp 2 + \snippet json/savegame/game.cpp 2 We write the game to JSON similarly to how we write Level. - \snippet savegame/game.cpp 3 + \snippet json/savegame/game.cpp 3 When loading a saved game in loadGame(), the first thing we do is open the save file based on which format it was saved to; \c "save.json" for JSON, @@ -144,7 +144,7 @@ After constructing the QJsonDocument, we instruct the Game object to read itself and then return \c true to indicate success. - \snippet savegame/game.cpp 4 + \snippet json/savegame/game.cpp 4 Not surprisingly, saveGame() looks very much like loadGame(). We determine the file extension based on the format, print a warning and return \c false @@ -155,7 +155,7 @@ We are now ready to enter main(): - \snippet savegame/main.cpp 0 + \snippet json/savegame/main.cpp 0 Since we're only interested in demonstrating \e serialization of a game with JSON, our game is not actually playable. Therefore, we only need @@ -163,7 +163,7 @@ the player had a great time and made lots of progress, altering the internal state of our Character, Level and Game objects. - \snippet savegame/main.cpp 1 + \snippet json/savegame/main.cpp 1 When the player has finished, we save their game. For demonstration purposes, we serialize to both JSON and binary. You can examine the contents diff --git a/examples/json/savegame/game.cpp b/examples/corelib/json/savegame/game.cpp similarity index 100% rename from examples/json/savegame/game.cpp rename to examples/corelib/json/savegame/game.cpp diff --git a/examples/json/savegame/game.h b/examples/corelib/json/savegame/game.h similarity index 100% rename from examples/json/savegame/game.h rename to examples/corelib/json/savegame/game.h diff --git a/examples/json/savegame/level.cpp b/examples/corelib/json/savegame/level.cpp similarity index 100% rename from examples/json/savegame/level.cpp rename to examples/corelib/json/savegame/level.cpp diff --git a/examples/json/savegame/level.h b/examples/corelib/json/savegame/level.h similarity index 100% rename from examples/json/savegame/level.h rename to examples/corelib/json/savegame/level.h diff --git a/examples/json/savegame/main.cpp b/examples/corelib/json/savegame/main.cpp similarity index 100% rename from examples/json/savegame/main.cpp rename to examples/corelib/json/savegame/main.cpp diff --git a/examples/json/savegame/savegame.pro b/examples/corelib/json/savegame/savegame.pro similarity index 80% rename from examples/json/savegame/savegame.pro rename to examples/corelib/json/savegame/savegame.pro index fd754ace80..6706444506 100644 --- a/examples/json/savegame/savegame.pro +++ b/examples/corelib/json/savegame/savegame.pro @@ -8,7 +8,7 @@ CONFIG -= app_bundle TEMPLATE = app # install -target.path = $$[QT_INSTALL_EXAMPLES]/json/savegame +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/json/savegame INSTALLS += target SOURCES += main.cpp \ diff --git a/examples/threads/README b/examples/corelib/threads/README similarity index 100% rename from examples/threads/README rename to examples/corelib/threads/README diff --git a/examples/threads/doc/images/mandelbrot-example.png b/examples/corelib/threads/doc/images/mandelbrot-example.png similarity index 100% rename from examples/threads/doc/images/mandelbrot-example.png rename to examples/corelib/threads/doc/images/mandelbrot-example.png diff --git a/examples/threads/doc/images/mandelbrot_scroll1.png b/examples/corelib/threads/doc/images/mandelbrot_scroll1.png similarity index 100% rename from examples/threads/doc/images/mandelbrot_scroll1.png rename to examples/corelib/threads/doc/images/mandelbrot_scroll1.png diff --git a/examples/threads/doc/images/mandelbrot_scroll2.png b/examples/corelib/threads/doc/images/mandelbrot_scroll2.png similarity index 100% rename from examples/threads/doc/images/mandelbrot_scroll2.png rename to examples/corelib/threads/doc/images/mandelbrot_scroll2.png diff --git a/examples/threads/doc/images/mandelbrot_scroll3.png b/examples/corelib/threads/doc/images/mandelbrot_scroll3.png similarity index 100% rename from examples/threads/doc/images/mandelbrot_scroll3.png rename to examples/corelib/threads/doc/images/mandelbrot_scroll3.png diff --git a/examples/threads/doc/images/mandelbrot_zoom1.png b/examples/corelib/threads/doc/images/mandelbrot_zoom1.png similarity index 100% rename from examples/threads/doc/images/mandelbrot_zoom1.png rename to examples/corelib/threads/doc/images/mandelbrot_zoom1.png diff --git a/examples/threads/doc/images/mandelbrot_zoom2.png b/examples/corelib/threads/doc/images/mandelbrot_zoom2.png similarity index 100% rename from examples/threads/doc/images/mandelbrot_zoom2.png rename to examples/corelib/threads/doc/images/mandelbrot_zoom2.png diff --git a/examples/threads/doc/images/mandelbrot_zoom3.png b/examples/corelib/threads/doc/images/mandelbrot_zoom3.png similarity index 100% rename from examples/threads/doc/images/mandelbrot_zoom3.png rename to examples/corelib/threads/doc/images/mandelbrot_zoom3.png diff --git a/examples/threads/doc/images/queuedcustomtype-example.png b/examples/corelib/threads/doc/images/queuedcustomtype-example.png similarity index 100% rename from examples/threads/doc/images/queuedcustomtype-example.png rename to examples/corelib/threads/doc/images/queuedcustomtype-example.png diff --git a/examples/threads/doc/src/mandelbrot.qdoc b/examples/corelib/threads/doc/src/mandelbrot.qdoc similarity index 88% rename from examples/threads/doc/src/mandelbrot.qdoc rename to examples/corelib/threads/doc/src/mandelbrot.qdoc index c1393769f1..75d424e6a4 100644 --- a/examples/threads/doc/src/mandelbrot.qdoc +++ b/examples/corelib/threads/doc/src/mandelbrot.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example mandelbrot + \example threads/mandelbrot \title Mandelbrot Example \ingroup qtconcurrent-mtexamples @@ -101,7 +101,7 @@ We'll start with the definition of the \c RenderThread class: - \snippet mandelbrot/renderthread.h 0 + \snippet threads/mandelbrot/renderthread.h 0 The class inherits QThread so that it gains the ability to run in a separate thread. Apart from the constructor and destructor, \c @@ -117,7 +117,7 @@ \section1 RenderThread Class Implementation - \snippet mandelbrot/renderthread.cpp 0 + \snippet threads/mandelbrot/renderthread.cpp 0 In the constructor, we initialize the \c restart and \c abort variables to \c false. These variables control the flow of the \c @@ -126,7 +126,7 @@ We also initialize the \c colormap array, which contains a series of RGB colors. - \snippet mandelbrot/renderthread.cpp 1 + \snippet threads/mandelbrot/renderthread.cpp 1 The destructor can be called at any point while the thread is active. We set \c abort to \c true to tell \c run() to stop @@ -147,7 +147,7 @@ until \c run() has exited before the base class destructor is invoked. - \snippet mandelbrot/renderthread.cpp 2 + \snippet threads/mandelbrot/renderthread.cpp 2 The \c render() function is called by the \c MandelbrotWidget whenever it needs to generate a new image of the Mandelbrot set. @@ -161,7 +161,7 @@ computation and start again with the new parameters) and wakes up the thread, which might be sleeping. - \snippet mandelbrot/renderthread.cpp 3 + \snippet threads/mandelbrot/renderthread.cpp 3 \c run() is quite a big function, so we'll break it down into parts. @@ -177,10 +177,10 @@ The \c forever keyword is, like \c foreach, a Qt pseudo-keyword. - \snippet mandelbrot/renderthread.cpp 4 - \snippet mandelbrot/renderthread.cpp 5 - \snippet mandelbrot/renderthread.cpp 6 - \snippet mandelbrot/renderthread.cpp 7 + \snippet threads/mandelbrot/renderthread.cpp 4 + \snippet threads/mandelbrot/renderthread.cpp 5 + \snippet threads/mandelbrot/renderthread.cpp 6 + \snippet threads/mandelbrot/renderthread.cpp 7 Then comes the core of the algorithm. Instead of trying to create a perfect Mandelbrot set image, we do multiple passes and @@ -197,15 +197,15 @@ The core algorithm is beyond the scope of this tutorial. - \snippet mandelbrot/renderthread.cpp 8 - \snippet mandelbrot/renderthread.cpp 9 + \snippet threads/mandelbrot/renderthread.cpp 8 + \snippet threads/mandelbrot/renderthread.cpp 9 Once we're done with all the iterations, we call QWaitCondition::wait() to put the thread to sleep by calling, unless \c restart is \c true. There's no use in keeping a worker thread looping indefinitely while there's nothing to do. - \snippet mandelbrot/renderthread.cpp 10 + \snippet threads/mandelbrot/renderthread.cpp 10 The \c rgbFromWaveLength() function is a helper function that converts a wave length to a RGB value compatible with 32-bit @@ -217,7 +217,7 @@ The \c MandelbrotWidget class uses \c RenderThread to draw the Mandelbrot set on screen. Here's the class definition: - \snippet mandelbrot/mandelbrotwidget.h 0 + \snippet threads/mandelbrot/mandelbrotwidget.h 0 The widget reimplements many event handlers from QWidget. In addition, it has an \c updatePixmap() slot that we'll connect to @@ -230,12 +230,12 @@ \section1 MandelbrotWidget Class Implementation - \snippet mandelbrot/mandelbrotwidget.cpp 0 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 0 The implementation starts with a few contants that we'll need later on. - \snippet mandelbrot/mandelbrotwidget.cpp 1 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 1 The interesting part of the constructor is the qRegisterMetaType() and QObject::connect() calls. Let's start @@ -258,19 +258,19 @@ template function qRegisterMetaType() before we can use QImage as parameter in queued connections. - \snippet mandelbrot/mandelbrotwidget.cpp 2 - \snippet mandelbrot/mandelbrotwidget.cpp 3 - \snippet mandelbrot/mandelbrotwidget.cpp 4 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 2 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 3 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 4 In \l{QWidget::paintEvent()}{paintEvent()}, we start by filling the background with black. If we have nothing yet to paint (\c pixmap is null), we print a message on the widget asking the user to be patient and return from the function immediately. - \snippet mandelbrot/mandelbrotwidget.cpp 5 - \snippet mandelbrot/mandelbrotwidget.cpp 6 - \snippet mandelbrot/mandelbrotwidget.cpp 7 - \snippet mandelbrot/mandelbrotwidget.cpp 8 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 5 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 6 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 7 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 8 If the pixmap has the right scale factor, we draw the pixmap directly onto the widget. Otherwise, we scale and translate the \l{Coordinate @@ -280,12 +280,12 @@ QPainter::save() and QPainter::restore() make sure that any painting performed afterwards uses the standard coordinate system. - \snippet mandelbrot/mandelbrotwidget.cpp 9 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 9 At the end of the paint event handler, we draw a text string and a semi-transparent rectangle on top of the fractal. - \snippet mandelbrot/mandelbrotwidget.cpp 10 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 10 Whenever the user resizes the widget, we call \c render() to start generating a new image, with the same \c centerX, \c @@ -295,13 +295,13 @@ called by Qt when the widget is shown the first time to generate the image the very first time. - \snippet mandelbrot/mandelbrotwidget.cpp 11 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 11 The key press event handler provides a few keyboard bindings for the benefit of users who don't have a mouse. The \c zoom() and \c scroll() functions will be covered later. - \snippet mandelbrot/mandelbrotwidget.cpp 12 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 12 The wheel event handler is reimplemented to make the mouse wheel control the zoom level. QWheelEvent::delta() returns the angle of @@ -312,18 +312,18 @@ (i.e., +30 degrees), the zoom factor becomes \c ZoomInFactor to the second power, i.e. 0.8 * 0.8 = 0.64. - \snippet mandelbrot/mandelbrotwidget.cpp 13 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 13 When the user presses the left mouse button, we store the mouse pointer position in \c lastDragPos. - \snippet mandelbrot/mandelbrotwidget.cpp 14 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 14 When the user moves the mouse pointer while the left mouse button is pressed, we adjust \c pixmapOffset to paint the pixmap at a shifted position and call QWidget::update() to force a repaint. - \snippet mandelbrot/mandelbrotwidget.cpp 15 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 15 When the left mouse button is released, we update \c pixmapOffset just like we did on a mouse move and we reset \c lastDragPos to a @@ -332,7 +332,7 @@ because areas revealed when dragging the pixmap are drawn in black.) - \snippet mandelbrot/mandelbrotwidget.cpp 16 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 16 The \c updatePixmap() slot is invoked when the worker thread has finished rendering an image. We start by checking whether a drag @@ -349,14 +349,14 @@ be converted into a pixmap. It's better to do the conversion once and for all here, rather than in \c paintEvent(). - \snippet mandelbrot/mandelbrotwidget.cpp 17 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 17 In \c zoom(), we recompute \c curScale. Then we call QWidget::update() to draw a scaled pixmap, and we ask the worker thread to render a new image corresponding to the new \c curScale value. - \snippet mandelbrot/mandelbrotwidget.cpp 18 + \snippet threads/mandelbrot/mandelbrotwidget.cpp 18 \c scroll() is similar to \c zoom(), except that the affected parameters are \c centerX and \c centerY. @@ -366,5 +366,5 @@ The application's multithreaded nature has no impact on its \c main() function, which is as simple as usual: - \snippet mandelbrot/main.cpp 0 + \snippet threads/mandelbrot/main.cpp 0 */ diff --git a/examples/threads/doc/src/queuedcustomtype.qdoc b/examples/corelib/threads/doc/src/queuedcustomtype.qdoc similarity index 87% rename from examples/threads/doc/src/queuedcustomtype.qdoc rename to examples/corelib/threads/doc/src/queuedcustomtype.qdoc index 40ec2668de..cca68b4513 100644 --- a/examples/threads/doc/src/queuedcustomtype.qdoc +++ b/examples/corelib/threads/doc/src/queuedcustomtype.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example queuedcustomtype + \example threads/queuedcustomtype \title Queued Custom Type Example \brief Demonstrates multi-thread programming using Qt \ingroup qtconcurrent-mtexamples @@ -57,7 +57,7 @@ constructor and destructor in the public section of the class that the meta-object system requires. It describes a colored rectangle. - \snippet queuedcustomtype/block.h custom type definition and meta-type declaration + \snippet threads/queuedcustomtype/block.h custom type definition and meta-type declaration We will still need to register it with the meta-object system at run-time by calling the qRegisterMetaType() template function before @@ -74,7 +74,7 @@ \c Block object. The rest of the class is concerned with managing the user interface and handling images. - \snippet queuedcustomtype/window.h Window class definition + \snippet threads/queuedcustomtype/window.h Window class definition The \c Window class also contains a worker thread, provided by a \c RenderThread object. This will emit signals to send \c Block objects @@ -87,22 +87,22 @@ interface containing a label and two push buttons that are connected to slots in the same class. - \snippet queuedcustomtype/window.cpp Window constructor start - \snippet queuedcustomtype/window.cpp set up widgets and connections - \snippet queuedcustomtype/window.cpp connecting signal with custom type + \snippet threads/queuedcustomtype/window.cpp Window constructor start + \snippet threads/queuedcustomtype/window.cpp set up widgets and connections + \snippet threads/queuedcustomtype/window.cpp connecting signal with custom type In the last of these connections, we connect a signal in the \c RenderThread object to the \c addBlock(Block) slot in the window. \dots - \snippet queuedcustomtype/window.cpp Window constructor finish + \snippet threads/queuedcustomtype/window.cpp Window constructor finish The rest of the constructor simply sets up the layout of the window. The \c addBlock(Block) slot receives blocks from the rendering thread via the signal-slot connection set up in the constructor: - \snippet queuedcustomtype/window.cpp Adding blocks to the display + \snippet threads/queuedcustomtype/window.cpp Adding blocks to the display We simply paint these onto the label as they arrive. @@ -112,7 +112,7 @@ and using the \c sendBlock(Block) signal to send them to other components in the example. - \snippet queuedcustomtype/renderthread.h RenderThread class definition + \snippet threads/queuedcustomtype/renderthread.h RenderThread class definition The constructor and destructor are not quoted here. These take care of setting up the thread's internal state and cleaning up when it is destroyed. @@ -120,13 +120,13 @@ Processing is started with the \c processImage() function, which calls the \c RenderThread class's reimplementation of the QThread::run() function: - \snippet queuedcustomtype/renderthread.cpp processing the image (start) + \snippet threads/queuedcustomtype/renderthread.cpp processing the image (start) Ignoring the details of the way the image is processed, we see that the signal containing a block is emitted in the usual way: \dots - \snippet queuedcustomtype/renderthread.cpp processing the image (finish) + \snippet threads/queuedcustomtype/renderthread.cpp processing the image (finish) Each signal that is emitted will be queued and delivered later to the window's \c addBlock(Block) slot. @@ -137,7 +137,7 @@ \c Block class as a custom type with the meta-object system by calling the qRegisterMetaType() template function: - \snippet queuedcustomtype/main.cpp main function + \snippet threads/queuedcustomtype/main.cpp main function This call is placed here to ensure that the type is registered before any signal-slot connections are made that use it. diff --git a/examples/threads/doc/src/semaphores.qdoc b/examples/corelib/threads/doc/src/semaphores.qdoc similarity index 94% rename from examples/threads/doc/src/semaphores.qdoc rename to examples/corelib/threads/doc/src/semaphores.qdoc index e90045f824..0b1a2e852e 100644 --- a/examples/threads/doc/src/semaphores.qdoc +++ b/examples/corelib/threads/doc/src/semaphores.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example semaphores + \example threads/semaphores \title Semaphores Example \brief Demonstrates multi-thread programming using Qt \ingroup qtconcurrent-mtexamples @@ -61,7 +61,7 @@ Let's start by reviewing the circular buffer and the associated semaphores: - \snippet semaphores/semaphores.cpp 0 + \snippet threads/semaphores/semaphores.cpp 0 \c DataSize is the amout of data that the producer will generate. To keep the example as simple as possible, we make it a constant. @@ -89,8 +89,8 @@ Let's review the code for the \c Producer class: - \snippet semaphores/semaphores.cpp 1 - \snippet semaphores/semaphores.cpp 2 + \snippet threads/semaphores/semaphores.cpp 1 + \snippet threads/semaphores/semaphores.cpp 2 The producer generates \c DataSize bytes of data. Before it writes a byte to the circular buffer, it must acquire a "free" @@ -106,8 +106,8 @@ Let's now turn to the \c Consumer class: - \snippet semaphores/semaphores.cpp 3 - \snippet semaphores/semaphores.cpp 4 + \snippet threads/semaphores/semaphores.cpp 3 + \snippet threads/semaphores/semaphores.cpp 4 The code is very similar to the producer, except that this time we acquire a "used" byte and release a "free" byte, instead of @@ -118,8 +118,8 @@ In \c main(), we create the two threads and call QThread::wait() to ensure that both threads get time to finish before we exit: - \snippet semaphores/semaphores.cpp 5 - \snippet semaphores/semaphores.cpp 6 + \snippet threads/semaphores/semaphores.cpp 5 + \snippet threads/semaphores/semaphores.cpp 6 So what happens when we run the program? Initially, the producer thread is the only one that can do anything; the consumer is diff --git a/examples/threads/doc/src/waitconditions.qdoc b/examples/corelib/threads/doc/src/waitconditions.qdoc similarity index 93% rename from examples/threads/doc/src/waitconditions.qdoc rename to examples/corelib/threads/doc/src/waitconditions.qdoc index 25c9ce88fb..aff6997b55 100644 --- a/examples/threads/doc/src/waitconditions.qdoc +++ b/examples/corelib/threads/doc/src/waitconditions.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example waitconditions + \example threads/waitconditions \title Wait Conditions Example \brief Demonstrates multi-thread programming using Qt \ingroup qtconcurrent-mtexamples @@ -61,7 +61,7 @@ Let's start by reviewing the circular buffer and the associated synchronization tools: - \snippet waitconditions/waitconditions.cpp 0 + \snippet threads/waitconditions/waitconditions.cpp 0 \c DataSize is the amount of data that the producer will generate. To keep the example as simple as possible, we make it a constant. @@ -86,8 +86,8 @@ Let's review the code for the \c Producer class: - \snippet waitconditions/waitconditions.cpp 1 - \snippet waitconditions/waitconditions.cpp 2 + \snippet threads/waitconditions/waitconditions.cpp 1 + \snippet threads/waitconditions/waitconditions.cpp 2 The producer generates \c DataSize bytes of data. Before it writes a byte to the circular buffer, it must first check whether @@ -110,8 +110,8 @@ Let's turn to the \c Consumer class: - \snippet waitconditions/waitconditions.cpp 3 - \snippet waitconditions/waitconditions.cpp 4 + \snippet threads/waitconditions/waitconditions.cpp 3 + \snippet threads/waitconditions/waitconditions.cpp 4 The code is very similar to the producer. Before we read the byte, we check whether the buffer is empty (\c numUsedBytes is 0) @@ -126,8 +126,8 @@ In \c main(), we create the two threads and call QThread::wait() to ensure that both threads get time to finish before we exit: - \snippet waitconditions/waitconditions.cpp 5 - \snippet waitconditions/waitconditions.cpp 6 + \snippet threads/waitconditions/waitconditions.cpp 5 + \snippet threads/waitconditions/waitconditions.cpp 6 So what happens when we run the program? Initially, the producer thread is the only one that can do anything; the consumer is diff --git a/examples/threads/mandelbrot/main.cpp b/examples/corelib/threads/mandelbrot/main.cpp similarity index 100% rename from examples/threads/mandelbrot/main.cpp rename to examples/corelib/threads/mandelbrot/main.cpp diff --git a/examples/threads/mandelbrot/mandelbrot.pro b/examples/corelib/threads/mandelbrot/mandelbrot.pro similarity index 79% rename from examples/threads/mandelbrot/mandelbrot.pro rename to examples/corelib/threads/mandelbrot/mandelbrot.pro index 45f21baf08..5a01a405f2 100644 --- a/examples/threads/mandelbrot/mandelbrot.pro +++ b/examples/corelib/threads/mandelbrot/mandelbrot.pro @@ -9,5 +9,5 @@ SOURCES = main.cpp \ unix:!mac:!vxworks:!integrity:LIBS += -lm # install -target.path = $$[QT_INSTALL_EXAMPLES]/threads/mandelbrot +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/threads/mandelbrot INSTALLS += target diff --git a/examples/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp similarity index 100% rename from examples/threads/mandelbrot/mandelbrotwidget.cpp rename to examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp diff --git a/examples/threads/mandelbrot/mandelbrotwidget.h b/examples/corelib/threads/mandelbrot/mandelbrotwidget.h similarity index 100% rename from examples/threads/mandelbrot/mandelbrotwidget.h rename to examples/corelib/threads/mandelbrot/mandelbrotwidget.h diff --git a/examples/threads/mandelbrot/renderthread.cpp b/examples/corelib/threads/mandelbrot/renderthread.cpp similarity index 100% rename from examples/threads/mandelbrot/renderthread.cpp rename to examples/corelib/threads/mandelbrot/renderthread.cpp diff --git a/examples/threads/mandelbrot/renderthread.h b/examples/corelib/threads/mandelbrot/renderthread.h similarity index 100% rename from examples/threads/mandelbrot/renderthread.h rename to examples/corelib/threads/mandelbrot/renderthread.h diff --git a/examples/threads/queuedcustomtype/block.cpp b/examples/corelib/threads/queuedcustomtype/block.cpp similarity index 100% rename from examples/threads/queuedcustomtype/block.cpp rename to examples/corelib/threads/queuedcustomtype/block.cpp diff --git a/examples/threads/queuedcustomtype/block.h b/examples/corelib/threads/queuedcustomtype/block.h similarity index 100% rename from examples/threads/queuedcustomtype/block.h rename to examples/corelib/threads/queuedcustomtype/block.h diff --git a/examples/threads/queuedcustomtype/main.cpp b/examples/corelib/threads/queuedcustomtype/main.cpp similarity index 100% rename from examples/threads/queuedcustomtype/main.cpp rename to examples/corelib/threads/queuedcustomtype/main.cpp diff --git a/examples/threads/queuedcustomtype/queuedcustomtype.pro b/examples/corelib/threads/queuedcustomtype/queuedcustomtype.pro similarity index 77% rename from examples/threads/queuedcustomtype/queuedcustomtype.pro rename to examples/corelib/threads/queuedcustomtype/queuedcustomtype.pro index 8b18b13ba6..77421eb638 100644 --- a/examples/threads/queuedcustomtype/queuedcustomtype.pro +++ b/examples/corelib/threads/queuedcustomtype/queuedcustomtype.pro @@ -8,7 +8,7 @@ SOURCES = main.cpp \ QT += widgets # install -target.path = $$[QT_INSTALL_EXAMPLES]/threads/mandelbrot +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/threads/mandelbrot INSTALLS += target diff --git a/examples/threads/queuedcustomtype/renderthread.cpp b/examples/corelib/threads/queuedcustomtype/renderthread.cpp similarity index 100% rename from examples/threads/queuedcustomtype/renderthread.cpp rename to examples/corelib/threads/queuedcustomtype/renderthread.cpp diff --git a/examples/threads/queuedcustomtype/renderthread.h b/examples/corelib/threads/queuedcustomtype/renderthread.h similarity index 100% rename from examples/threads/queuedcustomtype/renderthread.h rename to examples/corelib/threads/queuedcustomtype/renderthread.h diff --git a/examples/threads/queuedcustomtype/window.cpp b/examples/corelib/threads/queuedcustomtype/window.cpp similarity index 100% rename from examples/threads/queuedcustomtype/window.cpp rename to examples/corelib/threads/queuedcustomtype/window.cpp diff --git a/examples/threads/queuedcustomtype/window.h b/examples/corelib/threads/queuedcustomtype/window.h similarity index 100% rename from examples/threads/queuedcustomtype/window.h rename to examples/corelib/threads/queuedcustomtype/window.h diff --git a/examples/threads/semaphores/semaphores.cpp b/examples/corelib/threads/semaphores/semaphores.cpp similarity index 100% rename from examples/threads/semaphores/semaphores.cpp rename to examples/corelib/threads/semaphores/semaphores.cpp diff --git a/examples/threads/semaphores/semaphores.pro b/examples/corelib/threads/semaphores/semaphores.pro similarity index 61% rename from examples/threads/semaphores/semaphores.pro rename to examples/corelib/threads/semaphores/semaphores.pro index 7dfe7c3ba0..69154e57eb 100644 --- a/examples/threads/semaphores/semaphores.pro +++ b/examples/corelib/threads/semaphores/semaphores.pro @@ -5,5 +5,5 @@ CONFIG -= app_bundle CONFIG += console # install -target.path = $$[QT_INSTALL_EXAMPLES]/threads/semaphores +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/threads/semaphores INSTALLS += target diff --git a/examples/threads/threads.pro b/examples/corelib/threads/threads.pro similarity index 100% rename from examples/threads/threads.pro rename to examples/corelib/threads/threads.pro diff --git a/examples/threads/waitconditions/waitconditions.cpp b/examples/corelib/threads/waitconditions/waitconditions.cpp similarity index 100% rename from examples/threads/waitconditions/waitconditions.cpp rename to examples/corelib/threads/waitconditions/waitconditions.cpp diff --git a/examples/threads/waitconditions/waitconditions.pro b/examples/corelib/threads/waitconditions/waitconditions.pro similarity index 62% rename from examples/threads/waitconditions/waitconditions.pro rename to examples/corelib/threads/waitconditions/waitconditions.pro index 7f9491a0b1..2dbe7df68a 100644 --- a/examples/threads/waitconditions/waitconditions.pro +++ b/examples/corelib/threads/waitconditions/waitconditions.pro @@ -5,5 +5,5 @@ CONFIG += console SOURCES += waitconditions.cpp # install -target.path = $$[QT_INSTALL_EXAMPLES]/threads/waitconditions +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/threads/waitconditions INSTALLS += target diff --git a/examples/tools/README b/examples/corelib/tools/README similarity index 100% rename from examples/tools/README rename to examples/corelib/tools/README diff --git a/examples/tools/contiguouscache/contiguouscache.pro b/examples/corelib/tools/contiguouscache/contiguouscache.pro similarity index 67% rename from examples/tools/contiguouscache/contiguouscache.pro rename to examples/corelib/tools/contiguouscache/contiguouscache.pro index d384a1845a..fb2267fc64 100644 --- a/examples/tools/contiguouscache/contiguouscache.pro +++ b/examples/corelib/tools/contiguouscache/contiguouscache.pro @@ -5,5 +5,5 @@ SOURCES = randomlistmodel.cpp \ main.cpp # install -target.path = $$[QT_INSTALL_EXAMPLES]/tools/contiguouscache +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/tools/contiguouscache INSTALLS += target diff --git a/examples/tools/contiguouscache/main.cpp b/examples/corelib/tools/contiguouscache/main.cpp similarity index 100% rename from examples/tools/contiguouscache/main.cpp rename to examples/corelib/tools/contiguouscache/main.cpp diff --git a/examples/tools/contiguouscache/randomlistmodel.cpp b/examples/corelib/tools/contiguouscache/randomlistmodel.cpp similarity index 100% rename from examples/tools/contiguouscache/randomlistmodel.cpp rename to examples/corelib/tools/contiguouscache/randomlistmodel.cpp diff --git a/examples/tools/contiguouscache/randomlistmodel.h b/examples/corelib/tools/contiguouscache/randomlistmodel.h similarity index 100% rename from examples/tools/contiguouscache/randomlistmodel.h rename to examples/corelib/tools/contiguouscache/randomlistmodel.h diff --git a/examples/tools/customtype/customtype.pro b/examples/corelib/tools/customtype/customtype.pro similarity index 62% rename from examples/tools/customtype/customtype.pro rename to examples/corelib/tools/customtype/customtype.pro index d05540f403..1bd792db85 100644 --- a/examples/tools/customtype/customtype.pro +++ b/examples/corelib/tools/customtype/customtype.pro @@ -4,5 +4,5 @@ SOURCES = main.cpp \ QT += widgets # install -target.path = $$[QT_INSTALL_EXAMPLES]/tools/customcompleter +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/tools/customcompleter INSTALLS += target diff --git a/examples/tools/customtype/main.cpp b/examples/corelib/tools/customtype/main.cpp similarity index 100% rename from examples/tools/customtype/main.cpp rename to examples/corelib/tools/customtype/main.cpp diff --git a/examples/tools/customtype/message.cpp b/examples/corelib/tools/customtype/message.cpp similarity index 100% rename from examples/tools/customtype/message.cpp rename to examples/corelib/tools/customtype/message.cpp diff --git a/examples/tools/customtype/message.h b/examples/corelib/tools/customtype/message.h similarity index 100% rename from examples/tools/customtype/message.h rename to examples/corelib/tools/customtype/message.h diff --git a/examples/tools/customtypesending/customtypesending.pro b/examples/corelib/tools/customtypesending/customtypesending.pro similarity index 70% rename from examples/tools/customtypesending/customtypesending.pro rename to examples/corelib/tools/customtypesending/customtypesending.pro index faa07bf339..672f6569c2 100644 --- a/examples/tools/customtypesending/customtypesending.pro +++ b/examples/corelib/tools/customtypesending/customtypesending.pro @@ -6,5 +6,5 @@ SOURCES = main.cpp \ QT += widgets # install -target.path = $$[QT_INSTALL_EXAMPLES]/tools/customcompleter +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/tools/customcompleter INSTALLS += target diff --git a/examples/tools/customtypesending/main.cpp b/examples/corelib/tools/customtypesending/main.cpp similarity index 100% rename from examples/tools/customtypesending/main.cpp rename to examples/corelib/tools/customtypesending/main.cpp diff --git a/examples/tools/customtypesending/message.cpp b/examples/corelib/tools/customtypesending/message.cpp similarity index 100% rename from examples/tools/customtypesending/message.cpp rename to examples/corelib/tools/customtypesending/message.cpp diff --git a/examples/tools/customtypesending/message.h b/examples/corelib/tools/customtypesending/message.h similarity index 100% rename from examples/tools/customtypesending/message.h rename to examples/corelib/tools/customtypesending/message.h diff --git a/examples/tools/customtypesending/window.cpp b/examples/corelib/tools/customtypesending/window.cpp similarity index 100% rename from examples/tools/customtypesending/window.cpp rename to examples/corelib/tools/customtypesending/window.cpp diff --git a/examples/tools/customtypesending/window.h b/examples/corelib/tools/customtypesending/window.h similarity index 100% rename from examples/tools/customtypesending/window.h rename to examples/corelib/tools/customtypesending/window.h diff --git a/examples/tools/doc/contiguouscache.qdoc b/examples/corelib/tools/doc/src/contiguouscache.qdoc similarity index 96% rename from examples/tools/doc/contiguouscache.qdoc rename to examples/corelib/tools/doc/src/contiguouscache.qdoc index 2f7ea716e6..e88b2629b8 100644 --- a/examples/tools/doc/contiguouscache.qdoc +++ b/examples/corelib/tools/doc/src/contiguouscache.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example contiguouscache + \example tools/contiguouscache \title Contiguous Cache Example \brief The Contiguous Cache example shows how to use QContiguousCache to manage memory usage for @@ -40,7 +40,7 @@ a view requests an item at row N it is also likely to ask for items at rows near to N. - \snippet contiguouscache/randomlistmodel.cpp 0 + \snippet tools/contiguouscache/randomlistmodel.cpp 0 After getting the row, the class determines if the row is in the bounds of the contiguous cache's current range. It would have been equally valid to @@ -74,7 +74,7 @@ to see how the cache range is kept for a local number of rows when running the example. - \snippet contiguouscache/randomlistmodel.cpp 1 + \snippet tools/contiguouscache/randomlistmodel.cpp 1 It is also worth considering pre-fetching items into the cache outside of the application's paint routine. This can be done either with a separate thread diff --git a/examples/tools/doc/src/customtype.qdoc b/examples/corelib/tools/doc/src/customtype.qdoc similarity index 89% rename from examples/tools/doc/src/customtype.qdoc rename to examples/corelib/tools/doc/src/customtype.qdoc index e016933e04..f03fafec30 100644 --- a/examples/tools/doc/src/customtype.qdoc +++ b/examples/corelib/tools/doc/src/customtype.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example customtype + \example tools/customtype \title Custom Type Example \brief The Custom Type example shows how to integrate a custom type into Qt's @@ -56,7 +56,7 @@ of information (a QString and a QStringList), each of which can be read using trivial getter functions: - \snippet customtype/message.h custom type definition + \snippet tools/customtype/message.h custom type definition The default constructor, copy constructor and destructor are all required, and must be public, if the type is to be integrated into the @@ -67,14 +67,14 @@ To enable the type to be used with QVariant, we declare it using the Q_DECLARE_METATYPE() macro: - \snippet customtype/message.h custom type meta-type declaration + \snippet tools/customtype/message.h custom type meta-type declaration We do not need to write any additional code to accompany this macro. To allow us to see a readable description of each \c Message object when it is sent to the debug output stream, we define a streaming operator: - \snippet customtype/message.h custom type streaming operator + \snippet tools/customtype/message.h custom type streaming operator This facility is useful if you need to insert tracing statements in your code for debugging purposes. @@ -84,11 +84,11 @@ The implementation of the default constructor, copy constructor and destructor are straightforward for the \c Message class: - \snippet customtype/message.cpp Message class implementation + \snippet tools/customtype/message.cpp Message class implementation The streaming operator is implemented in the following way: - \snippet customtype/message.cpp custom type streaming operator + \snippet tools/customtype/message.cpp custom type streaming operator Here, we want to represent each value depending on how many lines are stored in the message body. We stream text to the QDebug object passed to the @@ -99,7 +99,7 @@ We include the code for the getter functions for completeness: - \snippet customtype/message.cpp getter functions + \snippet tools/customtype/message.cpp getter functions With the type fully defined, implemented, and integrated with the meta-object system, we can now use it. @@ -109,13 +109,13 @@ In the example's \c{main()} function, we show how a \c Message object can be printed to the console by sending it to the debug stream: - \snippet customtype/main.cpp printing a custom type + \snippet tools/customtype/main.cpp printing a custom type You can use the type with QVariant in exactly the same way as you would use standard Qt value types. Here's how to store a value using the QVariant::setValue() function: - \snippet customtype/main.cpp storing a custom value + \snippet tools/customtype/main.cpp storing a custom value Alternatively, the QVariant::fromValue() and qVariantSetValue() functions can be used if you are using a compiler without support for member template @@ -124,7 +124,7 @@ The value can be retrieved using the QVariant::value() member template function: - \snippet customtype/main.cpp retrieving a custom value + \snippet tools/customtype/main.cpp retrieving a custom value Alternatively, the qVariantValue() template function can be used if you are using a compiler without support for member template functions. diff --git a/examples/tools/tools.pro b/examples/corelib/tools/tools.pro similarity index 100% rename from examples/tools/tools.pro rename to examples/corelib/tools/tools.pro diff --git a/examples/examples.pro b/examples/examples.pro index 052802b803..bcc13704dc 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -2,18 +2,15 @@ TEMPLATE = subdirs CONFIG += no_docs_target SUBDIRS = \ + corelib \ dbus \ embedded \ gui \ - ipc \ - json \ network \ qpa \ qtconcurrent \ qtestlib \ sql \ - threads \ - tools \ touch \ widgets \ xml diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index 7c879cbbfd..5a14ba9088 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -4,7 +4,7 @@ project = QtCore description = Qt Core Reference Documentation version = $QT_VERSION -examplesinstallpath = core +examplesinstallpath = corelib qhp.projects = QtCore @@ -35,10 +35,7 @@ sourcedirs += .. exampledirs += \ ../ \ snippets \ - ../../../examples/threads/ \ - ../../../examples/tools/ \ - ../../../examples/ipc/ \ - ../../../examples/json/ \ + ../../../examples/corelib \ ../../../examples/network/dnslookup imagedirs += images diff --git a/src/corelib/doc/src/custom-types.qdoc b/src/corelib/doc/src/custom-types.qdoc index bac4a90829..81ce698735 100644 --- a/src/corelib/doc/src/custom-types.qdoc +++ b/src/corelib/doc/src/custom-types.qdoc @@ -61,7 +61,7 @@ The following \c Message class definition includes these members: - \snippet customtype/message.h custom type definition + \snippet tools/customtype/message.h custom type definition The class also provides a constructor for normal use and two public member functions that are used to obtain the private data. @@ -77,7 +77,7 @@ to this class, we invoke the Q_DECLARE_METATYPE() macro on the class in the header file where it is defined: - \snippet customtype/message.h custom type meta-type declaration + \snippet tools/customtype/message.h custom type meta-type declaration This now makes it possible for \c Message values to be stored in QVariant objects and retrieved later. See the \l{Custom Type Example} for code that demonstrates @@ -104,19 +104,19 @@ The \l{Queued Custom Type Example} declares a \c Block class which is registered in the \c{main.cpp} file: - \snippet queuedcustomtype/main.cpp main start + \snippet threads/queuedcustomtype/main.cpp main start \dots - \snippet queuedcustomtype/main.cpp register meta-type for queued communications + \snippet threads/queuedcustomtype/main.cpp register meta-type for queued communications \dots - \snippet queuedcustomtype/main.cpp main finish + \snippet threads/queuedcustomtype/main.cpp main finish This type is later used in a signal-slot connection in the \c{window.cpp} file: - \snippet queuedcustomtype/window.cpp Window constructor start + \snippet threads/queuedcustomtype/window.cpp Window constructor start \dots - \snippet queuedcustomtype/window.cpp connecting signal with custom type + \snippet threads/queuedcustomtype/window.cpp connecting signal with custom type \dots - \snippet queuedcustomtype/window.cpp Window constructor finish + \snippet threads/queuedcustomtype/window.cpp Window constructor finish If a type is used in a queued connection without being registered, a warning will be printed at the console; for example: @@ -131,18 +131,18 @@ It is often quite useful to make a custom type printable for debugging purposes, as in the following code: - \snippet customtype/main.cpp printing a custom type + \snippet tools/customtype/main.cpp printing a custom type This is achieved by creating a streaming operator for the type, which is often defined in the header file for that type: - \snippet customtype/message.h custom type streaming operator + \snippet tools/customtype/message.h custom type streaming operator The implementation for the \c Message type in the \l{Custom Type Example} goes to some effort to make the printable representation as readable as possible: - \snippet customtype/message.cpp custom type streaming operator + \snippet tools/customtype/message.cpp custom type streaming operator The output sent to the debug stream can, of course, be made as simple or as complicated as you like. Note that the value returned by this function is From 3d94a564f4c439ca0d1c2a0af807b9edeeb39299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Mon, 29 Sep 2014 14:16:28 +0200 Subject: [PATCH 058/102] Android: Improve cache logic in findClass() This change adds guards to ensure that we only do a class look-up once when calling QJNIEnvironmentPrivate::findClass(). IF someone calls findClass() with an environment that does not contain a "valid" class loader, we should fallback to loadClass(), but only once. Change-Id: If5fc82956db889f3269bb33c98a16c49cae55def Reviewed-by: Yoann Lopes --- src/corelib/kernel/qjni.cpp | 65 ++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 173127b063..452e3464d6 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -80,38 +80,22 @@ static QString toDotEncodedClassName(const char *className) return QString::fromLatin1(className).replace(QLatin1Char('/'), QLatin1Char('.')); } -static jclass getCachedClass(const QString &classDotEnc) +static jclass getCachedClass(const QString &classDotEnc, bool *isCached = 0) { QHash::iterator it = cachedClasses->find(classDotEnc); + const bool found = (it != cachedClasses->end()); - if (it == cachedClasses->end()) - return 0; + if (isCached != 0) + *isCached = found; - return it.value(); + return found ? it.value() : 0; } -static jclass findClass(const char *className, JNIEnv *env) +static jclass loadClassDotEnc(const QString &classDotEnc, JNIEnv *env) { - const QString &classDotEnc = toDotEncodedClassName(className); - jclass clazz = getCachedClass(classDotEnc); - if (clazz != 0) - return clazz; - - jclass fclazz = env->FindClass(className); - if (!exceptionCheckAndClear(env)) { - clazz = static_cast(env->NewGlobalRef(fclazz)); - env->DeleteLocalRef(fclazz); - } - - cachedClasses->insert(classDotEnc, clazz); - return clazz; -} - -static jclass loadClass(const char *className, JNIEnv *env) -{ - const QString &classDotEnc = toDotEncodedClassName(className); - jclass clazz = getCachedClass(classDotEnc); - if (clazz != 0) + bool isCached = false; + jclass clazz = getCachedClass(classDotEnc, &isCached); + if (clazz != 0 || isCached) return clazz; QJNIObjectPrivate classLoader = QtAndroidPrivate::classLoader(); @@ -130,6 +114,11 @@ static jclass loadClass(const char *className, JNIEnv *env) return clazz; } +inline static jclass loadClass(const char *className, JNIEnv *env) +{ + return loadClassDotEnc(toDotEncodedClassName(className), env); +} + typedef QHash JMethodIDHash; Q_GLOBAL_STATIC(JMethodIDHash, cachedMethodID) @@ -224,12 +213,28 @@ JNIEnv *QJNIEnvironmentPrivate::operator->() jclass QJNIEnvironmentPrivate::findClass(const char *className, JNIEnv *env) { - jclass clazz = 0; - if (env != 0) - clazz = ::findClass(className, env); + const QString &classDotEnc = toDotEncodedClassName(className); + bool isCached = false; + jclass clazz = getCachedClass(classDotEnc, &isCached); - if (clazz == 0) - clazz = loadClass(className, QJNIEnvironmentPrivate()); + const bool found = (clazz != 0) || (clazz == 0 && isCached); + + if (found) + return clazz; + + if (env != 0) { // We got an env. pointer (We expect this to be the right env. and call FindClass()) + jclass fclazz = env->FindClass(className); + if (!exceptionCheckAndClear(env)) { + clazz = static_cast(env->NewGlobalRef(fclazz)); + env->DeleteLocalRef(fclazz); + } + + if (clazz != 0) + cachedClasses->insert(classDotEnc, clazz); + } + + if (clazz == 0) // We didn't get an env. pointer or we got one with the WRONG class loader... + clazz = loadClassDotEnc(classDotEnc, QJNIEnvironmentPrivate()); return clazz; } From 06e706bdbb826b521389409b53079483fda5584a Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 16 Oct 2014 20:25:00 +0200 Subject: [PATCH 059/102] Fix QAbstractListModel's detailed description. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3f3e6b9d4e021620505c03458e78856326dcd859 Reviewed-by: Topi Reiniö --- src/corelib/itemmodels/qabstractitemmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 68ab03976f..74a7ea1988 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3375,7 +3375,7 @@ Qt::ItemFlags QAbstractTableModel::flags(const QModelIndex &index) const QAbstractItemModel, it is not suitable for use with tree views; you will need to subclass QAbstractItemModel if you want to provide a model for that purpose. If you need to use a number of list models to manage data, - it may be more appropriate to subclass QAbstractTableModel class instead. + it may be more appropriate to subclass QAbstractTableModel instead. Simple models can be created by subclassing this class and implementing the minimum number of required functions. For example, we could implement @@ -3399,7 +3399,7 @@ Qt::ItemFlags QAbstractTableModel::flags(const QModelIndex &index) const 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 + setData(), and implement the flags() function so that it returns a value containing \l{Qt::ItemFlags}{Qt::ItemIsEditable}. Note that QAbstractListModel provides a default implementation of From 4de382f4a222e3f589e9fd554610f920c1957d10 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 2 Oct 2014 17:57:42 +0400 Subject: [PATCH 060/102] Make font hinting and antialiasing size dependent when using FontConfig Add the pixel size of the font to the search pattern to get size dependent font settings. This patch allows to take into account KDE settings for font sizes which should be excluded from antialiasing. Change-Id: I8bd8b7b3d585009d0a39db631cd02b7970537f5c Reviewed-by: Allan Sandfeld Jensen --- .../fontdatabases/fontconfig/qfontconfigdatabase.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 1aac0791cd..2b9883eb36 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -845,6 +845,9 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef FcPatternAdd(pattern,FC_INDEX,value,true); } + if (fontDef.pixelSize > 0.1) + FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontDef.pixelSize); + FcResult result; FcConfigSubstitute(0, pattern, FcMatchPattern); From 239b71d07d8a129ed445c7553c738934c7828711 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 17 Oct 2014 16:19:16 +0200 Subject: [PATCH 061/102] Fix use-after-delete bug in tst_QWidget::taskQTBUG_27643_enterEvents() ASAN report: READ of size 8 at 0x606000011990 thread T0 #0 0x505e3b in EnterTestMainDialog::eventFilter(QObject*, QEvent*) tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp:10294 [...] 0x606000011990 is located 48 bytes inside of 56-byte region [0x606000011960,0x606000011998) freed by thread T0 here: #0 0x2b8df3551c79 in operator delete(void*) ../../../../gcc/libsanitizer/asan/asan_new_delete.cc:92 #1 0x418ab5 in EnterTestMainDialog::buttonPressed() tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp:10276 previously allocated by thread T0 here: #0 0x2b8df3551739 in operator new(unsigned long) ../../../../gcc/libsanitizer/asan/asan_new_delete.cc:60 #1 0x4188cf in EnterTestMainDialog::buttonPressed() tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp:10272 EnterTestMainDialog::eventFilter() checks for nullness of 'modal' before accessing it, but buttonPressed() did not reset 'modal' to nullptr after deletion. Change-Id: I65562a29f8264a6996d7d615e06de1d1afb5af53 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 34bb4cfdf6..ec3e8ece6a 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -10274,6 +10274,7 @@ public slots: QTimer::singleShot(100, this, SLOT(doMouseMoves())); modal->exec(); delete modal; + modal = Q_NULLPTR; } void doMouseMoves() From 8dd15fd9554e096a71443d3e370473978ef96e49 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 3 Oct 2014 14:14:09 +0200 Subject: [PATCH 062/102] QMacStyle: Add optional block parameter to drawNSViewInRect() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases we want to do something different than just calling - [NSView drawRect:]. Change-Id: I7db704daa39611f33f270b0192c4301de62ec1bf Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qmacstyle_mac.mm | 7 +++++-- src/widgets/styles/qmacstyle_mac_p_p.h | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 9347a6ea90..6990cb6fe8 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1888,7 +1888,7 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons return bv; } -void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPainter *p) const +void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPainter *p, QCocoaDrawRectBlock drawRectBlock) const { QMacCGContext ctx(p); CGContextSaveGState(ctx); @@ -1901,7 +1901,10 @@ void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPain [backingStoreNSView addSubview:view]; view.frame = rect; - [view drawRect:rect]; + if (drawRectBlock) + drawRectBlock(rect, (CGContextRef)ctx); + else + [view drawRect:rect]; [view removeFromSuperviewWithoutNeedingDisplay]; [NSGraphicsContext restoreGraphicsState]; diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index b6267c43e6..1c5e7b5c45 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -132,6 +132,8 @@ enum QCocoaWidgetKind { typedef QPair QCocoaWidget; +typedef void (^QCocoaDrawRectBlock)(NSRect, CGContextRef); + #define SIZE(large, small, mini) \ (controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini)) @@ -201,7 +203,7 @@ public: NSView *cocoaControl(QCocoaWidget widget, QPoint *offset) const; - void drawNSViewInRect(NSView *view, const QRect &rect, QPainter *p) const; + void drawNSViewInRect(NSView *view, const QRect &rect, QPainter *p, QCocoaDrawRectBlock drawRectBlock = nil) const; void resolveCurrentNSView(QWindow *window); public: From cb2e65eea29ce0928cd1d93c005f015fb8225560 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 15 Oct 2014 17:53:15 +0200 Subject: [PATCH 063/102] QMacStyle: Fix QSlider appearance on Yosemite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First, we adjust the min and max positions, which HITheme has been unable to render properly for years. This involves separating the knob and track rendering. Also, on Yosemite, the tickmarks-less slider shows a blue progress fill in the track, on the knob's left side. Finaly, and this is valid for all versions, the tickmarks are being drawn before the knob (or the whole slider for OS X versions before 10.10) Change-Id: I6fce2e298a80858a18fd9fe1e799b65265a8aefd Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qmacstyle_mac.mm | 148 +++++++++++++++++++++++-- src/widgets/styles/qmacstyle_mac_p_p.h | 4 +- 2 files changed, 142 insertions(+), 10 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 6990cb6fe8..2b2f729972 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1661,10 +1661,34 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti tdi->kind = kThemeSmallSlider; break; } + + bool usePlainKnob = slider->tickPosition == QSlider::NoTicks + || slider->tickPosition == QSlider::TicksBothSides; + tdi->bounds = qt_hirectForQRect(slider->rect); - tdi->min = slider->minimum; - tdi->max = slider->maximum; - tdi->value = slider->sliderPosition; + if (isScrollbar || QSysInfo::MacintoshVersion <= QSysInfo::MV_10_9) { + tdi->min = slider->minimum; + tdi->max = slider->maximum; + tdi->value = slider->sliderPosition; + } else { + // Fix min and max positions. HITheme seems confused when it comes to rendering + // a slider at those positions. We give it a hand by extending and offsetting + // the slider range accordingly. See also comment for CC_Slider in drawComplexControl() + tdi->min = 0; + if (slider->orientation == Qt::Horizontal) + tdi->max = 10 * slider->rect.width(); + else + tdi->max = 10 * slider->rect.height(); + + if (usePlainKnob || slider->orientation == Qt::Horizontal) { + int endsCorrection = usePlainKnob ? 25 : 10; + tdi->value = (tdi->max + 2 * endsCorrection) * (slider->sliderPosition - slider->minimum) + / (slider->maximum - slider->minimum) - endsCorrection; + } else { + tdi->value = (tdi->max + 30) * (slider->sliderPosition - slider->minimum) + / (slider->maximum - slider->minimum) - 20; + } + } tdi->attributes = kThemeTrackShowThumb; if (slider->upsideDown) tdi->attributes |= kThemeTrackRightToLeft; @@ -1681,7 +1705,7 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti // Tiger broke reverse scroll bars so put them back and "fake it" if (isScrollbar && (tdi->attributes & kThemeTrackRightToLeft)) { tdi->attributes &= ~kThemeTrackRightToLeft; - tdi->value = tdi->max - slider->sliderPosition; + tdi->value = tdi->max - tdi->value; } tdi->enableState = (slider->state & QStyle::State_Enabled) ? kThemeTrackActive @@ -1689,7 +1713,7 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti if (!isScrollbar) { if (slider->state & QStyle::QStyle::State_HasFocus) tdi->attributes |= kThemeTrackHasFocus; - if (slider->tickPosition == QSlider::NoTicks || slider->tickPosition == QSlider::TicksBothSides) + if (usePlainKnob) tdi->trackInfo.slider.thumbDir = kThemeThumbPlain; else if (slider->tickPosition == QSlider::TicksAbove) tdi->trackInfo.slider.thumbDir = kThemeThumbUpward; @@ -1815,6 +1839,12 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons bv = [[NSPopUpButton alloc] init]; else if (widget.first == QCocoaComboBox) bv = [[NSComboBox alloc] init]; + else if (widget.first == QCocoaHorizontalSlider) + bv = [[NSSlider alloc] init]; + else if (widget.first == QCocoaVerticalSlider) + // Cocoa sets the orientation from the view's frame + // at construction time, and it cannot be changed later. + bv = [[NSSlider alloc] initWithFrame:NSMakeRect(0, 0, 10, 100)]; else bv = [[NSButton alloc] init]; @@ -5315,6 +5345,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex // because on Tiger I only "fake" the reverse stuff. bool reverseHorizontal = (slider->direction == Qt::RightToLeft && slider->orientation == Qt::Horizontal); + if ((reverseHorizontal && slider->activeSubControls == SC_ScrollBarAddLine) || (!reverseHorizontal @@ -5365,6 +5396,9 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex tdi.attributes |= kThemeTrackHideTrack; } + const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; + const bool isHorizontal = slider->orientation == Qt::Horizontal; + #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (cc == CC_ScrollBar && proxy()->styleHint(SH_ScrollBar_Transient, opt, widget)) { bool wasActive = false; @@ -5449,8 +5483,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } } - const bool isHorizontal = slider->orientation == Qt::Horizontal; - CGContextSaveGState(cg); [NSGraphicsContext saveGraphicsState]; @@ -5535,9 +5567,86 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex { d->stopAnimation(opt->styleObject); - HIThemeDrawTrack(&tdi, tracking ? 0 : &macRect, cg, - kHIThemeOrientationNormal); + if (usingYosemiteOrLater && cc == CC_Slider) { + // Fix min and max positions. (See also getSliderInfo() + // for the slider values adjustments.) + // HITheme seems to have forgotten how to render + // a slide at those positions, leaving a gap between + // the knob and the ends of the track. + // We fix this by rendering the track first, and then + // the knob on top. However, in order to not clip the + // knob, we reduce the the drawing rect for the track. + HIRect bounds = tdi.bounds; + if (isHorizontal) { + tdi.bounds.size.width -= 2; + tdi.bounds.origin.x += 1; + if (tdi.trackInfo.slider.thumbDir == kThemeThumbDownward) + tdi.bounds.origin.y -= 2; + else if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) + tdi.bounds.origin.y += 3; + } else { + tdi.bounds.size.height -= 2; + tdi.bounds.origin.y += 1; + if (tdi.trackInfo.slider.thumbDir == kThemeThumbDownward) // pointing right + tdi.bounds.origin.x -= 4; + else if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) // pointing left + tdi.bounds.origin.x += 2; + } + + // Yosemite demands its blue progress track when no tickmarks are present + if (!(slider->subControls & SC_SliderTickmarks)) { + QCocoaWidgetKind sliderKind = slider->orientation == Qt::Horizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider; + NSSlider *sl = (NSSlider *)d->cocoaControl(QCocoaWidget(sliderKind, QAquaSizeLarge), 0); + sl.minValue = slider->minimum; + sl.maxValue = slider->maximum; + sl.intValue = slider->sliderValue; + sl.enabled = slider->state & QStyle::State_Enabled; + d->drawNSViewInRect(sl, opt->rect, p, ^(NSRect rect, CGContextRef ctx) { + if (slider->upsideDown) { + if (isHorizontal) { + CGContextTranslateCTM(ctx, rect.size.width, 0); + CGContextScaleCTM(ctx, -1, 1); + } + } else if (!isHorizontal) { + CGContextTranslateCTM(ctx, 0, rect.size.height); + CGContextScaleCTM(ctx, 1, -1); + } + [sl.cell drawBarInside:tdi.bounds flipped:NO]; + // No need to restore the CTM later, the context has been saved + // and will be restored at the end of drawNSViewInRect() + }); + tdi.attributes |= kThemeTrackHideTrack; + } else { + tdi.attributes &= ~(kThemeTrackShowThumb | kThemeTrackHasFocus); + HIThemeDrawTrack(&tdi, tracking ? 0 : &macRect, cg, + kHIThemeOrientationNormal); + tdi.attributes |= kThemeTrackHideTrack | kThemeTrackShowThumb; + } + + tdi.bounds = bounds; + } + if (cc == CC_Slider && slider->subControls & SC_SliderTickmarks) { + + HIRect bounds; + if (usingYosemiteOrLater) { + // As part of fixing the min and max positions, + // we need to adjust the tickmarks as well + bounds = tdi.bounds; + if (slider->orientation == Qt::Horizontal) { + tdi.bounds.size.width += 2; + tdi.bounds.origin.x -= 1; + if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) + tdi.bounds.origin.y -= 2; + } else { + tdi.bounds.size.height += 3; + tdi.bounds.origin.y -= 3; + tdi.bounds.origin.y += 1; + if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) // pointing left + tdi.bounds.origin.x -= 2; + } + } + if (qt_mac_is_metal(widget)) { if (tdi.enableState == kThemeTrackInactive) tdi.enableState = kThemeTrackActive; // Looks more Cocoa-like @@ -5559,16 +5668,37 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex cg, kHIThemeOrientationNormal); tdi.trackInfo.slider.thumbDir = kThemeThumbUpward; + if (usingYosemiteOrLater) { + if (slider->orientation == Qt::Vertical) + tdi.bounds.origin.x -= 2; + } HIThemeDrawTrackTickMarks(&tdi, numMarks, cg, kHIThemeOrientationNormal); + // Reset to plain thumb to be drawn further down + tdi.trackInfo.slider.thumbDir = kThemeThumbPlain; } else { HIThemeDrawTrackTickMarks(&tdi, numMarks, cg, kHIThemeOrientationNormal); + } + if (usingYosemiteOrLater) + tdi.bounds = bounds; + } + + if (usingYosemiteOrLater && cc == CC_Slider) { + // Still as part of fixing the min and max positions, + // we also adjust the knob position. We can do this + // because it's rendered separately from the track. + if (slider->orientation == Qt::Vertical) { + if (tdi.trackInfo.slider.thumbDir == kThemeThumbDownward) // pointing right + tdi.bounds.origin.x -= 2; } } + + HIThemeDrawTrack(&tdi, tracking ? 0 : &macRect, cg, + kHIThemeOrientationNormal); } } break; diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 1c5e7b5c45..f36ba2c190 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -127,7 +127,9 @@ enum QCocoaWidgetKind { QCocoaComboBox, // Editable QComboBox QCocoaPopupButton, // Non-editable QComboBox QCocoaPushButton, - QCocoaRadioButton + QCocoaRadioButton, + QCocoaHorizontalSlider, + QCocoaVerticalSlider }; typedef QPair QCocoaWidget; From cd512cbcab25a96519c540de062959961877fbc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 6 Oct 2014 11:04:55 +0200 Subject: [PATCH 064/102] Bump default deployment target to 10.7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 10.6 is no longer supported. Change-Id: I4c799ba2a9622aa1dd8a79ff70608b50b2bbd26a Reviewed-by: Gabriel de Dietrich Reviewed-by: Tor Arne Vestbø --- mkspecs/macx-clang-32/qmake.conf | 2 +- mkspecs/macx-clang/qmake.conf | 2 +- mkspecs/macx-g++-32/qmake.conf | 2 +- mkspecs/macx-g++/qmake.conf | 2 +- mkspecs/macx-g++40/qmake.conf | 2 +- mkspecs/macx-g++42/qmake.conf | 2 +- mkspecs/macx-icc/qmake.conf | 2 +- mkspecs/macx-llvm/qmake.conf | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mkspecs/macx-clang-32/qmake.conf b/mkspecs/macx-clang-32/qmake.conf index e0c4bd57b7..87c601ee74 100644 --- a/mkspecs/macx-clang-32/qmake.conf +++ b/mkspecs/macx-clang-32/qmake.conf @@ -11,7 +11,7 @@ include(../common/gcc-base-mac.conf) include(../common/clang.conf) include(../common/clang-mac.conf) -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 QMAKE_CFLAGS += -arch i386 QMAKE_OBJECTIVE_CFLAGS += -arch i386 diff --git a/mkspecs/macx-clang/qmake.conf b/mkspecs/macx-clang/qmake.conf index f28b728bd9..d14b11179a 100644 --- a/mkspecs/macx-clang/qmake.conf +++ b/mkspecs/macx-clang/qmake.conf @@ -11,6 +11,6 @@ include(../common/gcc-base-mac.conf) include(../common/clang.conf) include(../common/clang-mac.conf) -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 load(qt_config) diff --git a/mkspecs/macx-g++-32/qmake.conf b/mkspecs/macx-g++-32/qmake.conf index 6ef78aacbf..2a8197ebbd 100644 --- a/mkspecs/macx-g++-32/qmake.conf +++ b/mkspecs/macx-g++-32/qmake.conf @@ -14,7 +14,7 @@ include(../common/macx.conf) include(../common/gcc-base-mac.conf) include(../common/g++-macx.conf) -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 QMAKE_CFLAGS += -arch i386 QMAKE_OBJECTIVE_CFLAGS += -arch i386 diff --git a/mkspecs/macx-g++/qmake.conf b/mkspecs/macx-g++/qmake.conf index a6c075a2ce..9c44f278e9 100644 --- a/mkspecs/macx-g++/qmake.conf +++ b/mkspecs/macx-g++/qmake.conf @@ -14,6 +14,6 @@ include(../common/macx.conf) include(../common/gcc-base-mac.conf) include(../common/g++-macx.conf) -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 load(qt_config) diff --git a/mkspecs/macx-g++40/qmake.conf b/mkspecs/macx-g++40/qmake.conf index f40315a602..0f2dd6bb71 100644 --- a/mkspecs/macx-g++40/qmake.conf +++ b/mkspecs/macx-g++40/qmake.conf @@ -14,7 +14,7 @@ include(../common/macx.conf) include(../common/gcc-base-mac.conf) include(../common/g++-macx.conf) -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 QMAKE_CC = gcc-4.0 QMAKE_CXX = g++-4.0 diff --git a/mkspecs/macx-g++42/qmake.conf b/mkspecs/macx-g++42/qmake.conf index 25383e9cb6..e003193e1b 100644 --- a/mkspecs/macx-g++42/qmake.conf +++ b/mkspecs/macx-g++42/qmake.conf @@ -14,7 +14,7 @@ include(../common/macx.conf) include(../common/gcc-base-mac.conf) include(../common/g++-macx.conf) -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 QMAKE_CC = gcc-4.2 QMAKE_CXX = g++-4.2 diff --git a/mkspecs/macx-icc/qmake.conf b/mkspecs/macx-icc/qmake.conf index 521e64e364..a1783c97ad 100644 --- a/mkspecs/macx-icc/qmake.conf +++ b/mkspecs/macx-icc/qmake.conf @@ -85,7 +85,7 @@ QMAKE_CXXFLAGS_PRECOMPILE = -c -pch-create ${QMAKE_PCH_OUTPUT} -include ${QMAKE_ QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 include(../common/macx.conf) diff --git a/mkspecs/macx-llvm/qmake.conf b/mkspecs/macx-llvm/qmake.conf index 7bdef70943..cf4e00cd61 100644 --- a/mkspecs/macx-llvm/qmake.conf +++ b/mkspecs/macx-llvm/qmake.conf @@ -14,7 +14,7 @@ include(../common/macx.conf) include(../common/gcc-base-mac.conf) include(../common/llvm.conf) -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 QMAKE_XCODE_GCC_VERSION = com.apple.compilers.llvmgcc42 From 1cfd45782638b8266d46af289de5abdd0371fc27 Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Mon, 15 Sep 2014 15:25:33 -0700 Subject: [PATCH 065/102] OS X: Emit QClipboard::dataChanged when activating application MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QClipboard documentation states that on OS X it will emit dataChanged() when activating the application, if the system clipboard had changed. It wasn't doing this in Qt5. Task-number: QTBUG-34941 Change-Id: I7f34e757876757691f0a6c94dd2ae76a60146291 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoaclipboard.h | 8 +++++++- src/plugins/platforms/cocoa/qcocoaclipboard.mm | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.h b/src/plugins/platforms/cocoa/qcocoaclipboard.h index 5ebdad79f1..2c34ef9278 100644 --- a/src/plugins/platforms/cocoa/qcocoaclipboard.h +++ b/src/plugins/platforms/cocoa/qcocoaclipboard.h @@ -40,8 +40,10 @@ QT_BEGIN_NAMESPACE -class QCocoaClipboard : public QPlatformClipboard +class QCocoaClipboard : public QObject, public QPlatformClipboard { + Q_OBJECT + public: QCocoaClipboard(); @@ -49,6 +51,10 @@ public: void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard); bool supportsMode(QClipboard::Mode mode) const; bool ownsMode(QClipboard::Mode mode) const; + +private Q_SLOTS: + void handleApplicationStateChanged(Qt::ApplicationState state); + protected: QMacPasteboard *pasteboardForMode(QClipboard::Mode mode) const; diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.mm b/src/plugins/platforms/cocoa/qcocoaclipboard.mm index f6c424d4fd..1a23da8a8e 100644 --- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm +++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm @@ -40,7 +40,6 @@ ****************************************************************************/ #include "qcocoaclipboard.h" -#include "qmacclipboard.h" QT_BEGIN_NAMESPACE @@ -48,7 +47,7 @@ QCocoaClipboard::QCocoaClipboard() :m_clipboard(new QMacPasteboard(kPasteboardClipboard, QMacInternalPasteboardMime::MIME_CLIP)) ,m_find(new QMacPasteboard(kPasteboardFind, QMacInternalPasteboardMime::MIME_CLIP)) { - + connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QCocoaClipboard::handleApplicationStateChanged); } QMimeData *QCocoaClipboard::mimeData(QClipboard::Mode mode) @@ -94,4 +93,17 @@ QMacPasteboard *QCocoaClipboard::pasteboardForMode(QClipboard::Mode mode) const return 0; } +void QCocoaClipboard::handleApplicationStateChanged(Qt::ApplicationState state) +{ + if (state != Qt::ApplicationActive) + return; + + if (m_clipboard->sync()) + emitChanged(QClipboard::Clipboard); + if (m_find->sync()) + emitChanged(QClipboard::FindBuffer); +} + +#include "moc_qcocoaclipboard.cpp" + QT_END_NAMESPACE From fc567acefb9eddb4d52d7cbe6510364fa865f330 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 14 Oct 2014 14:04:59 +0200 Subject: [PATCH 066/102] iOS: ensure edit menu works on iOS6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Method "- (id)targetForAction:(SEL)action withSender:(id)sender" is only available from iOS7. So change implementation to use whats available on iOS 6. Change-Id: I4e21495073364e83ef396dfab47a7ea2a23bbead Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/quiview.mm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 200b07b5fc..81f82ba97d 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -340,11 +340,16 @@ QWindowSystemInterface::flushWindowSystemEvents(); } -- (id)targetForAction:(SEL)action withSender:(id)sender +- (BOOL)canPerformAction:(SEL)action withSender:(id)sender { // Check first if QIOSMenu should handle the action before continuing up the responder chain - id target = [QIOSMenu::menuActionTarget() targetForAction:action withSender:sender]; - return target ? target : [super targetForAction:action withSender:sender]; + return [QIOSMenu::menuActionTarget() targetForAction:action withSender:sender] != 0; +} + +- (id)forwardingTargetForSelector:(SEL)selector +{ + Q_UNUSED(selector) + return QIOSMenu::menuActionTarget(); } @end From 3797ee7747988c721740871f3a601d885d91d881 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 15 Oct 2014 16:02:06 +0200 Subject: [PATCH 067/102] CoreText font database: Use dynamic type on iOS to resolve theme fonts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use Dynamic Type to resolve theme fonts, so that we get the correct font sizes and styling based on user preferences in Settings app. Change-Id: I2222199a5ba21badb2e3696993eee503e720c476 Reviewed-by: Tor Arne Vestbø --- .../mac/qcoretextfontdatabase.mm | 50 +++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 52cb928615..fc289579ea 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -759,6 +759,50 @@ static CTFontUIFontType fontTypeFromTheme(QPlatformTheme::Font f) } } +static CTFontDescriptorRef fontDescriptorFromTheme(QPlatformTheme::Font f) +{ +#ifdef Q_OS_IOS + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) { + // Use Dynamic Type to resolve theme fonts if possible, to get + // correct font sizes and style based on user configuration. + NSString *textStyle = 0; + switch (f) { + case QPlatformTheme::TitleBarFont: + case QPlatformTheme::HeaderViewFont: + textStyle = UIFontTextStyleHeadline; + break; + case QPlatformTheme::MdiSubWindowTitleFont: + textStyle = UIFontTextStyleSubheadline; + break; + case QPlatformTheme::TipLabelFont: + case QPlatformTheme::SmallFont: + textStyle = UIFontTextStyleFootnote; + break; + case QPlatformTheme::MiniFont: + textStyle = UIFontTextStyleCaption2; + break; + case QPlatformTheme::FixedFont: + // Fall back to regular code path, as iOS doesn't provide + // an appropriate text style for this theme font. + break; + default: + textStyle = UIFontTextStyleBody; + break; + } + + if (textStyle) { + UIFontDescriptor *desc = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle]; + return static_cast(CFBridgingRetain(desc)); + } + } +#endif // Q_OS_IOS + + // OSX default case and iOS fallback case + CTFontUIFontType fontType = fontTypeFromTheme(f); + QCFType ctFont = CTFontCreateUIFontForLanguage(fontType, 0.0, NULL); + return CTFontCopyFontDescriptor(ctFont); +} + const QHash &QCoreTextFontDatabase::themeFonts() const { if (m_themeFonts.isEmpty()) { @@ -773,11 +817,7 @@ const QHash &QCoreTextFontDatabase::themeFonts() QFont *QCoreTextFontDatabase::themeFont(QPlatformTheme::Font f) const { - CTFontUIFontType fontType = fontTypeFromTheme(f); - - QCFType ctFont = CTFontCreateUIFontForLanguage(fontType, 0.0, NULL); - CTFontDescriptorRef fontDesc = CTFontCopyFontDescriptor(ctFont); - + CTFontDescriptorRef fontDesc = fontDescriptorFromTheme(f); FontDescription fd; getFontDescription(fontDesc, &fd); m_systemFontDescriptors.insert(fontDesc); From 0ed65a651307007fc0e61ad69b33783ba9c3a736 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 14 Oct 2014 16:26:17 +0200 Subject: [PATCH 068/102] iOS: ignore sender of actions for edit menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reason is that the sender is sometimes 'NULL', so we cannot rely on it. But the current test with our prefix should suffice. Change-Id: Ie58bf062cbade08feda622bda753d63e1d811a8d Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosmenu.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm index c247c16514..005b06547e 100644 --- a/src/plugins/platforms/ios/qiosmenu.mm +++ b/src/plugins/platforms/ios/qiosmenu.mm @@ -88,8 +88,9 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_"; - (id)targetForAction:(SEL)action withSender:(id)sender { + Q_UNUSED(sender); BOOL containsPrefix = ([NSStringFromSelector(action) rangeOfString:kSelectorPrefix].location != NSNotFound); - return (containsPrefix && [sender isKindOfClass:[UIMenuController class]]) ? self : 0; + return containsPrefix ? self : 0; } - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector From e57153b0821acd876f1938a192f21843c3f70679 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 17 Oct 2014 10:59:44 +0200 Subject: [PATCH 069/102] iOS: ensure we have a valid focusObject before sending it IM events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should not really happen, but since we don't store the focus object given to us, we should do a check. A crash was seen from this when running the "Application" example for widgets. Change-Id: I9c4121766d7028a4eceede7d7b15c8c53d34e16e Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index 13e91889a2..ac6e339633 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -322,7 +322,7 @@ bool QIOSInputContext::isInputPanelVisible() const void QIOSInputContext::cursorRectangleChanged() { - if (!m_keyboardListener->m_keyboardVisibleAndDocked) + if (!m_keyboardListener->m_keyboardVisibleAndDocked || !qApp->focusObject()) return; // Check if the cursor has changed position inside the input item. Since From adadb5e870c1b805aa3dabe12ae29005c8f1a406 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 4 Oct 2014 01:21:18 +0200 Subject: [PATCH 070/102] QSizePolicy: remind to mark as Q_PRIMITIVE_TYPE in Qt 6 Change-Id: I1f18b4cd99f37aadf199e70d3acade9c8f5f9799 Reviewed-by: Thiago Macieira --- src/widgets/kernel/qsizepolicy.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 9730ec1206..41adf5c58a 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -150,6 +150,10 @@ private: quint32 data; }; }; +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +// Can't add in Qt 5, as QList would be BiC: +Q_DECLARE_TYPEINFO(QSizePolicy, Q_PRIMITIVE_TYPE); +#endif Q_DECLARE_OPERATORS_FOR_FLAGS(QSizePolicy::ControlTypes) From e8bdc949fc3646ff323a4fb4b83835e089a86b77 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 25 Sep 2014 15:55:35 +0200 Subject: [PATCH 071/102] Add qHash(QSslCertificate) overload qsslsocket_winrt.cpp defined it locally, which runs the risk of clashes with a potential user-defined qHash(QSslCertificate), so make it public. Also, the implementation in qsslsocket_winrt.cpp simply hashed the handle(), which violates the principle that equal instances must hash to the same value. Also, for some platforms, the implementation returns nullptr unconditionally, which, while not violating the above-mentioned principle, will make all users of the hash have worst-case complexity. To calculate a meaningful hash, therefore, the certificate needs to be inspected deeper than just the handle. For OpenSSL, we use X509::sha1_hash, which also X509_cmp uses internally to determine inequality (it checks more stuff, but if X059::sha1_hash is different, X509_cmp() returns non-zero, which is sufficient for the purposes of qHash()). sha1_hash may not be up-to-date, though, so we call X509_cmp to make it valid. Ugh. For WinRT/Qt, we use the DER encoding, as that is the native storage format used in QSslCertificate. This is not equivalent to the implementation used in qsslsocket_winrt.cpp before, but since handle() == handle() => toDer() == toDer(), it should not be a problem. [ChangeLog][QtNetwork][QSslCertificate] Can now be used as a key in QSet/QHash. Change-Id: I10858fe648c70fc9535af6913dd3b7f3b2cf0eba Reviewed-by: Oliver Wolff --- src/network/ssl/qsslcertificate.cpp | 6 ++++++ src/network/ssl/qsslcertificate.h | 6 ++++++ src/network/ssl/qsslcertificate_openssl.cpp | 11 +++++++++++ src/network/ssl/qsslcertificate_qt.cpp | 6 ++++++ src/network/ssl/qsslsocket_winrt.cpp | 5 ----- .../ssl/qsslcertificate/tst_qsslcertificate.cpp | 9 +++++++++ 6 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 8d38a5fd54..13bddcb3ea 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -662,7 +662,13 @@ QByteArray QSslCertificatePrivate::subjectInfoToString(QSslCertificate::SubjectI return str; } +/*! + \fn uint qHash(const QSslCertificate &key, uint seed) + Returns the hash value for the \a key, using \a seed to seed the calculation. + \since 5.4 + \relates QHash +*/ #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, const QSslCertificate &certificate) diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h index d1290b1d42..e34ea97fc4 100644 --- a/src/network/ssl/qsslcertificate.h +++ b/src/network/ssl/qsslcertificate.h @@ -59,6 +59,10 @@ class QSslKey; class QSslCertificateExtension; class QStringList; +class QSslCertificate; +// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) +Q_NETWORK_EXPORT uint qHash(const QSslCertificate &key, uint seed = 0) Q_DECL_NOTHROW; + class QSslCertificatePrivate; class Q_NETWORK_EXPORT QSslCertificate { @@ -145,6 +149,8 @@ private: QExplicitlySharedDataPointer d; friend class QSslCertificatePrivate; friend class QSslSocketBackendPrivate; + + friend Q_NETWORK_EXPORT uint qHash(const QSslCertificate &key, uint seed) Q_DECL_NOTHROW; }; Q_DECLARE_SHARED(QSslCertificate) diff --git a/src/network/ssl/qsslcertificate_openssl.cpp b/src/network/ssl/qsslcertificate_openssl.cpp index 850654835d..1906c72ff8 100644 --- a/src/network/ssl/qsslcertificate_openssl.cpp +++ b/src/network/ssl/qsslcertificate_openssl.cpp @@ -62,6 +62,17 @@ bool QSslCertificate::operator==(const QSslCertificate &other) const return false; } +uint qHash(const QSslCertificate &key, uint seed) Q_DECL_NOTHROW +{ + if (X509 * const x509 = key.d->x509) { + (void)q_X509_cmp(x509, x509); // populate x509->sha1_hash + // (if someone knows a better way...) + return qHashBits(x509->sha1_hash, SHA_DIGEST_LENGTH, seed); + } else { + return seed; + } +} + bool QSslCertificate::isNull() const { return d->null; diff --git a/src/network/ssl/qsslcertificate_qt.cpp b/src/network/ssl/qsslcertificate_qt.cpp index 16df4a8f73..d74042a95f 100644 --- a/src/network/ssl/qsslcertificate_qt.cpp +++ b/src/network/ssl/qsslcertificate_qt.cpp @@ -67,6 +67,12 @@ bool QSslCertificate::operator==(const QSslCertificate &other) const return d->derData == other.d->derData; } +uint qHash(const QSslCertificate &key, uint seed) Q_DECL_NOTHROW +{ + // DER is the native encoding here, so toDer() is just "return d->derData": + return qHash(key.toDer(), seed); +} + bool QSslCertificate::isNull() const { return d->null; diff --git a/src/network/ssl/qsslsocket_winrt.cpp b/src/network/ssl/qsslsocket_winrt.cpp index c9ddd9ec1b..69f8b6d68a 100644 --- a/src/network/ssl/qsslsocket_winrt.cpp +++ b/src/network/ssl/qsslsocket_winrt.cpp @@ -70,11 +70,6 @@ inline uint qHash(const QSslError &error, uint seed) Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(error))) { return (qHash(error.error()) ^ seed); } -// For QSet -inline uint qHash(const QSslCertificate &certificate, uint seed) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(certificate))) -{ return (qHash(certificate.handle()) ^ seed); } - bool QSslSocketPrivate::s_libraryLoaded = true; bool QSslSocketPrivate::s_loadRootCertsOnDemand = true; bool QSslSocketPrivate::s_loadedCiphersAndCerts = false; diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 67cbd5059f..49ff1b48fe 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -70,6 +70,7 @@ public slots: #ifndef QT_NO_SSL private slots: + void hash(); void emptyConstructor(); void constructor_data(); void constructor(); @@ -164,6 +165,14 @@ void tst_QSslCertificate::cleanupTestCase() #ifndef QT_NO_SSL +void tst_QSslCertificate::hash() +{ + // mostly a compile-only test, to check that qHash(QSslCertificate) is found. + QSet certs; + certs << QSslCertificate(); + QCOMPARE(certs.size(), 1); +} + static QByteArray readFile(const QString &absFilePath) { QFile file(absFilePath); From 32dfbd6dbf8393dcd4e4eaa557902108a2714326 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 25 Sep 2014 16:01:09 +0200 Subject: [PATCH 072/102] Add qHash(QSslError) overload qsslsocket_winrt.cpp defined it locally, which runs the risk of clashes with a potential user-defined qHash(QSslError), so make it public. Also included both .error() and .certificate() in the hash, as both of these are used to determine equality (the WinRT version only used .error()). [ChangeLog][QtNetwork][QSslError] Can now be used in QSet/QHash. Change-Id: Ieb7995bed491ff011d4be9dad544248b56fd4f73 Reviewed-by: Oliver Wolff Reviewed-by: Andrew Knight --- src/network/ssl/qsslerror.cpp | 13 +++++++++++++ src/network/ssl/qsslerror.h | 2 ++ src/network/ssl/qsslsocket_winrt.cpp | 5 ----- tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp | 9 +++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp index ff30098347..5004e561a8 100644 --- a/src/network/ssl/qsslerror.cpp +++ b/src/network/ssl/qsslerror.cpp @@ -305,6 +305,19 @@ QSslCertificate QSslError::certificate() const return d->certificate; } +/*! + Returns the hash value for the \a key, using \a seed to seed the calculation. + \since 5.4 + \relates QHash +*/ +uint qHash(const QSslError &key, uint seed) Q_DECL_NOTHROW +{ + // 2x boost::hash_combine inlined: + seed ^= qHash(key.error()) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + seed ^= qHash(key.certificate()) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + return seed; +} + #ifndef QT_NO_DEBUG_STREAM //class QDebug; QDebug operator<<(QDebug debug, const QSslError &error) diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h index d25546b68b..c00532e294 100644 --- a/src/network/ssl/qsslerror.h +++ b/src/network/ssl/qsslerror.h @@ -102,6 +102,8 @@ private: }; Q_DECLARE_SHARED(QSslError) +Q_NETWORK_EXPORT uint qHash(const QSslError &key, uint seed = 0) Q_DECL_NOTHROW; + #ifndef QT_NO_DEBUG_STREAM class QDebug; Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslError &error); diff --git a/src/network/ssl/qsslsocket_winrt.cpp b/src/network/ssl/qsslsocket_winrt.cpp index 69f8b6d68a..da4c72be01 100644 --- a/src/network/ssl/qsslsocket_winrt.cpp +++ b/src/network/ssl/qsslsocket_winrt.cpp @@ -65,11 +65,6 @@ using namespace ABI::Windows::Storage::Streams; QT_BEGIN_NAMESPACE -// For QSet -inline uint qHash(const QSslError &error, uint seed) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(error))) -{ return (qHash(error.error()) ^ seed); } - bool QSslSocketPrivate::s_libraryLoaded = true; bool QSslSocketPrivate::s_loadRootCertsOnDemand = true; bool QSslSocketPrivate::s_loadedCiphersAndCerts = false; diff --git a/tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp b/tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp index 58136f9a68..7fd6dc8233 100644 --- a/tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp +++ b/tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp @@ -64,6 +64,7 @@ public: #ifndef QT_NO_SSL private slots: void constructing(); + void hash(); #endif private: @@ -79,6 +80,14 @@ void tst_QSslError::constructing() QSslError error; } +void tst_QSslError::hash() +{ + // mostly a compile-only test, to check that qHash(QSslError) is found + QSet errors; + errors << QSslError(); + QCOMPARE(errors.size(), 1); +} + #endif // QT_NO_SSL QTEST_MAIN(tst_QSslError) From e5f48c63d2c6f9a6c4f8a21bcf634111e002ae5b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 17 Oct 2014 12:33:06 +0200 Subject: [PATCH 073/102] Widgets: only update IM if the widget is the current focus object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QInputMethod works on focusObject, not focusWidget. These two are not always the same, and sometimes the focusObject is also NULL. In either case, we should not tell QInputMethod to commit, reset or otherwise emit signals based on the internal state of widgets that are not the focus object. This led to a crash on iOS, since we got a call to cursorRectangleChanged when focus object was NULL, which the code didn't (and shouldn't need to) take into account. Change-Id: I54e40d7ec35210ba6599a78c5a8c7f982a1c3dbb Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qwidget.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index de64755e4f..e7d33d3bd8 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9688,7 +9688,8 @@ void QWidget::setInputMethodHints(Qt::InputMethodHints hints) if (d->imHints == hints) return; d->imHints = hints; - qApp->inputMethod()->update(Qt::ImHints); + if (this == qApp->focusObject()) + qApp->inputMethod()->update(Qt::ImHints); #endif //QT_NO_IM } @@ -11031,7 +11032,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) d->createTLSysExtra(); #ifndef QT_NO_IM QWidget *focusWidget = d->effectiveFocusWidget(); - if (on && !internalWinId() && hasFocus() + if (on && !internalWinId() && this == qApp->focusObject() && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) { qApp->inputMethod()->commit(); qApp->inputMethod()->update(Qt::ImEnabled); @@ -11040,7 +11041,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) parentWidget()->d_func()->enforceNativeChildren(); if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) d->createWinId(); - if (isEnabled() && focusWidget->isEnabled() + if (isEnabled() && focusWidget->isEnabled() && this == qApp->focusObject() && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) { qApp->inputMethod()->update(Qt::ImEnabled); } @@ -11566,7 +11567,8 @@ void QWidget::setShortcutAutoRepeat(int id, bool enable) void QWidget::updateMicroFocus() { // updating everything since this is currently called for any kind of state change - qApp->inputMethod()->update(Qt::ImQueryAll); + if (this == qApp->focusObject()) + qApp->inputMethod()->update(Qt::ImQueryAll); } /*! From c5b0308dc562880cdcf55d8f86cad11769e65155 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 16 Oct 2014 11:02:08 +0300 Subject: [PATCH 074/102] Android: Update Ministro's requirements. Task-number: QTBUG-41968 Change-Id: Ia0c204dd87b9de3cbb7bb388099c435b855ad4d5 Reviewed-by: Paul Olav Tvete --- .../java/src/org/qtproject/qt5/android/bindings/QtActivity.java | 2 +- src/android/templates/res/values/libs.xml | 2 +- 2 files changed, 2 insertions(+), 2 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 e526c0a210..0c52bc7530 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 @@ -99,7 +99,7 @@ import android.view.ActionMode.Callback; public class QtActivity extends Activity { private final static int MINISTRO_INSTALL_REQUEST_CODE = 0xf3ee; // request code used to know when Ministro instalation is finished - private static final int MINISTRO_API_LEVEL = 4; // Ministro api level (check IMinistro.aidl file) + private static final int MINISTRO_API_LEVEL = 5; // Ministro api level (check IMinistro.aidl file) private static final int NECESSITAS_API_LEVEL = 2; // Necessitas api level used by platform plugin private static final int QT_VERSION = 0x050100; // This app requires at least Qt version 5.1.0 diff --git a/src/android/templates/res/values/libs.xml b/src/android/templates/res/values/libs.xml index 664ab0abec..4d68673cb0 100644 --- a/src/android/templates/res/values/libs.xml +++ b/src/android/templates/res/values/libs.xml @@ -1,7 +1,7 @@ - https://download.qt-project.org/ministro/android/qt5/qt-5.3 + https://download.qt-project.org/ministro/android/qt5/qt-5.4