From 8dcfb43d8f6bdd9d1331391bb4dfbee73de30658 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 17 Dec 2014 16:05:23 +0100 Subject: [PATCH 001/101] Resolve GLES3 functions from the shared lib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unfortunately the few functions that are part of the OpenGL ES 3.0 standard and are used by QtGui have to have special handling after all. Just directly calling the functions causes issues when building on a GLES3 capable system and deploying somewhere where only GLES2 is available. Using eglGetProcAddress and such is not an option because the ES spec does not guarantee that standard functions are resolvable via that mechanism. Task-number: QTBUG-43318 Change-Id: I72f985d75ca669835839016573cbb8e4a3fb41db Reviewed-by: Jørgen Lind --- src/gui/opengl/qopenglextensions_p.h | 27 ++++++ src/gui/opengl/qopenglfunctions.cpp | 99 +++++++++++++++------ src/gui/opengl/qopengltexturehelper.cpp | 31 ++++--- src/gui/opengl/qopenglvertexarrayobject.cpp | 16 ++-- 4 files changed, 123 insertions(+), 50 deletions(-) diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h index 23cfe164678..f53addaf0e7 100644 --- a/src/gui/opengl/qopenglextensions_p.h +++ b/src/gui/opengl/qopenglextensions_p.h @@ -46,11 +46,36 @@ // #include "qopenglfunctions.h" +#include QT_BEGIN_NAMESPACE class QOpenGLExtensionsPrivate; +class QOpenGLES3Helper +{ +public: + QOpenGLES3Helper(); + + GLvoid* (QOPENGLF_APIENTRYP MapBufferRange)(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr length, GLbitfield access); + GLboolean (QOPENGLF_APIENTRYP UnmapBuffer)(GLenum target); + void (QOPENGLF_APIENTRYP BlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + void (QOPENGLF_APIENTRYP RenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height); + + void (QOPENGLF_APIENTRYP GenVertexArrays)(GLsizei n, GLuint *arrays); + void (QOPENGLF_APIENTRYP DeleteVertexArrays)(GLsizei n, const GLuint *arrays); + void (QOPENGLF_APIENTRYP BindVertexArray)(GLuint array); + GLboolean (QOPENGLF_APIENTRYP IsVertexArray)(GLuint array); + + void (QOPENGLF_APIENTRYP TexImage3D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + void (QOPENGLF_APIENTRYP TexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + void (QOPENGLF_APIENTRYP CompressedTexImage3D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); + void (QOPENGLF_APIENTRYP CompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); + +private: + QLibrary m_gl; +}; + class Q_GUI_EXPORT QOpenGLExtensions : public QOpenGLFunctions { Q_DECLARE_PRIVATE(QOpenGLExtensions) @@ -102,6 +127,8 @@ public: void glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data); + QOpenGLES3Helper *gles3Helper(); + private: static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != 0; } }; diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 44b56699df2..d561e65d8ef 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -3187,65 +3187,105 @@ static void QOPENGLF_APIENTRY qopenglfResolveVertexAttribPointer(GLuint indx, GL #endif // !QT_OPENGL_ES_2 +// Functions part of the OpenGL ES 3.0+ standard need special handling. These, +// just like the 2.0 functions, are not guaranteed to be resolvable via +// eglGetProcAddress or similar. Calling them directly is, unlike the 2.0 +// functions, not feasible because one may build the binaries on a GLES3-capable +// system and then deploy on a GLES2-only system that does not have these +// symbols. Until ES3 gets universally available, they have to be dlsym'ed. + +Q_GLOBAL_STATIC(QOpenGLES3Helper, qgles3Helper) + +QOpenGLES3Helper::QOpenGLES3Helper() +{ +#ifdef Q_OS_WIN +#ifdef QT_DEBUG + m_gl.setFileName(QStringLiteral("libGLESv2")); +#else + m_gl.setFileName(QStringLiteral("libGLESv2d")); +#endif +#else + m_gl.setFileName(QStringLiteral("GLESv2")); +#endif + if (m_gl.load()) { + MapBufferRange = (GLvoid* (QOPENGLF_APIENTRYP)(GLenum, qopengl_GLintptr, qopengl_GLsizeiptr, GLbitfield)) m_gl.resolve("glMapBufferRange"); + UnmapBuffer = (GLboolean (QOPENGLF_APIENTRYP)(GLenum)) m_gl.resolve("glUnmapBuffer"); + BlitFramebuffer = (void (QOPENGLF_APIENTRYP)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum)) m_gl.resolve("glBlitFramebuffer"); + RenderbufferStorageMultisample = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)) m_gl.resolve("glRenderbufferStorageMultisample"); + + GenVertexArrays = (void (QOPENGLF_APIENTRYP)(GLsizei, GLuint *)) m_gl.resolve("glGenVertexArrays"); + DeleteVertexArrays = (void (QOPENGLF_APIENTRYP)(GLsizei, const GLuint *)) m_gl.resolve("glDeleteVertexArrays"); + BindVertexArray = (void (QOPENGLF_APIENTRYP)(GLuint)) m_gl.resolve("glBindVertexArray"); + IsVertexArray = (GLboolean (QOPENGLF_APIENTRYP)(GLuint)) m_gl.resolve("glIsVertexArray"); + + TexImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *)) m_gl.resolve("glTexImage3D"); + TexSubImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) m_gl.resolve("glTexSubImage3D"); + CompressedTexImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)) m_gl.resolve("glCompressedTexImage3D"); + CompressedTexSubImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)) m_gl.resolve("glCompressedTexSubImage3D"); + + if (!MapBufferRange || !GenVertexArrays || !TexImage3D) + qFatal("OpenGL ES 3.0 entry points not found"); + } else { + qFatal("Failed to load libGLESv2"); + } +} + +static inline bool isES3() +{ + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + return ctx->isOpenGLES() && ctx->format().majorVersion() >= 3; +} + static GLvoid *QOPENGLF_APIENTRY qopenglfResolveMapBuffer(GLenum target, GLenum access) { -#ifdef QT_OPENGL_ES_3 // It is possible that GL_OES_map_buffer is present, but then having to // differentiate between glUnmapBufferOES and glUnmapBuffer causes extra // headache. QOpenGLBuffer::map() will handle this automatically, while direct // calls are better off with migrating to the standard glMapBufferRange. - if (QOpenGLContext::currentContext()->format().majorVersion() >= 3) { + if (isES3()) { qWarning("QOpenGLFunctions: glMapBuffer is not available in OpenGL ES 3.0 and up. Use glMapBufferRange instead."); return 0; - } else -#endif - RESOLVE_FUNC(GLvoid *, ResolveOES, MapBuffer)(target, access); + } else { + RESOLVE_FUNC(GLvoid *, ResolveOES, MapBuffer)(target, access); + } } static GLvoid *QOPENGLF_APIENTRY qopenglfResolveMapBufferRange(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr length, GLbitfield access) { -#ifdef QT_OPENGL_ES_3 - if (QOpenGLContext::currentContext()->format().majorVersion() >= 3) - return ::glMapBufferRange(target, offset, length, access); + if (isES3()) + return qgles3Helper()->MapBufferRange(target, offset, length, access); else -#endif - RESOLVE_FUNC(GLvoid *, 0, MapBufferRange)(target, offset, length, access); + RESOLVE_FUNC(GLvoid *, 0, MapBufferRange)(target, offset, length, access); } static GLboolean QOPENGLF_APIENTRY qopenglfResolveUnmapBuffer(GLenum target) { -#ifdef QT_OPENGL_ES_3 - if (QOpenGLContext::currentContext()->format().majorVersion() >= 3) - return ::glUnmapBuffer(target); + if (isES3()) + return qgles3Helper()->UnmapBuffer(target); else -#endif - RESOLVE_FUNC(GLboolean, ResolveOES, UnmapBuffer)(target); + RESOLVE_FUNC(GLboolean, ResolveOES, UnmapBuffer)(target); } static void QOPENGLF_APIENTRY qopenglfResolveBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { -#ifdef QT_OPENGL_ES_3 - if (QOpenGLContext::currentContext()->format().majorVersion() >= 3) - ::glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); + if (isES3()) + qgles3Helper()->BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); else -#endif - RESOLVE_FUNC_VOID(ResolveEXT | ResolveANGLE | ResolveNV, BlitFramebuffer) - (srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); + RESOLVE_FUNC_VOID(ResolveEXT | ResolveANGLE | ResolveNV, BlitFramebuffer) + (srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); } static void QOPENGLF_APIENTRY qopenglfResolveRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height) { -#ifdef QT_OPENGL_ES_3 - if (QOpenGLContext::currentContext()->format().majorVersion() >= 3) - ::glRenderbufferStorageMultisample(target, samples, internalFormat, width, height); + if (isES3()) + qgles3Helper()->RenderbufferStorageMultisample(target, samples, internalFormat, width, height); else -#endif - RESOLVE_FUNC_VOID(ResolveEXT | ResolveANGLE | ResolveNV, RenderbufferStorageMultisample) - (target, samples, internalFormat, width, height); + RESOLVE_FUNC_VOID(ResolveEXT | ResolveANGLE | ResolveNV, RenderbufferStorageMultisample) + (target, samples, internalFormat, width, height); } static void QOPENGLF_APIENTRY qopenglfResolveGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data) @@ -3494,4 +3534,9 @@ QOpenGLExtensionsPrivate::QOpenGLExtensionsPrivate(QOpenGLContext *ctx) GetBufferSubData = qopenglfResolveGetBufferSubData; } +QOpenGLES3Helper *QOpenGLExtensions::gles3Helper() +{ + return qgles3Helper(); +} + QT_END_NAMESPACE diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index 29cecf0ea88..e1e3593f4f5 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -34,6 +34,7 @@ #include "qopengltexturehelper_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -242,21 +243,23 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) CompressedTexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3DOES"))); CompressedTexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3DOES"))); } else { -#ifdef QT_OPENGL_ES_3 - // OpenGL ES 3.0+ has glTexImage3D. - TexImage3D = ::glTexImage3D; - TexSubImage3D = ::glTexSubImage3D; - CompressedTexImage3D = ::glCompressedTexImage3D; - CompressedTexSubImage3D = ::glCompressedTexSubImage3D; -#else - // OpenGL 1.2 - TexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexImage3D"))); - TexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexSubImage3D"))); + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + if (ctx->isOpenGLES() && ctx->format().majorVersion() >= 3) { + // OpenGL ES 3.0+ has glTexImage3D. + QOpenGLES3Helper *es3 = static_cast(ctx->functions())->gles3Helper(); + TexImage3D = es3->TexImage3D; + TexSubImage3D = es3->TexSubImage3D; + CompressedTexImage3D = es3->CompressedTexImage3D; + CompressedTexSubImage3D = es3->CompressedTexSubImage3D; + } else { + // OpenGL 1.2 + TexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexImage3D"))); + TexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glTexSubImage3D"))); - // OpenGL 1.3 - CompressedTexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3D"))); - CompressedTexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3D"))); -#endif + // OpenGL 1.3 + CompressedTexImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3D"))); + CompressedTexSubImage3D = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3D"))); + } } #ifndef QT_OPENGL_ES_2 diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 5520dfed08c..d3eadf9ae12 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -35,12 +35,12 @@ #include #include -#include #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -56,16 +56,14 @@ void qtInitializeVertexArrayObjectHelper(QOpenGLVertexArrayObjectHelper *helper, bool tryARB = true; if (context->isOpenGLES()) { -#ifdef QT_OPENGL_ES_3 if (context->format().majorVersion() >= 3) { - helper->GenVertexArrays = ::glGenVertexArrays; - helper->DeleteVertexArrays = ::glDeleteVertexArrays; - helper->BindVertexArray = ::glBindVertexArray; - helper->IsVertexArray = ::glIsVertexArray; + QOpenGLES3Helper *es3 = static_cast(context->functions())->gles3Helper(); + helper->GenVertexArrays = es3->GenVertexArrays; + helper->DeleteVertexArrays = es3->DeleteVertexArrays; + helper->BindVertexArray = es3->BindVertexArray; + helper->IsVertexArray = es3->IsVertexArray; tryARB = false; - } else -#endif - if (context->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) { + } else if (context->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) { helper->GenVertexArrays = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glGenVertexArraysOES"))); helper->DeleteVertexArrays = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArraysOES"))); helper->BindVertexArray = reinterpret_cast(context->getProcAddress(QByteArrayLiteral("glBindVertexArrayOES"))); From be5cfa960b617fb31a2a1f4ce850c35dcb23fde5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 8 Jan 2015 14:24:34 +0100 Subject: [PATCH 002/101] QMacPasteboardMimeFileUri: Use file paths instead of file references Change-Id: I732d94bc6add2814c8ebd2c7fe80592024dd1b9a Task-number: QTBUG-40449 Reviewed-by: Eike Ziller --- src/platformsupport/clipboard/qmacmime.mm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm index 6fcd19e07bf..44580b017c9 100644 --- a/src/platformsupport/clipboard/qmacmime.mm +++ b/src/platformsupport/clipboard/qmacmime.mm @@ -611,9 +611,21 @@ QVariant QMacPasteboardMimeFileUri::convertToMime(const QString &mime, QList ret; for (int i = 0; i < data.size(); ++i) { - QUrl url = QUrl::fromEncoded(data.at(i)); + const QByteArray &a = data.at(i); + NSString *urlString = [[[NSString alloc] initWithBytesNoCopy:(void *)a.data() length:a.size() + encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease]; + NSURL *nsurl = [NSURL URLWithString:urlString]; + QUrl url; + // OS X 10.10 sends file references instead of file paths + if ([nsurl isFileReferenceURL]) { + url = QUrl::fromNSURL([nsurl filePathURL]); + } else { + url = QUrl::fromNSURL(nsurl); + } + if (url.host().toLower() == QLatin1String("localhost")) url.setHost(QString()); + url.setPath(url.path().normalized(QString::NormalizationForm_C)); ret.append(url); } From ea9a366d3f01262f32134d1e9f7853d17832dbac Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 11 Dec 2014 09:47:43 +0100 Subject: [PATCH 003/101] Swallow wheel events while a popup widget is open. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wheel events should not cause a popup widget parented on a scrollable widget to be closed or moved to correctly reflect the system behavior on OS X and Windows. Task-number: QTBUG-42731 Task-number: QTBUG-40656 Change-Id: I4ef75aa8331390309c251316ac76db2cf9ec51f7 Reviewed-by: Morten Johan Sørvig --- src/widgets/kernel/qapplication.cpp | 8 +++----- .../auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 11 +++++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index b7d0869289d..abd0231b001 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3320,12 +3320,10 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QWidget* w = static_cast(receiver); QWheelEvent* wheel = static_cast(e); - // QTBUG-40656, combo and other popups should close when the main window gets a wheel event. - while (QWidget *popup = QApplication::activePopupWidget()) { + // QTBUG-40656, QTBUG-42731: ignore wheel events when a popup (QComboBox) is open. + if (const QWidget *popup = QApplication::activePopupWidget()) { if (w->window() != popup) - popup->close(); - else - break; + return true; } QPoint relpos = wheel->pos(); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index ac32ee4968c..23d0ffd2d21 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -124,7 +124,7 @@ private slots: void pixmapIcon(); void mouseWheel_data(); void mouseWheel(); - void wheelClosingPopup(); + void popupWheelHandling(); void layoutDirection(); void itemListPosition(); void separatorItem_data(); @@ -2037,9 +2037,9 @@ void tst_QComboBox::mouseWheel() } } -void tst_QComboBox::wheelClosingPopup() +void tst_QComboBox::popupWheelHandling() { - // QTBUG-40656, combo and other popups should close when the main window gets a wheel event. + // QTBUG-40656, QTBUG-42731 combo and other popups should not be affected by wheel events. QScrollArea scrollArea; scrollArea.move(300, 300); QWidget *widget = new QWidget; @@ -2058,9 +2058,12 @@ void tst_QComboBox::wheelClosingPopup() QVERIFY(QTest::qWaitForWindowExposed(&scrollArea)); comboBox->showPopup(); QTRY_VERIFY(comboBox->view() && comboBox->view()->isVisible()); + const QPoint popupPos = comboBox->view()->pos(); QWheelEvent event(QPointF(10, 10), WHEEL_DELTA, Qt::NoButton, Qt::NoModifier); QVERIFY(QCoreApplication::sendEvent(scrollArea.windowHandle(), &event)); - QTRY_VERIFY(!comboBox->view()->isVisible()); + QCoreApplication::processEvents(); + QVERIFY(comboBox->view()->isVisible()); + QCOMPARE(comboBox->view()->pos(), popupPos); } void tst_QComboBox::layoutDirection() From ecd74bcc945b60ac0d21a28c5fd18528f1a19090 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 13 Jan 2015 09:00:44 +0100 Subject: [PATCH 004/101] Bump copyright year to 2015 Bump copyright year in tool output and user visible strings to 2015. Change-Id: I9b29907fe3f555e78005cb296a49d92f601fb7ec Reviewed-by: Lars Knoll Reviewed-by: Martin Smith --- LICENSE.LGPLv21 | 2 +- LICENSE.LGPLv3 | 2 +- doc/global/config.qdocconf | 2 +- doc/global/html-footer-online.qdocconf | 2 +- doc/global/html-footer.qdocconf | 2 +- doc/global/qt-module-defaults-online.qdocconf | 2 +- src/corelib/global/qlibraryinfo.cpp | 4 ++-- src/corelib/kernel/qtcore_eval.cpp | 6 +++--- src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp | 4 ++-- src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp | 4 ++-- src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc | 4 ++-- src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc | 4 ++-- src/tools/qlalr/cppgenerator.cpp | 4 ++-- src/widgets/dialogs/qmessagebox.cpp | 4 ++-- 14 files changed, 23 insertions(+), 23 deletions(-) diff --git a/LICENSE.LGPLv21 b/LICENSE.LGPLv21 index 341aa9eea37..d26836dccc1 100644 --- a/LICENSE.LGPLv21 +++ b/LICENSE.LGPLv21 @@ -1,6 +1,6 @@ GNU LESSER GENERAL PUBLIC LICENSE - The Qt Toolkit is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). + The Qt Toolkit is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). Contact: http://www.qt-project.org/legal You may use, distribute and copy the Qt GUI Toolkit under the terms of diff --git a/LICENSE.LGPLv3 b/LICENSE.LGPLv3 index aed671a0c9a..747fb695c0b 100644 --- a/LICENSE.LGPLv3 +++ b/LICENSE.LGPLv3 @@ -1,6 +1,6 @@ GNU LESSER GENERAL PUBLIC LICENSE - The Qt Toolkit is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). + The Qt Toolkit is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). Contact: http://www.qt-project.org/legal You may use, distribute and copy the Qt GUI Toolkit under the terms of diff --git a/doc/global/config.qdocconf b/doc/global/config.qdocconf index a6ab546b75b..51bd7b4f96d 100644 --- a/doc/global/config.qdocconf +++ b/doc/global/config.qdocconf @@ -3,7 +3,7 @@ dita.metadata.default.author = Qt Project dita.metadata.default.permissions = all dita.metadata.default.publisher = Qt Project -dita.metadata.default.copyryear = 2014 +dita.metadata.default.copyryear = 2015 dita.metadata.default.copyrholder = Digia Plc dita.metadata.default.audience = programmer diff --git a/doc/global/html-footer-online.qdocconf b/doc/global/html-footer-online.qdocconf index 326900160c5..d40e908f819 100644 --- a/doc/global/html-footer-online.qdocconf +++ b/doc/global/html-footer-online.qdocconf @@ -76,7 +76,7 @@ HTML.footer += \ "
\n" \ " \n" \ "
\n" \ "\n" \ diff --git a/doc/global/html-footer.qdocconf b/doc/global/html-footer.qdocconf index a77950ff994..217494575fa 100644 --- a/doc/global/html-footer.qdocconf +++ b/doc/global/html-footer.qdocconf @@ -8,7 +8,7 @@ HTML.footer = \ "\n" \ "
\n" \ "

\n" \ - " © 2014 Digia Plc and/or its\n" \ + " © 2015 Digia Plc and/or its\n" \ " subsidiaries. Documentation contributions included herein are the copyrights of\n" \ " their respective owners.
" \ " The documentation provided herein is licensed under the terms of the" \ diff --git a/doc/global/qt-module-defaults-online.qdocconf b/doc/global/qt-module-defaults-online.qdocconf index fcff1976d11..6e6854ff82b 100644 --- a/doc/global/qt-module-defaults-online.qdocconf +++ b/doc/global/qt-module-defaults-online.qdocconf @@ -5,7 +5,7 @@ HTML.footer = \ "

\n" \ "

\n" \ - " © 2014 Digia Plc and/or its\n" \ + " © 2015 Digia Plc and/or its\n" \ " subsidiaries. Documentation contributions included herein are the copyrights of\n" \ " their respective owners. " \ " The documentation provided herein is licensed under the terms of the" \ diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 7ca0aa7f0bf..2698098be0d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Intel Corporation ** Contact: http://www.qt-project.org/legal ** @@ -605,7 +605,7 @@ extern "C" void qt_core_boilerplate(); void qt_core_boilerplate() { printf("This is the QtCore library version " QT_BUILD_STR "\n" - "Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).\n" + "Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).\n" "Contact: http://www.qt-project.org/legal\n" "\n" "Build date: %s\n" diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp index eb1019534cd..2ee8c20bc3d 100644 --- a/src/corelib/kernel/qtcore_eval.cpp +++ b/src/corelib/kernel/qtcore_eval.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE static const char boilerplate_supported_but_time_limited[] = "\nQt %1 Evaluation License\n" - "Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).\n" + "Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).\n" "This trial version may only be used for evaluation purposes\n" "and will shut down after 120 minutes.\n" "Registered to:\n" @@ -57,7 +57,7 @@ static const char boilerplate_supported_but_time_limited[] = static const char boilerplate_supported[] = "\nQt %1 Evaluation License\n" - "Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).\n" + "Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).\n" "This trial version may only be used for evaluation purposes\n" "Registered to:\n" " Licensee: %2\n\n" diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index dc735df2978..8b13334ca0a 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the tools applications of the Qt Toolkit. @@ -67,7 +67,7 @@ static const char docTypeHeader[] = #define PROGRAMNAME "qdbuscpp2xml" #define PROGRAMVERSION "0.2" -#define PROGRAMCOPYRIGHT "Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies)." +#define PROGRAMCOPYRIGHT "Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies)." static QString outputFile; static int flags; diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index a85dd44f652..5b8de7c2abd 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the tools applications of the Qt Toolkit. @@ -49,7 +49,7 @@ #define PROGRAMNAME "qdbusxml2cpp" #define PROGRAMVERSION "0.8" -#define PROGRAMCOPYRIGHT "Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies)." +#define PROGRAMCOPYRIGHT "Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies)." #define ANNOTATION_NO_WAIT "org.freedesktop.DBus.Method.NoReply" diff --git a/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc b/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc index c04cdeca2b6..7825fc3a914 100644 --- a/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc +++ b/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt Toolkit. @@ -3789,7 +3789,7 @@ Qt Development Frameworks Qt Project - + Qt Project diff --git a/src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc b/src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc index 093f9cc2c6c..cf1f7b2426f 100644 --- a/src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc +++ b/src/tools/qdoc/doc/qdoc-manual-qdocconf.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt Toolkit. @@ -1576,7 +1576,7 @@ dita.metadata.default.author = Qt Development Frameworks dita.metadata.default.permissions = all dita.metadata.default.publisher = Qt Project - dita.metadata.default.copyryear = 2014 + dita.metadata.default.copyryear = 2015 dita.metadata.default.copyrholder = Qt Project dita.metadata.default.audience = programmer \endcode diff --git a/src/tools/qlalr/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp index 05c3c94cc96..6ffe322217a 100644 --- a/src/tools/qlalr/cppgenerator.cpp +++ b/src/tools/qlalr/cppgenerator.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QLALR module of the Qt Toolkit. @@ -47,7 +47,7 @@ QString CppGenerator::copyrightHeader() const return QLatin1String( "/****************************************************************************\n" "**\n" - "** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).\n" + "** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).\n" "** Contact: http://www.qt-project.org/legal\n" "**\n" "** This file is part of the Qt Toolkit.\n" diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index effcef2bc99..391c1d4fb95 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1906,7 +1906,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) "

Qt and the Qt logo are trademarks of Digia Plc and/or its subsidiary(-ies).

" "

Qt is a Digia product developed as an open source project. See %3 " "for more information.

" - ).arg(QStringLiteral("2014"), + ).arg(QStringLiteral("2015"), QStringLiteral("qt.io/licensing"), QStringLiteral("qt.io")); QMessageBox *msgBox = new QMessageBox(parent); From 0fa092cbae1593ca73577ecf9ec71283ae3f2498 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 8 Jan 2015 15:43:29 +0100 Subject: [PATCH 005/101] Windows: Add GPU detection. Compile qwindowsopengltester on all platforms and add struct GpuDescription with detection method based on IDirect3D9 (dynamically loaded). Expose as a QVariantMap-property to QWindowsNativeInterface to be able to access it from qtdiag. Task-number: QTBUG-43263 Change-Id: I3c6cd0bbbe36465e0e05f7064ecfc943d6ea4101 Reviewed-by: Laszlo Agocs --- .../windows/qwindowsnativeinterface.cpp | 8 +- .../windows/qwindowsnativeinterface.h | 5 +- .../windows/qwindowsopengltester.cpp | 142 +++++++++++++++++- .../platforms/windows/qwindowsopengltester.h | 58 ++++++- src/plugins/platforms/windows/windows.pri | 11 +- 5 files changed, 213 insertions(+), 11 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index 002f4ae92cf..12ecc53f922 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -35,6 +35,7 @@ #include "qwindowswindow.h" #include "qwindowscontext.h" #include "qwindowsopenglcontext.h" +#include "qwindowsopengltester.h" #include "qwindowsintegration.h" #include "qwindowsmime.h" @@ -216,4 +217,9 @@ int QWindowsNativeInterface::registerMimeType(const QString &mimeType) return QWindowsMime::registerMimeType(mimeType); } +QVariant QWindowsNativeInterface::gpu() const +{ + return GpuDescription::detect().toVariant(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h index 3d47dbe7217..349ed28b1d4 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.h +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -58,6 +58,7 @@ class QWindowsNativeInterface : public QPlatformNativeInterface { Q_OBJECT Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose) + Q_PROPERTY(QVariant gpu READ gpu STORED false) public: void *nativeResourceForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE; @@ -81,6 +82,8 @@ public: bool asyncExpose() const; void setAsyncExpose(bool value); + QVariant gpu() const; + QVariantMap windowProperties(QPlatformWindow *window) const Q_DECL_OVERRIDE; QVariant windowProperty(QPlatformWindow *window, const QString &name) const Q_DECL_OVERRIDE; QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index ba3a95ce7ab..5ef3dc0855f 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -32,13 +32,148 @@ ****************************************************************************/ #include "qwindowsopengltester.h" -#include "qt_windows.h" #include "qwindowscontext.h" +#include +#include +#include + +#ifndef Q_OS_WINCE +# include +# include +# include +#endif + QT_BEGIN_NAMESPACE +QString GpuDriverVersion::toString() const +{ + return QString::number(product) + + QLatin1Char('.') + QString::number(version) + + QLatin1Char('.') + QString::number(subVersion) + + QLatin1Char('.') + QString::number(build); +} + +int GpuDriverVersion::compare(const GpuDriverVersion &rhs) const +{ + if (product < rhs.product) + return -1; + if (product > rhs.product) + return 1; + if (version < rhs.version) + return -1; + if (version > rhs.version) + return 1; + if (subVersion < rhs.subVersion) + return -1; + if (subVersion > rhs.subVersion) + return 1; + if (build < rhs.build) + return -1; + if (build > rhs.build) + return 1; + return 0; +} + +GpuDescription GpuDescription::detect() +{ +#ifndef Q_OS_WINCE + typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT); + + GpuDescription result; + QSystemLibrary d3d9lib(QStringLiteral("d3d9")); + if (!d3d9lib.load()) + return result; + PtrDirect3DCreate9 direct3DCreate9 = (PtrDirect3DCreate9)d3d9lib.resolve("Direct3DCreate9"); + if (!direct3DCreate9) + return result; + IDirect3D9 *direct3D9 = direct3DCreate9(D3D_SDK_VERSION); + if (!direct3D9) + return result; + D3DADAPTER_IDENTIFIER9 adapterIdentifier; + const HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier); + direct3D9->Release(); + if (SUCCEEDED(hr)) { + result.vendorId = int(adapterIdentifier.VendorId); + result.deviceId = int(adapterIdentifier.DeviceId); + result.revision = int(adapterIdentifier.Revision); + result.subSysId = int(adapterIdentifier.SubSysId); + result.driverVersion.product = HIWORD(adapterIdentifier.DriverVersion.HighPart); + result.driverVersion.version = LOWORD(adapterIdentifier.DriverVersion.HighPart); + result.driverVersion.subVersion = HIWORD(adapterIdentifier.DriverVersion.LowPart); + result.driverVersion.build = LOWORD(adapterIdentifier.DriverVersion.LowPart); + result.driverName = adapterIdentifier.Driver; + result.description = adapterIdentifier.Description; + } + return result; +#else // !Q_OS_WINCE + GpuDescription result; + result.vendorId = result.deviceId = result.revision + = result.driverVersion.product = result.driverVersion.version + = result.driverVersion.build = 1; + result.driverName = result.description = QByteArrayLiteral("Generic"); + return result; +#endif +} + +QDebug operator<<(QDebug d, const GpuDriverVersion &v) +{ + QDebugStateSaver s(d); + d.nospace(); + d << v.product << '.' << v.version << '.' << v.subVersion << '.' << v.build; + return d; +} + +QDebug operator<<(QDebug d, const GpuDescription &gd) +{ + QDebugStateSaver s(d); + d.nospace(); + d << hex << showbase << "GpuDescription(vendorId=" << gd.vendorId + << ", deviceId=" << gd.deviceId << ", subSysId=" << gd.subSysId + << dec << noshowbase << ", revision=" << gd.revision + << ", driver: " << gd.driverName + << ", version=" << gd.driverVersion << ", " << gd.description << ')'; + return d; +} + +// Return printable string formatted like the output of the dxdiag tool. +QString GpuDescription::toString() const +{ + QString result; + QTextStream str(&result); + str << " Card name: " << description + << "\n Driver Name: " << driverName + << "\n Driver Version: " << driverVersion.toString() + << "\n Vendor ID: 0x" << qSetPadChar(QLatin1Char('0')) + << uppercasedigits << hex << qSetFieldWidth(4) << vendorId + << "\n Device ID: 0x" << qSetFieldWidth(4) << deviceId + << "\n SubSys ID: 0x" << qSetFieldWidth(8) << subSysId + << "\n Revision ID: 0x" << qSetFieldWidth(4) << revision + << dec; + return result; +} + +QVariant GpuDescription::toVariant() const +{ + QVariantMap result; + result.insert(QStringLiteral("vendorId"), QVariant(vendorId)); + result.insert(QStringLiteral("deviceId"), QVariant(deviceId)); + result.insert(QStringLiteral("subSysId"),QVariant(subSysId)); + result.insert(QStringLiteral("revision"), QVariant(revision)); + result.insert(QStringLiteral("driver"), QVariant(QLatin1String(driverName))); + result.insert(QStringLiteral("driverProduct"), QVariant(driverVersion.product)); + result.insert(QStringLiteral("driverVersion"), QVariant(driverVersion.version)); + result.insert(QStringLiteral("driverSubVersion"), QVariant(driverVersion.subVersion)); + result.insert(QStringLiteral("driverBuild"), QVariant(driverVersion.build)); + result.insert(QStringLiteral("driverVersionString"), driverVersion.toString()); + result.insert(QStringLiteral("description"), QVariant(QLatin1String(description))); + result.insert(QStringLiteral("printable"), QVariant(toString())); + return result; +} + bool QWindowsOpenGLTester::testDesktopGL() { +#ifndef Q_OS_WINCE HMODULE lib = 0; HWND wnd = 0; HDC dc = 0; @@ -133,6 +268,9 @@ cleanup: // No FreeLibrary. Some implementations, Mesa in particular, deadlock when trying to unload. return result; +#else // !Q_OS_WINCE + return false; +#endif } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h index 40a8e9d3ac1..98b707dcd2c 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.h +++ b/src/plugins/platforms/windows/qwindowsopengltester.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -31,10 +31,64 @@ ** ****************************************************************************/ +#ifndef QWINDOWSOPENGLTESTER_H +#define QWINDOWSOPENGLTESTER_H + #include +#include + QT_BEGIN_NAMESPACE +class QDebug; +class QVariant; + +struct GpuDriverVersion // ### fixme: Use QVersionNumber in Qt 5.5? +{ + GpuDriverVersion(int p = 0, int v = 0, int sv =0, int b = 0) : product(p), version(v), subVersion(sv), build(b) {} + QString toString() const; + int compare(const GpuDriverVersion &rhs) const; + + int product; + int version; + int subVersion; + int build; +}; + +inline bool operator==(const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return !v1.compare(v2); } +inline bool operator!=(const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2); } +inline bool operator< (const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2) < 0; } +inline bool operator<=(const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2) <= 0; } +inline bool operator> (const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2) > 0; } +inline bool operator>=(const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2) >= 0; } + +QDebug operator<<(QDebug d, const GpuDriverVersion &gd); + +struct GpuDescription +{ + GpuDescription() : vendorId(0), deviceId(0), revision(0), subSysId(0) {} + + static GpuDescription detect(); + QString toString() const; + QVariant toVariant() const; + + int vendorId; + int deviceId; + int revision; + int subSysId; + GpuDriverVersion driverVersion; + QByteArray driverName; + QByteArray description; +}; + +QDebug operator<<(QDebug d, const GpuDescription &gd); + class QWindowsOpenGLTester { public: @@ -42,3 +96,5 @@ public: }; QT_END_NAMESPACE + +#endif // QWINDOWSOPENGLTESTER_H diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index 8e5f35d2932..246598677fe 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -40,7 +40,8 @@ SOURCES += \ $$PWD/qwindowsservices.cpp \ $$PWD/qwindowsnativeimage.cpp \ $$PWD/qwindowsnativeinterface.cpp \ - $$PWD/qwindowsscaling.cpp + $$PWD/qwindowsscaling.cpp \ + $$PWD/qwindowsopengltester.cpp HEADERS += \ $$PWD/qwindowswindow.h \ @@ -66,9 +67,8 @@ HEADERS += \ $$PWD/qplatformfunctions_wince.h \ $$PWD/qwindowsnativeimage.h \ $$PWD/qwindowsnativeinterface.h \ - $$PWD/qwindowsscaling.h - -!wince: HEADERS += $$PWD/qwindowsopengltester.h + $$PWD/qwindowsscaling.h \ + $$PWD/qwindowsopengltester.h INCLUDEPATH += $$PWD @@ -84,8 +84,7 @@ contains(QT_CONFIG, opengles2) { # Dynamic GL needs both WGL and EGL contains(QT_CONFIG,dynamicgl) { - SOURCES += $$PWD/qwindowseglcontext.cpp \ - $$PWD/qwindowsopengltester.cpp + SOURCES += $$PWD/qwindowseglcontext.cpp HEADERS += $$PWD/qwindowseglcontext.h } From 97a82f62c46c272fe3ef1cd9d5c2214b6a7626af Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 12 Jan 2015 15:59:36 +0100 Subject: [PATCH 006/101] Windows: Add infrastructure to be able to a GL renderer based on GPU. Introduce flags for the renderer type and move code to qwindowsopengltester. Introduce QWindowsOpenGLTester::supportedGlesRenderers() where type-dependent checking can be added. Change-Id: I4bbffaf861cb0fdbea0919e081e3626fb5a872de Task-number: QTBUG-43263 Reviewed-by: Laszlo Agocs --- .../platforms/windows/qwindowseglcontext.cpp | 19 ++-- .../platforms/windows/qwindowseglcontext.h | 3 +- .../platforms/windows/qwindowsintegration.cpp | 88 +++++++++++-------- .../platforms/windows/qwindowsopenglcontext.h | 3 + .../windows/qwindowsopengltester.cpp | 82 +++++++++++++++++ .../platforms/windows/qwindowsopengltester.h | 21 +++++ 6 files changed, 168 insertions(+), 48 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index c0d0c1f77cc..bde0503ee00 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -340,7 +340,7 @@ QWindowsEGLStaticContext::QWindowsEGLStaticContext(EGLDisplay display, int versi { } -QWindowsEGLStaticContext *QWindowsEGLStaticContext::create() +QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester::Renderers preferredType) { const HDC dc = QWindowsContext::instance()->displayContext(); if (!dc){ @@ -359,27 +359,26 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create() EGLDisplay display = EGL_NO_DISPLAY; #ifdef EGL_ANGLE_platform_angle_opengl - if (libEGL.eglGetPlatformDisplayEXT && qEnvironmentVariableIsSet("QT_ANGLE_PLATFORM")) { + if (libEGL.eglGetPlatformDisplayEXT + && (preferredType & QWindowsOpenGLTester::AngleBackendMask)) { const EGLint anglePlatformAttributes[][5] = { { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_NONE }, { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, EGL_NONE }, { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_PLATFORM_ANGLE_USE_WARP_ANGLE, EGL_TRUE, EGL_NONE } }; const EGLint *attributes = 0; - const QByteArray anglePlatform = qgetenv("QT_ANGLE_PLATFORM"); - if (anglePlatform == "d3d11") + if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11) attributes = anglePlatformAttributes[0]; - else if (anglePlatform == "d3d9") + else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d9) attributes = anglePlatformAttributes[1]; - else if (anglePlatform == "warp") + else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11Warp) attributes = anglePlatformAttributes[2]; - else - qCWarning(lcQpaGl) << "Invalid value set for QT_ANGLE_PLATFORM:" << anglePlatform; - if (attributes) display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes); } -#endif // EGL_ANGLE_platform_angle_opengl +#else // EGL_ANGLE_platform_angle_opengl + Q_UNUSED(preferredType) +#endif if (display == EGL_NO_DISPLAY) display = libEGL.eglGetDisplay((EGLNativeDisplayType)dc); if (!display) { diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h index 63a7c25a6fd..45ccbfb7343 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.h +++ b/src/plugins/platforms/windows/qwindowseglcontext.h @@ -35,6 +35,7 @@ #define QWINDOWSEGLCONTEXT_H #include "qwindowsopenglcontext.h" +#include "qwindowsopengltester.h" #include QT_BEGIN_NAMESPACE @@ -249,7 +250,7 @@ class QWindowsEGLStaticContext : public QWindowsStaticOpenGLContext Q_DISABLE_COPY(QWindowsEGLStaticContext) public: - static QWindowsEGLStaticContext *create(); + static QWindowsEGLStaticContext *create(QWindowsOpenGLTester::Renderers preferredType); ~QWindowsEGLStaticContext(); EGLDisplay display() const { return m_display; } diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 54fb138d851..82686f38ad5 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -328,47 +328,61 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons } #ifndef QT_NO_OPENGL + +QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() +{ +#if defined(QT_OPENGL_DYNAMIC) + QWindowsOpenGLTester::Renderer requestedRenderer = QWindowsOpenGLTester::requestedRenderer(); + switch (requestedRenderer) { + case QWindowsOpenGLTester::DesktopGl: + if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) + return glCtx; + qCWarning(lcQpaGl, "System OpenGL failed. Falling back to Software OpenGL."); + return QOpenGLStaticContext::create(true); + // If ANGLE is requested, use it, don't try anything else. + case QWindowsOpenGLTester::AngleRendererD3d9: + case QWindowsOpenGLTester::AngleRendererD3d11: + case QWindowsOpenGLTester::AngleRendererD3d11Warp: + return QWindowsEGLStaticContext::create(requestedRenderer); + case QWindowsOpenGLTester::Gles: + return QWindowsEGLStaticContext::create(QWindowsOpenGLTester::supportedGlesRenderers()); + case QWindowsOpenGLTester::SoftwareRasterizer: + if (QWindowsStaticOpenGLContext *swCtx = QOpenGLStaticContext::create(true)) + return swCtx; + qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL."); + if (QWindowsOpenGLTester::supportedRenderers() & QWindowsOpenGLTester::DesktopGl) + return QOpenGLStaticContext::create(); + return Q_NULLPTR; + default: + break; + } + + const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(); + if (supportedRenderers & QWindowsOpenGLTester::DesktopGl) { + if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) + return glCtx; + } + if (QWindowsOpenGLTester::Renderers glesRenderers = supportedRenderers & QWindowsOpenGLTester::GlesMask) { + if (QWindowsEGLStaticContext *eglCtx = QWindowsEGLStaticContext::create(glesRenderers)) + return eglCtx; + } + return QOpenGLStaticContext::create(true); +#elif defined(QT_OPENGL_ES_2) + QWindowsOpenGLTester::Renderers glesRenderers = QWindowsOpenGLTester::requestedGlesRenderer(); + if (glesRenderers == QWindowsOpenGLTester::InvalidRenderer) + glesRenderers = QWindowsOpenGLTester::supportedGlesRenderers(); + return QWindowsEGLStaticContext::create(glesRenderers); +#elif !defined(QT_NO_OPENGL) + return QOpenGLStaticContext::create(); +#endif +} + static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0; QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create() { - QWindowsStaticOpenGLContext *ctx = 0; - -#if defined(QT_OPENGL_DYNAMIC) - const QByteArray requested = qgetenv("QT_OPENGL"); // angle, desktop, software - const bool angleRequested = QCoreApplication::testAttribute(Qt::AA_UseOpenGLES) || requested == "angle"; - const bool desktopRequested = QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL) || requested == "desktop"; - const bool softwareRequested = QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL) || requested == "software"; - - // If ANGLE is requested, use it, don't try anything else. - if (angleRequested) { - ctx = QWindowsEGLStaticContext::create(); - } else { - // If opengl32.dll seems to be OpenGL 2.x capable, or desktop OpenGL is requested, use it. - if (!softwareRequested && (desktopRequested || QWindowsOpenGLTester::testDesktopGL())) - ctx = QOpenGLStaticContext::create(); - // If failed and desktop OpenGL is not explicitly requested, try ANGLE. - if (!ctx && !desktopRequested && !softwareRequested) - ctx = QWindowsEGLStaticContext::create(); - // Try software. - if (!ctx) { - ctx = QOpenGLStaticContext::create(true); - // If software was explicitly requested but failed, try the regular one. - if (!ctx && softwareRequested && QWindowsOpenGLTester::testDesktopGL()) { - qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL."); - ctx = QOpenGLStaticContext::create(); - } - } - } -#elif defined(QT_OPENGL_ES_2) - ctx = QWindowsEGLStaticContext::create(); -#elif !defined(QT_NO_OPENGL) - ctx = QOpenGLStaticContext::create(); -#endif - - q_staticOpenGLContext = ctx; - - return ctx; + q_staticOpenGLContext = QWindowsStaticOpenGLContext::doCreate(); + return q_staticOpenGLContext; } bool QWindowsIntegrationPrivate::ensureStaticOpenGLContext() diff --git a/src/plugins/platforms/windows/qwindowsopenglcontext.h b/src/plugins/platforms/windows/qwindowsopenglcontext.h index 2f724f3dd70..550bf00a408 100644 --- a/src/plugins/platforms/windows/qwindowsopenglcontext.h +++ b/src/plugins/platforms/windows/qwindowsopenglcontext.h @@ -58,6 +58,9 @@ public: // reimplement these. virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/) { return 0; } virtual void destroyWindowSurface(void * /*nativeSurface*/) { } + +private: + static QWindowsStaticOpenGLContext *doCreate(); }; class QWindowsOpenGLContext : public QPlatformOpenGLContext diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index 5ef3dc0855f..ac886b6bee3 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #ifndef Q_OS_WINCE # include @@ -171,6 +172,87 @@ QVariant GpuDescription::toVariant() const return result; } +QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedGlesRenderer() +{ +#ifndef Q_OS_WINCE + const char platformVar[] = "QT_ANGLE_PLATFORM"; + if (qEnvironmentVariableIsSet(platformVar)) { + const QByteArray anglePlatform = qgetenv(platformVar); + if (anglePlatform == "d3d11") + return QWindowsOpenGLTester::AngleRendererD3d11; + if (anglePlatform == "d3d9") + return QWindowsOpenGLTester::AngleRendererD3d9; + if (anglePlatform == "warp") + return QWindowsOpenGLTester::AngleRendererD3d11Warp; + qCWarning(lcQpaGl) << "Invalid value set for " << platformVar << ": " << anglePlatform; + } +#endif // !Q_OS_WINCE + return QWindowsOpenGLTester::InvalidRenderer; +} + +QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedRenderer() +{ +#ifndef Q_OS_WINCE + const char openGlVar[] = "QT_OPENGL"; + if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES)) { + const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer(); + return glesRenderer != InvalidRenderer ? glesRenderer : Gles; + } + if (QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL)) + return QWindowsOpenGLTester::DesktopGl; + if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) + return QWindowsOpenGLTester::SoftwareRasterizer; + if (qEnvironmentVariableIsSet(openGlVar)) { + const QByteArray requested = qgetenv(openGlVar); + if (requested == "angle") { + const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer(); + return glesRenderer != InvalidRenderer ? glesRenderer : Gles; + } + if (requested == "desktop") + return QWindowsOpenGLTester::DesktopGl; + if (requested == "software") + return QWindowsOpenGLTester::SoftwareRasterizer; + qCWarning(lcQpaGl) << "Invalid value set for " << openGlVar << ": " << requested; + } +#endif // !Q_OS_WINCE + return QWindowsOpenGLTester::InvalidRenderer; +} + +static inline QWindowsOpenGLTester::Renderers + detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly) +{ + Q_UNUSED(gpu) +#ifndef Q_OS_WINCE + // Add checks for card types with known issues here. + QWindowsOpenGLTester::Renderers result(QWindowsOpenGLTester::AngleRendererD3d11 + | QWindowsOpenGLTester::AngleRendererD3d9 + | QWindowsOpenGLTester::AngleRendererD3d11Warp + | QWindowsOpenGLTester::SoftwareRasterizer); + + if (!glesOnly && QWindowsOpenGLTester::testDesktopGL()) + result |= QWindowsOpenGLTester::DesktopGl; + return result; +#else // !Q_OS_WINCE + return QWindowsOpenGLTester::Gles; +#endif +} + +QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedGlesRenderers() +{ + const GpuDescription gpu = GpuDescription::detect(); + const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, true); + qDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result; + return result; +} + +QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers() +{ + const GpuDescription gpu = GpuDescription::detect(); + const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, false); + qDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result; + return result; +} + bool QWindowsOpenGLTester::testDesktopGL() { #ifndef Q_OS_WINCE diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h index 98b707dcd2c..6238eea4b00 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.h +++ b/src/plugins/platforms/windows/qwindowsopengltester.h @@ -37,6 +37,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -92,9 +93,29 @@ QDebug operator<<(QDebug d, const GpuDescription &gd); class QWindowsOpenGLTester { public: + enum Renderer { + InvalidRenderer = 0x0000, + DesktopGl = 0x0001, + AngleRendererD3d11 = 0x0002, + AngleRendererD3d9 = 0x0004, + AngleRendererD3d11Warp = 0x0008, // "Windows Advanced Rasterization Platform" + AngleBackendMask = AngleRendererD3d11 | AngleRendererD3d9 | AngleRendererD3d11Warp, + Gles = 0x0010, // ANGLE/unspecified or Generic GLES for Windows CE. + GlesMask = Gles | AngleBackendMask, + SoftwareRasterizer = 0x0020 + }; + Q_DECLARE_FLAGS(Renderers, Renderer) + + static Renderer requestedGlesRenderer(); + static Renderer requestedRenderer(); + static Renderers supportedGlesRenderers(); + static Renderers supportedRenderers(); + static bool testDesktopGL(); }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsOpenGLTester::Renderers) + QT_END_NAMESPACE #endif // QWINDOWSOPENGLTESTER_H From 9b35c2cc27741e335a231afd7bc7842602ddc8a2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 14 Jan 2015 12:29:24 +0100 Subject: [PATCH 007/101] Windows: Fix crash when focus window does not have a native window. Check and warn in that case. Change-Id: Ic513334b5aa48e1c7e44685c30da3e9be52c3c52 Task-number: QTBUG-43833 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 94a27d146f4..ad63a57d3e0 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -209,7 +209,7 @@ void QWindowsInputContext::setFocusObject(QObject *object) imeNotifyCancelComposition(m_compositionContext.hwnd); const QWindow *window = QGuiApplication::focusWindow(); - if (object && window) { + if (object && window && window->handle()) { QWindowsWindow *platformWindow = QWindowsWindow::baseWindowOf(window); if (inputMethodAccepted()) { // Re-enable IME by associating default context saved on first disabling. From 5856f6e3057a881747d77e87f8934dd67860bed6 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 13 Jan 2015 12:49:40 +0100 Subject: [PATCH 008/101] Fix regression with frameless dialogs on Windows Task-number: QTBUG-41162 Change-Id: I6d4e6d0e8a262fead30d642d632f6b4021cc20ab Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 6279b6f4af9..b8ad744d051 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -514,8 +514,12 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag if (flags & Qt::WindowSystemMenuHint) style |= WS_SYSMENU; else if (dialog) { - style |= WS_SYSMENU | WS_BORDER; // QTBUG-2027, dialogs without system menu. - exStyle |= WS_EX_DLGMODALFRAME; + // QTBUG-2027, dialogs without system menu. + style |= WS_SYSMENU; + if (!(flags & Qt::FramelessWindowHint)) { + style |= WS_BORDER; + exStyle |= WS_EX_DLGMODALFRAME; + } } if (flags & Qt::WindowMinimizeButtonHint) style |= WS_MINIMIZEBOX; From 6839aead0430a9b07b60fa3a1a7d685fe5d2d1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Fri, 9 Jan 2015 11:53:17 +0100 Subject: [PATCH 009/101] Fix compile error if openssl is built with no-ssl3-method Since openssl 1.0.1k with enabled option no-ssl3-method we need to check for OPENSSL_NO_SSL3_METHOD to use following functions: - SSLv3_method - SSLv3_server_method - SSLv3_client_method Change-Id: Iee83a6f4bacbf5660baa6bdb89eb02ceb9f11614 Reviewed-by: Thiago Macieira --- src/network/ssl/qsslcontext_openssl.cpp | 6 ++++++ src/network/ssl/qsslsocket_openssl_symbols.cpp | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp index 92e726bc01c..18eef2fc60a 100644 --- a/src/network/ssl/qsslcontext_openssl.cpp +++ b/src/network/ssl/qsslcontext_openssl.cpp @@ -138,7 +138,13 @@ init_context: #endif break; case QSsl::SslV3: +#ifndef OPENSSL_NO_SSL3_METHOD sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv3_client_method() : q_SSLv3_server_method()); +#else + // SSL 3 not supported by the system, but chosen deliberately -> error + sslContext->ctx = 0; + unsupportedProtocol = true; +#endif break; case QSsl::SecureProtocols: // SSLv2 and SSLv3 will be disabled by SSL options diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index ea6e84adefa..c1fea930d02 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -270,7 +270,9 @@ DEFINEFUNC(SSL_SESSION*, SSL_get_session, const SSL *ssl, ssl, return 0, return) #ifndef OPENSSL_NO_SSL2 DEFINEFUNC(const SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return) #endif +#ifndef OPENSSL_NO_SSL3_METHOD DEFINEFUNC(const SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return) +#endif DEFINEFUNC(const SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return) DEFINEFUNC(const SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return) #if OPENSSL_VERSION_NUMBER >= 0x10001000L @@ -280,7 +282,9 @@ DEFINEFUNC(const SSL_METHOD *, TLSv1_2_client_method, DUMMYARG, DUMMYARG, return #ifndef OPENSSL_NO_SSL2 DEFINEFUNC(const SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return) #endif +#ifndef OPENSSL_NO_SSL3_METHOD DEFINEFUNC(const SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return) +#endif DEFINEFUNC(const SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return) DEFINEFUNC(const SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return) #if OPENSSL_VERSION_NUMBER >= 0x10001000L @@ -289,11 +293,15 @@ DEFINEFUNC(const SSL_METHOD *, TLSv1_2_server_method, DUMMYARG, DUMMYARG, return #endif #else DEFINEFUNC(SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return) +#ifndef OPENSSL_NO_SSL3_METHOD DEFINEFUNC(SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return) +#endif DEFINEFUNC(SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return) DEFINEFUNC(SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return) DEFINEFUNC(SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return) +#ifndef OPENSSL_NO_SSL3_METHOD DEFINEFUNC(SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return) +#endif DEFINEFUNC(SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return) DEFINEFUNC(SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return) #endif @@ -799,7 +807,9 @@ bool q_resolveOpenSslSymbols() #ifndef OPENSSL_NO_SSL2 RESOLVEFUNC(SSLv2_client_method) #endif +#ifndef OPENSSL_NO_SSL3_METHOD RESOLVEFUNC(SSLv3_client_method) +#endif RESOLVEFUNC(SSLv23_client_method) RESOLVEFUNC(TLSv1_client_method) #if OPENSSL_VERSION_NUMBER >= 0x10001000L @@ -809,7 +819,9 @@ bool q_resolveOpenSslSymbols() #ifndef OPENSSL_NO_SSL2 RESOLVEFUNC(SSLv2_server_method) #endif +#ifndef OPENSSL_NO_SSL3_METHOD RESOLVEFUNC(SSLv3_server_method) +#endif RESOLVEFUNC(SSLv23_server_method) RESOLVEFUNC(TLSv1_server_method) #if OPENSSL_VERSION_NUMBER >= 0x10001000L From 5bb2e84a764f611cf4470f2ddc0bb427c4d110cc Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 16 Jan 2015 10:18:00 +0100 Subject: [PATCH 010/101] Fall back to ANGLE on OpenGL 1.x Apparently on some cards, that only provide OpenGL 1.4, the check for OpenGL 2 specific functions is not sufficient (presumably some old extensions provide the functions and so the test passes, even though it really shouldn't) To avoid crashing the apps later on, we should check the context version and activate the fall back to ANGLE if it's below 2.0. Task-number: QTBUG-43870 Change-Id: Id0e3d8ad1f632334ba03bbb1a4802413f28436dc Reviewed-by: Friedemann Kleint --- .../windows/qwindowsopengltester.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index ac886b6bee3..f6caf8b06e3 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -43,6 +43,7 @@ # include # include # include +# include #endif QT_BEGIN_NAMESPACE @@ -326,6 +327,37 @@ bool QWindowsOpenGLTester::testDesktopGL() goto cleanup; // Now that there is finally a context current, try doing something useful. + + // Check the version. If we got 1.x then it's all hopeless and we can stop right here. + typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name); + GetString_t GetString = reinterpret_cast(::GetProcAddress(lib, "glGetString")); + if (GetString) { + const char *versionStr = (const char *) GetString(GL_VERSION); + if (versionStr) { + const QByteArray version(versionStr); + const int majorDot = version.indexOf('.'); + if (majorDot != -1) { + int minorDot = version.indexOf('.', majorDot + 1); + if (minorDot == -1) + minorDot = version.size(); + const int major = version.mid(0, majorDot).toInt(); + const int minor = version.mid(majorDot + 1, minorDot - majorDot - 1).toInt(); + qCDebug(lcQpaGl, "Basic wglCreateContext gives version %d.%d", major, minor); + // Try to be as lenient as possible. Missing version, bogus values and + // such are all accepted. The driver may still be functional. Only + // check for known-bad cases, like versions "1.4.0 ...". + if (major == 1) { + result = false; + qCDebug(lcQpaGl, "OpenGL version too low"); + } + } + } + } else { + result = false; + qCDebug(lcQpaGl, "OpenGL 1.x entry points not found"); + } + + // Check for a shader-specific function. if (WGL_GetProcAddress("glCreateShader")) { result = true; qCDebug(lcQpaGl, "OpenGL 2.0 entry points available"); From 3c21c4581dbd957d9f660dd52d0298ecef1001cb Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 7 Jan 2015 13:51:38 +0100 Subject: [PATCH 011/101] Fix drag and drop regression Fix regression introduced by e4becdc3d310a0dd1a6d34d0796a52b21dedeb2d Add QPlatformDrag::ownsDragObject() function, QDragManager can use the return value of this function to decide if it should take care of deleting QDrag object or platform plugin will take care of deleting QDrag. XCB platform plugins uses async dnd data delivery mechanism. It allows user to drop something and then continue working with the assurance that the target will get the data regardless of how slow the network connections are, which means that a source window should preserve QDrag data until dnd has finished. Change-Id: I1fbad7380cddec98b756698993dd397409833150 Task-number: QTBUG-43436 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qdnd.cpp | 3 ++- src/gui/kernel/qplatformdrag.cpp | 12 ++++++++++++ src/gui/kernel/qplatformdrag.h | 2 ++ src/plugins/platforms/xcb/qxcbdrag.cpp | 7 +++++++ src/plugins/platforms/xcb/qxcbdrag.h | 12 ++++++------ 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index f515fe18df7..2a6cc4fc994 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -134,7 +134,8 @@ Qt::DropAction QDragManager::drag(QDrag *o) QGuiApplicationPrivate::instance()->notifyDragStarted(o); const Qt::DropAction result = m_platformDrag->drag(m_object); m_object = 0; - o->deleteLater(); + if (!m_platformDrag->ownsDragObject()) + o->deleteLater(); return result; } diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp index 8a5c7264d15..326f092ead8 100644 --- a/src/gui/kernel/qplatformdrag.cpp +++ b/src/gui/kernel/qplatformdrag.cpp @@ -241,6 +241,18 @@ QPixmap QPlatformDrag::defaultPixmap() return *qt_drag_default_pixmap(); } +/*! + \since 5.4 + \brief Returns bool indicating whether QPlatformDrag takes ownership + and therefore responsibility of deleting the QDrag object passed in + from QPlatformDrag::drag. This can be useful on platforms where QDrag + object has to be kept around. + */ +bool QPlatformDrag::ownsDragObject() const +{ + return false; +} + #endif // QT_NO_DRAGANDDROP QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h index 34ad11e45fb..ce7a9aa1f22 100644 --- a/src/gui/kernel/qplatformdrag.h +++ b/src/gui/kernel/qplatformdrag.h @@ -98,6 +98,8 @@ public: static QPixmap defaultPixmap(); + virtual bool ownsDragObject() const; + private: QPlatformDragPrivate *d_ptr; diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 7037e102e2c..ec0399ed5f5 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -999,6 +999,8 @@ void QXcbDrag::handleFinished(const xcb_client_message_event_t *event) if (at != -1) { Transaction t = transactions.takeAt(at); + if (t.drag) + t.drag->deleteLater(); // QDragManager *manager = QDragManager::self(); // Window target = current_target; @@ -1186,6 +1188,11 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) } } +bool QXcbDrag::ownsDragObject() const +{ + return true; +} + QXcbDropData::QXcbDropData(QXcbDrag *d) : QXcbMime(), drag(d) diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index e273492837e..63a344a098b 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -70,12 +70,11 @@ public: virtual QMimeData *platformDropData(); - - void startDrag(); - void cancel(); - void move(const QMouseEvent *me); - void drop(const QMouseEvent *me); - void endDrag(); + void startDrag() Q_DECL_OVERRIDE; + void cancel() Q_DECL_OVERRIDE; + void move(const QMouseEvent *me) Q_DECL_OVERRIDE; + void drop(const QMouseEvent *me) Q_DECL_OVERRIDE; + void endDrag() Q_DECL_OVERRIDE; void handleEnter(QWindow *window, const xcb_client_message_event_t *event); void handlePosition(QWindow *w, const xcb_client_message_event_t *event); @@ -87,6 +86,7 @@ public: void handleFinished(const xcb_client_message_event_t *event); bool dndEnable(QXcbWindow *win, bool on); + bool ownsDragObject() const Q_DECL_OVERRIDE; void updatePixmap(); xcb_timestamp_t targetTime() { return target_time; } From 128cab4635c3ea42af5d3b9952f7b7e1d89284e7 Mon Sep 17 00:00:00 2001 From: Michael Marley Date: Mon, 12 Jan 2015 21:59:43 -0500 Subject: [PATCH 012/101] Set pendingClose to false on init in QSslSocket Fixes an issue where under certain circumstances, QSslSocket could get stuck in a state where it would disconnect immediately after starting encryption. Since it doesn't make any sense for the socket to be initialized to a state where any connection attempt will fail, the pendingClose value should be set to false. Thanks to Martin Sandsmark for his help debugging this issue. Task-number: QTBUG-43793 Change-Id: I7deebacbac588c21439a8e594db4222095cf3f22 Reviewed-by: Richard J. Moore --- src/network/ssl/qsslsocket.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 31c7b3087ea..0f7c376e046 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1982,6 +1982,7 @@ void QSslSocketPrivate::init() connectionEncrypted = false; ignoreAllSslErrors = false; shutdown = false; + pendingClose = false; // we don't want to clear the ignoreErrorsList, so // that it is possible setting it before connecting From 49fd3511f5bcdd61c92894636fcf0b2be23d1264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 13 Jan 2015 10:52:39 +0100 Subject: [PATCH 013/101] Fix memory leak in Qurl::toCFURL() Release the temp CFString. Change-Id: I8a5b8f18a42a4a9b2c6671f0f5b32a3f0b14238d Task-number: QTBUG-43710 Reviewed-by: Thiago Macieira --- src/corelib/io/qurl_mac.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qurl_mac.mm b/src/corelib/io/qurl_mac.mm index c235365ad82..4468bf0f2bd 100644 --- a/src/corelib/io/qurl_mac.mm +++ b/src/corelib/io/qurl_mac.mm @@ -54,7 +54,13 @@ QUrl QUrl::fromCFURL(CFURLRef url) CFURLRef QUrl::toCFURL() const { - return CFURLCreateWithString(0, toString(FullyEncoded).toCFString(), 0); + CFURLRef url = 0; + CFStringRef str = toString(FullyEncoded).toCFString(); + if (str) { + url = CFURLCreateWithString(0, str, 0); + CFRelease(str); + } + return url; } QUrl QUrl::fromNSURL(const NSURL *url) From cd389e4584754554282fbcb1cdc1b174d0f211dc Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 7 Jan 2015 12:50:14 +0100 Subject: [PATCH 014/101] Fix possible divide by zero in QMacStyle [ChangeLog][Widgets][QMacStyle] Fixed a possible divide by zero crash. Task-number: QTBUG-43398 Change-Id: I8b5c6fd87d07eb42ad43e8c2405b7cad19372b86 Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index c166b1b26ed..38c082baf51 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1675,13 +1675,14 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti else tdi->max = 10 * slider->rect.height(); - if (usePlainKnob || slider->orientation == Qt::Horizontal) { + int range = slider->maximum - slider->minimum; + if (range == 0) { + tdi->value = 0; + } else 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; + tdi->value = (tdi->max + 2 * endsCorrection) * (slider->sliderPosition - slider->minimum) / range - endsCorrection; } else { - tdi->value = (tdi->max + 30) * (slider->sliderPosition - slider->minimum) - / (slider->maximum - slider->minimum) - 20; + tdi->value = (tdi->max + 30) * (slider->sliderPosition - slider->minimum) / range - 20; } } tdi->attributes = kThemeTrackShowThumb; From 5ee8ed27e05f17dc7911a5917c012d0a4fa5afcb Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 16 Jan 2015 18:32:41 +0100 Subject: [PATCH 015/101] rcc: fix build failure on Windows XP / MinGW 4.9 The code makes usage of _fileno without including the appropriate header, which is stdio.h according to Microsoft: http://msdn.microsoft.com/en-us/library/zs6wbdhx%28v=vs.120%29.aspx Task-number: QTBUG-43900 Change-Id: Ic9d407c66243d64823353a1c7e79cf0825c735db Reviewed-by: Friedemann Kleint Reviewed-by: Kai Koehne --- src/tools/rcc/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 3c556d76a8a..c2e9b26fb31 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -47,6 +47,7 @@ #ifdef Q_OS_WIN # include # include +# include #endif // Q_OS_WIN QT_BEGIN_NAMESPACE From a8f37e47751d7d29ab63bef55f5849056f826e8b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 15 Jan 2015 17:04:29 +0100 Subject: [PATCH 016/101] Windows: Delay creation of the static OpenGL context. Delay initialization/GL detection until a surface is requested. Remove member variable from window and access static context from QWindowsIntegration only. Task-number: QTBUG-43832 Change-Id: I4b9a324b58af4399df5c314bfb2b952455b1e080 Reviewed-by: Laszlo Agocs --- .../platforms/windows/qwindowsintegration.cpp | 35 +++++++------------ .../platforms/windows/qwindowswindow.cpp | 10 ++++-- .../platforms/windows/qwindowswindow.h | 3 -- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 82686f38ad5..58d675876b3 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -130,7 +130,6 @@ struct QWindowsIntegrationPrivate { explicit QWindowsIntegrationPrivate(const QStringList ¶mList); ~QWindowsIntegrationPrivate(); - bool ensureStaticOpenGLContext(); unsigned m_options; QWindowsContext m_context; @@ -266,7 +265,9 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co case OpenGL: return true; case ThreadedOpenGL: - return d->ensureStaticOpenGLContext() ? d->m_staticOpenGLContext->supportsThreadedOpenGL() : false; + if (const QWindowsStaticOpenGLContext *glContext = QWindowsIntegration::staticOpenGLContext()) + return glContext->supportsThreadedOpenGL(); + return false; #endif // !QT_NO_OPENGL case WindowMasks: return true; @@ -312,11 +313,6 @@ QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const QWindowSystemInterface::handleGeometryChange(window, QWindowsScaling::mapFromNative(obtained.geometry)); } -#ifndef QT_NO_OPENGL - d->ensureStaticOpenGLContext(); - obtained.staticOpenGLContext = d->m_staticOpenGLContext; -#endif // QT_NO_OPENGL - return obtained; } @@ -377,26 +373,16 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() #endif } -static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0; - QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create() { - q_staticOpenGLContext = QWindowsStaticOpenGLContext::doCreate(); - return q_staticOpenGLContext; -} - -bool QWindowsIntegrationPrivate::ensureStaticOpenGLContext() -{ - if (m_staticOpenGLContext.isNull()) - m_staticOpenGLContext = QSharedPointer(QWindowsStaticOpenGLContext::create()); - return !m_staticOpenGLContext.isNull(); + return QWindowsStaticOpenGLContext::doCreate(); } QPlatformOpenGLContext *QWindowsIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { qCDebug(lcQpaGl) << __FUNCTION__ << context->format(); - if (d->ensureStaticOpenGLContext()) { - QScopedPointer result(d->m_staticOpenGLContext->createContext(context)); + if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) { + QScopedPointer result(staticOpenGLContext->createContext(context)); if (result->isValid()) return result.take(); } @@ -410,13 +396,18 @@ QOpenGLContext::OpenGLModuleType QWindowsIntegration::openGLModuleType() #elif !defined(QT_OPENGL_DYNAMIC) return QOpenGLContext::LibGL; #else - return d->ensureStaticOpenGLContext() ? d->m_staticOpenGLContext->moduleType() : QOpenGLContext::LibGL; + if (const QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) + return staticOpenGLContext->moduleType(); + return QOpenGLContext::LibGL; #endif } QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext() { - return q_staticOpenGLContext; + QWindowsIntegrationPrivate *d = QWindowsIntegration::instance()->d.data(); + if (d->m_staticOpenGLContext.isNull()) + d->m_staticOpenGLContext = QSharedPointer(QWindowsStaticOpenGLContext::create()); + return d->m_staticOpenGLContext.data(); } #endif // !QT_NO_OPENGL diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index b8ad744d051..926e7da67ea 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -37,6 +37,7 @@ #include "qwindowsdrag.h" #include "qwindowsscreen.h" #include "qwindowsscaling.h" +#include "qwindowsintegration.h" #ifdef QT_NO_CURSOR # include "qwindowscursor.h" #endif @@ -958,7 +959,8 @@ void QWindowsWindow::destroyWindow() setDropSiteEnabled(false); #ifndef QT_NO_OPENGL if (m_surface) { - m_data.staticOpenGLContext->destroyWindowSurface(m_surface); + if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) + staticOpenGLContext->destroyWindowSurface(m_surface); m_surface = 0; } #endif @@ -2302,8 +2304,10 @@ void *QWindowsWindow::surface(void *nativeConfig) #ifdef QT_NO_OPENGL return 0; #else - if (!m_surface) - m_surface = m_data.staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig); + if (!m_surface) { + if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) + m_surface = staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig); + } return m_surface; #endif diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 9822ebce459..922d00f2309 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -107,9 +107,6 @@ struct QWindowsWindowData QMargins customMargins; // User-defined, additional frame for NCCALCSIZE HWND hwnd; bool embedded; -#ifndef QT_NO_OPENGL - QSharedPointer staticOpenGLContext; -#endif // QT_NO_OPENGL static QWindowsWindowData create(const QWindow *w, const QWindowsWindowData ¶meters, From 2603873e75e4b3eedef2939ada3069da36231c09 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 19 Jan 2015 12:05:10 +0100 Subject: [PATCH 017/101] Make harfbuzz-old fallback available at run-time The old harfbuzz code path is included as a fail safe for any possible use case where the Harfbuzz-NG regresses, but because the variable was checked statically, it was not actually possible to build a releasable executable which employed the work-around. Instead we use the regular global static pattern where the variable is queried the first time it's needed. Task-number: QTBUG-43850 Change-Id: I9ade76bf0825bbfefebdbdc4e6ee5571f1a3deec Reviewed-by: Lars Knoll --- src/gui/text/qfontengine.cpp | 13 +++++++++---- src/gui/text/qtextengine.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index b2a7a8e91ff..b360ed5c85e 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -77,7 +77,12 @@ static inline bool qtransform_equals_no_translate(const QTransform &a, const QTr // Harfbuzz helper functions #ifdef QT_ENABLE_HARFBUZZ_NG -bool useHarfbuzzNG = qgetenv("QT_HARFBUZZ") != "old"; +Q_GLOBAL_STATIC_WITH_ARGS(bool, useHarfbuzzNG,(qgetenv("QT_HARFBUZZ") != "old")) + +bool qt_useHarfbuzzNG() +{ + return *useHarfbuzzNG(); +} #endif Q_STATIC_ASSERT(sizeof(HB_Glyph) == sizeof(glyph_t)); @@ -282,7 +287,7 @@ void *QFontEngine::harfbuzzFont() const { Q_ASSERT(type() != QFontEngine::Multi); #ifdef QT_ENABLE_HARFBUZZ_NG - if (useHarfbuzzNG) + if (qt_useHarfbuzzNG()) return hb_qt_font_get_for_engine(const_cast(this)); #endif if (!font_) { @@ -318,7 +323,7 @@ void *QFontEngine::harfbuzzFace() const { Q_ASSERT(type() != QFontEngine::Multi); #ifdef QT_ENABLE_HARFBUZZ_NG - if (useHarfbuzzNG) + if (qt_useHarfbuzzNG()) return hb_qt_face_get_for_engine(const_cast(this)); #endif if (!face_) { @@ -360,7 +365,7 @@ bool QFontEngine::supportsScript(QChar::Script script) const #endif #ifdef QT_ENABLE_HARFBUZZ_NG - if (useHarfbuzzNG) { + if (qt_useHarfbuzzNG()) { bool ret = false; if (hb_face_t *face = hb_qt_face_get_for_engine(const_cast(this))) { hb_tag_t script_tag_1, script_tag_2; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index d156124b984..13bfa2386d6 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -938,7 +938,7 @@ void QTextEngine::shapeLine(const QScriptLine &line) } #ifdef QT_ENABLE_HARFBUZZ_NG -extern bool useHarfbuzzNG; // defined in qfontengine.cpp +extern bool qt_useHarfbuzzNG(); // defined in qfontengine.cpp #endif void QTextEngine::shapeText(int item) const @@ -1051,7 +1051,7 @@ void QTextEngine::shapeText(int item) const } #ifdef QT_ENABLE_HARFBUZZ_NG - if (useHarfbuzzNG) + if (qt_useHarfbuzzNG()) si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled); else #endif @@ -1067,7 +1067,7 @@ void QTextEngine::shapeText(int item) const QGlyphLayout glyphs = shapedGlyphs(&si); #ifdef QT_ENABLE_HARFBUZZ_NG - if (useHarfbuzzNG) + if (qt_useHarfbuzzNG()) qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si)); #endif @@ -1607,7 +1607,7 @@ void QTextEngine::itemize() const } #ifdef QT_ENABLE_HARFBUZZ_NG analysis = scriptAnalysis.data(); - if (useHarfbuzzNG) { + if (qt_useHarfbuzzNG()) { // ### pretend HB-old behavior for now for (int i = 0; i < length; ++i) { switch (analysis[i].script) { From 1909ab4b8fce0f9528e0ceaec9b0edf534c220de Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Fri, 16 Jan 2015 10:46:16 +0200 Subject: [PATCH 018/101] Add test for QColorDialog initial color Task-number: QTBUG-43548 Change-Id: I9410072e5bf837933148d48c4f9d6797337485f5 Reviewed-by: Marc Mutz --- .../widgets/dialogs/qcolordialog/tst_qcolordialog.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp index fa50d104888..e4e4fda1cae 100644 --- a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp +++ b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp @@ -60,6 +60,7 @@ private slots: void defaultOkButton(); void native_activeModalWidget(); void task247349_alpha(); + void QTBUG_43548_initialColor(); }; class TestNativeDialog : public QColorDialog @@ -162,5 +163,14 @@ void tst_QColorDialog::task247349_alpha() QCOMPARE(alpha, qAlpha(dialog.currentColor().rgba())); } +void tst_QColorDialog::QTBUG_43548_initialColor() +{ + QColorDialog dialog; + dialog.setOption(QColorDialog::DontUseNativeDialog); + dialog.setCurrentColor(QColor(Qt::red)); + QColor a(Qt::red); + QCOMPARE(a, dialog.currentColor()); +} + QTEST_MAIN(tst_QColorDialog) #include "tst_qcolordialog.moc" From a15569b269598ef516b5fdb9ce3214f7d46bafb8 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 19 Jan 2015 10:56:05 +0200 Subject: [PATCH 019/101] Android: don't report xfail Change-Id: I2998632cffc29161eb26421b07cf51a4138fcad3 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: BogDan Vatra --- tests/auto/android/runtests_androiddeployqt.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/android/runtests_androiddeployqt.pl b/tests/auto/android/runtests_androiddeployqt.pl index 8e9376da359..5ab6a63962b 100755 --- a/tests/auto/android/runtests_androiddeployqt.pl +++ b/tests/auto/android/runtests_androiddeployqt.pl @@ -334,7 +334,7 @@ sub checkXMLOutput while (my($test_key, $test_valule) = each (%{$function_valule})) { next if $test_key ne "Incident"; for my $incident (@{$test_valule}) { - if ($incident->{type} ne "pass") { + if (($incident->{type} ne "pass") && ($incident->{type} ne "xfail")) { print "test $testName::$function_key failed $incident->{file}:$incident->{line}\n"; $fail = 1; } From 668a3a4da177f2da668555224954d0df70646fa8 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Mon, 19 Jan 2015 11:03:49 +0100 Subject: [PATCH 020/101] Autotest: Use QFINDTESTDATA to find test data Change-Id: Ie6c659f6d8e8b3eeaf2453f0cba6189d56f86581 Reviewed-by: Oliver Wolff Reviewed-by: Richard J. Moore --- .../auto/network/ssl/qsslcertificate/qsslcertificate.pro | 1 - .../network/ssl/qsslcertificate/tst_qsslcertificate.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro b/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro index 69cd241f842..f2d6589410e 100644 --- a/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro +++ b/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro @@ -6,6 +6,5 @@ SOURCES += tst_qsslcertificate.cpp QT = core network testlib TARGET = tst_qsslcertificate -DEFINES += SRCDIR=\\\"$$PWD/\\\" TESTDATA += certificates/* more-certificates/* verify-certs/* pkcs12/* diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 82050e73fd1..a300187b950 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -1301,7 +1301,7 @@ void tst_QSslCertificate::pkcs12() return; } - QFile f(QLatin1String(SRCDIR "pkcs12/leaf.p12")); + QFile f(testDataDir + QLatin1String("/pkcs12/leaf.p12")); bool ok = f.open(QIODevice::ReadOnly); QVERIFY(ok); @@ -1316,12 +1316,12 @@ void tst_QSslCertificate::pkcs12() QVERIFY(ok); f.close(); - QList leafCert = QSslCertificate::fromPath(QLatin1String( SRCDIR "pkcs12/leaf.crt")); + QList leafCert = QSslCertificate::fromPath(testDataDir + QLatin1String("/pkcs12/leaf.crt")); QVERIFY(!leafCert.isEmpty()); QCOMPARE(cert, leafCert.first()); - QFile f2(QLatin1String(SRCDIR "pkcs12/leaf.key")); + QFile f2(testDataDir + QLatin1String("/pkcs12/leaf.key")); ok = f2.open(QIODevice::ReadOnly); QVERIFY(ok); @@ -1331,7 +1331,7 @@ void tst_QSslCertificate::pkcs12() QVERIFY(!leafKey.isNull()); QCOMPARE(key, leafKey); - QList caCert = QSslCertificate::fromPath(QLatin1String(SRCDIR "pkcs12/inter.crt")); + QList caCert = QSslCertificate::fromPath(testDataDir + QLatin1String("/pkcs12/inter.crt")); QVERIFY(!caCert.isEmpty()); QVERIFY(!caCerts.isEmpty()); From d7068cbe1b37eb065c1902c8e944f3bc19db0ba4 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Tue, 13 Jan 2015 15:22:12 +0100 Subject: [PATCH 021/101] Make threaded rendering possible with LinuxFB It was previously not possible to render to a QBackingStore with the linuxfb platform plugin because of both the use of a QTimer created on the main thread and there was no lock on the backing store surface (which would lead to copy content to screen that being rendered in another thread). Change-Id: I0ea3600316ce29eb89f6595997847afe7086116f Reviewed-by: Laszlo Agocs --- .../fbconvenience/qfbbackingstore.cpp | 25 +++++++++++++ .../fbconvenience/qfbbackingstore_p.h | 10 +++++- .../fbconvenience/qfbscreen.cpp | 35 ++++++++++++++----- .../fbconvenience/qfbscreen_p.h | 3 +- 4 files changed, 63 insertions(+), 10 deletions(-) diff --git a/src/platformsupport/fbconvenience/qfbbackingstore.cpp b/src/platformsupport/fbconvenience/qfbbackingstore.cpp index 0fa23ebe026..733235ff428 100644 --- a/src/platformsupport/fbconvenience/qfbbackingstore.cpp +++ b/src/platformsupport/fbconvenience/qfbbackingstore.cpp @@ -69,5 +69,30 @@ void QFbBackingStore::resize(const QSize &size, const QRegion &staticContents) mImage = QImage(size, window()->screen()->handle()->format()); } +const QImage QFbBackingStore::image() +{ + return mImage; +} + +void QFbBackingStore::lock() +{ + mImageMutex.lock(); +} + +void QFbBackingStore::unlock() +{ + mImageMutex.unlock(); +} + +void QFbBackingStore::beginPaint(const QRegion &) +{ + lock(); +} + +void QFbBackingStore::endPaint() +{ + unlock(); +} + QT_END_NAMESPACE diff --git a/src/platformsupport/fbconvenience/qfbbackingstore_p.h b/src/platformsupport/fbconvenience/qfbbackingstore_p.h index 08a4b37eeee..a9917e1450b 100644 --- a/src/platformsupport/fbconvenience/qfbbackingstore_p.h +++ b/src/platformsupport/fbconvenience/qfbbackingstore_p.h @@ -46,6 +46,7 @@ // #include +#include QT_BEGIN_NAMESPACE @@ -64,12 +65,19 @@ public: virtual void resize(const QSize &size, const QRegion ®ion); - const QImage image() { return mImage; } + const QImage image(); + + void lock(); + void unlock(); + + void beginPaint(const QRegion &); + void endPaint(); protected: friend class QFbWindow; QImage mImage; + QMutex mImageMutex; }; QT_END_NAMESPACE diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp index aa35825be0e..13341344d80 100644 --- a/src/platformsupport/fbconvenience/qfbscreen.cpp +++ b/src/platformsupport/fbconvenience/qfbscreen.cpp @@ -37,11 +37,15 @@ #include "qfbbackingstore_p.h" #include +#include #include +#include +#include + QT_BEGIN_NAMESPACE -QFbScreen::QFbScreen() : mCursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), mCompositePainter(0), mIsUpToDate(false) +QFbScreen::QFbScreen() : mUpdatePending(false), mCursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), mCompositePainter(0), mIsUpToDate(false) { } @@ -54,10 +58,17 @@ QFbScreen::~QFbScreen() void QFbScreen::initializeCompositor() { mScreenImage = new QImage(mGeometry.size(), mFormat); + scheduleUpdate(); +} - mRedrawTimer.setSingleShot(true); - mRedrawTimer.setInterval(0); - connect(&mRedrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw())); +bool QFbScreen::event(QEvent *event) +{ + if (event->type() == QEvent::UpdateRequest) { + doRedraw(); + mUpdatePending = false; + return true; + } + return QObject::event(event); } void QFbScreen::addWindow(QFbWindow *window) @@ -146,8 +157,10 @@ void QFbScreen::setDirty(const QRect &rect) void QFbScreen::scheduleUpdate() { - if (!mRedrawTimer.isActive()) - mRedrawTimer.start(); + if (!mUpdatePending) { + mUpdatePending = true; + QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); + } } void QFbScreen::setPhysicalSize(const QSize &size) @@ -246,12 +259,19 @@ QRegion QFbScreen::doRedraw() continue; // if (mWindowStack[layerIndex]->isMinimized()) // continue; + QRect windowRect = mWindowStack[layerIndex]->geometry().translated(-screenOffset); QRect windowIntersect = rect.translated(-windowRect.left(), -windowRect.top()); + + QFbBackingStore *backingStore = mWindowStack[layerIndex]->backingStore(); - if (backingStore) + + if (backingStore) { + backingStore->lock(); mCompositePainter->drawImage(rect, backingStore->image(), windowIntersect); + backingStore->unlock(); + } if (firstLayer) { firstLayer = false; } @@ -272,7 +292,6 @@ QRegion QFbScreen::doRedraw() // qDebug() << "QFbScreen::doRedraw" << mWindowStack.size() << mScreenImage->size() << touchedRegion; - return touchedRegion; } diff --git a/src/platformsupport/fbconvenience/qfbscreen_p.h b/src/platformsupport/fbconvenience/qfbscreen_p.h index b6e50dc7867..55aacab9bc2 100644 --- a/src/platformsupport/fbconvenience/qfbscreen_p.h +++ b/src/platformsupport/fbconvenience/qfbscreen_p.h @@ -94,10 +94,11 @@ protected slots: protected: void initializeCompositor(); + bool event(QEvent *event); QList mWindowStack; QRegion mRepaintRegion; - QTimer mRedrawTimer; + bool mUpdatePending; QFbCursor *mCursor; QRect mGeometry; From 447ef9766afbb9cb9bbf1a4f193306fe6d680ab6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 18 Jan 2015 13:32:33 +0100 Subject: [PATCH 022/101] src/testlib/testlib.pro: add missing qbenchmarksmetric.h Change-Id: I9b879bb22f3e3f74e55234730d9cf79221812a36 Reviewed-by: Jason McDonald --- src/testlib/testlib.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 17a03781c25..dbcc588d100 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -17,6 +17,7 @@ HEADERS = qbenchmark.h \ qbenchmarkvalgrind_p.h \ qbenchmarkevent_p.h \ qbenchmarkperfevents_p.h \ + qbenchmarkmetric.h \ qbenchmarkmetric_p.h \ qsignalspy.h \ qtestaccessible.h \ From 23996a9e4007d12cf3eee8f80cebedaf2bcca2e1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 15 Jan 2015 18:02:38 +0100 Subject: [PATCH 023/101] Windows: make TranslucentBackground functional always QOpenGLWidget and QQuickWidget was not functional when WA_TranslucentBackground was set. This is due to the static "isGL" type of checks that are not suitable since 5.3 due to RasterGLSurface windows which may or may not be OpenGL windows, depending on their content. To handle this, we have to do some check on every makeCurrent and perform the necessary calls (most importantly SetLayeredWindowAttributes). Task-number: QTBUG-43854 Change-Id: If19c79482ec4f0a8b795ee710d52ed7e08b52563 Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowscontext.cpp | 8 +-- .../platforms/windows/qwindowscontext.h | 2 +- .../platforms/windows/qwindowseglcontext.cpp | 1 + .../platforms/windows/qwindowsglcontext.cpp | 1 + .../platforms/windows/qwindowswindow.cpp | 64 ++++++++++++++----- .../platforms/windows/qwindowswindow.h | 4 +- 6 files changed, 59 insertions(+), 21 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 13a3d044a05..2dab4f699fe 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -430,7 +430,7 @@ void QWindowsContext::setKeyGrabber(QWindow *w) // Window class registering code (from qapplication_win.cpp) -QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) +QString QWindowsContext::registerWindowClass(const QWindow *w) { Q_ASSERT(w); const Qt::WindowFlags flags = w->flags(); @@ -438,7 +438,9 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) // Determine style and icon. uint style = CS_DBLCLKS; bool icon = true; - if (isGL || (flags & Qt::MSWindowsOwnDC)) + // The following will not set CS_OWNDC for any widget window, even if it contains a + // QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage. + if (w->surfaceType() == QSurface::OpenGLSurface || (flags & Qt::MSWindowsOwnDC)) style |= CS_OWNDC; if (!(flags & Qt::NoDropShadowWindowHint) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) && (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) { @@ -471,8 +473,6 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) default: break; } - if (isGL) - cname += QStringLiteral("GL"); if (style & CS_DROPSHADOW) cname += QStringLiteral("DropShadow"); if (style & CS_SAVEBITS) diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 28202219d6b..5c2e21192bb 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -161,7 +161,7 @@ public: int defaultDPI() const; - QString registerWindowClass(const QWindow *w, bool isGL); + QString registerWindowClass(const QWindow *w); QString registerWindowClass(QString cname, WNDPROC proc, unsigned style = 0, HBRUSH brush = 0, bool icon = false); diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index c0d0c1f77cc..fbd56e2b028 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -573,6 +573,7 @@ bool QWindowsEGLContext::makeCurrent(QPlatformSurface *surface) QWindowsEGLStaticContext::libEGL.eglBindAPI(m_api); QWindowsWindow *window = static_cast(surface); + window->aboutToMakeCurrent(); EGLSurface eglSurface = static_cast(window->surface(m_eglConfig)); Q_ASSERT(eglSurface); diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 0e3e6826ecb..3348241d37a 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -1267,6 +1267,7 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface) // Do we already have a DC entry for that window? QWindowsWindow *window = static_cast(surface); + window->aboutToMakeCurrent(); const HWND hwnd = window->handle(); if (const QOpenGLContextData *contextData = findByHWND(m_windowContexts, hwnd)) { // Repeated calls to wglMakeCurrent when vsync is enabled in the driver will diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index e7061dbfde6..0b72f6db4d2 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -205,6 +205,18 @@ static inline QSize clientSize(HWND hwnd) return qSizeOfRect(rect); } +static inline bool windowIsOpenGL(const QWindow *w) +{ + switch (w->surfaceType()) { + case QSurface::OpenGLSurface: + return true; + case QSurface::RasterGLSurface: + return qt_window_private(const_cast(w))->compositing; + default: + return false; + } +} + static bool applyBlurBehindWindow(HWND hwnd) { #ifdef Q_OS_WINCE @@ -328,6 +340,17 @@ static void setWindowOpacity(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, bo #endif // !Q_OS_WINCE } +static inline void updateGLWindowSettings(const QWindow *w, HWND hwnd, Qt::WindowFlags flags, qreal opacity) +{ + const bool isGL = windowIsOpenGL(w); + const bool hasAlpha = w->format().hasAlpha(); + + if (isGL && hasAlpha) + applyBlurBehindWindow(hwnd); + + setWindowOpacity(hwnd, flags, hasAlpha, isGL, opacity); +} + /*! \class WindowCreationData \brief Window creation code. @@ -369,14 +392,13 @@ struct WindowCreationData void fromWindow(const QWindow *w, const Qt::WindowFlags flags, unsigned creationFlags = 0); inline WindowData create(const QWindow *w, const WindowData &data, QString title) const; inline void applyWindowFlags(HWND hwnd) const; - void initialize(HWND h, bool frameChange, qreal opacityLevel) const; + void initialize(const QWindow *w, HWND h, bool frameChange, qreal opacityLevel) const; Qt::WindowFlags flags; HWND parentHandle; Qt::WindowType type; unsigned style; unsigned exStyle; - bool isGL; bool topLevel; bool popup; bool dialog; @@ -389,7 +411,7 @@ struct WindowCreationData QDebug operator<<(QDebug debug, const WindowCreationData &d) { debug.nospace() << QWindowsWindow::debugWindowFlags(d.flags) - << " GL=" << d.isGL << " topLevel=" << d.topLevel << " popup=" + << " topLevel=" << d.topLevel << " popup=" << d.popup << " dialog=" << d.dialog << " desktop=" << d.desktop << " embedded=" << d.embedded << " tool=" << d.tool << " style=" << debugWinStyle(d.style) @@ -420,8 +442,6 @@ static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags) void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flagsIn, unsigned creationFlags) { - isGL = w->surfaceType() == QWindow::OpenGLSurface; - hasAlpha = w->format().hasAlpha(); flags = flagsIn; // Sometimes QWindow doesn't have a QWindow parent but does have a native parent window, @@ -494,7 +514,7 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag // ### Commented out for now as it causes some problems, but // this should be correct anyway, so dig some more into this #ifdef Q_FLATTEN_EXPOSE - if (isGL) + if (windowIsOpenGL(w)) // a bit incorrect since the is-opengl status may change from false to true at any time later on style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // see SetPixelFormat #else style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN ; @@ -569,7 +589,7 @@ QWindowsWindowData const HINSTANCE appinst = (HINSTANCE)GetModuleHandle(0); - const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w, isGL); + const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w); const QRect geometryDip = QWindowsScaling::mapFromNative(data.geometry); QRect fixedGeometryDip = QPlatformWindow::initialGeometry(w, geometryDip, defaultWindowWidth, defaultWindowHeight); @@ -612,9 +632,6 @@ QWindowsWindowData result.embedded = embedded; result.customMargins = context->customMargins; - if (isGL && hasAlpha) - applyBlurBehindWindow(result.hwnd); - return result; } @@ -637,7 +654,7 @@ void WindowCreationData::applyWindowFlags(HWND hwnd) const << debugWinExStyle(newExStyle); } -void WindowCreationData::initialize(HWND hwnd, bool frameChange, qreal opacityLevel) const +void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChange, qreal opacityLevel) const { if (desktop || !hwnd) return; @@ -662,8 +679,7 @@ void WindowCreationData::initialize(HWND hwnd, bool frameChange, qreal opacityLe else EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED); } - - setWindowOpacity(hwnd, flags, hasAlpha, isGL, opacityLevel); + updateGLWindowSettings(w, hwnd, flags, opacityLevel); } else { // child. SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, swpFlags); } @@ -1045,7 +1061,7 @@ QWindowsWindowData creationData.fromWindow(w, parameters.flags); QWindowsWindowData result = creationData.create(w, parameters, title); // Force WM_NCCALCSIZE (with wParam=1) via SWP_FRAMECHANGED for custom margin. - creationData.initialize(result.hwnd, !parameters.customMargins.isNull(), 1); + creationData.initialize(w, result.hwnd, !parameters.customMargins.isNull(), 1); return result; } @@ -1532,7 +1548,7 @@ QWindowsWindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt, WindowCreationData creationData; creationData.fromWindow(window(), wt, flags); creationData.applyWindowFlags(m_data.hwnd); - creationData.initialize(m_data.hwnd, true, m_opacity); + creationData.initialize(window(), m_data.hwnd, true, m_opacity); QWindowsWindowData result = m_data; result.flags = creationData.flags; @@ -2303,4 +2319,22 @@ void *QWindowsWindow::surface(void *nativeConfig) #endif } +void QWindowsWindow::aboutToMakeCurrent() +{ +#ifndef QT_NO_OPENGL + // For RasterGLSurface windows, that become OpenGL windows dynamically, it might be + // time to set up some GL specifics. This is particularly important for layered + // windows (WS_EX_LAYERED due to alpha > 0). + const bool isCompositing = qt_window_private(window())->compositing; + if (isCompositing != testFlag(Compositing)) { + if (isCompositing) + setFlag(Compositing); + else + clearFlag(Compositing); + + updateGLWindowSettings(window(), m_data.hwnd, m_data.flags, m_opacity); + } +#endif +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 9822ebce459..33be287f81f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -140,7 +140,8 @@ public: WithinCreate = 0x20000, WithinMaximize = 0x40000, MaximizeToFullScreen = 0x80000, - InputMethodDisabled =0x100000 + InputMethodDisabled = 0x100000, + Compositing = 0x200000 }; QWindowsWindow(QWindow *window, const QWindowsWindowData &data); @@ -253,6 +254,7 @@ public: void setWindowIcon(const QIcon &icon); void *surface(void *nativeConfig); + void aboutToMakeCurrent(); #ifndef Q_OS_WINCE void setAlertState(bool enabled); From 6a081125a5b1b7d629a2c6e16a696ecc06dbb427 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 19 Jan 2015 11:57:22 +0100 Subject: [PATCH 024/101] Make -static -opengl dynamic builds succeed Right now it breaks in qwindowseglcontext due to its ifdefs for static ANGLE-only builds. The checks for QT_STATIC should be extended with QT_OPENGL_DYNAMIC so that it continues to resolve functions dynamically in -opengl dynamic builds even when combined with -static. Task-number: QTBUG-43993 Change-Id: Iac6d0353ef16a32a22ab1db0a833fbb0165f328c Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowseglcontext.cpp | 10 +++++----- src/plugins/platforms/windows/qwindowseglcontext.h | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index fbd56e2b028..7fcb1f4ffe6 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE QWindowsLibEGL QWindowsEGLStaticContext::libEGL; QWindowsLibGLESv2 QWindowsEGLStaticContext::libGLESv2; -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) #ifdef Q_CC_MINGW static void *resolveFunc(HMODULE lib, const char *name) @@ -111,7 +111,7 @@ void *QWindowsLibEGL::resolve(const char *name) #endif // !QT_STATIC -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) # define RESOLVE(signature, name) signature(resolve( #name )); #else # define RESOLVE(signature, name) signature(&::name); @@ -127,7 +127,7 @@ bool QWindowsLibEGL::init() qCDebug(lcQpaGl) << "Qt: Using EGL from" << dllName; -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) m_lib = ::LoadLibraryW((const wchar_t *) QString::fromLatin1(dllName).utf16()); if (!m_lib) { qErrnoWarning(::GetLastError(), "Failed to load %s", dllName); @@ -159,7 +159,7 @@ bool QWindowsLibEGL::init() return eglGetError && eglGetDisplay && eglInitialize; } -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *QWindowsLibGLESv2::resolve(const char *name) { void *proc = m_lib ? resolveFunc(m_lib, name) : 0; @@ -179,7 +179,7 @@ bool QWindowsLibGLESv2::init() #endif qCDebug(lcQpaGl) << "Qt: Using OpenGL ES 2.0 from" << dllName; -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) m_lib = ::LoadLibraryW((const wchar_t *) QString::fromLatin1(dllName).utf16()); if (!m_lib) { qErrnoWarning(::GetLastError(), "Failed to load %s", dllName); diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h index 63a7c25a6fd..29df3ba8820 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.h +++ b/src/plugins/platforms/windows/qwindowseglcontext.h @@ -74,7 +74,7 @@ struct QWindowsLibEGL __eglMustCastToProperFunctionPointerType (EGLAPIENTRY * eglGetProcAddress)(const char *procname); private: -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *resolve(const char *name); HMODULE m_lib; #endif @@ -83,7 +83,8 @@ private: struct QWindowsLibGLESv2 { bool init(); -#ifndef QT_STATIC + +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *moduleHandle() const { return m_lib; } #else void *moduleHandle() const { return Q_NULLPTR; } @@ -238,7 +239,7 @@ struct QWindowsLibGLESv2 void (APIENTRY * glDepthRangef)(GLclampf nearVal, GLclampf farVal); private: -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *resolve(const char *name); HMODULE m_lib; #endif From 91d6aafad4805fb760a51f64565929952a37c5bf Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 19 Jan 2015 13:18:17 +0100 Subject: [PATCH 025/101] Windows: avoid generating exposes on plain moves The fake expose generation for shrunk windows is causing side effects with desktop GL: it will generate expose events even when only moving the window. This is bad. So change the condition to look for shrinking and do nothing if the size is same as before. This is reported to cause perf issues with e.g. QOpenGLWindow or similar where an expose does an immediate repaint (potentially with block swap). Task-number: QTBUG-32121 Change-Id: I4687ea8210cee6691d608450c48b1dbef52d6df3 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 0b72f6db4d2..1d8645f5f4f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1394,7 +1394,7 @@ void QWindowsWindow::handleGeometryChange() // QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive // expose events when shrinking, synthesize. if (!testFlag(OpenGL_ES2) && isExposed() - && !(m_data.geometry.width() > previousGeometry.width() || m_data.geometry.height() > previousGeometry.height())) { + && !(m_data.geometry.width() >= previousGeometry.width() || m_data.geometry.height() >= previousGeometry.height())) { fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true); } if (previousGeometry.topLeft() != m_data.geometry.topLeft()) { From 027d2fc84663b969bf8b166898bd5efec8fcf465 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 18 Jan 2015 11:25:09 +0100 Subject: [PATCH 026/101] Doc: add missing since 5.4 for new sessionProtocol() methods. They were added in 233a2f37bfa6c896612cbf9a7db42e8e0da788f5, which is in 5.4, but the \since information was missing. Change-Id: I346a049cad75647fdcd7b64df80dc169bb4ec70a Reviewed-by: Richard J. Moore --- src/network/ssl/qsslconfiguration.cpp | 1 + src/network/ssl/qsslsocket.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp index 7bb6e02b7e9..55c9a281ba0 100644 --- a/src/network/ssl/qsslconfiguration.cpp +++ b/src/network/ssl/qsslconfiguration.cpp @@ -512,6 +512,7 @@ QSslCipher QSslConfiguration::sessionCipher() const is set during the handshake phase. \sa protocol(), setProtocol() + \since 5.4 */ QSsl::SslProtocol QSslConfiguration::sessionProtocol() const { diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 31c7b3087ea..f735b6bd4fd 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1081,6 +1081,7 @@ QSslCipher QSslSocket::sessionCipher() const is set during the handshake phase. \sa protocol(), setProtocol() + \since 5.4 */ QSsl::SslProtocol QSslSocket::sessionProtocol() const { From ee1afbb8aa99e10f1dae11d8418e40351f685b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 13 Jan 2015 10:49:07 +0100 Subject: [PATCH 027/101] tst_qstring_mac: Correct memory management. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NSStrings return by QString::toNSString are autoreleased; manually releasing them is not correct. The test still works (no leaks or double deletes) since there is no autorelease pool in place when running it. We don't want to encourage incorrect usage: remove the release call an add an autorelease pool. Change-Id: Ic566fd3a8efd6cbc0eb6db850248a68bfc8fed0b Reviewed-by: Timur Pocheptsov Reviewed-by: Gabriel de Dietrich Reviewed-by: Tor Arne Vestbø Reviewed-by: Jake Petroules --- tests/auto/corelib/tools/qstring/tst_qstring_mac.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm b/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm index 9061b6c39d4..4cec5b3798f 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm +++ b/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm @@ -63,17 +63,23 @@ void tst_QString_macTypes() } // QString <-> NSString { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + QString qtString("test string"); const NSString *nsString = qtString.toNSString(); QCOMPARE(QString::fromNSString(nsString), qtString); - [nsString release]; + + [pool release]; } { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + QString qtString("test string"); const NSString *nsString = qtString.toNSString(); QString qtStringCopy(qtString); qtString = qtString.toUpper(); // modify QCOMPARE(QString::fromNSString(nsString), qtStringCopy); - [nsString release]; + + [pool release]; } } From 64c6bfd1f45f532ea32de49431b66e03e7593f01 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 19 Jan 2015 18:18:57 +0400 Subject: [PATCH 028/101] Fix crash with multi threaded QFont/QTextEngine usage Since we don't configure HB-NG via its configure script, we have to define all optional switchers we do care about by our own. Some of these switchers were missing in harfbuzz-ng.pro, causing HB-NG to be built with no threading support. Task-number: QTBUG-43850 Change-Id: I0944a68fe0bfae3306a3e6085e25704f0d0d0efc Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro index 79c2a3e2d64..6b51d9679ad 100644 --- a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro +++ b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro @@ -7,7 +7,12 @@ CONFIG += \ load(qt_helper_lib) -DEFINES += HAVE_OT HAVE_ATEXIT HB_NO_UNICODE_FUNCS HB_DISABLE_DEPRECATED +DEFINES += HAVE_OT HB_NO_UNICODE_FUNCS HB_DISABLE_DEPRECATED + +# platform/compiler specific definitions +DEFINES += HAVE_ATEXIT +gcc: DEFINES += HAVE_INTEL_ATOMIC_PRIMITIVES +unix: DEFINES += HAVE_PTHREAD HAVE_SCHED_H HAVE_SCHED_YIELD INCLUDEPATH += $$PWD/include From 8c5b3c6d912709d4db9624bb999b3166a27ee189 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Jan 2015 14:57:05 +0100 Subject: [PATCH 029/101] Fix QVERIFY() in tst_qwidget. Replace by QCOMPARE where applicable; introduce message to generate output for failed comparisons with QVERIFY2(). Task-number: QTBUG-43872 Change-Id: I09c8f9fd31ceed224e441f253049f68907ca0d7a Reviewed-by: Oliver Wolff --- .../widgets/kernel/qwidget/tst_qwidget.cpp | 90 +++++++++++-------- 1 file changed, 55 insertions(+), 35 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 756b22073eb..562328810e1 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -184,6 +184,14 @@ inline void setWindowsAnimationsEnabled(bool) {} static inline bool windowsAnimationsEnabled() { return false; } #endif // !Q_OS_WIN || Q_OS_WINCE || Q_OS_WINRT +template +static QByteArray msgComparisonFailed(T v1, const char *op, T v2) +{ + QString s; + QDebug(&s) << v1 << op << v2; + return s.toLocal8Bit(); +} + class tst_QWidget : public QObject { Q_OBJECT @@ -1393,11 +1401,13 @@ void tst_QWidget::fonts() newFont = newFont.resolve( testWidget->font() ); QVERIFY( cleanTestWidget->testAttribute(Qt::WA_SetFont) ); - QVERIFY( cleanTestWidget->font() == newFont ); + QVERIFY2( cleanTestWidget->font() == newFont, + msgComparisonFailed(cleanTestWidget->font(), "==", newFont)); cleanTestWidget->setFont(QFont()); QVERIFY( !cleanTestWidget->testAttribute(Qt::WA_SetFont) ); - QVERIFY( cleanTestWidget->font() == originalFont ); + QVERIFY2( cleanTestWidget->font() == originalFont, + msgComparisonFailed(cleanTestWidget->font(), "==", originalFont)); } void tst_QWidget::mapFromAndTo_data() @@ -1820,17 +1830,17 @@ void tst_QWidget::activation() widget2.show(); QTest::qWait(waitTime); - QVERIFY(qApp->activeWindow() == &widget2); + QCOMPARE(QApplication::activeWindow(), &widget2); widget2.showMinimized(); QTest::qWait(waitTime); - QVERIFY(qApp->activeWindow() == &widget1); + QCOMPARE(QApplication::activeWindow(), &widget1); widget2.showMaximized(); QTest::qWait(waitTime); - QVERIFY(qApp->activeWindow() == &widget2); + QCOMPARE(QApplication::activeWindow(), &widget2); widget2.showMinimized(); QTest::qWait(waitTime); - QVERIFY(qApp->activeWindow() == &widget1); + QCOMPARE(QApplication::activeWindow(), &widget1); widget2.showNormal(); QTest::qWait(waitTime); #ifndef Q_OS_WINCE @@ -1838,10 +1848,10 @@ void tst_QWidget::activation() QEXPECT_FAIL("", "MS introduced new behavior after XP", Continue); #endif QTest::qWait(waitTime); - QVERIFY(qApp->activeWindow() == &widget2); + QCOMPARE(QApplication::activeWindow(), &widget2); widget2.hide(); QTest::qWait(waitTime); - QVERIFY(qApp->activeWindow() == &widget1); + QCOMPARE(QApplication::activeWindow(), &widget1); } #endif // Q_OS_WIN @@ -2742,13 +2752,13 @@ void tst_QWidget::raise() QList list1; list1 << child1 << child2 << child3 << child4; - QVERIFY(parentPtr->children() == list1); + QCOMPARE(parentPtr->children(), list1); QCOMPARE(allChildren.count(), list1.count()); foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = child == child4 ? 1 : 0; if (expectedPaintEvents == 0) { - QVERIFY(child->numPaintEvents == 0); + QCOMPARE(child->numPaintEvents, 0); } else { // show() issues multiple paint events on some window managers QTRY_VERIFY(child->numPaintEvents >= expectedPaintEvents); @@ -2771,7 +2781,7 @@ void tst_QWidget::raise() QList list2; list2 << child1 << child3 << child4 << child2; - QVERIFY(parentPtr->children() == list2); + QCOMPARE(parentPtr->children(), list2); // Creates a widget on top of all the children and checks that raising one of // the children underneath doesn't trigger a repaint on the covering widget. @@ -2804,7 +2814,7 @@ void tst_QWidget::raise() QList list3; list3 << child1 << child4 << child2 << child3; - QVERIFY(parent->children() == list3); + QCOMPARE(parent->children(), list3); foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = 0; @@ -2846,13 +2856,13 @@ void tst_QWidget::lower() QList list1; list1 << child1 << child2 << child3 << child4; - QVERIFY(parent->children() == list1); + QCOMPARE(parent->children(), list1); QCOMPARE(allChildren.count(), list1.count()); foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = child == child4 ? 1 : 0; if (expectedPaintEvents == 0) { - QVERIFY(child->numPaintEvents == 0); + QCOMPARE(child->numPaintEvents, 0); } else { // show() issues multiple paint events on some window managers QTRY_VERIFY(child->numPaintEvents >= expectedPaintEvents); @@ -2876,7 +2886,7 @@ void tst_QWidget::lower() QList list2; list2 << child4 << child1 << child2 << child3; - QVERIFY(parent->children() == list2); + QCOMPARE(parent->children(), list2); } #endif @@ -2910,7 +2920,7 @@ void tst_QWidget::stackUnder() QVERIFY(QTest::qWaitForWindowExposed(parent.data())); QList list1; list1 << child1 << child2 << child3 << child4; - QVERIFY(parent->children() == list1); + QCOMPARE(parent->children(), list1); foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = child == child4 ? 1 : 0; @@ -2929,7 +2939,7 @@ void tst_QWidget::stackUnder() QList list2; list2 << child1 << child4 << child2 << child3; - QVERIFY(parent->children() == list2); + QCOMPARE(parent->children(), list2); foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = child == child3 ? 1 : 0; @@ -2945,7 +2955,7 @@ void tst_QWidget::stackUnder() QList list3; list3 << child4 << child2 << child1 << child3; - QVERIFY(parent->children() == list3); + QCOMPARE(parent->children(), list3); foreach (UpdateWidget *child, allChildren) { int expectedZOrderChangeEvents = child == child1 ? 1 : 0; @@ -3757,8 +3767,10 @@ void tst_QWidget::setMinimumSize() w.setMinimumSize(nonDefaultSize); w.showNormal(); QTest::qWait(50); - QVERIFY(w.height() >= nonDefaultSize.height()); - QVERIFY(w.width() >= nonDefaultSize.width()); + QVERIFY2(w.height() >= nonDefaultSize.height(), + msgComparisonFailed(w.height(), ">=", nonDefaultSize.height())); + QVERIFY2(w.width() >= nonDefaultSize.width(), + msgComparisonFailed(w.width(), ">=", nonDefaultSize.width())); #endif } @@ -3810,7 +3822,7 @@ void tst_QWidget::setFixedSize() QTest::qWait(50); if (m_platform == QStringLiteral("xcb")) QSKIP("QTBUG-26424"); - QVERIFY(w.size() == defaultSize + QSize(150,150)); + QCOMPARE(w.size(), defaultSize + QSize(150,150)); } void tst_QWidget::ensureCreated() @@ -4695,8 +4707,8 @@ void tst_QWidget::setGeometry_win() widget.show(); RECT rt; ::GetWindowRect(winHandleOf(&widget), &rt); - QVERIFY(rt.left <= 0); - QVERIFY(rt.top <= 0); + QVERIFY2(rt.left <= 0, msgComparisonFailed(int(rt.left), "<=", 0)); + QVERIFY2(rt.top <= 0, msgComparisonFailed(int(rt.top), "<=", 0)); } #endif // defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) @@ -6544,7 +6556,8 @@ void tst_QWidget::renderInvisible() QPixmap pixmap(topLevel.sizeHint()); topLevel.render(&pixmap); // triggers adjustSize() const QSize finalSize = topLevel.size(); - QVERIFY(finalSize != initialSize); + QVERIFY2(finalSize != initialSize, + msgComparisonFailed(finalSize, "!=", initialSize)); topLevel.layout()->removeWidget(widget); QCOMPARE(topLevel.size(), finalSize); @@ -7185,7 +7198,7 @@ void tst_QWidget::setContentsMargins() QSize oldSize = label.sizeHint(); label.setFrameStyle(QFrame::Sunken | QFrame::Box); QSize newSize = label.sizeHint(); - QVERIFY(oldSize != newSize); + QVERIFY2(oldSize != newSize, msgComparisonFailed(oldSize, "!=", newSize)); QLabel label2("why does it always rain on me?"); label2.show(); @@ -7718,8 +7731,10 @@ void tst_QWidget::adjustSize() child->resize(123, 456); child->adjustSize(); if (expectedSize == QSize(100000, 100000)) { - QVERIFY(child->size().width() < sizeHint.width()); - QVERIFY(child->size().height() < sizeHint.height()); + QVERIFY2(child->size().width() < sizeHint.width(), + msgComparisonFailed(child->size().width(), "<", sizeHint.width())); + QVERIFY2(child->size().height() < sizeHint.height(), + msgComparisonFailed(child->size().height(), "<", sizeHint.height())); } else { #if defined (Q_OS_WINCE) if (!haveParent) { @@ -9508,8 +9523,10 @@ void tst_QWidget::childAt_unifiedToolBar() // we use mapToGlobal/mapFromGlobal to re-calculate the corners. QPoint oldToolBarTopLeft = toolBarTopLeft; toolBarTopLeft = mainWindow.mapFromGlobal(toolBar->mapToGlobal(QPoint())); - QVERIFY(toolBarTopLeft != oldToolBarTopLeft); - QVERIFY(toolBarTopLeft.y() < 0); + QVERIFY2(toolBarTopLeft != oldToolBarTopLeft, + msgComparisonFailed(toolBarTopLeft, "!=", oldToolBarTopLeft)); + QVERIFY2(toolBarTopLeft.y() < 0, + msgComparisonFailed(toolBarTopLeft.y(), "<", 0)); labelTopLeft = mainWindow.mapFromGlobal(label->mapToGlobal(QPoint())); QCOMPARE(mainWindow.childAt(toolBarTopLeft), static_cast(toolBar)); @@ -9740,7 +9757,7 @@ void tst_QWidget::grabKeyboard() QTest::keyClick(w.windowHandle(), Qt::Key_A); grabber->releaseKeyboard(); QCOMPARE(grabber->text().toLower(), QStringLiteral("a")); - QVERIFY(nonGrabber->text().isEmpty()); + QVERIFY2(nonGrabber->text().isEmpty(), qPrintable(nonGrabber->text())); } class TouchMouseWidget : public QWidget { @@ -10092,7 +10109,7 @@ void tst_QWidget::underMouse() QVERIFY(QTest::qWaitForWindowExposed(&popupWidget)); QWindow *popupWindow = popupWidget.windowHandle(); QVERIFY(popupWindow); - QVERIFY(QApplication::activePopupWidget() == &popupWidget); + QCOMPARE(QApplication::activePopupWidget(), &popupWidget); // Send an artificial leave event for window, as it won't get generated automatically // due to cursor not actually being over the window. @@ -10365,13 +10382,15 @@ void tst_QWidget::largerThanScreen_QTBUG30142() widget.resize(200, 4000); widget.show(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); - QVERIFY(widget.frameGeometry().y() >= 0); + QVERIFY2(widget.frameGeometry().y() >= 0, + msgComparisonFailed(widget.frameGeometry().y(), " >=", 0)); QWidget widget2; widget2.resize(10000, 400); widget2.show(); QVERIFY(QTest::qWaitForWindowExposed(&widget2)); - QVERIFY(widget2.frameGeometry().x() >= 0); + QVERIFY2(widget2.frameGeometry().x() >= 0, + msgComparisonFailed(widget.frameGeometry().x(), " >=", 0)); } void tst_QWidget::resizeStaticContentsChildWidget_QTBUG35282() @@ -10386,13 +10405,14 @@ void tst_QWidget::resizeStaticContentsChildWidget_QTBUG35282() widget.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); - QVERIFY(childWidget.numPaintEvents == 0); + QCOMPARE(childWidget.numPaintEvents, 0); childWidget.reset(); widget.resize(1000,1000); QVERIFY(QTest::qWaitForWindowExposed(&widget)); QGuiApplication::sync(); - QVERIFY(childWidget.numPaintEvents >= 1); + QVERIFY2(childWidget.numPaintEvents >= 1, + msgComparisonFailed(childWidget.numPaintEvents, ">=", 1)); } QTEST_MAIN(tst_QWidget) From 0b62cd8da7d8ee078b799b95088a63626099caa4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Jan 2015 15:00:05 +0100 Subject: [PATCH 030/101] Windows: Fix coordinate offset when positioning the taskbar on the left. For windows that do not have WS_EX_TOOLWINDOW set, the WINDOWPLACEMENT API uses workspace/available aera coordinates. Introduce a helper function to return the offset and use that. Task-number: QTBUG-43872 Change-Id: I329c640f180524699b45b855b4583f447c4a0987 Reviewed-by: Oliver Wolff --- .../platforms/windows/qwindowsscreen.cpp | 9 +++++ .../platforms/windows/qwindowsscreen.h | 2 ++ .../platforms/windows/qwindowswindow.cpp | 34 ++++++++++++++++--- .../widgets/kernel/qwidget/tst_qwidget.cpp | 9 +++-- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index fd57d9ee616..ae8020a53e2 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -497,4 +497,13 @@ bool QWindowsScreenManager::handleScreenChanges() return true; } +const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const +{ + foreach (QWindowsScreen *scr, m_screens) { + if (scr->geometryDp().contains(p)) + return scr; + } + return Q_NULLPTR; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h index aa1408358ba..28256f30009 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.h +++ b/src/plugins/platforms/windows/qwindowsscreen.h @@ -137,6 +137,8 @@ public: bool handleDisplayChange(WPARAM wParam, LPARAM lParam); const WindowsScreenList &screens() const { return m_screens; } + const QWindowsScreen *screenAtDp(const QPoint &p) const; + private: void removeScreen(int index); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 1d8645f5f4f..fbb61a1aff2 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -169,6 +169,25 @@ QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p) } #endif // !Q_OS_WINCE +// QTBUG-43872, for windows that do not have WS_EX_TOOLWINDOW set, WINDOWPLACEMENT +// is in workspace/available area coordinates. +static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point) +{ +#ifndef Q_OS_WINCE + if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW) + return QPoint(0, 0); + const QWindowsScreenManager &screenManager = QWindowsContext::instance()->screenManager(); + const QWindowsScreen *screen = screenManager.screens().size() == 1 + ? screenManager.screens().first() : screenManager.screenAtDp(point); + if (screen) + return screen->availableGeometryDp().topLeft() - screen->geometryDp().topLeft(); +#else + Q_UNUSED(hwnd) + Q_UNUSED(point) +#endif + return QPoint(0, 0); +} + // Return the frame geometry relative to the parent // if there is one. static inline QRect frameGeometry(HWND hwnd, bool topLevel) @@ -179,8 +198,10 @@ static inline QRect frameGeometry(HWND hwnd, bool topLevel) WINDOWPLACEMENT windowPlacement; windowPlacement.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(hwnd, &windowPlacement); - if (windowPlacement.showCmd == SW_SHOWMINIMIZED) - return qrectFromRECT(windowPlacement.rcNormalPosition); + if (windowPlacement.showCmd == SW_SHOWMINIMIZED) { + const QRect result = qrectFromRECT(windowPlacement.rcNormalPosition); + return result.translated(windowPlacementOffset(hwnd, result.topLeft())); + } } #endif // !Q_OS_WINCE GetWindowRect(hwnd, &rect); // Screen coordinates. @@ -1297,8 +1318,10 @@ static QRect normalFrameGeometry(HWND hwnd) #ifndef Q_OS_WINCE WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); - if (GetWindowPlacement(hwnd, &wp)) - return qrectFromRECT(wp.rcNormalPosition); + if (GetWindowPlacement(hwnd, &wp)) { + const QRect result = qrectFromRECT(wp.rcNormalPosition); + return result.translated(windowPlacementOffset(hwnd, result.topLeft())); + } #else Q_UNUSED(hwnd) #endif @@ -1427,7 +1450,8 @@ void QWindowsWindow::setGeometry_sys(const QRect &rect) const // window, set the normal position of the window. if ((windowPlacement.showCmd == SW_MAXIMIZE && !IsWindowVisible(m_data.hwnd)) || windowPlacement.showCmd == SW_SHOWMINIMIZED) { - windowPlacement.rcNormalPosition = RECTfromQRect(frameGeometry); + windowPlacement.rcNormalPosition = + RECTfromQRect(frameGeometry.translated(-windowPlacementOffset(m_data.hwnd, frameGeometry.topLeft()))); windowPlacement.showCmd = windowPlacement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWMINIMIZED : SW_HIDE; result = SetWindowPlacement(m_data.hwnd, &windowPlacement); } else diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 562328810e1..d977f78b230 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4696,8 +4696,9 @@ void tst_QWidget::setWindowGeometry() void tst_QWidget::setGeometry_win() { QWidget widget; + setFrameless(&widget); - widget.setGeometry(0, 600, 100,100); + widget.setGeometry(QRect(m_availableTopLeft + QPoint(0, 600), QSize(100, 100))); widget.show(); widget.setWindowState(widget.windowState() | Qt::WindowMaximized); QRect geom = widget.normalGeometry(); @@ -4707,8 +4708,10 @@ void tst_QWidget::setGeometry_win() widget.show(); RECT rt; ::GetWindowRect(winHandleOf(&widget), &rt); - QVERIFY2(rt.left <= 0, msgComparisonFailed(int(rt.left), "<=", 0)); - QVERIFY2(rt.top <= 0, msgComparisonFailed(int(rt.top), "<=", 0)); + QVERIFY2(rt.left <= m_availableTopLeft.x(), + msgComparisonFailed(int(rt.left), "<=", m_availableTopLeft.x())); + QVERIFY2(rt.top <= m_availableTopLeft.y(), + msgComparisonFailed(int(rt.top), "<=", m_availableTopLeft.y())); } #endif // defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) From 473ad206c40ac99d00732f5862a51affcd746d2d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 7 Jan 2015 16:00:08 -0800 Subject: [PATCH 031/101] Fix QSharedPointer::create and QEnableSharedFromThis We forgot to initialize the tracker if create() was used. Task-number: QTBUG-43696 Change-Id: Ic5d393bfd36e48a193fcffff13b740931ff2204b Reviewed-by: Marc Mutz --- src/corelib/tools/qsharedpointer_impl.h | 2 ++ .../qsharedpointer/tst_qsharedpointer.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 061c7a5a2db..a18b2c28a12 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -412,6 +412,7 @@ public: # ifdef QT_SHAREDPOINTER_TRACK_POINTERS internalSafetyCheckAdd(result.d, result.value); # endif + result.enableSharedFromThis(result.data()); return result; } #else @@ -432,6 +433,7 @@ public: internalSafetyCheckAdd(result.d, result.value); # endif result.d->setQObjectShared(result.value, true); + result.enableSharedFromThis(result.data()); return result; } diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index d5a628889cb..346ce6fcf9f 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -2355,6 +2355,24 @@ void tst_QSharedPointer::sharedFromThis() QCOMPARE(Data::generationCounter, generations + 4); QCOMPARE(Data::destructorCounter, destructions + 4); + { + QSharedPointer scp2 = QSharedPointer::create(); + QVERIFY(!scp2.isNull()); + + scp = scp2->sharedFromThis(); + QVERIFY(!scp.isNull()); + + QVERIFY(scp == scp2); + QCOMPARE(Data::generationCounter, generations + 5); + QCOMPARE(Data::destructorCounter, destructions + 4); + } + QCOMPARE(Data::generationCounter, generations + 5); + QCOMPARE(Data::destructorCounter, destructions + 4); + + scp.clear(); + + QCOMPARE(Data::generationCounter, generations + 5); + QCOMPARE(Data::destructorCounter, destructions + 5); } namespace ReentrancyWhileDestructing { From 97af289954cf2ae1dc4ddf8636c8d72dee6e679f Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 20 Jan 2015 16:21:05 +0300 Subject: [PATCH 032/101] Doc: Improve description of QTextStream::readLine() Don't recommend a common value for maxlen, because we don't really know it. Soften a statement about not applying QString::trimmed() to the result because it may contain surrounding spaces. Change-Id: Ie90db6f033cfcc0dff0ef6796ba115028bcaaa77 Reviewed-by: David Faure Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qtextstream.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 089a915a361..571875c508d 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -1550,11 +1550,10 @@ QString QTextStream::readAll() the stream contains lines longer than this, then the lines will be split after \a maxlen characters and returned in parts. - If \a maxlen is 0, the lines can be of any length. A common value - for \a maxlen is 75. + If \a maxlen is 0, the lines can be of any length. The returned line has no trailing end-of-line characters ("\\n" - or "\\r\\n"), so calling QString::trimmed() is unnecessary. + or "\\r\\n"), so calling QString::trimmed() can be unnecessary. If the stream has read to the end of the file, \l {QTextStream::readLine()}{readLine()} will return a null QString. For strings, or for devices that support it, From bdbcf6704f4b0e7d9aaa522cc69e730148080cb8 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 21 Jan 2015 13:28:46 +0100 Subject: [PATCH 033/101] Make it possible to generate rcc files from stdin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's already some code to be able to generate the rcc files from stdin, only problem being that the input sanity check was not allowing the code path to proceed being left unreachable. This patch fixes it by allowing "-" as an acceptable argument and the process proceeds as expected. Change-Id: Icd47c7a65373ff1ea3f98d9528736f8a1b21b707 Reviewed-by: Albert Astals Cid Reviewed-by: Tor Arne Vestbø --- src/tools/rcc/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 3c556d76a8a..3c88be92bbd 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -199,7 +199,9 @@ int runRcc(int argc, char *argv[]) const QStringList filenamesIn = parser.positionalArguments(); foreach (const QString &file, filenamesIn) { - if (!QFile::exists(file)) { + if (file == QLatin1String("-")) + continue; + else if (!QFile::exists(file)) { qWarning("%s: File does not exist '%s'", argv[0], qPrintable(file)); return 1; } From 6338b1421ef5a9928df25dde5ef62c6b11682da6 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 16 Jan 2015 10:43:21 +0100 Subject: [PATCH 034/101] Safeguard QScreen::refreshRate against buggy platform behavior Change-Id: I891bd5272db76e8562f6722b633cc0fdaac5f7a2 Task-number: QTBUG-43853 Reviewed-by: Robin Burchell --- src/gui/kernel/qguiapplication.cpp | 11 ++++++++--- src/gui/kernel/qscreen_p.h | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index dc5501eaf59..928d0cddc9b 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2578,9 +2578,14 @@ void QGuiApplicationPrivate::reportRefreshRateChange(QWindowSystemInterfacePriva return; QScreen *s = e->screen.data(); - s->d_func()->refreshRate = e->rate; - - emit s->refreshRateChanged(s->refreshRate()); + qreal rate = e->rate; + // safeguard ourselves against buggy platform behavior... + if (rate < 1.0) + rate = 60.0; + if (!qFuzzyCompare(s->d_func()->refreshRate, rate)) { + s->d_func()->refreshRate = rate; + emit s->refreshRateChanged(s->refreshRate()); + } } void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e) diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h index cdb923c4297..53d4f3404a8 100644 --- a/src/gui/kernel/qscreen_p.h +++ b/src/gui/kernel/qscreen_p.h @@ -64,6 +64,9 @@ public: availableGeometry = platformScreen->availableGeometry(); logicalDpi = platformScreen->logicalDpi(); refreshRate = platformScreen->refreshRate(); + // safeguard ourselves against buggy platform behavior... + if (refreshRate < 1.0) + refreshRate = 60.0; updatePrimaryOrientation(); From 1755038134cfe16d3d52ec2aea543955462e2951 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 18 Jan 2015 21:52:18 +0100 Subject: [PATCH 035/101] QFixed: fix undefined behavior Left-shifting of negative values is undefined ([expr.shift]/2). Use multiplication with 64 instead. There are probably more instances in this class, but this patch already gets rid of vast amounts of ubsan errors in tests/auto/gui/text. Found by UBSan. Change-Id: I89b8bb61e4decba605fe4fb3efea68b1f1eacf1a Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- src/gui/painting/qfixed_p.h | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/gui/painting/qfixed_p.h b/src/gui/painting/qfixed_p.h index 69a7b06780e..a0ac69f02f4 100644 --- a/src/gui/painting/qfixed_p.h +++ b/src/gui/painting/qfixed_p.h @@ -56,10 +56,10 @@ private: Q_DECL_CONSTEXPR QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation public: Q_DECL_CONSTEXPR QFixed() : val(0) {} - Q_DECL_CONSTEXPR QFixed(int i) : val(i<<6) {} - Q_DECL_CONSTEXPR QFixed(long i) : val(i<<6) {} - QFixed &operator=(int i) { val = (i<<6); return *this; } - QFixed &operator=(long i) { val = (i<<6); return *this; } + Q_DECL_CONSTEXPR QFixed(int i) : val(i * 64) {} + Q_DECL_CONSTEXPR QFixed(long i) : val(i * 64) {} + QFixed &operator=(int i) { val = i * 64; return *this; } + QFixed &operator=(long i) { val = i * 64; return *this; } Q_DECL_CONSTEXPR static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); } Q_DECL_CONSTEXPR static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor @@ -70,21 +70,21 @@ public: Q_DECL_CONSTEXPR inline int toInt() const { return (((val)+32) & -64)>>6; } Q_DECL_CONSTEXPR inline qreal toReal() const { return ((qreal)val)/(qreal)64; } - Q_DECL_CONSTEXPR inline int truncate() const { return val>>6; } + Q_DECL_CONSTEXPR inline int truncate() const { return val / 64; } Q_DECL_CONSTEXPR inline QFixed round() const { return fromFixed(((val)+32) & -64); } Q_DECL_CONSTEXPR inline QFixed floor() const { return fromFixed((val) & -64); } Q_DECL_CONSTEXPR inline QFixed ceil() const { return fromFixed((val+63) & -64); } - Q_DECL_CONSTEXPR inline QFixed operator+(int i) const { return fromFixed((val + (i<<6))); } + Q_DECL_CONSTEXPR inline QFixed operator+(int i) const { return fromFixed(val + i * 64); } Q_DECL_CONSTEXPR inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); } Q_DECL_CONSTEXPR inline QFixed operator+(const QFixed &other) const { return fromFixed((val + other.val)); } - inline QFixed &operator+=(int i) { val += (i<<6); return *this; } + inline QFixed &operator+=(int i) { val += i * 64; return *this; } inline QFixed &operator+=(uint i) { val += (i<<6); return *this; } inline QFixed &operator+=(const QFixed &other) { val += other.val; return *this; } - Q_DECL_CONSTEXPR inline QFixed operator-(int i) const { return fromFixed((val - (i<<6))); } + Q_DECL_CONSTEXPR inline QFixed operator-(int i) const { return fromFixed(val - i * 64); } Q_DECL_CONSTEXPR inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); } Q_DECL_CONSTEXPR inline QFixed operator-(const QFixed &other) const { return fromFixed((val - other.val)); } - inline QFixed &operator-=(int i) { val -= (i<<6); return *this; } + inline QFixed &operator-=(int i) { val -= i * 64; return *this; } inline QFixed &operator-=(uint i) { val -= (i<<6); return *this; } inline QFixed &operator-=(const QFixed &other) { val -= other.val; return *this; } Q_DECL_CONSTEXPR inline QFixed operator-() const { return fromFixed(-val); } @@ -162,18 +162,18 @@ Q_DECL_CONSTEXPR inline QFixed operator+(uint i, const QFixed &d) { return d+i; Q_DECL_CONSTEXPR inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); } // Q_DECL_CONSTEXPR inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; } -Q_DECL_CONSTEXPR inline bool operator==(const QFixed &f, int i) { return f.value() == (i<<6); } -Q_DECL_CONSTEXPR inline bool operator==(int i, const QFixed &f) { return f.value() == (i<<6); } -Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &f, int i) { return f.value() != (i<<6); } -Q_DECL_CONSTEXPR inline bool operator!=(int i, const QFixed &f) { return f.value() != (i<<6); } -Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &f, int i) { return f.value() <= (i<<6); } -Q_DECL_CONSTEXPR inline bool operator<=(int i, const QFixed &f) { return (i<<6) <= f.value(); } -Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &f, int i) { return f.value() >= (i<<6); } -Q_DECL_CONSTEXPR inline bool operator>=(int i, const QFixed &f) { return (i<<6) >= f.value(); } -Q_DECL_CONSTEXPR inline bool operator<(const QFixed &f, int i) { return f.value() < (i<<6); } -Q_DECL_CONSTEXPR inline bool operator<(int i, const QFixed &f) { return (i<<6) < f.value(); } -Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > (i<<6); } -Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return (i<<6) > f.value(); } +Q_DECL_CONSTEXPR inline bool operator==(const QFixed &f, int i) { return f.value() == i * 64; } +Q_DECL_CONSTEXPR inline bool operator==(int i, const QFixed &f) { return f.value() == i * 64; } +Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &f, int i) { return f.value() != i * 64; } +Q_DECL_CONSTEXPR inline bool operator!=(int i, const QFixed &f) { return f.value() != i * 64; } +Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &f, int i) { return f.value() <= i * 64; } +Q_DECL_CONSTEXPR inline bool operator<=(int i, const QFixed &f) { return i * 64 <= f.value(); } +Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &f, int i) { return f.value() >= i * 64; } +Q_DECL_CONSTEXPR inline bool operator>=(int i, const QFixed &f) { return i * 64 >= f.value(); } +Q_DECL_CONSTEXPR inline bool operator<(const QFixed &f, int i) { return f.value() < i * 64; } +Q_DECL_CONSTEXPR inline bool operator<(int i, const QFixed &f) { return i * 64 < f.value(); } +Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > i * 64; } +Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return i * 64 > f.value(); } #ifndef QT_NO_DEBUG_STREAM inline QDebug &operator<<(QDebug &dbg, const QFixed &f) From fad17cf79c761a11163df48c70e81e709e6bb9a2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 21 Jan 2015 16:15:28 +0100 Subject: [PATCH 036/101] QFontDatabase: Make assert about failed delayed font population more verbose. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-43774 Change-Id: Ie55de75e31e1e569f4b4e336900a8f96f7c1b9c0 Reviewed-by: Tor Arne Vestbø --- src/gui/text/qfontdatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 99814dba82a..fcdb6ecca99 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -382,7 +382,7 @@ void QtFontFamily::ensurePopulated() return; QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFamily(name); - Q_ASSERT(populated); + Q_ASSERT_X(populated, Q_FUNC_INFO, qPrintable(name)); } class QFontDatabasePrivate From 0eaa86dd018294d1a961f486bf290f8647293c6d Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 1 Jul 2014 15:39:32 +0200 Subject: [PATCH 037/101] Accessibility: Fix selection change notifications on Linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The selection update is not implemented on other platforms (if needed at all). Task-number: QTBUG-39440 Change-Id: I8eb8c4eb1c23ba2d246bc95f1c77dc9da9e22495 Reviewed-by: Jan Arve Sæther --- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 4 ++-- src/widgets/itemviews/qlistview.cpp | 2 +- src/widgets/itemviews/qtableview.cpp | 2 +- src/widgets/itemviews/qtreeview.cpp | 2 +- tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index c3573489e99..c5de6ee533a 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -1047,6 +1047,8 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) } break; } + case QAccessible::SelectionAdd: + case QAccessible::SelectionRemove: case QAccessible::Selection: { QAccessibleInterface * iface = event->accessibleInterface(); if (!iface) { @@ -1104,7 +1106,6 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) case QAccessible::ParentChanged: case QAccessible::DialogStart: case QAccessible::DialogEnd: - case QAccessible::SelectionRemove: case QAccessible::PopupMenuStart: case QAccessible::PopupMenuEnd: case QAccessible::SoundPlayed: @@ -1146,7 +1147,6 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) case QAccessible::TextAttributeChanged: case QAccessible::TextColumnChanged: case QAccessible::VisibleDataChanged: - case QAccessible::SelectionAdd: case QAccessible::SelectionWithin: case QAccessible::LocationChanged: case QAccessible::HelpChanged: diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index e7d18092f12..add60d4d88f 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -3198,7 +3198,7 @@ void QListView::selectionChanged(const QItemSelection &selected, QModelIndex sel = selected.indexes().value(0); if (sel.isValid()) { int entry = visualIndex(sel); - QAccessibleEvent event(this, QAccessible::Selection); + QAccessibleEvent event(this, QAccessible::SelectionAdd); event.setChild(entry); QAccessible::updateAccessibility(&event); } diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index b5eb509766a..be1bfce9ff1 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -3337,7 +3337,7 @@ void QTableView::selectionChanged(const QItemSelection &selected, QModelIndex sel = selected.indexes().value(0); if (sel.isValid()) { int entry = d->accessibleTable2Index(sel); - QAccessibleEvent event(this, QAccessible::Selection); + QAccessibleEvent event(this, QAccessible::SelectionAdd); event.setChild(entry); QAccessible::updateAccessibility(&event); } diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 2c5f4b7c72f..531ef8b8aa0 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -3981,7 +3981,7 @@ void QTreeView::selectionChanged(const QItemSelection &selected, if (sel.isValid()) { int entry = d->accessibleTree2Index(sel); Q_ASSERT(entry >= 0); - QAccessibleEvent event(this, QAccessible::Selection); + QAccessibleEvent event(this, QAccessible::SelectionAdd); event.setChild(entry); QAccessible::updateAccessibility(&event); } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index ef70509541d..e59509a944c 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -2779,7 +2779,7 @@ void tst_QAccessibility::listTest() // Check for events QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(1)).center()); - QAccessibleEvent selectionEvent(listView, QAccessible::Selection); + QAccessibleEvent selectionEvent(listView, QAccessible::SelectionAdd); selectionEvent.setChild(1); QAccessibleEvent focusEvent(listView, QAccessible::Focus); focusEvent.setChild(1); @@ -2787,7 +2787,7 @@ void tst_QAccessibility::listTest() QVERIFY(QTestAccessibility::containsEvent(&focusEvent)); QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(2)).center()); - QAccessibleEvent selectionEvent2(listView, QAccessible::Selection); + QAccessibleEvent selectionEvent2(listView, QAccessible::SelectionAdd); selectionEvent2.setChild(2); QAccessibleEvent focusEvent2(listView, QAccessible::Focus); focusEvent2.setChild(2); @@ -3281,7 +3281,7 @@ void tst_QAccessibility::tableTest() tableView->setSelectionBehavior(QAbstractItemView::SelectItems); tableView->setSelectionMode(QAbstractItemView::SingleSelection); tableView->selectionModel()->select(index00, QItemSelectionModel::ClearAndSelect); - QAccessibleEvent event(tableView, QAccessible::Selection); + QAccessibleEvent event(tableView, QAccessible::SelectionAdd); event.setChild(12); QCOMPARE(QTestAccessibility::containsEvent(&event), true); QTestAccessibility::clearEvents(); From 358a9ac9362917e644e4c09c8d5c85d13faf5503 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sun, 7 Sep 2014 08:48:29 +0200 Subject: [PATCH 038/101] Do not include accessibility.pri twice Change-Id: Id4b312a57b098ad893ba08e7a3c7f1a0fb891eef Reviewed-by: Friedemann Kleint --- src/platformsupport/linuxaccessibility/linuxaccessibility.pri | 1 - tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/linuxaccessibility/linuxaccessibility.pri b/src/platformsupport/linuxaccessibility/linuxaccessibility.pri index 1d51d2876c6..1b65fb1cad6 100644 --- a/src/platformsupport/linuxaccessibility/linuxaccessibility.pri +++ b/src/platformsupport/linuxaccessibility/linuxaccessibility.pri @@ -2,7 +2,6 @@ contains(QT_CONFIG, accessibility-atspi-bridge) { QT_FOR_PRIVATE += dbus include(../../3rdparty/atspi2/atspi2.pri) - include(../accessibility/accessibility.pri) INCLUDEPATH += $$PWD diff --git a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro index cb5bc04c1d7..2ea54ab6032 100644 --- a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro +++ b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro @@ -3,6 +3,7 @@ CONFIG += testcase # This is temporary to start running the test as part of normal CI. CONFIG += insignificant_test # QTBUG-27732 +include($$QT_SOURCE_TREE/src/platformsupport/accessibility/accessibility.pri) include($$QT_SOURCE_TREE/src/platformsupport/linuxaccessibility/linuxaccessibility.pri) TARGET = tst_qaccessibilitylinux From a4c837b3a1168ab07415501f141395dfffc3ed18 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 20 Jan 2015 12:30:26 -0800 Subject: [PATCH 039/101] Fix QUdpSocket's emission of readyRead() The documentation says that QUdpSocket emits readyRead() only for one datagram and that if you don't read it, the class will not emit again. That should be implemented by disabling of the socket notifier once we have the datagram already read, but was broken. In turn, that breakage caused a live-lock of the event loop: since we didn't disable the notifier nor read the pending datagram, the event loop would fire every time for the same datagram. The re-enabling of the notifier was already working. Task-number: QTBUG-43857 Change-Id: Ic5d393bfd36e48a193fcffff13bb32ad390b5fe8 Reviewed-by: Peter Hartmann Reviewed-by: Richard J. Moore --- src/network/socket/qabstractsocket.cpp | 11 ++- .../socket/qudpsocket/tst_qudpsocket.cpp | 90 +++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 604214ce8e6..5a1ad40b901 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -740,8 +740,15 @@ bool QAbstractSocketPrivate::canReadNotification() return true; } - if ((isBuffered || socketType != QAbstractSocket::TcpSocket) && socketEngine) - socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable()); + if (socketEngine) { + // turn the socket engine off if we've either: + // - got pending datagrams + // - reached the buffer size limit + if (isBuffered) + socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable()); + else if (socketType != QAbstractSocket::TcpSocket) + socketEngine->setReadNotificationEnabled(!socketEngine->hasPendingDatagrams()); + } // reset the read socket notifier state if we reentered inside the // readyRead() connected slot. diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index db09ec4486e..49a3a720c77 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Intel Corporation. ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -114,6 +115,8 @@ private slots: void echo(); void linkLocalIPv6(); void linkLocalIPv4(); + void readyRead(); + void readyReadForEmptyDatagram(); protected slots: void empty_readyReadSlot(); @@ -1515,5 +1518,92 @@ void tst_QUdpSocket::linkLocalIPv4() qDeleteAll(sockets); } +void tst_QUdpSocket::readyRead() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + char buf[1]; + QUdpSocket sender, receiver; +#ifdef FORCE_SESSION + sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); + receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); +#endif + + QVERIFY(receiver.bind(QHostAddress(QHostAddress::AnyIPv4), 0)); + quint16 port = receiver.localPort(); + QVERIFY(port != 0); + + QSignalSpy spy(&receiver, SIGNAL(readyRead())); + + // send a datagram to that port + sender.writeDatagram("a", makeNonAny(receiver.localAddress()), port); + + // wait a little + // if QTBUG-43857 is still going, we'll live-lock on socket notifications from receiver's socket + QTest::qWait(100); + + // make sure only one signal was emitted + QCOMPARE(spy.count(), 1); + QVERIFY(receiver.hasPendingDatagrams()); + QCOMPARE(receiver.bytesAvailable(), qint64(1)); + QCOMPARE(receiver.pendingDatagramSize(), qint64(1)); + + // write another datagram + sender.writeDatagram("ab", makeNonAny(receiver.localAddress()), port); + + // no new signal should be emitted because we haven't read the first datagram yet + QTest::qWait(100); + QCOMPARE(spy.count(), 1); + QVERIFY(receiver.hasPendingDatagrams()); + QVERIFY(receiver.bytesAvailable() >= 1); // most likely is 1, but it could be 1 + 2 in the future + QCOMPARE(receiver.pendingDatagramSize(), qint64(1)); + + // read all the datagrams (we could read one only, but we can't be sure the OS is queueing) + while (receiver.hasPendingDatagrams()) + receiver.readDatagram(buf, sizeof buf); + + // write a new datagram and ensure the signal is emitted now + sender.writeDatagram("abc", makeNonAny(receiver.localAddress()), port); + QTest::qWait(100); + QCOMPARE(spy.count(), 2); + QVERIFY(receiver.hasPendingDatagrams()); + QCOMPARE(receiver.bytesAvailable(), qint64(3)); + QCOMPARE(receiver.pendingDatagramSize(), qint64(3)); +} + +void tst_QUdpSocket::readyReadForEmptyDatagram() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + QUdpSocket sender, receiver; +#ifdef FORCE_SESSION + sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); + receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); +#endif + + QVERIFY(receiver.bind(QHostAddress(QHostAddress::AnyIPv4), 0)); + quint16 port = receiver.localPort(); + QVERIFY(port != 0); + + connect(&receiver, SIGNAL(readyRead()), SLOT(empty_readyReadSlot())); + + // send an empty datagram to that port + sender.writeDatagram("", makeNonAny(receiver.localAddress()), port); + + // ensure that we got a readyRead, despite bytesAvailable() == 0 + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); + + char buf[1]; + QVERIFY(receiver.hasPendingDatagrams()); + QCOMPARE(receiver.pendingDatagramSize(), qint64(0)); + QCOMPARE(receiver.bytesAvailable(), qint64(0)); + QCOMPARE(receiver.readDatagram(buf, sizeof buf), qint64(0)); +} + QTEST_MAIN(tst_QUdpSocket) #include "tst_qudpsocket.moc" From c8c68ecb8fc3b713e1b77c15b85ab94c7dde7d67 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Wed, 21 Jan 2015 08:00:34 +0100 Subject: [PATCH 040/101] Autotest: Make mimedatabase testdata resources Change-Id: Ia410d6b0cdece248651213dbbb035c951e5f6983 Reviewed-by: David Faure --- .../qmimedatabase-cache/qmimedatabase-cache.pro | 4 ++-- .../qmimedatabase-xml/qmimedatabase-xml.pro | 3 ++- .../corelib/mimetypes/qmimedatabase/testdata.qrc | 7 +++++++ .../mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 13 ++++++------- 4 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 tests/auto/corelib/mimetypes/qmimedatabase/testdata.qrc diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro index 9f006b4a4fe..d0dbf077c84 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro @@ -6,8 +6,8 @@ QT = core testlib concurrent SOURCES = tst_qmimedatabase-cache.cpp HEADERS = ../tst_qmimedatabase.h - -DEFINES += CORE_SOURCES='"\\"$$QT_SOURCE_TREE/src/corelib\\""' +RESOURCES += $$QT_SOURCE_TREE/src/corelib/mimetypes/mimetypes.qrc +RESOURCES += ../testdata.qrc *-g++*:QMAKE_CXXFLAGS += -W -Wall -Wextra -Wshadow -Wno-long-long -Wnon-virtual-dtor DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro index 8dd8d930c14..6d7cbc6016b 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro @@ -7,7 +7,8 @@ QT = core testlib concurrent SOURCES += tst_qmimedatabase-xml.cpp HEADERS += ../tst_qmimedatabase.h -DEFINES += CORE_SOURCES='"\\"$$QT_SOURCE_TREE/src/corelib\\""' +RESOURCES += $$QT_SOURCE_TREE/src/corelib/mimetypes/mimetypes.qrc +RESOURCES += ../testdata.qrc *-g++*:QMAKE_CXXFLAGS += -W -Wall -Wextra -Wshadow -Wno-long-long -Wnon-virtual-dtor DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/testdata.qrc b/tests/auto/corelib/mimetypes/qmimedatabase/testdata.qrc new file mode 100644 index 00000000000..48d32044733 --- /dev/null +++ b/tests/auto/corelib/mimetypes/qmimedatabase/testdata.qrc @@ -0,0 +1,7 @@ + + + yast2-metapackage-handler-mimetypes.xml + qml-again.xml + test.qml + + diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 6dec691b1f8..686e25c800f 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -45,6 +45,7 @@ static const char yastFileName[] ="yast2-metapackage-handler-mimetypes.xml"; static const char qmlAgainFileName[] ="qml-again.xml"; +#define RESOURCE_PREFIX ":/qt-project.org/qmime/" void initializeLang() { @@ -99,9 +100,7 @@ void tst_QMimeDatabase::initTestCase() << "\nGlobal XDG_DATA_DIRS: " << m_globalXdgDir; const QString freeDesktopXml = QStringLiteral("freedesktop.org.xml"); - const QString xmlFileName = QLatin1String(CORE_SOURCES) - + QStringLiteral("/mimetypes/mime/packages/") - + freeDesktopXml; + const QString xmlFileName = QLatin1String(RESOURCE_PREFIX) + freeDesktopXml; QVERIFY2(QFileInfo(xmlFileName).exists(), qPrintable(xmlFileName + QStringLiteral(" does not exist"))); QFile xml(xmlFileName); QVERIFY(xml.copy(globalPackageDir + '/' + freeDesktopXml)); @@ -110,11 +109,11 @@ void tst_QMimeDatabase::initTestCase() if (m_testSuite.isEmpty()) qWarning("%s", qPrintable(testSuiteWarning())); - m_yastMimeTypes = QFINDTESTDATA(yastFileName); + m_yastMimeTypes = QLatin1String(RESOURCE_PREFIX) + yastFileName; QVERIFY2(!m_yastMimeTypes.isEmpty(), qPrintable(QString::fromLatin1("Cannot find '%1' starting from '%2'"). arg(yastFileName, QDir::currentPath()))); - m_qmlAgainFileName = QFINDTESTDATA(qmlAgainFileName); + m_qmlAgainFileName = QLatin1String(RESOURCE_PREFIX) + qmlAgainFileName; QVERIFY2(!m_qmlAgainFileName.isEmpty(), qPrintable(QString::fromLatin1("Cannot find '%1' starting from '%2'"). arg(qmlAgainFileName, QDir::currentPath()))); @@ -844,7 +843,7 @@ void tst_QMimeDatabase::installNewGlobalMimeType() checkHasMimeType("text/x-suse-ymp"); // Test that a double-definition of a mimetype doesn't lead to sniffing ("conflicting globs"). - const QString qmlTestFile = QFINDTESTDATA("test.qml"); + const QString qmlTestFile = QLatin1String(RESOURCE_PREFIX "test.qml"); QVERIFY2(!qmlTestFile.isEmpty(), qPrintable(QString::fromLatin1("Cannot find '%1' starting from '%2'"). arg("test.qml", QDir::currentPath()))); @@ -893,7 +892,7 @@ void tst_QMimeDatabase::installNewLocalMimeType() checkHasMimeType("text/x-suse-ymp"); // Test that a double-definition of a mimetype doesn't lead to sniffing ("conflicting globs"). - const QString qmlTestFile = QFINDTESTDATA("test.qml"); + const QString qmlTestFile = QLatin1String(RESOURCE_PREFIX "test.qml"); QVERIFY2(!qmlTestFile.isEmpty(), qPrintable(QString::fromLatin1("Cannot find '%1' starting from '%2'"). arg("test.qml", QDir::currentPath()))); From 2ecde56f65c21e91c2d7e9fe72ecb9c9d1ff1d33 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 14 Jan 2015 00:25:26 +0100 Subject: [PATCH 041/101] QSortFilterProxyModel: fix a regression bec1854cc023fb705319c582a636d5f484adafcc introduced a regression: when sorting a tree model, children items would not follow the sorted parents any more (they wouldn't be remapped correctly), resulting in crashes. So, the fix needs more reasoning; let's revert the fix, but leave the original test around for any subsequent attempt, and introduce a new test which looks for the right behavior when sorting trees. This commit partially reverts bec1854cc023fb705319c582a636d5f484adafcc. Task-number: QTBUG-43827 Change-Id: Ic83ac53aef639f870f6c36a8b4b2992f5b485b13 Reviewed-by: David Faure Reviewed-by: Volker Krause (cherry-picked from qtbase/e9ad46ed412987e3e46c5a641e5f30408b97ac90) --- .../itemmodels/qsortfilterproxymodel.cpp | 6 ++- .../tst_qsortfilterproxymodel.cpp | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 0b2b0e41880..b01c9db4186 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -1196,7 +1196,11 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc parents << q->mapFromSource(source_parent); emit q->layoutAboutToBeChanged(parents, QAbstractItemModel::VerticalSortHint); QModelIndexPairList source_indexes = store_persistent_indexes(); - sort_source_rows(m->source_rows, source_parent); + remove_source_items(m->proxy_rows, m->source_rows, source_rows_resort, + source_parent, Qt::Vertical, false); + sort_source_rows(source_rows_resort, source_parent); + insert_source_items(m->proxy_rows, m->source_rows, source_rows_resort, + source_parent, Qt::Vertical, false); update_persistent_indexes(source_indexes); emit q->layoutChanged(parents, QAbstractItemModel::VerticalSortHint); // Make sure we also emit dataChanged for the rows diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 53ed1bc9a06..5bb7ffc4017 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -96,6 +96,7 @@ private slots: void changeSourceData_data(); void changeSourceData(); void changeSourceDataKeepsStableSorting_qtbug1548(); + void resortingDoesNotBreakTreeModels(); void sortFilterRole(); void selectionFilteredOut(); void match_data(); @@ -2029,6 +2030,8 @@ static void checkSortedTableModel(const QAbstractItemModel *model, const QString void tst_QSortFilterProxyModel::changeSourceDataKeepsStableSorting_qtbug1548() { + QSKIP("This test will fail, see QTBUG-1548"); + // Check that emitting dataChanged from the source model // for a change of a role which is not the sorting role // doesn't alter the sorting. In this case, we sort on the DisplayRole, @@ -4028,5 +4031,39 @@ void tst_QSortFilterProxyModel::canDropMimeData() QCOMPARE(proxy.canDropMimeData(0, Qt::CopyAction, -1, -1, proxy.index(row, 0)), row < 5); } +void tst_QSortFilterProxyModel::resortingDoesNotBreakTreeModels() +{ + QStandardItemModel *treeModel = new QStandardItemModel(this); + QStandardItem *e1 = new QStandardItem("Loading..."); + e1->appendRow(new QStandardItem("entry10")); + treeModel->appendRow(e1); + QStandardItem *e0 = new QStandardItem("Loading..."); + e0->appendRow(new QStandardItem("entry00")); + e0->appendRow(new QStandardItem("entry01")); + treeModel->appendRow(e0); + + QSortFilterProxyModel proxy; + proxy.setDynamicSortFilter(true); + proxy.sort(0); + proxy.setSourceModel(treeModel); + + ModelTest modelTest(&proxy); + + QCOMPARE(proxy.rowCount(), 2); + e1->setText("entry1"); + e0->setText("entry0"); + + QModelIndex pi0 = proxy.index(0, 0); + QCOMPARE(pi0.data().toString(), QString("entry0")); + QCOMPARE(proxy.rowCount(pi0), 2); + + QModelIndex pi01 = proxy.index(1, 0, pi0); + QCOMPARE(pi01.data().toString(), QString("entry01")); + + QModelIndex pi1 = proxy.index(1, 0); + QCOMPARE(pi1.data().toString(), QString("entry1")); + QCOMPARE(proxy.rowCount(pi1), 1); +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" From 9e4ef3539a5770f1b422b73b41dc3218ff4efc81 Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Tue, 20 Jan 2015 12:40:50 +0100 Subject: [PATCH 042/101] Fix finding widgets for Windows Embedded Compact ChildWindowFromPoint does not work properly under wince, so lets use the plain old WindowFromPoint. Task-number: QTBUG-44022 Change-Id: I49bae6409f2d11ddc01bea01f4c2f91a02b90892 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 13a3d044a05..ffa7f82d8e2 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -676,7 +676,7 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c const HWND child = ChildWindowFromPointEx(*hwnd, point, cwexFlags); #else Q_UNUSED(cwexFlags) - const HWND child = ChildWindowFromPoint(*hwnd, point); + const HWND child = WindowFromPoint(point); #endif if (!child || child == *hwnd) return false; From 508b1fa173e135c839f07e0e4cd6009ac63a577c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 20 Jan 2015 09:34:42 +0100 Subject: [PATCH 043/101] QTemporaryDir: Remove directories on failure When creating a temporary directory but failing to set its permissions, we need to remove the directory we created to avoid leaving 256 empty, unused directories in the destination folder. This happens on Android if you try creating a QTemporaryDir in the download path on the sdcard. Task-number: QTBUG-43352 Change-Id: Ic88fb7572f1abd65e5c7d8882b59c95f4b22ed72 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/io/qtemporarydir.cpp | 5 ++++- .../corelib/io/qtemporarydir/tst_qtemporarydir.cpp | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp index 5e0def74eeb..5f0c5001838 100644 --- a/src/corelib/io/qtemporarydir.cpp +++ b/src/corelib/io/qtemporarydir.cpp @@ -128,8 +128,11 @@ static char *q_mkdtemp(char *templateName) QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner, error); - if (error.error() != 0) + if (error.error() != 0) { + if (!QFileSystemEngine::removeDirectory(fileSystemEntry, false)) + qWarning() << "Unable to remove unused directory" << templateNameStr; continue; + } return templateName; } } diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index a68a1185b81..e909b90a128 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -70,6 +70,8 @@ private slots: void QTBUG_4796_data(); void QTBUG_4796(); + void QTBUG43352_failedSetPermissions(); + public: }; @@ -419,5 +421,17 @@ void tst_QTemporaryDir::QTBUG_4796() // unicode support cleaner.reset(); } +void tst_QTemporaryDir::QTBUG43352_failedSetPermissions() +{ + QString path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QStringLiteral("/"); + int count = QDir(path).entryList().size(); + + { + QTemporaryDir dir(path); + } + + QCOMPARE(QDir(path).entryList().size(), count); +} + QTEST_MAIN(tst_QTemporaryDir) #include "tst_qtemporarydir.moc" From 0c4c841ce8cd3a3b8ebc636dd41f7c7a2011991d Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Wed, 21 Jan 2015 22:20:26 +0100 Subject: [PATCH 044/101] Fix invalid memory access when a slot deletes the sender. Only happens with active signal spy callbacks. The Connection object can be deleted when returning from the slot here, so accessing it for the method index for the signal end callback will access invalid memory. Change-Id: I44643a171863c35a94e7a5ffa096fcaac5abd509 Reviewed-by: Milian Wolff Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a1a04b3ce58..f2ceb7081cc 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3710,13 +3710,14 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i } else if (callFunction && c->method_offset <= receiver->metaObject()->methodOffset()) { //we compare the vtable to make sure we are not in the destructor of the object. locker.unlock(); + const int methodIndex = c->method(); if (qt_signal_spy_callback_set.slot_begin_callback != 0) - qt_signal_spy_callback_set.slot_begin_callback(receiver, c->method(), argv ? argv : empty_argv); + qt_signal_spy_callback_set.slot_begin_callback(receiver, methodIndex, argv ? argv : empty_argv); callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv ? argv : empty_argv); if (qt_signal_spy_callback_set.slot_end_callback != 0) - qt_signal_spy_callback_set.slot_end_callback(receiver, c->method()); + qt_signal_spy_callback_set.slot_end_callback(receiver, methodIndex); locker.relock(); } else { const int method = method_relative + c->method_offset; From 586fd042345b619acceafb13e84b912863961e56 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 21 Jan 2015 12:55:42 +0100 Subject: [PATCH 045/101] OS X/iOS: Fix stretched font rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Setting the stretch of a QFont did not work correctly on OS X or iOS. Two things are needed to make it work: First of all, we need to properly set the transform when creating the CTFont. In addition, we need to manually scale the advances, as CTRunGetPositions() does not do this for us. On OS X 10.6, however, there was a regression and CTRunGetPositions() would return scaled positions, so we exclude the step to scale the advances on this particular version. This is an adaptation of bc25cfdd65452efa226cbd544c9ae9803eb6748a in Qt 4. [ChangeLog][QtGui][OS X/iOS] Fixed a bug when rendering fonts that were set to be stretched. Task-number: QTBUG-43801 Change-Id: I4902a9f5e29299761e3c2c5c6d6d80ee1dea1a25 Reviewed-by: Tor Arne Vestbø --- src/gui/text/qtextengine.cpp | 9 +++++++++ .../fontdatabases/mac/qcoretextfontdatabase.mm | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index d156124b984..8f60847250e 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1237,6 +1237,15 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st } #ifdef Q_OS_MAC + // CTRunGetPosition has a bug which applies matrix on 10.6, so we disable + // scaling the advances for this particular version + if (actualFontEngine->fontDef.stretch != 100 + && QSysInfo::MacintoshVersion != QSysInfo::MV_10_6) { + QFixed stretch = QFixed(actualFontEngine->fontDef.stretch) / QFixed(100); + for (uint i = 0; i < num_glyphs; ++i) + g.advances[i] *= stretch; + } + if (actualFontEngine->fontDef.styleStrategy & QFont::ForceIntegerMetrics) { for (uint i = 0; i < num_glyphs; ++i) g.advances[i] = g.advances[i].round(); diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 5a6c5de0b4b..fe408305e03 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -370,6 +370,8 @@ void QCoreTextFontDatabase::releaseHandle(void *handle) CFRelease(CTFontDescriptorRef(handle)); } +extern CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef); + QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, void *usrPtr) { qreal scaledPointSize = f.pixelSize; @@ -384,7 +386,8 @@ QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, void *usrPtr) scaledPointSize = f.pointSize; CTFontDescriptorRef descriptor = (CTFontDescriptorRef) usrPtr; - CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, scaledPointSize, NULL); + CGAffineTransform matrix = qt_transform_from_fontdef(f); + CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, scaledPointSize, &matrix); if (font) { QFontEngine *engine = new QCoreTextFontEngine(font, f); engine->fontDef = f; From 06602f9c96e9ea07851fa1d8a43b9792a825c4cd Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Jan 2015 10:48:39 +0100 Subject: [PATCH 046/101] Android: Don't force-include android-9 headers in qpa plugin When we supported platforms < android-9, we needed to include some headers which were introduced in android-9 to compile the QPA plugin. This is no longer needed, and also creates problems when you pick e.g. android-21 as your platform, since some definitions (specifically fd_set) are different in the two sets of headers, giving us an undefined reference to QEventDispatcherUNIX::select(). Change-Id: Ifd28479b4bf3be0e9e62200a01fc4cf2cc855215 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/android.pro | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro index 3c3a4b4b2ed..e6f4db0e947 100644 --- a/src/plugins/platforms/android/android.pro +++ b/src/plugins/platforms/android/android.pro @@ -8,12 +8,7 @@ DEFINES += QT_STATICPLUGIN load(qt_plugin) -!contains(ANDROID_PLATFORM, android-9) { - INCLUDEPATH += $$NDK_ROOT/platforms/android-9/arch-$$ANDROID_ARCHITECTURE/usr/include - LIBS += -L$$NDK_ROOT/platforms/android-9/arch-$$ANDROID_ARCHITECTURE/usr/lib -ljnigraphics -landroid -} else { - LIBS += -ljnigraphics -landroid -} +LIBS += -ljnigraphics -landroid QT += core-private gui-private platformsupport-private From db853fa75dc6598b30ce512997fc8bad0a37354f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Jan 2015 10:52:33 +0100 Subject: [PATCH 047/101] Android: Fix name of header in .pro file Gets rid of warning that the file is missing, but probably doesn't have any other effect since the file in question does not require moc-ing. Change-Id: I22085a55c212b6285341d61462dfaf548787e11c Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/android.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro index e6f4db0e947..3ba817bf5bc 100644 --- a/src/plugins/platforms/android/android.pro +++ b/src/plugins/platforms/android/android.pro @@ -49,7 +49,7 @@ SOURCES += $$PWD/androidplatformplugin.cpp \ $$PWD/qandroideventdispatcher.cpp HEADERS += $$PWD/qandroidplatformintegration.h \ - $$PWD/androidandroiddeadlockprotector.h \ + $$PWD/androiddeadlockprotector.h \ $$PWD/androidjnimain.h \ $$PWD/androidjniaccessibility.h \ $$PWD/androidjniinput.h \ From 2f097d4e239938f2ef752f416066ff5a1f1954a4 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 6 Jan 2015 12:18:00 +0100 Subject: [PATCH 048/101] Doc: fix copy/paste error in QTextCharFormat::setFont documentation Change-Id: I2190975762c6283daa004b754da607829d263b0a Reviewed-by: Konstantin Ritt --- src/gui/text/qtextformat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index ecd87188e77..fa294e44fdc 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -1904,7 +1904,7 @@ void QTextCharFormat::setFont(const QFont &font) If \a behavior is QTextCharFormat::FontPropertiesAll, the font property that has not been explicitly set is treated like as it were set with default value; - If \a behavior is QTextCharFormat::FontPropertiesAll, the font property that + If \a behavior is QTextCharFormat::FontPropertiesSpecifiedOnly, the font property that has not been explicitly set is ignored and the respective property value remains unchanged. From 416c09920544b12e24813e53aa6dbe8ed87e111e Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 15 Jan 2015 13:20:29 +0100 Subject: [PATCH 049/101] Doc: remove wrong note in QTreeWidget::itemWidget. The note is already in setItemWidget where it makes sense. This looks like a copy/paste error; this method doesn't change anything in terms of ownership, it's a getter. Change-Id: Idc963787b81f53fb37bbe59e9bf35f47d3441b34 Reviewed-by: Jarek Kobus --- src/widgets/itemviews/qtreewidget.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 0a4e57812a0..7378b9979a1 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -2934,8 +2934,6 @@ void QTreeWidget::closePersistentEditor(QTreeWidgetItem *item, int column) Returns the widget displayed in the cell specified by \a item and the given \a column. - \note The tree takes ownership of the widget. - */ QWidget *QTreeWidget::itemWidget(QTreeWidgetItem *item, int column) const { From 2b5df245d6cdbfb3150ee815debccf655af8f19f Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Tue, 20 Jan 2015 13:17:36 +0100 Subject: [PATCH 050/101] Implement Multitouch handling for WinCE Implemented handling of GID_DirectManipulation for WinCE. Derive touch information out of gesture event directmanipulation. Task-number: QTBUG-31216 Change-Id: I74e90f32d2384fc3550b47af0b72edf0292dea8f Reviewed-by: Friedemann Kleint --- .../platforms/windows/qtwindows_additional.h | 4 + .../platforms/windows/qtwindowsglobal.h | 3 + .../platforms/windows/qwindowscontext.cpp | 2 + .../windows/qwindowsmousehandler.cpp | 86 ++++++++++++++++++- .../platforms/windows/qwindowsmousehandler.h | 4 + .../platforms/windows/qwindowswindow.cpp | 4 + 6 files changed, 100 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qtwindows_additional.h b/src/plugins/platforms/windows/qtwindows_additional.h index 9451b9ce559..4e773501322 100644 --- a/src/plugins/platforms/windows/qtwindows_additional.h +++ b/src/plugins/platforms/windows/qtwindows_additional.h @@ -166,4 +166,8 @@ typedef TOUCHINPUT const * PCTOUCHINPUT; #endif // if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE) +#ifndef WM_GESTURE +# define WM_GESTURE 0x0119 +#endif + #endif // QTWINDOWS_ADDITIONAL_H diff --git a/src/plugins/platforms/windows/qtwindowsglobal.h b/src/plugins/platforms/windows/qtwindowsglobal.h index 90e6d6ab9d7..083d82ed8c9 100644 --- a/src/plugins/platforms/windows/qtwindowsglobal.h +++ b/src/plugins/platforms/windows/qtwindowsglobal.h @@ -109,6 +109,7 @@ enum WindowsEventType // Simplify event types DisplayChangedEvent = 437, SettingChangedEvent = DisplayChangedEvent + 1, ContextMenu = 123, + GestureEvent = 124, UnknownEvent = 542 }; @@ -247,6 +248,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI case WM_APPCOMMAND: return QtWindows::AppCommandEvent; #endif + case WM_GESTURE: + return QtWindows::GestureEvent; default: break; } diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 2dab4f699fe..1cc596ca8d9 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -905,6 +905,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, return QWindowsInputContext::instance()->endComposition(hwnd); case QtWindows::InputMethodRequest: return QWindowsInputContext::instance()->handleIME_Request(wParam, lParam, result); + case QtWindows::GestureEvent: + return d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result); case QtWindows::InputMethodOpenCandidateWindowEvent: case QtWindows::InputMethodCloseCandidateWindowEvent: // TODO: Release/regrab mouse if a popup has mouse grab. diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index acb692579bc..0fa34041d6f 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -422,11 +422,12 @@ bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND, } // from bool QApplicationPrivate::translateTouchEvent() -bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, +bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType, MSG msg, LRESULT *) { #ifndef Q_OS_WINCE + Q_UNUSED(hwnd); typedef QWindowSystemInterface::TouchPoint QTouchPoint; typedef QList QTouchPointList; @@ -495,8 +496,87 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, m_touchDevice, touchPoints); return true; -#else - return false; +#else //Q_OS_WINCE + GESTUREINFO gi; + memset(&gi, 0, sizeof(GESTUREINFO)); + gi.cbSize = sizeof(GESTUREINFO); + + if (!GetGestureInfo((HGESTUREINFO)msg.lParam, &gi)) + return false; + + const QPoint position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y); + + if (gi.dwID != GID_DIRECTMANIPULATION) + return true; + static QPoint lastTouchPos; + const QRect screenGeometry = window->screen()->geometry(); + QWindowSystemInterface::TouchPoint touchPoint; + static QWindowSystemInterface::TouchPoint touchPoint2; + touchPoint.id = 0;//gi.dwInstanceID; + touchPoint.pressure = 1.0; + + if (gi.dwFlags & GF_BEGIN) + touchPoint.state = Qt::TouchPointPressed; + else if (gi.dwFlags & GF_END) + touchPoint.state = Qt::TouchPointReleased; + else if (gi.dwFlags == 0) + touchPoint.state = Qt::TouchPointMoved; + else + return true; + touchPoint2.pressure = 1.0; + touchPoint2.id = 1; + const QPoint winEventPosition = position; + const int deltaX = GID_DIRECTMANIPULATION_DELTA_X(gi.ullArguments); + const int deltaY = GID_DIRECTMANIPULATION_DELTA_Y(gi.ullArguments); + //Touch points are taken from the whole screen so map the position to the screen + const QPoint globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition); + const QPoint globalPosition2 = QWindowsGeometryHint::mapToGlobal(hwnd, QPoint(position.x() + deltaX, position.y() + deltaY)); + + touchPoint.normalPosition = + QPointF( (qreal)globalPosition.x() / screenGeometry.width(), (qreal)globalPosition.y() / screenGeometry.height() ); + + touchPoint.area.moveCenter(globalPosition); + + QList pointList; + pointList.append(touchPoint); + if (deltaX != 0 && deltaY != 0) { + touchPoint2.state = m_had2ndTouchPoint ? Qt::TouchPointMoved : Qt::TouchPointPressed; + m_had2ndTouchPoint = true; + touchPoint2.normalPosition = + QPointF( (qreal)globalPosition2.x() / screenGeometry.width(), (qreal)globalPosition2.y() / screenGeometry.height() ); + + touchPoint2.area.moveCenter(globalPosition2); + lastTouchPos = globalPosition2; + pointList.append(touchPoint2); + } else if (m_had2ndTouchPoint) { + touchPoint2.normalPosition = + QPointF( (qreal)lastTouchPos.x() / screenGeometry.width(), (qreal)lastTouchPos.y() / screenGeometry.height() ); + + touchPoint2.area.moveCenter(lastTouchPos); + touchPoint2.state = Qt::TouchPointReleased; + pointList.append(touchPoint2); + m_had2ndTouchPoint = false; + } + + if (!m_touchDevice) { + m_touchDevice = new QTouchDevice; + // TODO: Device used to be hardcoded to screen in previous code. + m_touchDevice->setType(QTouchDevice::TouchScreen); + m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition); + QWindowSystemInterface::registerTouchDevice(m_touchDevice); + } + + QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, pointList); + // handle window focusing in/out + if (window != m_windowUnderMouse) { + if (m_windowUnderMouse) + QWindowSystemInterface::handleLeaveEvent(m_windowUnderMouse); + if (window) + QWindowSystemInterface::handleEnterEvent(window); + m_windowUnderMouse = window; + } + + return true; #endif } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h index 6491de93b51..60fe26b2b98 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.h +++ b/src/plugins/platforms/windows/qwindowsmousehandler.h @@ -79,6 +79,10 @@ private: QTouchDevice *m_touchDevice; bool m_leftButtonDown; QWindow *m_previousCaptureWindow; +#ifdef Q_OS_WINCE +//This is required to send a touch up if we don't get a second touch position any more + bool m_had2ndTouchPoint; +#endif }; Qt::MouseButtons QWindowsMouseHandler::keyStateToMouseButtons(int wParam) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index fbb61a1aff2..2e5308f1570 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -639,6 +639,10 @@ QWindowsWindowData context->frameX, context->frameY, context->frameWidth, context->frameHeight, parentHandle, NULL, appinst, NULL); +#ifdef Q_OS_WINCE + if (DisableGestures(result.hwnd, TGF_GID_ALL, TGF_SCOPE_WINDOW)) + EnableGestures(result.hwnd, TGF_GID_DIRECTMANIPULATION, TGF_SCOPE_WINDOW); +#endif qCDebug(lcQpaWindows).nospace() << "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: " << context->obtainedGeometry << context->margins; From 03dc2b2e82750d1c531cf00a406368cde4a8928b Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sun, 11 Jan 2015 12:05:55 +0300 Subject: [PATCH 051/101] QSystemTrayIcon: handle submenus correctly This fixes a bug when submenus are shown as simple actions when a platform system tray icon is used. To correctly handle submenus, we need to set platform menus on all submenus, and only then on a parent menu. Change-Id: If2bfcc703b938dbb14ba4b9aa810039ced07e946 Reviewed-by: Friedemann Kleint Reviewed-by: Dimitrios Glentadakis Reviewed-by: Shawn Rutledge --- src/widgets/util/qsystemtrayicon.cpp | 28 +++++++++++++++++++++++----- src/widgets/util/qsystemtrayicon_p.h | 1 + 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 7d04cab05e7..d151e57d048 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -37,6 +37,7 @@ #ifndef QT_NO_SYSTEMTRAYICON #include "qmenu.h" +#include "qlist.h" #include "qevent.h" #include "qpoint.h" #include "qlabel.h" @@ -704,11 +705,7 @@ void QSystemTrayIconPrivate::updateIcon_sys_qpa() void QSystemTrayIconPrivate::updateMenu_sys_qpa() { if (menu) { - if (!menu->platformMenu()) { - QPlatformMenu *platformMenu = qpa_sys->createMenu(); - if (platformMenu) - menu->setPlatformMenu(platformMenu); - } + addPlatformMenu(menu); qpa_sys->updateMenu(menu->platformMenu()); } } @@ -741,6 +738,27 @@ void QSystemTrayIconPrivate::showMessage_sys_qpa(const QString &message, static_cast(icon), msecs); } +void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const +{ + if (menu->platformMenu()) + return; // The platform menu already exists. + + // The recursion depth is the same as menu depth, so should not + // be higher than 3 levels. + QListIterator it(menu->actions()); + while (it.hasNext()) { + QAction *action = it.next(); + if (action->menu()) + addPlatformMenu(action->menu()); + } + + // This menu should be processed *after* its children, otherwise + // setMenu() is not called on respective QPlatformMenuItems. + QPlatformMenu *platformMenu = qpa_sys->createMenu(); + if (platformMenu) + menu->setPlatformMenu(platformMenu); +} + QT_END_NAMESPACE #endif // QT_NO_SYSTEMTRAYICON diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h index 0dda689c514..f05bf9e3f9a 100644 --- a/src/widgets/util/qsystemtrayicon_p.h +++ b/src/widgets/util/qsystemtrayicon_p.h @@ -99,6 +99,7 @@ private: void updateMenu_sys_qpa(); QRect geometry_sys_qpa() const; void showMessage_sys_qpa(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs); + void addPlatformMenu(QMenu *menu) const; }; class QBalloonTip : public QWidget From 5b1da97b6b4a011f9ce5582869a7a957f6f1369c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 21 Jan 2015 13:23:41 +0100 Subject: [PATCH 052/101] Revert "Fix font enumeration, with the same family name, on Windows." This reverts commit 8456adf0eeb9df8dd5f0547d4ad5a81888295f03. The change introduces a massive slowdown of the application startup caused by the inner enumeration. Task-number: QTBUG-43774 Task-number: QTBUG-40828 Change-Id: I694938eab93ea409d97537b55e8a025bb7a0e393 Reviewed-by: Konstantin Ritt --- .../windows/qwindowsfontdatabase.cpp | 36 ++----------------- .../windows/qwindowsfontdatabase_ft.cpp | 36 ++----------------- 2 files changed, 4 insertions(+), 68 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index f15783490e0..246032dc948 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -964,31 +964,6 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr return 1; } -static int QT_WIN_CALLBACK storeFontSub(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, - int type, LPARAM namesSetIn) -{ - Q_UNUSED(textmetric) - Q_UNUSED(type) - - HDC dummy = GetDC(0); - LOGFONT lf; - lf.lfCharSet = DEFAULT_CHARSET; - if (wcslen(f->elfLogFont.lfFaceName) >= LF_FACESIZE) { - qWarning("%s: Unable to enumerate family '%s'.", - __FUNCTION__, qPrintable(QString::fromWCharArray(f->elfLogFont.lfFaceName))); - return 1; - } - wmemcpy(lf.lfFaceName, f->elfLogFont.lfFaceName, - wcslen(f->elfLogFont.lfFaceName) + 1); - lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)namesSetIn, 0); - ReleaseDC(0, dummy); - - // keep on enumerating - return 1; -} - void QWindowsFontDatabase::populateFontDatabase() { m_families.clear(); @@ -1024,15 +999,8 @@ void QWindowsFontDatabase::populate(const QString &family) wmemcpy(lf.lfFaceName, reinterpret_cast(family.utf16()), family.size() + 1); lf.lfPitchAndFamily = 0; - - if (family.isEmpty()) { - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFontSub, - (LPARAM)&m_families, 0); - } else { - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)&m_families, 0); - } - + EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, + (LPARAM)&m_families, 0); ReleaseDC(0, dummy); } diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index 42e5a8c6ad9..0fc5e0dc0c4 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -375,31 +375,6 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr return 1; } -static int QT_WIN_CALLBACK storeFontSub(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, - int type, LPARAM namesSetIn) -{ - Q_UNUSED(textmetric) - Q_UNUSED(type) - - HDC dummy = GetDC(0); - LOGFONT lf; - lf.lfCharSet = DEFAULT_CHARSET; - if (wcslen(f->elfLogFont.lfFaceName) >= LF_FACESIZE) { - qWarning("%s: Unable to enumerate family '%s'.", - __FUNCTION__, qPrintable(QString::fromWCharArray(f->elfLogFont.lfFaceName))); - return 1; - } - wmemcpy(lf.lfFaceName, f->elfLogFont.lfFaceName, - wcslen(f->elfLogFont.lfFaceName) + 1); - lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)namesSetIn, 0); - ReleaseDC(0, dummy); - - // keep on enumerating - return 1; -} - void QWindowsFontDatabaseFT::populateFontDatabase() { m_families.clear(); @@ -434,15 +409,8 @@ void QWindowsFontDatabaseFT::populate(const QString &family) wmemcpy(lf.lfFaceName, reinterpret_cast(family.utf16()), family.size() + 1); lf.lfPitchAndFamily = 0; - - if (family.isEmpty()) { - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFontSub, - (LPARAM)&m_families, 0); - } else { - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)&m_families, 0); - } - + EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, + (LPARAM)&m_families, 0); ReleaseDC(0, dummy); } From 560c8ac09865caa93228da8c343a93dce6ba01d2 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 14 Jan 2015 12:44:29 +0100 Subject: [PATCH 053/101] Android: Fix some tests for QCompleter When checking for completion on the file system, we need to check for directories that actually exists. Change-Id: Id83e3802abcd40355dcd8cd47f2d55061eacd117 Reviewed-by: Christian Stromme --- tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index 1d6e75e76e6..f8f39003721 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -601,6 +601,9 @@ void tst_QCompleter::directoryModel_data() QTest::newRow("()") << "" << "" << "/" << "/"; QTest::newRow("(/a)") << "/a" << "" << "Applications" << "/Applications"; QTest::newRow("(/u)") << "/u" << "" << "Users" << "/Users"; +#elif defined(Q_OS_ANDROID) + QTest::newRow("()") << "" << "" << "/" << "/"; + QTest::newRow("(/et)") << "/et" << "" << "etc" << "/etc"; #else QTest::newRow("()") << "" << "" << "/" << "/"; #if !defined(Q_OS_IRIX) && !defined(Q_OS_AIX) && !defined(Q_OS_HPUX) && !defined(Q_OS_QNX) @@ -647,6 +650,9 @@ void tst_QCompleter::fileSystemModel_data() QTest::newRow("()") << "" << "" << "/" << "/"; QTest::newRow("(/a)") << "/a" << "" << "Applications" << "/Applications"; // QTest::newRow("(/d)") << "/d" << "" << "Developer" << "/Developer"; +#elif defined(Q_OS_ANDROID) + QTest::newRow("()") << "" << "" << "/" << "/"; + QTest::newRow("(/et)") << "/et" << "" << "etc" << "/etc"; #else QTest::newRow("()") << "" << "" << "/" << "/"; #if !defined(Q_OS_IRIX) && !defined(Q_OS_AIX) && !defined(Q_OS_HPUX) && !defined(Q_OS_QNX) From cebd6d59cb52bad59e4056691c8eb04690858897 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 22 Jan 2015 16:53:16 +0100 Subject: [PATCH 054/101] Diaglib: Fix compilation with Qt 5.3. QDebug does not have noquote() in Qt 5.3. Task-number: QTBUG-44021 Change-Id: If35b926d6b1e5bb9ad3534357630533dfcecd076 Reviewed-by: Kai Koehne --- tests/manual/diaglib/nativewindowdump_win.cpp | 2 +- tests/manual/diaglib/qwidgetdump.cpp | 2 +- tests/manual/diaglib/qwindowdump.cpp | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/manual/diaglib/nativewindowdump_win.cpp b/tests/manual/diaglib/nativewindowdump_win.cpp index 814b580f4b0..a8e715583da 100644 --- a/tests/manual/diaglib/nativewindowdump_win.cpp +++ b/tests/manual/diaglib/nativewindowdump_win.cpp @@ -166,7 +166,7 @@ static void dumpNativeWindows(const WIdVector& wins) dc.stream = QSharedPointer(new QTextStream(&s)); foreach (WId win, wins) dumpNativeWindowRecursion(reinterpret_cast(win), &dc); -#if QT_VERSION > 0x050000 +#if QT_VERSION >= 0x050400 qDebug().noquote() << s; #else qDebug("%s", qPrintable(s)); diff --git a/tests/manual/diaglib/qwidgetdump.cpp b/tests/manual/diaglib/qwidgetdump.cpp index d4f985c7c82..894f51bce36 100644 --- a/tests/manual/diaglib/qwidgetdump.cpp +++ b/tests/manual/diaglib/qwidgetdump.cpp @@ -84,7 +84,7 @@ void dumpAllWidgets(FormatWindowOptions options) str << "### QWidgets:\n"; foreach (QWidget *tw, QApplication::topLevelWidgets()) dumpWidgetRecursion(str, tw, options); -#if QT_VERSION > 0x050000 +#if QT_VERSION >= 0x050400 qDebug().noquote() << d; #else qDebug("%s", qPrintable(d)); diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp index 2ecc52ca779..228472cd448 100644 --- a/tests/manual/diaglib/qwindowdump.cpp +++ b/tests/manual/diaglib/qwindowdump.cpp @@ -157,7 +157,11 @@ void dumpAllWindows(FormatWindowOptions options) str << "### QWindows:\n"; foreach (QWindow *w, QGuiApplication::topLevelWindows()) dumpWindowRecursion(str, w, options); +#if QT_VERSION >= 0x050400 qDebug().noquote() << d; +#else + qDebug() << d; +#endif } #else // Qt 5 From 906577c8b0045724b9b961926085e933c8e0d339 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 9 Dec 2014 15:10:09 +0100 Subject: [PATCH 055/101] Enter/Return should cause an edit inside an itemview on OS X This was available before but was protected with the wrong define for OS X, so this is changed to the right define. Task-number: QTBUG-23696 QTBUG-23703 Change-Id: I669a6cf2ff7c01020693adff9f04a4b8b9404d02 Reviewed-by: David Faure --- src/widgets/itemviews/qabstractitemview.cpp | 4 ++-- tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 3 --- tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 0f346a96821..9b8c19df6d4 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -2388,7 +2388,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) } #endif break; -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC case Qt::Key_Enter: case Qt::Key_Return: // Propagate the enter if you couldn't edit the item and there are no @@ -2418,7 +2418,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) selectAll(); break; } -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC if (event->key() == Qt::Key_O && event->modifiers() & Qt::ControlModifier && currentIndex().isValid()) { emit activated(currentIndex()); break; diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 92200618d6b..92f768586a7 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -1299,9 +1299,6 @@ void tst_QFiledialog::clearLineEdit() #endif QTest::qWait(2000); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23703", Abort); -#endif QVERIFY(fd.directory().absolutePath() != QDir::home().absolutePath()); QVERIFY(!lineEdit->text().isEmpty()); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 6ab93ba6dba..0ca836d9463 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -861,9 +861,6 @@ void tst_QTreeView::editTriggers() } // Check if we got an editor -#ifdef Q_OS_MAC - QEXPECT_FAIL("EditKeyPressed 4", "QTBUG-23696", Continue); -#endif QTRY_COMPARE(view.findChild(QString()) != 0, editorOpened); } From ff59d73ac6e964212b5e3ff16a30e88e828f01b2 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 19 Jan 2015 19:02:38 +0400 Subject: [PATCH 056/101] Fix typo in the docs QEvent::ChildRemoved appeared twice. Change-Id: Ibd992f18d073a3ba47ab515368d2050d29e8c0e6 Reviewed-by: Oswald Buddenhagen --- src/corelib/kernel/qcoreevent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index 191ceaa37b1..85b7f51bd6d 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -538,7 +538,7 @@ QTimerEvent::~QTimerEvent() \a child. \a type can be QEvent::ChildAdded, QEvent::ChildRemoved, - QEvent::ChildPolished, or QEvent::ChildRemoved. + or QEvent::ChildPolished. \sa child() */ From 83097588797c5d0d549d70621b6f5158dfd3fac7 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Mon, 19 Jan 2015 18:18:30 +0200 Subject: [PATCH 057/101] QTextCharFormat: fix word spacing setup Properly check QFont::WordSpacingResolved when use setFont() with QTextCharFormat::FontPropertiesSpecifiedOnly Change-Id: I72f1641ef7587cbaf8fcf5fef2f3c44393b0ebfc Reviewed-by: Konstantin Ritt --- src/gui/text/qtextformat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index fa294e44fdc..0bffbcc802d 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -1942,7 +1942,7 @@ void QTextCharFormat::setFont(const QFont &font, FontPropertiesInheritanceBehavi setFontFixedPitch(font.fixedPitch()); if (mask & QFont::CapitalizationResolved) setFontCapitalization(font.capitalization()); - if (mask & QFont::LetterSpacingResolved) + if (mask & QFont::WordSpacingResolved) setFontWordSpacing(font.wordSpacing()); if (mask & QFont::LetterSpacingResolved) { setFontLetterSpacingType(font.letterSpacingType()); From 3527fd62c2705a0292458dd751d9d7f8d4be357f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 18 Jan 2015 21:47:40 +0100 Subject: [PATCH 058/101] src/gui/painting/painting.pri: add missing qfixed_p.h Change-Id: Iba176345ec9448c936cd89b06ea24272df94fc1f Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- src/gui/painting/painting.pri | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index a5a395cce21..579c0bc2a99 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -13,6 +13,7 @@ HEADERS += \ painting/qdrawhelper_x86_p.h \ painting/qdrawingprimitive_sse2_p.h \ painting/qemulationpaintengine_p.h \ + painting/qfixed_p.h \ painting/qgrayraster_p.h \ painting/qmatrix.h \ painting/qmemrotate_p.h \ From 817800ad39df10ca78e2c965a61d4d2025df622b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 22 Dec 2014 21:19:27 -0200 Subject: [PATCH 059/101] Fix QXmlStreamReader parsing of files containing NULs Due to a flaw in the internal API, QXmlStreamReader's internal buffering would mistake a NUL byte in the input stream for EOF during parsing, but wouldn't set atEnd == true because it hadn't yet processed all bytes. This resulted in an infinite loop in QXmlStreamReaderPrivate::parse. So, instead of returning zero (false) to indicate EOF, return -1 (but in unsigned form, ~0, to avoid ICC warnings of change of sign). In turn, this required enlarging a few variables to avoid ~0U becoming 0xffff, which is a valid QChar (could happen if the input is a QString, not a QIODevice). Task-number: QTBUG-43513 Change-Id: If5badcfd3e4176b79517da1fd108e0abb93a3fd1 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/corelib/xml/qxmlstream.cpp | 41 ++++++++++-------- src/corelib/xml/qxmlstream_p.h | 12 ++--- .../qxmlstream/data/carriagereturn+nul.ref | 3 ++ .../qxmlstream/data/carriagereturn+nul.xml | Bin 0 -> 60 bytes .../auto/corelib/xml/qxmlstream/data/nul0.ref | 2 + .../auto/corelib/xml/qxmlstream/data/nul0.xml | Bin 0 -> 1 bytes .../auto/corelib/xml/qxmlstream/data/nul1.ref | 2 + .../auto/corelib/xml/qxmlstream/data/nul1.xml | Bin 0 -> 3 bytes .../auto/corelib/xml/qxmlstream/data/nul2.ref | 3 ++ .../auto/corelib/xml/qxmlstream/data/nul2.xml | Bin 0 -> 4 bytes .../auto/corelib/xml/qxmlstream/data/nul3.ref | 2 + .../auto/corelib/xml/qxmlstream/data/nul3.xml | Bin 0 -> 7 bytes .../corelib/xml/qxmlstream/data/nul3bis.ref | 2 + .../corelib/xml/qxmlstream/data/nul3bis.xml | Bin 0 -> 9 bytes .../auto/corelib/xml/qxmlstream/data/nul4.ref | 2 + .../auto/corelib/xml/qxmlstream/data/nul4.xml | Bin 0 -> 8 bytes .../corelib/xml/qxmlstream/data/nul4bis.ref | 2 + .../corelib/xml/qxmlstream/data/nul4bis.xml | Bin 0 -> 10 bytes .../auto/corelib/xml/qxmlstream/data/nul5.ref | 3 ++ .../auto/corelib/xml/qxmlstream/data/nul5.xml | Bin 0 -> 23 bytes 20 files changed, 49 insertions(+), 25 deletions(-) create mode 100644 tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.ref create mode 100644 tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.xml create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul0.ref create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul0.xml create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul1.ref create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul1.xml create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul2.ref create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul2.xml create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul3.ref create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul3.xml create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul3bis.ref create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul3bis.xml create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul4.ref create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul4.xml create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul4bis.ref create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul4bis.xml create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul5.ref create mode 100644 tests/auto/corelib/xml/qxmlstream/data/nul5.xml diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 94f6a8bcdec..d1698b812f8 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -64,6 +64,8 @@ QT_BEGIN_NAMESPACE #include "qxmlstream_p.h" +enum { StreamEOF = ~0U }; + /*! \enum QXmlStreamReader::TokenType @@ -903,7 +905,7 @@ inline uint QXmlStreamReaderPrivate::filterCarriageReturn() ++readBufferPos; return peekc; } - if (peekc == 0) { + if (peekc == StreamEOF) { putChar('\r'); return 0; } @@ -912,13 +914,13 @@ inline uint QXmlStreamReaderPrivate::filterCarriageReturn() /*! \internal - If the end of the file is encountered, 0 is returned. + If the end of the file is encountered, ~0 is returned. */ inline uint QXmlStreamReaderPrivate::getChar() { uint c; if (putStack.size()) { - c = atEnd ? 0 : putStack.pop(); + c = atEnd ? StreamEOF : putStack.pop(); } else { if (readBufferPos < readBuffer.size()) c = readBuffer.at(readBufferPos++).unicode(); @@ -937,7 +939,7 @@ inline uint QXmlStreamReaderPrivate::peekChar() } else if (readBufferPos < readBuffer.size()) { c = readBuffer.at(readBufferPos).unicode(); } else { - if ((c = getChar_helper())) + if ((c = getChar_helper()) != StreamEOF) --readBufferPos; } @@ -961,7 +963,8 @@ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject) int pos = textBuffer.size(); int oldLineNumber = lineNumber; - while (uint c = getChar()) { + uint c; + while ((c = getChar()) != StreamEOF) { /* First, we do the validation & normalization. */ switch (c) { case '\r': @@ -1007,9 +1010,9 @@ bool QXmlStreamReaderPrivate::scanString(const char *str, short tokenToInject, b { int n = 0; while (str[n]) { - ushort c = getChar(); + uint c = getChar(); if (c != ushort(str[n])) { - if (c) + if (c != StreamEOF) putChar(c); while (n--) { putChar(ushort(str[n])); @@ -1137,7 +1140,7 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent() { int n = 0; uint c; - while ((c = getChar())) { + while ((c = getChar()) != StreamEOF) { switch (ushort(c)) { case 0xfffe: case 0xffff: @@ -1182,8 +1185,8 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent() inline int QXmlStreamReaderPrivate::fastScanSpace() { int n = 0; - ushort c; - while ((c = getChar())) { + uint c; + while ((c = getChar()) != StreamEOF) { switch (c) { case '\r': if ((c = filterCarriageReturn()) == 0) @@ -1216,7 +1219,7 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList() { int n = 0; uint c; - while ((c = getChar())) { + while ((c = getChar()) != StreamEOF) { switch (ushort(c)) { case 0xfffe: case 0xffff: @@ -1279,8 +1282,8 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList() inline int QXmlStreamReaderPrivate::fastScanName(int *prefix) { int n = 0; - ushort c; - while ((c = getChar())) { + uint c; + while ((c = getChar()) != StreamEOF) { switch (c) { case '\n': case ' ': @@ -1396,7 +1399,7 @@ inline int QXmlStreamReaderPrivate::fastScanNMTOKEN() { int n = 0; uint c; - while ((c = getChar())) { + while ((c = getChar()) != StreamEOF) { if (fastDetermineNameChar(c) == NotName) { putChar(c); return n; @@ -1452,7 +1455,7 @@ void QXmlStreamReaderPrivate::putReplacementInAttributeValue(const QString &s) } } -ushort QXmlStreamReaderPrivate::getChar_helper() +uint QXmlStreamReaderPrivate::getChar_helper() { const int BUFFER_SIZE = 8192; characterOffset += readBufferPos; @@ -1476,7 +1479,7 @@ ushort QXmlStreamReaderPrivate::getChar_helper() } if (!nbytesread) { atEnd = true; - return 0; + return StreamEOF; } #ifndef QT_NO_TEXTCODEC @@ -1484,7 +1487,7 @@ ushort QXmlStreamReaderPrivate::getChar_helper() if (nbytesread < 4) { // the 4 is to cover 0xef 0xbb 0xbf plus // one extra for the utf8 codec atEnd = true; - return 0; + return StreamEOF; } int mib = 106; // UTF-8 @@ -1517,7 +1520,7 @@ ushort QXmlStreamReaderPrivate::getChar_helper() if(lockEncoding && decoder->hasFailure()) { raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content.")); readBuffer.clear(); - return 0; + return StreamEOF; } #else readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread); @@ -1531,7 +1534,7 @@ ushort QXmlStreamReaderPrivate::getChar_helper() } atEnd = true; - return 0; + return StreamEOF; } QStringRef QXmlStreamReaderPrivate::namespaceForPrefix(const QStringRef &prefix) diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h index 7ff65e1718a..087d64fce89 100644 --- a/src/corelib/xml/qxmlstream_p.h +++ b/src/corelib/xml/qxmlstream_p.h @@ -944,7 +944,7 @@ public: short token; - ushort token_char; + uint token_char; uint filterCarriageReturn(); inline uint getChar(); @@ -955,7 +955,7 @@ public: void putStringLiteral(const QString &s); void putReplacement(const QString &s); void putReplacementInAttributeValue(const QString &s); - ushort getChar_helper(); + uint getChar_helper(); bool scanUntil(const char *str, short tokenToInject = -1); bool scanString(const char *str, short tokenToInject, bool requireSpace = true); @@ -1068,7 +1068,7 @@ bool QXmlStreamReaderPrivate::parse() documentVersion.clear(); documentEncoding.clear(); #ifndef QT_NO_TEXTCODEC - if (decoder->hasFailure()) { + if (decoder && decoder->hasFailure()) { raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content.")); readBuffer.clear(); return false; @@ -1099,8 +1099,8 @@ bool QXmlStreamReaderPrivate::parse() if (token == -1 && - TERMINAL_COUNT != action_index[act]) { uint cu = getChar(); token = NOTOKEN; - token_char = cu; - if (cu & 0xff0000) { + token_char = cu == ~0U ? cu : ushort(cu); + if ((cu != ~0U) && (cu & 0xff0000)) { token = cu >> 16; } else switch (token_char) { case 0xfffe: @@ -1119,7 +1119,7 @@ bool QXmlStreamReaderPrivate::parse() break; } // fall through - case '\0': { + case ~0U: { token = EOF_SYMBOL; if (!tagsDone && !inParseEntity) { int a = t_action(act, token); diff --git a/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.ref b/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.ref new file mode 100644 index 00000000000..b636d802947 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.ref @@ -0,0 +1,3 @@ +StartDocument( ) +Invalid( processingInstructionTarget="xml_" ) +ERROR: Invalid XML character. diff --git a/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.xml b/tests/auto/corelib/xml/qxmlstream/data/carriagereturn+nul.xml new file mode 100644 index 0000000000000000000000000000000000000000..e87bf56453c2ad1ca7df3dd2804cf0d7730796ed GIT binary patch literal 60 zcmcDqugJ}b=jCNkC`&CW&dkrVRWj5wP*OID literal 0 HcmV?d00001 diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul3bis.ref b/tests/auto/corelib/xml/qxmlstream/data/nul3bis.ref new file mode 100644 index 00000000000..cf4dd3848b0 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul3bis.ref @@ -0,0 +1,2 @@ +Invalid( ) +ERROR: Expected 'version', but got ''. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul3bis.xml b/tests/auto/corelib/xml/qxmlstream/data/nul3bis.xml new file mode 100644 index 0000000000000000000000000000000000000000..61e011014eccbfea406e112ba99cb40f6ea798c6 GIT binary patch literal 9 QcmcDqugJ~eVzA=^01UkX9{>OV literal 0 HcmV?d00001 diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul4.ref b/tests/auto/corelib/xml/qxmlstream/data/nul4.ref new file mode 100644 index 00000000000..cf4dd3848b0 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul4.ref @@ -0,0 +1,2 @@ +Invalid( ) +ERROR: Expected 'version', but got ''. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul4.xml b/tests/auto/corelib/xml/qxmlstream/data/nul4.xml new file mode 100644 index 0000000000000000000000000000000000000000..90f20eebf0751d54fbeb57b51b81fe4f92c5a792 GIT binary patch literal 8 PcmcDqugJ|&;9>v(3bq0F literal 0 HcmV?d00001 diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul4bis.ref b/tests/auto/corelib/xml/qxmlstream/data/nul4bis.ref new file mode 100644 index 00000000000..cf4dd3848b0 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul4bis.ref @@ -0,0 +1,2 @@ +Invalid( ) +ERROR: Expected 'version', but got ''. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul4bis.xml b/tests/auto/corelib/xml/qxmlstream/data/nul4bis.xml new file mode 100644 index 0000000000000000000000000000000000000000..15d2d106857fc9c29b7f87778159c093421f7b10 GIT binary patch literal 10 RcmcDqugJ|&;9{`j0ss#x0zUu% literal 0 HcmV?d00001 diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul5.ref b/tests/auto/corelib/xml/qxmlstream/data/nul5.ref new file mode 100644 index 00000000000..9432b74a991 --- /dev/null +++ b/tests/auto/corelib/xml/qxmlstream/data/nul5.ref @@ -0,0 +1,3 @@ +StartDocument( documentVersion="1.0" ) +Invalid( ) +ERROR: Start tag expected. diff --git a/tests/auto/corelib/xml/qxmlstream/data/nul5.xml b/tests/auto/corelib/xml/qxmlstream/data/nul5.xml new file mode 100644 index 0000000000000000000000000000000000000000..6a79cbdc7521791dc3d127183c07a63580af27bc GIT binary patch literal 23 ecmcDqugJ|&C`&CW&dkrVRWj5wP_nn Date: Mon, 26 Jan 2015 19:40:35 +0100 Subject: [PATCH 060/101] Windows/ANGLE: Fix initialization of contexts. Immediately try to initialize a context obtained by eglGetPlatformDisplayEXT() and clear display in case it fails, falling back to eglGetDisplay(). Change-Id: Ia6c1c6da4daff6651153c854eda4fb8749bdc526 Reviewed-by: Laszlo Agocs --- .../platforms/windows/qwindowseglcontext.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index bde0503ee00..7f0421ad908 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -358,6 +358,8 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: } EGLDisplay display = EGL_NO_DISPLAY; + EGLint major = 0; + EGLint minor = 0; #ifdef EGL_ANGLE_platform_angle_opengl if (libEGL.eglGetPlatformDisplayEXT && (preferredType & QWindowsOpenGLTester::AngleBackendMask)) { @@ -373,8 +375,13 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: attributes = anglePlatformAttributes[1]; else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11Warp) attributes = anglePlatformAttributes[2]; - if (attributes) + if (attributes) { display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes); + if (!libEGL.eglInitialize(display, &major, &minor)) { + display = EGL_NO_DISPLAY; + major = minor = 0; + } + } } #else // EGL_ANGLE_platform_angle_opengl Q_UNUSED(preferredType) @@ -386,9 +393,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: return 0; } - EGLint major; - EGLint minor; - if (!libEGL.eglInitialize(display, &major, &minor)) { + if (!major && !libEGL.eglInitialize(display, &major, &minor)) { int err = libEGL.eglGetError(); qWarning("%s: Could not initialize EGL display: error 0x%x\n", Q_FUNC_INFO, err); if (err == 0x3001) From 6430d6e3ec31afabe0e674397088dd6d9e056195 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 27 Jan 2015 14:20:52 +0100 Subject: [PATCH 061/101] Use qt.io rather than qt-project.org for network tests Mainly because of a change in certificates which is causing failing tests. This patch is cherry-picked from https://codereview.qt-project.org/104619/ Change-Id: I8304e5ac4107428a250b71be5df7b5399a811017 Reviewed-by: Richard J. Moore --- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 2 +- .../tst_qsslsocket_onDemandCertificates_member.cpp | 2 +- .../tst_qsslsocket_onDemandCertificates_static.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index aa954429def..a355cfeb170 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -772,7 +772,7 @@ void tst_QSslSocket::peerCertificateChain() QVERIFY(socket->waitForDisconnected()); // connect again to a different server - socket->connectToHostEncrypted("qt-project.org", 443); + socket->connectToHostEncrypted("www.qt.io", 443); socket->ignoreSslErrors(); QCOMPARE(socket->mode(), QSslSocket::UnencryptedMode); QVERIFY(socket->peerCertificateChain().isEmpty()); diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp index 94d7c3905ce..1a65d5f9f3f 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp @@ -185,7 +185,7 @@ void tst_QSslSocket_onDemandCertificates_member::proxyAuthenticationRequired(con void tst_QSslSocket_onDemandCertificates_member::onDemandRootCertLoadingMemberMethods() { - QString host("qt-project.org"); + QString host("www.qt.io"); // not using any root certs -> should not work QSslSocketPtr socket2 = newSocket(); diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp index 418c7020309..ad1f218471b 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp @@ -181,7 +181,7 @@ void tst_QSslSocket_onDemandCertificates_static::proxyAuthenticationRequired(con void tst_QSslSocket_onDemandCertificates_static::onDemandRootCertLoadingStaticMethods() { - QString host("qt-project.org"); + QString host("www.qt.io"); // not using any root certs -> should not work QSslSocket::setDefaultCaCertificates(QList()); From 2e2df81537429e78ff65be33a328e7ee7f480a88 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 21 Jan 2015 14:36:02 +0100 Subject: [PATCH 062/101] Only use Xft font settings as defaults, and let fontconfig override On a GNOME or UNITY desktop, Qt will currently read font-settings from Xft and use those ignoring any fontconfig instructions. This patch changes the behavior so the Xft settings are only used as default, but any explicit overrides by fontconfig will take precedence. Task-number: QTBUG-43660 Change-Id: Ie10d5828cbfdd95fe5364c63a625d455d9213936 Reviewed-by: Konstantin Ritt Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontconfig/qfontconfigdatabase.cpp | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 27ff33be869..e7b03e9651d 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -526,6 +526,23 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin return QFontEngine::HintNone; } + int hint_style = 0; + if (FcPatternGetInteger (match, FC_HINT_STYLE, 0, &hint_style) == FcResultMatch) { + switch (hint_style) { + case FC_HINT_NONE: + return QFontEngine::HintNone; + case FC_HINT_SLIGHT: + return QFontEngine::HintLight; + case FC_HINT_MEDIUM: + return QFontEngine::HintMedium; + case FC_HINT_FULL: + return QFontEngine::HintFull; + default: + Q_UNREACHABLE(); + break; + } + } + if (useXftConf) { void *hintStyleResource = QGuiApplication::platformNativeInterface()->nativeResourceForScreen("hintstyle", @@ -535,27 +552,31 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin return QFontEngine::HintStyle(hintStyle - 1); } - int hint_style = 0; - if (FcPatternGetInteger (match, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch) - hint_style = FC_HINT_FULL; - switch (hint_style) { - case FC_HINT_NONE: - return QFontEngine::HintNone; - case FC_HINT_SLIGHT: - return QFontEngine::HintLight; - case FC_HINT_MEDIUM: - return QFontEngine::HintMedium; - case FC_HINT_FULL: - return QFontEngine::HintFull; - default: - Q_UNREACHABLE(); - break; - } return QFontEngine::HintFull; } QFontEngine::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match, bool useXftConf) { + int subpixel = FC_RGBA_UNKNOWN; + if (FcPatternGetInteger(match, FC_RGBA, 0, &subpixel) == FcResultMatch) { + switch (subpixel) { + case FC_RGBA_UNKNOWN: + case FC_RGBA_NONE: + return QFontEngine::Subpixel_None; + case FC_RGBA_RGB: + return QFontEngine::Subpixel_RGB; + case FC_RGBA_BGR: + return QFontEngine::Subpixel_BGR; + case FC_RGBA_VRGB: + return QFontEngine::Subpixel_VRGB; + case FC_RGBA_VBGR: + return QFontEngine::Subpixel_VBGR; + default: + Q_UNREACHABLE(); + break; + } + } + if (useXftConf) { void *subpixelTypeResource = QGuiApplication::platformNativeInterface()->nativeResourceForScreen("subpixeltype", @@ -565,25 +586,6 @@ QFontEngine::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match, bo return QFontEngine::SubpixelAntialiasingType(subpixelType - 1); } - int subpixel = FC_RGBA_UNKNOWN; - FcPatternGetInteger(match, FC_RGBA, 0, &subpixel); - - switch (subpixel) { - case FC_RGBA_UNKNOWN: - case FC_RGBA_NONE: - return QFontEngine::Subpixel_None; - case FC_RGBA_RGB: - return QFontEngine::Subpixel_RGB; - case FC_RGBA_BGR: - return QFontEngine::Subpixel_BGR; - case FC_RGBA_VRGB: - return QFontEngine::Subpixel_VRGB; - case FC_RGBA_VBGR: - return QFontEngine::Subpixel_VBGR; - default: - Q_UNREACHABLE(); - break; - } return QFontEngine::Subpixel_None; } } // namespace @@ -823,10 +825,8 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled", QGuiApplication::primaryScreen()); int antialiasingEnabled = int(reinterpret_cast(antialiasResource)); - if (antialiasingEnabled > 0) { + if (antialiasingEnabled > 0) antialias = antialiasingEnabled - 1; - forcedAntialiasSetting = true; - } } QFontEngine::GlyphFormat format; From f8c8c79029867a087c9a753269d82b808c16f047 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 2 Feb 2015 13:10:50 +0100 Subject: [PATCH 063/101] Fix build of egl integration Add missing includes and reorder includes to avoid X defines breakage Change-Id: Iaf95ae2488df3d3301436262ed79f7091b4be0a9 Reviewed-by: Laszlo Agocs --- .../eglconvenience/qeglplatformcontext_p.h | 1 + .../qeglplatformintegration_p.h | 2 +- src/plugins/platforms/eglfs/qeglfscontext.cpp | 15 +++++++------ .../platforms/eglfs/qeglfshooks_stub.cpp | 2 +- .../platforms/eglfs/qeglfsintegration.cpp | 22 +++++++++---------- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 4 +++- src/plugins/platforms/eglfs/qeglfswindow.cpp | 6 +++-- .../minimalegl/qminimaleglwindow.cpp | 4 ++-- 8 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h index 7825c7b3d78..0c107103047 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h @@ -45,6 +45,7 @@ // We mean it. // +#include #include #include #include diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h b/src/platformsupport/eglconvenience/qeglplatformintegration_p.h index 4d7adce3096..2b5d5f50fbd 100644 --- a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformintegration_p.h @@ -45,9 +45,9 @@ // We mean it. // +#include #include #include -#include #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp index 6216fa8575d..6470280e2c2 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp @@ -31,16 +31,17 @@ ** ****************************************************************************/ -#include "qeglfscontext.h" -#include "qeglfswindow.h" -#include "qeglfshooks.h" - -#include -#include -#include #include #include +#include +#include +#include + +#include "qeglfswindow.h" +#include "qeglfshooks.h" +#include "qeglfscontext.h" + QT_BEGIN_NAMESPACE QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp index 26d77a2abb3..120c603125a 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp @@ -31,10 +31,10 @@ ** ****************************************************************************/ -#include "qeglfshooks.h" #include #include #include +#include "qeglfshooks.h" #if defined(Q_OS_LINUX) #include diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 2a4eae3fe2d..fbdd1d4c4dd 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -31,19 +31,9 @@ ** ****************************************************************************/ -#include "qeglfsintegration.h" - -#include "qeglfswindow.h" -#include "qeglfshooks.h" -#include "qeglfscontext.h" - +#include #include -#include -#include -#include -#include - #include #include #include @@ -51,6 +41,16 @@ #include #include +#include "qeglfsintegration.h" +#include "qeglfswindow.h" +#include "qeglfshooks.h" +#include "qeglfscontext.h" + +#include +#include +#include +#include + #include static void initResources() diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index cd68540581d..bc93fe28e76 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -31,10 +31,12 @@ ** ****************************************************************************/ +#include +#include + #include "qeglfsscreen.h" #include "qeglfswindow.h" #include "qeglfshooks.h" -#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index f5839e086d7..39a3ef94e98 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -31,8 +31,7 @@ ** ****************************************************************************/ -#include "qeglfswindow.h" -#include "qeglfshooks.h" +#include #include #include #include @@ -40,6 +39,9 @@ #include #include +#include "qeglfswindow.h" +#include "qeglfshooks.h" + #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp b/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp index 906a1308da9..d4bee2c9e44 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp @@ -31,10 +31,10 @@ ** ****************************************************************************/ -#include "qminimaleglwindow.h" - #include +#include "qminimaleglwindow.h" + QT_BEGIN_NAMESPACE QMinimalEglWindow::QMinimalEglWindow(QWindow *w) From 8cb611be7b9266c98a9ccb2175c90dc62d81194b Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 28 Jan 2015 10:05:45 +0100 Subject: [PATCH 064/101] Add some punctuation to QTextCursor's detailed description. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3b3eab74888f283a9890321fadcae67c09c24b61 Reviewed-by: Topi Reiniö --- src/gui/text/qtextcursor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 2e289e2bd8d..b1205a8c850 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -910,8 +910,8 @@ QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{ select text. For selections see selectionStart(), selectionEnd(), hasSelection(), clearSelection(), and removeSelectedText(). - If the position() is at the start of a block atBlockStart() - returns \c true; and if it is at the end of a block atBlockEnd() returns + If the position() is at the start of a block, atBlockStart() + returns \c true; and if it is at the end of a block, atBlockEnd() returns true. The format of the current character is returned by charFormat(), and the format of the current block is returned by blockFormat(). @@ -921,9 +921,9 @@ QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{ mergeBlockFormat() functions. The 'set' functions will replace the cursor's current character or block format, while the 'merge' functions add the given format properties to the cursor's current - format. If the cursor has a selection the given format is applied - to the current selection. Note that when only parts of a block is - selected the block format is applied to the entire block. The text + format. If the cursor has a selection, the given format is applied + to the current selection. Note that when only a part of a block is + selected, the block format is applied to the entire block. The text at the current character position can be turned into a list using createList(). From ee973083cf52882b68ab0e4c067f637cef1dda3e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 9 Oct 2014 01:28:20 +0200 Subject: [PATCH 065/101] uic: update sources from current generate_ui Change-Id: I3b64fa94bd5904feeed753d34e80f4fc0611725e Reviewed-by: Friedemann Kleint --- src/tools/uic/ui4.cpp | 127 +++++++++++++++++++++--------------------- src/tools/uic/ui4.h | 2 +- 2 files changed, 66 insertions(+), 63 deletions(-) diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index 01b4437db79..d7b741b74ba 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -30,6 +30,9 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + +// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! + #include "ui4.h" @@ -380,7 +383,7 @@ void DomUI::setElementClass(const QString& a) m_class = a; } -DomWidget* DomUI::takeElementWidget() +DomWidget* DomUI::takeElementWidget() { DomWidget* a = m_widget; m_widget = 0; @@ -395,7 +398,7 @@ void DomUI::setElementWidget(DomWidget* a) m_widget = a; } -DomLayoutDefault* DomUI::takeElementLayoutDefault() +DomLayoutDefault* DomUI::takeElementLayoutDefault() { DomLayoutDefault* a = m_layoutDefault; m_layoutDefault = 0; @@ -410,7 +413,7 @@ void DomUI::setElementLayoutDefault(DomLayoutDefault* a) m_layoutDefault = a; } -DomLayoutFunction* DomUI::takeElementLayoutFunction() +DomLayoutFunction* DomUI::takeElementLayoutFunction() { DomLayoutFunction* a = m_layoutFunction; m_layoutFunction = 0; @@ -431,7 +434,7 @@ void DomUI::setElementPixmapFunction(const QString& a) m_pixmapFunction = a; } -DomCustomWidgets* DomUI::takeElementCustomWidgets() +DomCustomWidgets* DomUI::takeElementCustomWidgets() { DomCustomWidgets* a = m_customWidgets; m_customWidgets = 0; @@ -446,7 +449,7 @@ void DomUI::setElementCustomWidgets(DomCustomWidgets* a) m_customWidgets = a; } -DomTabStops* DomUI::takeElementTabStops() +DomTabStops* DomUI::takeElementTabStops() { DomTabStops* a = m_tabStops; m_tabStops = 0; @@ -461,7 +464,7 @@ void DomUI::setElementTabStops(DomTabStops* a) m_tabStops = a; } -DomImages* DomUI::takeElementImages() +DomImages* DomUI::takeElementImages() { DomImages* a = m_images; m_images = 0; @@ -476,7 +479,7 @@ void DomUI::setElementImages(DomImages* a) m_images = a; } -DomIncludes* DomUI::takeElementIncludes() +DomIncludes* DomUI::takeElementIncludes() { DomIncludes* a = m_includes; m_includes = 0; @@ -491,7 +494,7 @@ void DomUI::setElementIncludes(DomIncludes* a) m_includes = a; } -DomResources* DomUI::takeElementResources() +DomResources* DomUI::takeElementResources() { DomResources* a = m_resources; m_resources = 0; @@ -506,7 +509,7 @@ void DomUI::setElementResources(DomResources* a) m_resources = a; } -DomConnections* DomUI::takeElementConnections() +DomConnections* DomUI::takeElementConnections() { DomConnections* a = m_connections; m_connections = 0; @@ -521,7 +524,7 @@ void DomUI::setElementConnections(DomConnections* a) m_connections = a; } -DomDesignerData* DomUI::takeElementDesignerdata() +DomDesignerData* DomUI::takeElementDesignerdata() { DomDesignerData* a = m_designerdata; m_designerdata = 0; @@ -536,7 +539,7 @@ void DomUI::setElementDesignerdata(DomDesignerData* a) m_designerdata = a; } -DomSlots* DomUI::takeElementSlots() +DomSlots* DomUI::takeElementSlots() { DomSlots* a = m_slots; m_slots = 0; @@ -551,7 +554,7 @@ void DomUI::setElementSlots(DomSlots* a) m_slots = a; } -DomButtonGroups* DomUI::takeElementButtonGroups() +DomButtonGroups* DomUI::takeElementButtonGroups() { DomButtonGroups* a = m_buttonGroups; m_buttonGroups = 0; @@ -1632,7 +1635,7 @@ void DomImage::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -DomImageData* DomImage::takeElementData() +DomImageData* DomImage::takeElementData() { DomImageData* a = m_data; m_data = 0; @@ -2075,7 +2078,7 @@ void DomCustomWidget::setElementExtends(const QString& a) m_extends = a; } -DomHeader* DomCustomWidget::takeElementHeader() +DomHeader* DomCustomWidget::takeElementHeader() { DomHeader* a = m_header; m_header = 0; @@ -2090,7 +2093,7 @@ void DomCustomWidget::setElementHeader(DomHeader* a) m_header = a; } -DomSize* DomCustomWidget::takeElementSizeHint() +DomSize* DomCustomWidget::takeElementSizeHint() { DomSize* a = m_sizeHint; m_sizeHint = 0; @@ -2117,7 +2120,7 @@ void DomCustomWidget::setElementContainer(int a) m_container = a; } -DomSizePolicyData* DomCustomWidget::takeElementSizePolicy() +DomSizePolicyData* DomCustomWidget::takeElementSizePolicy() { DomSizePolicyData* a = m_sizePolicy; m_sizePolicy = 0; @@ -2138,7 +2141,7 @@ void DomCustomWidget::setElementPixmap(const QString& a) m_pixmap = a; } -DomScript* DomCustomWidget::takeElementScript() +DomScript* DomCustomWidget::takeElementScript() { DomScript* a = m_script; m_script = 0; @@ -2153,7 +2156,7 @@ void DomCustomWidget::setElementScript(DomScript* a) m_script = a; } -DomProperties* DomCustomWidget::takeElementProperties() +DomProperties* DomCustomWidget::takeElementProperties() { DomProperties* a = m_properties; m_properties = 0; @@ -2168,7 +2171,7 @@ void DomCustomWidget::setElementProperties(DomProperties* a) m_properties = a; } -DomSlots* DomCustomWidget::takeElementSlots() +DomSlots* DomCustomWidget::takeElementSlots() { DomSlots* a = m_slots; m_slots = 0; @@ -2183,7 +2186,7 @@ void DomCustomWidget::setElementSlots(DomSlots* a) m_slots = a; } -DomPropertySpecifications* DomCustomWidget::takeElementPropertyspecifications() +DomPropertySpecifications* DomCustomWidget::takeElementPropertyspecifications() { DomPropertySpecifications* a = m_propertyspecifications; m_propertyspecifications = 0; @@ -3073,7 +3076,7 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons writer.writeEndElement(); } -DomWidget* DomLayoutItem::takeElementWidget() +DomWidget* DomLayoutItem::takeElementWidget() { DomWidget* a = m_widget; m_widget = 0; @@ -3087,7 +3090,7 @@ void DomLayoutItem::setElementWidget(DomWidget* a) m_widget = a; } -DomLayout* DomLayoutItem::takeElementLayout() +DomLayout* DomLayoutItem::takeElementLayout() { DomLayout* a = m_layout; m_layout = 0; @@ -3101,7 +3104,7 @@ void DomLayoutItem::setElementLayout(DomLayout* a) m_layout = a; } -DomSpacer* DomLayoutItem::takeElementSpacer() +DomSpacer* DomLayoutItem::takeElementSpacer() { DomSpacer* a = m_spacer; m_spacer = 0; @@ -4035,7 +4038,7 @@ void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) co writer.writeEndElement(); } -DomColor* DomGradientStop::takeElementColor() +DomColor* DomGradientStop::takeElementColor() { DomColor* a = m_color; m_color = 0; @@ -4394,7 +4397,7 @@ void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -DomColor* DomBrush::takeElementColor() +DomColor* DomBrush::takeElementColor() { DomColor* a = m_color; m_color = 0; @@ -4408,7 +4411,7 @@ void DomBrush::setElementColor(DomColor* a) m_color = a; } -DomProperty* DomBrush::takeElementTexture() +DomProperty* DomBrush::takeElementTexture() { DomProperty* a = m_texture; m_texture = 0; @@ -4422,7 +4425,7 @@ void DomBrush::setElementTexture(DomProperty* a) m_texture = a; } -DomGradient* DomBrush::takeElementGradient() +DomGradient* DomBrush::takeElementGradient() { DomGradient* a = m_gradient; m_gradient = 0; @@ -4516,7 +4519,7 @@ void DomColorRole::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -DomBrush* DomColorRole::takeElementBrush() +DomBrush* DomColorRole::takeElementBrush() { DomBrush* a = m_brush; m_brush = 0; @@ -4724,7 +4727,7 @@ void DomPalette::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -DomColorGroup* DomPalette::takeElementActive() +DomColorGroup* DomPalette::takeElementActive() { DomColorGroup* a = m_active; m_active = 0; @@ -4739,7 +4742,7 @@ void DomPalette::setElementActive(DomColorGroup* a) m_active = a; } -DomColorGroup* DomPalette::takeElementInactive() +DomColorGroup* DomPalette::takeElementInactive() { DomColorGroup* a = m_inactive; m_inactive = 0; @@ -4754,7 +4757,7 @@ void DomPalette::setElementInactive(DomColorGroup* a) m_inactive = a; } -DomColorGroup* DomPalette::takeElementDisabled() +DomColorGroup* DomPalette::takeElementDisabled() { DomColorGroup* a = m_disabled; m_disabled = 0; @@ -6378,7 +6381,7 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co writer.writeEndElement(); } -DomResourcePixmap* DomResourceIcon::takeElementNormalOff() +DomResourcePixmap* DomResourceIcon::takeElementNormalOff() { DomResourcePixmap* a = m_normalOff; m_normalOff = 0; @@ -6393,7 +6396,7 @@ void DomResourceIcon::setElementNormalOff(DomResourcePixmap* a) m_normalOff = a; } -DomResourcePixmap* DomResourceIcon::takeElementNormalOn() +DomResourcePixmap* DomResourceIcon::takeElementNormalOn() { DomResourcePixmap* a = m_normalOn; m_normalOn = 0; @@ -6408,7 +6411,7 @@ void DomResourceIcon::setElementNormalOn(DomResourcePixmap* a) m_normalOn = a; } -DomResourcePixmap* DomResourceIcon::takeElementDisabledOff() +DomResourcePixmap* DomResourceIcon::takeElementDisabledOff() { DomResourcePixmap* a = m_disabledOff; m_disabledOff = 0; @@ -6423,7 +6426,7 @@ void DomResourceIcon::setElementDisabledOff(DomResourcePixmap* a) m_disabledOff = a; } -DomResourcePixmap* DomResourceIcon::takeElementDisabledOn() +DomResourcePixmap* DomResourceIcon::takeElementDisabledOn() { DomResourcePixmap* a = m_disabledOn; m_disabledOn = 0; @@ -6438,7 +6441,7 @@ void DomResourceIcon::setElementDisabledOn(DomResourcePixmap* a) m_disabledOn = a; } -DomResourcePixmap* DomResourceIcon::takeElementActiveOff() +DomResourcePixmap* DomResourceIcon::takeElementActiveOff() { DomResourcePixmap* a = m_activeOff; m_activeOff = 0; @@ -6453,7 +6456,7 @@ void DomResourceIcon::setElementActiveOff(DomResourcePixmap* a) m_activeOff = a; } -DomResourcePixmap* DomResourceIcon::takeElementActiveOn() +DomResourcePixmap* DomResourceIcon::takeElementActiveOn() { DomResourcePixmap* a = m_activeOn; m_activeOn = 0; @@ -6468,7 +6471,7 @@ void DomResourceIcon::setElementActiveOn(DomResourcePixmap* a) m_activeOn = a; } -DomResourcePixmap* DomResourceIcon::takeElementSelectedOff() +DomResourcePixmap* DomResourceIcon::takeElementSelectedOff() { DomResourcePixmap* a = m_selectedOff; m_selectedOff = 0; @@ -6483,7 +6486,7 @@ void DomResourceIcon::setElementSelectedOff(DomResourcePixmap* a) m_selectedOff = a; } -DomResourcePixmap* DomResourceIcon::takeElementSelectedOn() +DomResourcePixmap* DomResourceIcon::takeElementSelectedOn() { DomResourcePixmap* a = m_selectedOn; m_selectedOn = 0; @@ -7102,7 +7105,7 @@ void DomUrl::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -DomString* DomUrl::takeElementString() +DomString* DomUrl::takeElementString() { DomString* a = m_string; m_string = 0; @@ -7681,7 +7684,7 @@ void DomProperty::setElementBool(const QString& a) m_bool = a; } -DomColor* DomProperty::takeElementColor() +DomColor* DomProperty::takeElementColor() { DomColor* a = m_color; m_color = 0; @@ -7723,7 +7726,7 @@ void DomProperty::setElementEnum(const QString& a) m_enum = a; } -DomFont* DomProperty::takeElementFont() +DomFont* DomProperty::takeElementFont() { DomFont* a = m_font; m_font = 0; @@ -7737,7 +7740,7 @@ void DomProperty::setElementFont(DomFont* a) m_font = a; } -DomResourceIcon* DomProperty::takeElementIconSet() +DomResourceIcon* DomProperty::takeElementIconSet() { DomResourceIcon* a = m_iconSet; m_iconSet = 0; @@ -7751,7 +7754,7 @@ void DomProperty::setElementIconSet(DomResourceIcon* a) m_iconSet = a; } -DomResourcePixmap* DomProperty::takeElementPixmap() +DomResourcePixmap* DomProperty::takeElementPixmap() { DomResourcePixmap* a = m_pixmap; m_pixmap = 0; @@ -7765,7 +7768,7 @@ void DomProperty::setElementPixmap(DomResourcePixmap* a) m_pixmap = a; } -DomPalette* DomProperty::takeElementPalette() +DomPalette* DomProperty::takeElementPalette() { DomPalette* a = m_palette; m_palette = 0; @@ -7779,7 +7782,7 @@ void DomProperty::setElementPalette(DomPalette* a) m_palette = a; } -DomPoint* DomProperty::takeElementPoint() +DomPoint* DomProperty::takeElementPoint() { DomPoint* a = m_point; m_point = 0; @@ -7793,7 +7796,7 @@ void DomProperty::setElementPoint(DomPoint* a) m_point = a; } -DomRect* DomProperty::takeElementRect() +DomRect* DomProperty::takeElementRect() { DomRect* a = m_rect; m_rect = 0; @@ -7814,7 +7817,7 @@ void DomProperty::setElementSet(const QString& a) m_set = a; } -DomLocale* DomProperty::takeElementLocale() +DomLocale* DomProperty::takeElementLocale() { DomLocale* a = m_locale; m_locale = 0; @@ -7828,7 +7831,7 @@ void DomProperty::setElementLocale(DomLocale* a) m_locale = a; } -DomSizePolicy* DomProperty::takeElementSizePolicy() +DomSizePolicy* DomProperty::takeElementSizePolicy() { DomSizePolicy* a = m_sizePolicy; m_sizePolicy = 0; @@ -7842,7 +7845,7 @@ void DomProperty::setElementSizePolicy(DomSizePolicy* a) m_sizePolicy = a; } -DomSize* DomProperty::takeElementSize() +DomSize* DomProperty::takeElementSize() { DomSize* a = m_size; m_size = 0; @@ -7856,7 +7859,7 @@ void DomProperty::setElementSize(DomSize* a) m_size = a; } -DomString* DomProperty::takeElementString() +DomString* DomProperty::takeElementString() { DomString* a = m_string; m_string = 0; @@ -7870,7 +7873,7 @@ void DomProperty::setElementString(DomString* a) m_string = a; } -DomStringList* DomProperty::takeElementStringList() +DomStringList* DomProperty::takeElementStringList() { DomStringList* a = m_stringList; m_stringList = 0; @@ -7905,7 +7908,7 @@ void DomProperty::setElementDouble(double a) m_double = a; } -DomDate* DomProperty::takeElementDate() +DomDate* DomProperty::takeElementDate() { DomDate* a = m_date; m_date = 0; @@ -7919,7 +7922,7 @@ void DomProperty::setElementDate(DomDate* a) m_date = a; } -DomTime* DomProperty::takeElementTime() +DomTime* DomProperty::takeElementTime() { DomTime* a = m_time; m_time = 0; @@ -7933,7 +7936,7 @@ void DomProperty::setElementTime(DomTime* a) m_time = a; } -DomDateTime* DomProperty::takeElementDateTime() +DomDateTime* DomProperty::takeElementDateTime() { DomDateTime* a = m_dateTime; m_dateTime = 0; @@ -7947,7 +7950,7 @@ void DomProperty::setElementDateTime(DomDateTime* a) m_dateTime = a; } -DomPointF* DomProperty::takeElementPointF() +DomPointF* DomProperty::takeElementPointF() { DomPointF* a = m_pointF; m_pointF = 0; @@ -7961,7 +7964,7 @@ void DomProperty::setElementPointF(DomPointF* a) m_pointF = a; } -DomRectF* DomProperty::takeElementRectF() +DomRectF* DomProperty::takeElementRectF() { DomRectF* a = m_rectF; m_rectF = 0; @@ -7975,7 +7978,7 @@ void DomProperty::setElementRectF(DomRectF* a) m_rectF = a; } -DomSizeF* DomProperty::takeElementSizeF() +DomSizeF* DomProperty::takeElementSizeF() { DomSizeF* a = m_sizeF; m_sizeF = 0; @@ -7996,7 +7999,7 @@ void DomProperty::setElementLongLong(qlonglong a) m_longLong = a; } -DomChar* DomProperty::takeElementChar() +DomChar* DomProperty::takeElementChar() { DomChar* a = m_char; m_char = 0; @@ -8010,7 +8013,7 @@ void DomProperty::setElementChar(DomChar* a) m_char = a; } -DomUrl* DomProperty::takeElementUrl() +DomUrl* DomProperty::takeElementUrl() { DomUrl* a = m_url; m_url = 0; @@ -8038,7 +8041,7 @@ void DomProperty::setElementULongLong(qulonglong a) m_uLongLong = a; } -DomBrush* DomProperty::takeElementBrush() +DomBrush* DomProperty::takeElementBrush() { DomBrush* a = m_brush; m_brush = 0; @@ -8246,7 +8249,7 @@ void DomConnection::setElementSlot(const QString& a) m_slot = a; } -DomConnectionHints* DomConnection::takeElementHints() +DomConnectionHints* DomConnection::takeElementHints() { DomConnectionHints* a = m_hints; m_hints = 0; diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index d50a70c4683..51a70749ce7 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -42,7 +42,7 @@ // We mean it. // -// THIS FILE IS AUTOMATICALLY GENERATED +// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! #ifndef UI4_H #define UI4_H From a776e4cf78d55ccd2d05911b2b466148edeb8015 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 8 Oct 2014 11:36:56 +0200 Subject: [PATCH 066/101] uic: don't use QStringLiteral in comparisons (this is committing the new output of generate_ui from qttools) For QLatin1String, operator== is overloaded, even for QStringRef, so comparing to a latin-1 (C) string literal is efficient, since strlen() is comparatively fast. OTOH, QStringLiteral, when not using RVO, litters the code with QString dtor calls, which are not inline. Worse, absent lambdas, it even allocates memory. So, just compare using QLatin1String instead. Change-Id: I5035d259085c21689ab0f62fd49819ab5223ffe8 Reviewed-by: Thiago Macieira --- src/tools/uic/ui4.cpp | 546 +++++++++++++++++++++--------------------- 1 file changed, 273 insertions(+), 273 deletions(-) diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index d7b741b74ba..7563d1d64b2 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -131,23 +131,23 @@ void DomUI::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("version")) { + if (name == QLatin1String("version")) { setAttributeVersion(attribute.value().toString()); continue; } - if (name == QStringLiteral("language")) { + if (name == QLatin1String("language")) { setAttributeLanguage(attribute.value().toString()); continue; } - if (name == QStringLiteral("displayname")) { + if (name == QLatin1String("displayname")) { setAttributeDisplayname(attribute.value().toString()); continue; } - if (name == QStringLiteral("stdsetdef")) { + if (name == QLatin1String("stdsetdef")) { setAttributeStdsetdef(attribute.value().toString().toInt()); continue; } - if (name == QStringLiteral("stdSetDef")) { + if (name == QLatin1String("stdSetDef")) { setAttributeStdSetDef(attribute.value().toString().toInt()); continue; } @@ -158,93 +158,93 @@ void DomUI::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("author")) { + if (tag == QLatin1String("author")) { setElementAuthor(reader.readElementText()); continue; } - if (tag == QStringLiteral("comment")) { + if (tag == QLatin1String("comment")) { setElementComment(reader.readElementText()); continue; } - if (tag == QStringLiteral("exportmacro")) { + if (tag == QLatin1String("exportmacro")) { setElementExportMacro(reader.readElementText()); continue; } - if (tag == QStringLiteral("class")) { + if (tag == QLatin1String("class")) { setElementClass(reader.readElementText()); continue; } - if (tag == QStringLiteral("widget")) { + if (tag == QLatin1String("widget")) { DomWidget *v = new DomWidget(); v->read(reader); setElementWidget(v); continue; } - if (tag == QStringLiteral("layoutdefault")) { + if (tag == QLatin1String("layoutdefault")) { DomLayoutDefault *v = new DomLayoutDefault(); v->read(reader); setElementLayoutDefault(v); continue; } - if (tag == QStringLiteral("layoutfunction")) { + if (tag == QLatin1String("layoutfunction")) { DomLayoutFunction *v = new DomLayoutFunction(); v->read(reader); setElementLayoutFunction(v); continue; } - if (tag == QStringLiteral("pixmapfunction")) { + if (tag == QLatin1String("pixmapfunction")) { setElementPixmapFunction(reader.readElementText()); continue; } - if (tag == QStringLiteral("customwidgets")) { + if (tag == QLatin1String("customwidgets")) { DomCustomWidgets *v = new DomCustomWidgets(); v->read(reader); setElementCustomWidgets(v); continue; } - if (tag == QStringLiteral("tabstops")) { + if (tag == QLatin1String("tabstops")) { DomTabStops *v = new DomTabStops(); v->read(reader); setElementTabStops(v); continue; } - if (tag == QStringLiteral("images")) { + if (tag == QLatin1String("images")) { DomImages *v = new DomImages(); v->read(reader); setElementImages(v); continue; } - if (tag == QStringLiteral("includes")) { + if (tag == QLatin1String("includes")) { DomIncludes *v = new DomIncludes(); v->read(reader); setElementIncludes(v); continue; } - if (tag == QStringLiteral("resources")) { + if (tag == QLatin1String("resources")) { DomResources *v = new DomResources(); v->read(reader); setElementResources(v); continue; } - if (tag == QStringLiteral("connections")) { + if (tag == QLatin1String("connections")) { DomConnections *v = new DomConnections(); v->read(reader); setElementConnections(v); continue; } - if (tag == QStringLiteral("designerdata")) { + if (tag == QLatin1String("designerdata")) { DomDesignerData *v = new DomDesignerData(); v->read(reader); setElementDesignerdata(v); continue; } - if (tag == QStringLiteral("slots")) { + if (tag == QLatin1String("slots")) { DomSlots *v = new DomSlots(); v->read(reader); setElementSlots(v); continue; } - if (tag == QStringLiteral("buttongroups")) { + if (tag == QLatin1String("buttongroups")) { DomButtonGroups *v = new DomButtonGroups(); v->read(reader); setElementButtonGroups(v); @@ -708,7 +708,7 @@ void DomIncludes::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("include")) { + if (tag == QLatin1String("include")) { DomInclude *v = new DomInclude(); v->read(reader); m_include.append(v); @@ -779,11 +779,11 @@ void DomInclude::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("location")) { + if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; } - if (name == QStringLiteral("impldecl")) { + if (name == QLatin1String("impldecl")) { setAttributeImpldecl(attribute.value().toString()); continue; } @@ -856,7 +856,7 @@ void DomResources::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } @@ -867,7 +867,7 @@ void DomResources::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("include")) { + if (tag == QLatin1String("include")) { DomResource *v = new DomResource(); v->read(reader); m_include.append(v); @@ -938,7 +938,7 @@ void DomResource::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("location")) { + if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; } @@ -1020,7 +1020,7 @@ void DomActionGroup::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } @@ -1031,25 +1031,25 @@ void DomActionGroup::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("action")) { + if (tag == QLatin1String("action")) { DomAction *v = new DomAction(); v->read(reader); m_action.append(v); continue; } - if (tag == QStringLiteral("actiongroup")) { + if (tag == QLatin1String("actiongroup")) { DomActionGroup *v = new DomActionGroup(); v->read(reader); m_actionGroup.append(v); continue; } - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QStringLiteral("attribute")) { + if (tag == QLatin1String("attribute")) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); @@ -1160,11 +1160,11 @@ void DomAction::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } - if (name == QStringLiteral("menu")) { + if (name == QLatin1String("menu")) { setAttributeMenu(attribute.value().toString()); continue; } @@ -1175,13 +1175,13 @@ void DomAction::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QStringLiteral("attribute")) { + if (tag == QLatin1String("attribute")) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); @@ -1265,7 +1265,7 @@ void DomActionRef::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } @@ -1339,7 +1339,7 @@ void DomButtonGroup::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } @@ -1350,13 +1350,13 @@ void DomButtonGroup::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QStringLiteral("attribute")) { + if (tag == QLatin1String("attribute")) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); @@ -1441,7 +1441,7 @@ void DomButtonGroups::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("buttongroup")) { + if (tag == QLatin1String("buttongroup")) { DomButtonGroup *v = new DomButtonGroup(); v->read(reader); m_buttonGroup.append(v); @@ -1513,7 +1513,7 @@ void DomImages::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("image")) { + if (tag == QLatin1String("image")) { DomImage *v = new DomImage(); v->read(reader); m_image.append(v); @@ -1585,7 +1585,7 @@ void DomImage::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } @@ -1596,7 +1596,7 @@ void DomImage::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("data")) { + if (tag == QLatin1String("data")) { DomImageData *v = new DomImageData(); v->read(reader); setElementData(v); @@ -1688,11 +1688,11 @@ void DomImageData::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("format")) { + if (name == QLatin1String("format")) { setAttributeFormat(attribute.value().toString()); continue; } - if (name == QStringLiteral("length")) { + if (name == QLatin1String("length")) { setAttributeLength(attribute.value().toString().toInt()); continue; } @@ -1765,7 +1765,7 @@ void DomCustomWidgets::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("customwidget")) { + if (tag == QLatin1String("customwidget")) { DomCustomWidget *v = new DomCustomWidget(); v->read(reader); m_customWidget.append(v); @@ -1834,7 +1834,7 @@ void DomHeader::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("location")) { + if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; } @@ -1930,63 +1930,63 @@ void DomCustomWidget::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("class")) { + if (tag == QLatin1String("class")) { setElementClass(reader.readElementText()); continue; } - if (tag == QStringLiteral("extends")) { + if (tag == QLatin1String("extends")) { setElementExtends(reader.readElementText()); continue; } - if (tag == QStringLiteral("header")) { + if (tag == QLatin1String("header")) { DomHeader *v = new DomHeader(); v->read(reader); setElementHeader(v); continue; } - if (tag == QStringLiteral("sizehint")) { + if (tag == QLatin1String("sizehint")) { DomSize *v = new DomSize(); v->read(reader); setElementSizeHint(v); continue; } - if (tag == QStringLiteral("addpagemethod")) { + if (tag == QLatin1String("addpagemethod")) { setElementAddPageMethod(reader.readElementText()); continue; } - if (tag == QStringLiteral("container")) { + if (tag == QLatin1String("container")) { setElementContainer(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("sizepolicy")) { + if (tag == QLatin1String("sizepolicy")) { DomSizePolicyData *v = new DomSizePolicyData(); v->read(reader); setElementSizePolicy(v); continue; } - if (tag == QStringLiteral("pixmap")) { + if (tag == QLatin1String("pixmap")) { setElementPixmap(reader.readElementText()); continue; } - if (tag == QStringLiteral("script")) { + if (tag == QLatin1String("script")) { DomScript *v = new DomScript(); v->read(reader); setElementScript(v); continue; } - if (tag == QStringLiteral("properties")) { + if (tag == QLatin1String("properties")) { DomProperties *v = new DomProperties(); v->read(reader); setElementProperties(v); continue; } - if (tag == QStringLiteral("slots")) { + if (tag == QLatin1String("slots")) { DomSlots *v = new DomSlots(); v->read(reader); setElementSlots(v); continue; } - if (tag == QStringLiteral("propertyspecifications")) { + if (tag == QLatin1String("propertyspecifications")) { DomPropertySpecifications *v = new DomPropertySpecifications(); v->read(reader); setElementPropertyspecifications(v); @@ -2305,7 +2305,7 @@ void DomProperties::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomPropertyData *v = new DomPropertyData(); v->read(reader); m_property.append(v); @@ -2373,7 +2373,7 @@ void DomPropertyData::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("type")) { + if (name == QLatin1String("type")) { setAttributeType(attribute.value().toString()); continue; } @@ -2443,11 +2443,11 @@ void DomSizePolicyData::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("hordata")) { + if (tag == QLatin1String("hordata")) { setElementHorData(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("verdata")) { + if (tag == QLatin1String("verdata")) { setElementVerData(reader.readElementText().toInt()); continue; } @@ -2539,11 +2539,11 @@ void DomLayoutDefault::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("spacing")) { + if (name == QLatin1String("spacing")) { setAttributeSpacing(attribute.value().toString().toInt()); continue; } - if (name == QStringLiteral("margin")) { + if (name == QLatin1String("margin")) { setAttributeMargin(attribute.value().toString().toInt()); continue; } @@ -2614,11 +2614,11 @@ void DomLayoutFunction::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("spacing")) { + if (name == QLatin1String("spacing")) { setAttributeSpacing(attribute.value().toString()); continue; } - if (name == QStringLiteral("margin")) { + if (name == QLatin1String("margin")) { setAttributeMargin(attribute.value().toString()); continue; } @@ -2689,7 +2689,7 @@ void DomTabStops::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("tabstop")) { + if (tag == QLatin1String("tabstop")) { m_tabStop.append(reader.readElementText()); continue; } @@ -2779,31 +2779,31 @@ void DomLayout::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("class")) { + if (name == QLatin1String("class")) { setAttributeClass(attribute.value().toString()); continue; } - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } - if (name == QStringLiteral("stretch")) { + if (name == QLatin1String("stretch")) { setAttributeStretch(attribute.value().toString()); continue; } - if (name == QStringLiteral("rowstretch")) { + if (name == QLatin1String("rowstretch")) { setAttributeRowStretch(attribute.value().toString()); continue; } - if (name == QStringLiteral("columnstretch")) { + if (name == QLatin1String("columnstretch")) { setAttributeColumnStretch(attribute.value().toString()); continue; } - if (name == QStringLiteral("rowminimumheight")) { + if (name == QLatin1String("rowminimumheight")) { setAttributeRowMinimumHeight(attribute.value().toString()); continue; } - if (name == QStringLiteral("columnminimumwidth")) { + if (name == QLatin1String("columnminimumwidth")) { setAttributeColumnMinimumWidth(attribute.value().toString()); continue; } @@ -2814,19 +2814,19 @@ void DomLayout::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QStringLiteral("attribute")) { + if (tag == QLatin1String("attribute")) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } - if (tag == QStringLiteral("item")) { + if (tag == QLatin1String("item")) { DomLayoutItem *v = new DomLayoutItem(); v->read(reader); m_item.append(v); @@ -2965,23 +2965,23 @@ void DomLayoutItem::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("row")) { + if (name == QLatin1String("row")) { setAttributeRow(attribute.value().toString().toInt()); continue; } - if (name == QStringLiteral("column")) { + if (name == QLatin1String("column")) { setAttributeColumn(attribute.value().toString().toInt()); continue; } - if (name == QStringLiteral("rowspan")) { + if (name == QLatin1String("rowspan")) { setAttributeRowSpan(attribute.value().toString().toInt()); continue; } - if (name == QStringLiteral("colspan")) { + if (name == QLatin1String("colspan")) { setAttributeColSpan(attribute.value().toString().toInt()); continue; } - if (name == QStringLiteral("alignment")) { + if (name == QLatin1String("alignment")) { setAttributeAlignment(attribute.value().toString()); continue; } @@ -2992,19 +2992,19 @@ void DomLayoutItem::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("widget")) { + if (tag == QLatin1String("widget")) { DomWidget *v = new DomWidget(); v->read(reader); setElementWidget(v); continue; } - if (tag == QStringLiteral("layout")) { + if (tag == QLatin1String("layout")) { DomLayout *v = new DomLayout(); v->read(reader); setElementLayout(v); continue; } - if (tag == QStringLiteral("spacer")) { + if (tag == QLatin1String("spacer")) { DomSpacer *v = new DomSpacer(); v->read(reader); setElementSpacer(v); @@ -3148,7 +3148,7 @@ void DomRow::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); @@ -3220,7 +3220,7 @@ void DomColumn::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); @@ -3302,11 +3302,11 @@ void DomItem::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("row")) { + if (name == QLatin1String("row")) { setAttributeRow(attribute.value().toString().toInt()); continue; } - if (name == QStringLiteral("column")) { + if (name == QLatin1String("column")) { setAttributeColumn(attribute.value().toString().toInt()); continue; } @@ -3317,13 +3317,13 @@ void DomItem::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QStringLiteral("item")) { + if (tag == QLatin1String("item")) { DomItem *v = new DomItem(); v->read(reader); m_item.append(v); @@ -3465,16 +3465,16 @@ void DomWidget::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("class")) { + if (name == QLatin1String("class")) { setAttributeClass(attribute.value().toString()); continue; } - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } - if (name == QStringLiteral("native")) { - setAttributeNative(attribute.value().toString() == QStringLiteral("true")); + if (name == QLatin1String("native")) { + setAttributeNative(attribute.value().toString() == QLatin1String("true")); continue; } reader.raiseError(QStringLiteral("Unexpected attribute ") + name.toString()); @@ -3484,83 +3484,83 @@ void DomWidget::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("class")) { + if (tag == QLatin1String("class")) { m_class.append(reader.readElementText()); continue; } - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QStringLiteral("script")) { + if (tag == QLatin1String("script")) { DomScript *v = new DomScript(); v->read(reader); m_script.append(v); continue; } - if (tag == QStringLiteral("widgetdata")) { + if (tag == QLatin1String("widgetdata")) { DomWidgetData *v = new DomWidgetData(); v->read(reader); m_widgetData.append(v); continue; } - if (tag == QStringLiteral("attribute")) { + if (tag == QLatin1String("attribute")) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } - if (tag == QStringLiteral("row")) { + if (tag == QLatin1String("row")) { DomRow *v = new DomRow(); v->read(reader); m_row.append(v); continue; } - if (tag == QStringLiteral("column")) { + if (tag == QLatin1String("column")) { DomColumn *v = new DomColumn(); v->read(reader); m_column.append(v); continue; } - if (tag == QStringLiteral("item")) { + if (tag == QLatin1String("item")) { DomItem *v = new DomItem(); v->read(reader); m_item.append(v); continue; } - if (tag == QStringLiteral("layout")) { + if (tag == QLatin1String("layout")) { DomLayout *v = new DomLayout(); v->read(reader); m_layout.append(v); continue; } - if (tag == QStringLiteral("widget")) { + if (tag == QLatin1String("widget")) { DomWidget *v = new DomWidget(); v->read(reader); m_widget.append(v); continue; } - if (tag == QStringLiteral("action")) { + if (tag == QLatin1String("action")) { DomAction *v = new DomAction(); v->read(reader); m_action.append(v); continue; } - if (tag == QStringLiteral("actiongroup")) { + if (tag == QLatin1String("actiongroup")) { DomActionGroup *v = new DomActionGroup(); v->read(reader); m_actionGroup.append(v); continue; } - if (tag == QStringLiteral("addaction")) { + if (tag == QLatin1String("addaction")) { DomActionRef *v = new DomActionRef(); v->read(reader); m_addAction.append(v); continue; } - if (tag == QStringLiteral("zorder")) { + if (tag == QLatin1String("zorder")) { m_zOrder.append(reader.readElementText()); continue; } @@ -3769,7 +3769,7 @@ void DomSpacer::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } @@ -3780,7 +3780,7 @@ void DomSpacer::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); @@ -3859,7 +3859,7 @@ void DomColor::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("alpha")) { + if (name == QLatin1String("alpha")) { setAttributeAlpha(attribute.value().toString().toInt()); continue; } @@ -3870,15 +3870,15 @@ void DomColor::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("red")) { + if (tag == QLatin1String("red")) { setElementRed(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("green")) { + if (tag == QLatin1String("green")) { setElementGreen(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("blue")) { + if (tag == QLatin1String("blue")) { setElementBlue(reader.readElementText().toInt()); continue; } @@ -3988,7 +3988,7 @@ void DomGradientStop::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("position")) { + if (name == QLatin1String("position")) { setAttributePosition(attribute.value().toString().toDouble()); continue; } @@ -3999,7 +3999,7 @@ void DomGradientStop::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("color")) { + if (tag == QLatin1String("color")) { DomColor *v = new DomColor(); v->read(reader); setElementColor(v); @@ -4134,55 +4134,55 @@ void DomGradient::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("startx")) { + if (name == QLatin1String("startx")) { setAttributeStartX(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("starty")) { + if (name == QLatin1String("starty")) { setAttributeStartY(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("endx")) { + if (name == QLatin1String("endx")) { setAttributeEndX(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("endy")) { + if (name == QLatin1String("endy")) { setAttributeEndY(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("centralx")) { + if (name == QLatin1String("centralx")) { setAttributeCentralX(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("centraly")) { + if (name == QLatin1String("centraly")) { setAttributeCentralY(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("focalx")) { + if (name == QLatin1String("focalx")) { setAttributeFocalX(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("focaly")) { + if (name == QLatin1String("focaly")) { setAttributeFocalY(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("radius")) { + if (name == QLatin1String("radius")) { setAttributeRadius(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("angle")) { + if (name == QLatin1String("angle")) { setAttributeAngle(attribute.value().toString().toDouble()); continue; } - if (name == QStringLiteral("type")) { + if (name == QLatin1String("type")) { setAttributeType(attribute.value().toString()); continue; } - if (name == QStringLiteral("spread")) { + if (name == QLatin1String("spread")) { setAttributeSpread(attribute.value().toString()); continue; } - if (name == QStringLiteral("coordinatemode")) { + if (name == QLatin1String("coordinatemode")) { setAttributeCoordinateMode(attribute.value().toString()); continue; } @@ -4193,7 +4193,7 @@ void DomGradient::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("gradientstop")) { + if (tag == QLatin1String("gradientstop")) { DomGradientStop *v = new DomGradientStop(); v->read(reader); m_gradientStop.append(v); @@ -4314,7 +4314,7 @@ void DomBrush::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("brushstyle")) { + if (name == QLatin1String("brushstyle")) { setAttributeBrushStyle(attribute.value().toString()); continue; } @@ -4325,19 +4325,19 @@ void DomBrush::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("color")) { + if (tag == QLatin1String("color")) { DomColor *v = new DomColor(); v->read(reader); setElementColor(v); continue; } - if (tag == QStringLiteral("texture")) { + if (tag == QLatin1String("texture")) { DomProperty *v = new DomProperty(); v->read(reader); setElementTexture(v); continue; } - if (tag == QStringLiteral("gradient")) { + if (tag == QLatin1String("gradient")) { DomGradient *v = new DomGradient(); v->read(reader); setElementGradient(v); @@ -4469,7 +4469,7 @@ void DomColorRole::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("role")) { + if (name == QLatin1String("role")) { setAttributeRole(attribute.value().toString()); continue; } @@ -4480,7 +4480,7 @@ void DomColorRole::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("brush")) { + if (tag == QLatin1String("brush")) { DomBrush *v = new DomBrush(); v->read(reader); setElementBrush(v); @@ -4575,13 +4575,13 @@ void DomColorGroup::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("colorrole")) { + if (tag == QLatin1String("colorrole")) { DomColorRole *v = new DomColorRole(); v->read(reader); m_colorRole.append(v); continue; } - if (tag == QStringLiteral("color")) { + if (tag == QLatin1String("color")) { DomColor *v = new DomColor(); v->read(reader); m_color.append(v); @@ -4671,19 +4671,19 @@ void DomPalette::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("active")) { + if (tag == QLatin1String("active")) { DomColorGroup *v = new DomColorGroup(); v->read(reader); setElementActive(v); continue; } - if (tag == QStringLiteral("inactive")) { + if (tag == QLatin1String("inactive")) { DomColorGroup *v = new DomColorGroup(); v->read(reader); setElementInactive(v); continue; } - if (tag == QStringLiteral("disabled")) { + if (tag == QLatin1String("disabled")) { DomColorGroup *v = new DomColorGroup(); v->read(reader); setElementDisabled(v); @@ -4835,44 +4835,44 @@ void DomFont::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("family")) { + if (tag == QLatin1String("family")) { setElementFamily(reader.readElementText()); continue; } - if (tag == QStringLiteral("pointsize")) { + if (tag == QLatin1String("pointsize")) { setElementPointSize(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("weight")) { + if (tag == QLatin1String("weight")) { setElementWeight(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("italic")) { - setElementItalic(reader.readElementText() == QStringLiteral("true")); + if (tag == QLatin1String("italic")) { + setElementItalic(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QStringLiteral("bold")) { - setElementBold(reader.readElementText() == QStringLiteral("true")); + if (tag == QLatin1String("bold")) { + setElementBold(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QStringLiteral("underline")) { - setElementUnderline(reader.readElementText() == QStringLiteral("true")); + if (tag == QLatin1String("underline")) { + setElementUnderline(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QStringLiteral("strikeout")) { - setElementStrikeOut(reader.readElementText() == QStringLiteral("true")); + if (tag == QLatin1String("strikeout")) { + setElementStrikeOut(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QStringLiteral("antialiasing")) { - setElementAntialiasing(reader.readElementText() == QStringLiteral("true")); + if (tag == QLatin1String("antialiasing")) { + setElementAntialiasing(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QStringLiteral("stylestrategy")) { + if (tag == QLatin1String("stylestrategy")) { setElementStyleStrategy(reader.readElementText()); continue; } - if (tag == QStringLiteral("kerning")) { - setElementKerning(reader.readElementText() == QStringLiteral("true")); + if (tag == QLatin1String("kerning")) { + setElementKerning(reader.readElementText() == QLatin1String("true")); continue; } reader.raiseError(QStringLiteral("Unexpected element ") + tag); @@ -5081,11 +5081,11 @@ void DomPoint::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QString(QLatin1Char('x'))) { + if (tag == QLatin1String("x")) { setElementX(reader.readElementText().toInt()); continue; } - if (tag == QString(QLatin1Char('y'))) { + if (tag == QLatin1String("y")) { setElementY(reader.readElementText().toInt()); continue; } @@ -5179,19 +5179,19 @@ void DomRect::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QString(QLatin1Char('x'))) { + if (tag == QLatin1String("x")) { setElementX(reader.readElementText().toInt()); continue; } - if (tag == QString(QLatin1Char('y'))) { + if (tag == QLatin1String("y")) { setElementY(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("width")) { + if (tag == QLatin1String("width")) { setElementWidth(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("height")) { + if (tag == QLatin1String("height")) { setElementHeight(reader.readElementText().toInt()); continue; } @@ -5309,11 +5309,11 @@ void DomLocale::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("language")) { + if (name == QLatin1String("language")) { setAttributeLanguage(attribute.value().toString()); continue; } - if (name == QStringLiteral("country")) { + if (name == QLatin1String("country")) { setAttributeCountry(attribute.value().toString()); continue; } @@ -5392,11 +5392,11 @@ void DomSizePolicy::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("hsizetype")) { + if (name == QLatin1String("hsizetype")) { setAttributeHSizeType(attribute.value().toString()); continue; } - if (name == QStringLiteral("vsizetype")) { + if (name == QLatin1String("vsizetype")) { setAttributeVSizeType(attribute.value().toString()); continue; } @@ -5407,19 +5407,19 @@ void DomSizePolicy::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("hsizetype")) { + if (tag == QLatin1String("hsizetype")) { setElementHSizeType(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("vsizetype")) { + if (tag == QLatin1String("vsizetype")) { setElementVSizeType(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("horstretch")) { + if (tag == QLatin1String("horstretch")) { setElementHorStretch(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("verstretch")) { + if (tag == QLatin1String("verstretch")) { setElementVerStretch(reader.readElementText().toInt()); continue; } @@ -5545,11 +5545,11 @@ void DomSize::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("width")) { + if (tag == QLatin1String("width")) { setElementWidth(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("height")) { + if (tag == QLatin1String("height")) { setElementHeight(reader.readElementText().toInt()); continue; } @@ -5641,15 +5641,15 @@ void DomDate::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("year")) { + if (tag == QLatin1String("year")) { setElementYear(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("month")) { + if (tag == QLatin1String("month")) { setElementMonth(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("day")) { + if (tag == QLatin1String("day")) { setElementDay(reader.readElementText().toInt()); continue; } @@ -5756,15 +5756,15 @@ void DomTime::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("hour")) { + if (tag == QLatin1String("hour")) { setElementHour(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("minute")) { + if (tag == QLatin1String("minute")) { setElementMinute(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("second")) { + if (tag == QLatin1String("second")) { setElementSecond(reader.readElementText().toInt()); continue; } @@ -5877,27 +5877,27 @@ void DomDateTime::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("hour")) { + if (tag == QLatin1String("hour")) { setElementHour(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("minute")) { + if (tag == QLatin1String("minute")) { setElementMinute(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("second")) { + if (tag == QLatin1String("second")) { setElementSecond(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("year")) { + if (tag == QLatin1String("year")) { setElementYear(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("month")) { + if (tag == QLatin1String("month")) { setElementMonth(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("day")) { + if (tag == QLatin1String("day")) { setElementDay(reader.readElementText().toInt()); continue; } @@ -6049,15 +6049,15 @@ void DomStringList::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("notr")) { + if (name == QLatin1String("notr")) { setAttributeNotr(attribute.value().toString()); continue; } - if (name == QStringLiteral("comment")) { + if (name == QLatin1String("comment")) { setAttributeComment(attribute.value().toString()); continue; } - if (name == QStringLiteral("extracomment")) { + if (name == QLatin1String("extracomment")) { setAttributeExtraComment(attribute.value().toString()); continue; } @@ -6068,7 +6068,7 @@ void DomStringList::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("string")) { + if (tag == QLatin1String("string")) { m_string.append(reader.readElementText()); continue; } @@ -6146,11 +6146,11 @@ void DomResourcePixmap::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("resource")) { + if (name == QLatin1String("resource")) { setAttributeResource(attribute.value().toString()); continue; } - if (name == QStringLiteral("alias")) { + if (name == QLatin1String("alias")) { setAttributeAlias(attribute.value().toString()); continue; } @@ -6254,11 +6254,11 @@ void DomResourceIcon::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("theme")) { + if (name == QLatin1String("theme")) { setAttributeTheme(attribute.value().toString()); continue; } - if (name == QStringLiteral("resource")) { + if (name == QLatin1String("resource")) { setAttributeResource(attribute.value().toString()); continue; } @@ -6269,49 +6269,49 @@ void DomResourceIcon::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("normaloff")) { + if (tag == QLatin1String("normaloff")) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementNormalOff(v); continue; } - if (tag == QStringLiteral("normalon")) { + if (tag == QLatin1String("normalon")) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementNormalOn(v); continue; } - if (tag == QStringLiteral("disabledoff")) { + if (tag == QLatin1String("disabledoff")) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementDisabledOff(v); continue; } - if (tag == QStringLiteral("disabledon")) { + if (tag == QLatin1String("disabledon")) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementDisabledOn(v); continue; } - if (tag == QStringLiteral("activeoff")) { + if (tag == QLatin1String("activeoff")) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementActiveOff(v); continue; } - if (tag == QStringLiteral("activeon")) { + if (tag == QLatin1String("activeon")) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementActiveOn(v); continue; } - if (tag == QStringLiteral("selectedoff")) { + if (tag == QLatin1String("selectedoff")) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementSelectedOff(v); continue; } - if (tag == QStringLiteral("selectedon")) { + if (tag == QLatin1String("selectedon")) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementSelectedOn(v); @@ -6588,15 +6588,15 @@ void DomString::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("notr")) { + if (name == QLatin1String("notr")) { setAttributeNotr(attribute.value().toString()); continue; } - if (name == QStringLiteral("comment")) { + if (name == QLatin1String("comment")) { setAttributeComment(attribute.value().toString()); continue; } - if (name == QStringLiteral("extracomment")) { + if (name == QLatin1String("extracomment")) { setAttributeExtraComment(attribute.value().toString()); continue; } @@ -6672,11 +6672,11 @@ void DomPointF::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QString(QLatin1Char('x'))) { + if (tag == QLatin1String("x")) { setElementX(reader.readElementText().toDouble()); continue; } - if (tag == QString(QLatin1Char('y'))) { + if (tag == QLatin1String("y")) { setElementY(reader.readElementText().toDouble()); continue; } @@ -6770,19 +6770,19 @@ void DomRectF::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QString(QLatin1Char('x'))) { + if (tag == QLatin1String("x")) { setElementX(reader.readElementText().toDouble()); continue; } - if (tag == QString(QLatin1Char('y'))) { + if (tag == QLatin1String("y")) { setElementY(reader.readElementText().toDouble()); continue; } - if (tag == QStringLiteral("width")) { + if (tag == QLatin1String("width")) { setElementWidth(reader.readElementText().toDouble()); continue; } - if (tag == QStringLiteral("height")) { + if (tag == QLatin1String("height")) { setElementHeight(reader.readElementText().toDouble()); continue; } @@ -6902,11 +6902,11 @@ void DomSizeF::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("width")) { + if (tag == QLatin1String("width")) { setElementWidth(reader.readElementText().toDouble()); continue; } - if (tag == QStringLiteral("height")) { + if (tag == QLatin1String("height")) { setElementHeight(reader.readElementText().toDouble()); continue; } @@ -6994,7 +6994,7 @@ void DomChar::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("unicode")) { + if (tag == QLatin1String("unicode")) { setElementUnicode(reader.readElementText().toInt()); continue; } @@ -7069,7 +7069,7 @@ void DomUrl::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("string")) { + if (tag == QLatin1String("string")) { DomString *v = new DomString(); v->read(reader); setElementString(v); @@ -7257,11 +7257,11 @@ void DomProperty::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } - if (name == QStringLiteral("stdset")) { + if (name == QLatin1String("stdset")) { setAttributeStdset(attribute.value().toString().toInt()); continue; } @@ -7272,175 +7272,175 @@ void DomProperty::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("bool")) { + if (tag == QLatin1String("bool")) { setElementBool(reader.readElementText()); continue; } - if (tag == QStringLiteral("color")) { + if (tag == QLatin1String("color")) { DomColor *v = new DomColor(); v->read(reader); setElementColor(v); continue; } - if (tag == QStringLiteral("cstring")) { + if (tag == QLatin1String("cstring")) { setElementCstring(reader.readElementText()); continue; } - if (tag == QStringLiteral("cursor")) { + if (tag == QLatin1String("cursor")) { setElementCursor(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("cursorshape")) { + if (tag == QLatin1String("cursorshape")) { setElementCursorShape(reader.readElementText()); continue; } - if (tag == QStringLiteral("enum")) { + if (tag == QLatin1String("enum")) { setElementEnum(reader.readElementText()); continue; } - if (tag == QStringLiteral("font")) { + if (tag == QLatin1String("font")) { DomFont *v = new DomFont(); v->read(reader); setElementFont(v); continue; } - if (tag == QStringLiteral("iconset")) { + if (tag == QLatin1String("iconset")) { DomResourceIcon *v = new DomResourceIcon(); v->read(reader); setElementIconSet(v); continue; } - if (tag == QStringLiteral("pixmap")) { + if (tag == QLatin1String("pixmap")) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementPixmap(v); continue; } - if (tag == QStringLiteral("palette")) { + if (tag == QLatin1String("palette")) { DomPalette *v = new DomPalette(); v->read(reader); setElementPalette(v); continue; } - if (tag == QStringLiteral("point")) { + if (tag == QLatin1String("point")) { DomPoint *v = new DomPoint(); v->read(reader); setElementPoint(v); continue; } - if (tag == QStringLiteral("rect")) { + if (tag == QLatin1String("rect")) { DomRect *v = new DomRect(); v->read(reader); setElementRect(v); continue; } - if (tag == QStringLiteral("set")) { + if (tag == QLatin1String("set")) { setElementSet(reader.readElementText()); continue; } - if (tag == QStringLiteral("locale")) { + if (tag == QLatin1String("locale")) { DomLocale *v = new DomLocale(); v->read(reader); setElementLocale(v); continue; } - if (tag == QStringLiteral("sizepolicy")) { + if (tag == QLatin1String("sizepolicy")) { DomSizePolicy *v = new DomSizePolicy(); v->read(reader); setElementSizePolicy(v); continue; } - if (tag == QStringLiteral("size")) { + if (tag == QLatin1String("size")) { DomSize *v = new DomSize(); v->read(reader); setElementSize(v); continue; } - if (tag == QStringLiteral("string")) { + if (tag == QLatin1String("string")) { DomString *v = new DomString(); v->read(reader); setElementString(v); continue; } - if (tag == QStringLiteral("stringlist")) { + if (tag == QLatin1String("stringlist")) { DomStringList *v = new DomStringList(); v->read(reader); setElementStringList(v); continue; } - if (tag == QStringLiteral("number")) { + if (tag == QLatin1String("number")) { setElementNumber(reader.readElementText().toInt()); continue; } - if (tag == QStringLiteral("float")) { + if (tag == QLatin1String("float")) { setElementFloat(reader.readElementText().toFloat()); continue; } - if (tag == QStringLiteral("double")) { + if (tag == QLatin1String("double")) { setElementDouble(reader.readElementText().toDouble()); continue; } - if (tag == QStringLiteral("date")) { + if (tag == QLatin1String("date")) { DomDate *v = new DomDate(); v->read(reader); setElementDate(v); continue; } - if (tag == QStringLiteral("time")) { + if (tag == QLatin1String("time")) { DomTime *v = new DomTime(); v->read(reader); setElementTime(v); continue; } - if (tag == QStringLiteral("datetime")) { + if (tag == QLatin1String("datetime")) { DomDateTime *v = new DomDateTime(); v->read(reader); setElementDateTime(v); continue; } - if (tag == QStringLiteral("pointf")) { + if (tag == QLatin1String("pointf")) { DomPointF *v = new DomPointF(); v->read(reader); setElementPointF(v); continue; } - if (tag == QStringLiteral("rectf")) { + if (tag == QLatin1String("rectf")) { DomRectF *v = new DomRectF(); v->read(reader); setElementRectF(v); continue; } - if (tag == QStringLiteral("sizef")) { + if (tag == QLatin1String("sizef")) { DomSizeF *v = new DomSizeF(); v->read(reader); setElementSizeF(v); continue; } - if (tag == QStringLiteral("longlong")) { + if (tag == QLatin1String("longlong")) { setElementLongLong(reader.readElementText().toLongLong()); continue; } - if (tag == QStringLiteral("char")) { + if (tag == QLatin1String("char")) { DomChar *v = new DomChar(); v->read(reader); setElementChar(v); continue; } - if (tag == QStringLiteral("url")) { + if (tag == QLatin1String("url")) { DomUrl *v = new DomUrl(); v->read(reader); setElementUrl(v); continue; } - if (tag == QStringLiteral("uint")) { + if (tag == QLatin1String("uint")) { setElementUInt(reader.readElementText().toUInt()); continue; } - if (tag == QStringLiteral("ulonglong")) { + if (tag == QLatin1String("ulonglong")) { setElementULongLong(reader.readElementText().toULongLong()); continue; } - if (tag == QStringLiteral("brush")) { + if (tag == QLatin1String("brush")) { DomBrush *v = new DomBrush(); v->read(reader); setElementBrush(v); @@ -8085,7 +8085,7 @@ void DomConnections::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("connection")) { + if (tag == QLatin1String("connection")) { DomConnection *v = new DomConnection(); v->read(reader); m_connection.append(v); @@ -8157,23 +8157,23 @@ void DomConnection::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("sender")) { + if (tag == QLatin1String("sender")) { setElementSender(reader.readElementText()); continue; } - if (tag == QStringLiteral("signal")) { + if (tag == QLatin1String("signal")) { setElementSignal(reader.readElementText()); continue; } - if (tag == QStringLiteral("receiver")) { + if (tag == QLatin1String("receiver")) { setElementReceiver(reader.readElementText()); continue; } - if (tag == QStringLiteral("slot")) { + if (tag == QLatin1String("slot")) { setElementSlot(reader.readElementText()); continue; } - if (tag == QStringLiteral("hints")) { + if (tag == QLatin1String("hints")) { DomConnectionHints *v = new DomConnectionHints(); v->read(reader); setElementHints(v); @@ -8321,7 +8321,7 @@ void DomConnectionHints::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("hint")) { + if (tag == QLatin1String("hint")) { DomConnectionHint *v = new DomConnectionHint(); v->read(reader); m_hint.append(v); @@ -8393,7 +8393,7 @@ void DomConnectionHint::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("type")) { + if (name == QLatin1String("type")) { setAttributeType(attribute.value().toString()); continue; } @@ -8404,11 +8404,11 @@ void DomConnectionHint::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QString(QLatin1Char('x'))) { + if (tag == QLatin1String("x")) { setElementX(reader.readElementText().toInt()); continue; } - if (tag == QString(QLatin1Char('y'))) { + if (tag == QLatin1String("y")) { setElementY(reader.readElementText().toInt()); continue; } @@ -8499,11 +8499,11 @@ void DomScript::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("source")) { + if (name == QLatin1String("source")) { setAttributeSource(attribute.value().toString()); continue; } - if (name == QStringLiteral("language")) { + if (name == QLatin1String("language")) { setAttributeLanguage(attribute.value().toString()); continue; } @@ -8576,7 +8576,7 @@ void DomWidgetData::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); @@ -8648,7 +8648,7 @@ void DomDesignerData::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("property")) { + if (tag == QLatin1String("property")) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); @@ -8720,11 +8720,11 @@ void DomSlots::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("signal")) { + if (tag == QLatin1String("signal")) { m_signal.append(reader.readElementText()); continue; } - if (tag == QStringLiteral("slot")) { + if (tag == QLatin1String("slot")) { m_slot.append(reader.readElementText()); continue; } @@ -8804,7 +8804,7 @@ void DomPropertySpecifications::read(QXmlStreamReader &reader) switch (reader.readNext()) { case QXmlStreamReader::StartElement : { const QString tag = reader.name().toString().toLower(); - if (tag == QStringLiteral("stringpropertyspecification")) { + if (tag == QLatin1String("stringpropertyspecification")) { DomStringPropertySpecification *v = new DomStringPropertySpecification(); v->read(reader); m_stringpropertyspecification.append(v); @@ -8876,15 +8876,15 @@ void DomStringPropertySpecification::read(QXmlStreamReader &reader) foreach (const QXmlStreamAttribute &attribute, reader.attributes()) { QStringRef name = attribute.name(); - if (name == QStringLiteral("name")) { + if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; } - if (name == QStringLiteral("type")) { + if (name == QLatin1String("type")) { setAttributeType(attribute.value().toString()); continue; } - if (name == QStringLiteral("notr")) { + if (name == QLatin1String("notr")) { setAttributeNotr(attribute.value().toString()); continue; } From 46d3c25980cac2592c4ad07a927f1f9a4a9e0f53 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 28 Jan 2015 09:51:18 +0100 Subject: [PATCH 067/101] Partially revert "QFixed: fix undefined behavior" This partially reverts commit 1755038134cfe16d3d52ec2aea543955462e2951, which did not only fix undefined (signed left-shift), but also implementation-defined (signed right-shift) behavior. It turned out that code depends on a particular implementation behavior (logical instead of arithmetic right-shift), and needs to be fixed first. Change-Id: I9ba32d06f127d17d05e0c6f6eac3d26268587bca Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Eike Ziller --- src/gui/painting/qfixed_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qfixed_p.h b/src/gui/painting/qfixed_p.h index a0ac69f02f4..68314d0434f 100644 --- a/src/gui/painting/qfixed_p.h +++ b/src/gui/painting/qfixed_p.h @@ -70,7 +70,7 @@ public: Q_DECL_CONSTEXPR inline int toInt() const { return (((val)+32) & -64)>>6; } Q_DECL_CONSTEXPR inline qreal toReal() const { return ((qreal)val)/(qreal)64; } - Q_DECL_CONSTEXPR inline int truncate() const { return val / 64; } + Q_DECL_CONSTEXPR inline int truncate() const { return val>>6; } Q_DECL_CONSTEXPR inline QFixed round() const { return fromFixed(((val)+32) & -64); } Q_DECL_CONSTEXPR inline QFixed floor() const { return fromFixed((val) & -64); } Q_DECL_CONSTEXPR inline QFixed ceil() const { return fromFixed((val+63) & -64); } From 2b9949169273efa0c918a168c340aa0d837911fb Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Fri, 10 Oct 2014 09:56:13 -0700 Subject: [PATCH 068/101] Fix leaks in OS X bundle detection There were several leaked CFStringRefs in the new OS X bundle detection code that is part of QFileSystemEngine. Change-Id: Id0817e9692da411c7eb8287b9bf71b99ae28f960 Reviewed-by: Thiago Macieira Reviewed-by: Samuel Gaist Reviewed-by: Jake Petroules --- src/corelib/io/qfilesystemengine_unix.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index cd42aff35c4..bfa4483ca7f 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -83,13 +83,13 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e if (suffix.length() > 0) { // First step: is the extension known ? - CFStringRef extensionRef = QCFString::toCFStringRef(suffix); - CFStringRef uniformTypeIdentifier = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extensionRef, NULL); + QCFType extensionRef = QCFString::toCFStringRef(suffix); + QCFType uniformTypeIdentifier = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extensionRef, NULL); if (UTTypeConformsTo(uniformTypeIdentifier, kUTTypeBundle)) return true; // Second step: check if an application knows the package type - CFStringRef path = QCFString::toCFStringRef(entry.filePath()); + QCFType path = QCFString::toCFStringRef(entry.filePath()); QCFType url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, true); UInt32 type, creator; From 2a27fc41a418cc3fda26334fdbaf1e31c9eecce5 Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Mon, 26 Jan 2015 14:45:09 -0800 Subject: [PATCH 069/101] Fix QGraphicsWidget window frame section logic CppCat detected duplicate sub-expressions in the code that checked for BottomLeftSection and BottomRightSection. It was fairly obvious to see what the values should be. Change-Id: Id45ca5bbd26c92b800c60867fef5170578216eee Reviewed-by: Andreas Aardal Hanssen --- src/widgets/graphicsview/qgraphicswidget.cpp | 4 +-- .../qgraphicswidget/tst_qgraphicswidget.cpp | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index 5bd563e535b..98e011ff05a 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -1311,7 +1311,7 @@ Qt::WindowFrameSection QGraphicsWidget::windowFrameSectionAt(const QPointF &pos) if (x <= left + cornerMargin) { if (y <= top + windowFrameWidth || (x <= left + windowFrameWidth && y <= top + cornerMargin)) { s = Qt::TopLeftSection; - } else if (y >= bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >= bottom - windowFrameWidth)) { + } else if (y >= bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >= bottom - cornerMargin)) { s = Qt::BottomLeftSection; } else if (x <= left + windowFrameWidth) { s = Qt::LeftSection; @@ -1319,7 +1319,7 @@ Qt::WindowFrameSection QGraphicsWidget::windowFrameSectionAt(const QPointF &pos) } else if (x >= right - cornerMargin) { if (y <= top + windowFrameWidth || (x >= right - windowFrameWidth && y <= top + cornerMargin)) { s = Qt::TopRightSection; - } else if (y >= bottom - windowFrameWidth || (x >= right - windowFrameWidth && y >= bottom - windowFrameWidth)) { + } else if (y >= bottom - windowFrameWidth || (x >= right - windowFrameWidth && y >= bottom - cornerMargin)) { s = Qt::BottomRightSection; } else if (x >= right - windowFrameWidth) { s = Qt::RightSection; diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 6fde8321f95..e817157c79a 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -171,6 +171,7 @@ private slots: void fontPropagatesResolveViaNonWidget(); void fontPropagatesResolveFromScene(); void tabFocus(); + void windowFrameSectionAt(); // Task fixes void task236127_bspTreeIndexFails(); @@ -243,6 +244,9 @@ public: void call_updateGeometry() { return QGraphicsWidget::updateGeometry(); } + Qt::WindowFrameSection call_windowFrameSectionAt(const QPointF &pos) const + { return QGraphicsWidget::windowFrameSectionAt(pos); } + int eventCount; Qt::LayoutDirection m_painterLayoutDirection; @@ -3411,6 +3415,31 @@ void tst_QGraphicsWidget::tabFocus() delete widget6; } +void tst_QGraphicsWidget::windowFrameSectionAt() +{ + SubQGraphicsWidget widget; + widget.setWindowFrameMargins(5, 5, 5, 5); + widget.setGeometry(0, 0, 200, 200); + + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(50, 50)), Qt::NoSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(-2, -2)), Qt::TopLeftSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(-2, 10)), Qt::TopLeftSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(-2, 30)), Qt::LeftSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(-2, 170)), Qt::LeftSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(-2, 198)), Qt::BottomLeftSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(-2, 202)), Qt::BottomLeftSection); + + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(202, -2)), Qt::TopRightSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(202, 10)), Qt::TopRightSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(202, 30)), Qt::RightSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(202, 170)), Qt::RightSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(202, 198)), Qt::BottomRightSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(202, 202)), Qt::BottomRightSection); + + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(50, -2)), Qt::TopSection); + QCOMPARE(widget.call_windowFrameSectionAt(QPointF(50, 202)), Qt::BottomSection); +} + void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() { QGraphicsScene scene; From ec71482374969c3bebd59f3bd001cf2d922e6bcd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 27 Jan 2015 14:40:04 +0100 Subject: [PATCH 070/101] Add qopenglconfig test. Add some parts of the qtdiag tool as a qtbase test to output the graphics configuration to the CI log and to verify that Open GL can be initialized for platforms on which the qopengl test is marked as insignificant (for example, ANGLE). Change-Id: Id445e57928e0307ad38cd433c52a62501f1097c6 Reviewed-by: Laszlo Agocs --- tests/auto/gui/gui.pro | 3 +- .../auto/gui/qopenglconfig/qopenglconfig.pro | 10 + .../gui/qopenglconfig/tst_qopenglconfig.cpp | 222 ++++++++++++++++++ 3 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 tests/auto/gui/qopenglconfig/qopenglconfig.pro create mode 100644 tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp diff --git a/tests/auto/gui/gui.pro b/tests/auto/gui/gui.pro index 78386cc0b17..d3393663ed9 100644 --- a/tests/auto/gui/gui.pro +++ b/tests/auto/gui/gui.pro @@ -7,9 +7,10 @@ SUBDIRS = \ image \ math3d \ painting \ + qopenglconfig \ qopengl \ text \ util \ itemmodels \ -!contains(QT_CONFIG, opengl(es2)?): SUBDIRS -= qopengl +!contains(QT_CONFIG, opengl(es2)?): SUBDIRS -= qopengl qopenglconfig diff --git a/tests/auto/gui/qopenglconfig/qopenglconfig.pro b/tests/auto/gui/qopenglconfig/qopenglconfig.pro new file mode 100644 index 00000000000..ebeb509d0b5 --- /dev/null +++ b/tests/auto/gui/qopenglconfig/qopenglconfig.pro @@ -0,0 +1,10 @@ +############################################################ +# Project file for autotest for gui/openglconfig functionality +############################################################ + +CONFIG += testcase +CONFIG += parallel_test +TARGET = tst_qopenglconfig +QT += gui-private core-private testlib + +SOURCES += tst_qopenglconfig.cpp diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp new file mode 100644 index 00000000000..75cc0e06f7e --- /dev/null +++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#define DUMP_CAPABILITY(str, integration, capability) \ + if (platformIntegration->hasCapability(QPlatformIntegration::capability)) \ + str << ' ' << #capability; + +QTextStream &operator<<(QTextStream &str, const QSize &s) +{ + str << s.width() << 'x' << s.height(); + return str; +} + +QTextStream &operator<<(QTextStream &str, const QRect &r) +{ + str << r.size() << '+' << r.x() << '+' << r.y(); + return str; +} + +QTextStream &operator<<(QTextStream &str, const QSizeF &s) +{ + str << s.width() << 'x' << s.height(); + return str; +} + +QTextStream &operator<<(QTextStream &str, const QSurfaceFormat &format) +{ + str << "Version: " << format.majorVersion() << '.' + << format.minorVersion() << " Profile: " << format.profile() + << " Swap behavior: " << format.swapBehavior() + << " Buffer size (RGB"; + if (format.hasAlpha()) + str << 'A'; + str << "): " << format.redBufferSize() << ',' << format.greenBufferSize() + << ',' << format.blueBufferSize(); + if (format.hasAlpha()) + str << ',' << format.alphaBufferSize(); + if (const int dbs = format.depthBufferSize()) + str << " Depth buffer: " << dbs; + if (const int sbs = format.stencilBufferSize()) + str << " Stencil buffer: " << sbs; + const int samples = format.samples(); + if (samples > 0) + str << " Samples: " << samples; + return str; +} + +/* This test contains code from the qtdiag tool. Its purpose is to output the + * graphics configuration to the CI log and to verify that Open GL can be + * initialized for platforms on which the qopengl test is marked as + * insignificant. */ + +class tst_QOpenGlConfig : public QObject +{ + Q_OBJECT + +private slots: + void testConfiguration(); + void testGlConfiguration(); +}; + +static void dumpConfiguration(QTextStream &str) +{ + const QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); + str << "\nBuild : " << QLibraryInfo::build() + << "\nPlatform : " << QGuiApplication::platformName() + << "\nOS : " << QSysInfo::prettyProductName() << " [" + << QSysInfo::kernelType() << " version " << QSysInfo::kernelVersion() << ']' + << "\nArchitecture : " << QSysInfo::currentCpuArchitecture() + << "\nCapabilities :"; + DUMP_CAPABILITY(str, platformIntegration, ThreadedPixmaps) + DUMP_CAPABILITY(str, platformIntegration, OpenGL) + DUMP_CAPABILITY(str, platformIntegration, ThreadedOpenGL) + DUMP_CAPABILITY(str, platformIntegration, SharedGraphicsCache) + DUMP_CAPABILITY(str, platformIntegration, BufferQueueingOpenGL) + DUMP_CAPABILITY(str, platformIntegration, WindowMasks) + DUMP_CAPABILITY(str, platformIntegration, RasterGLSurface) + DUMP_CAPABILITY(str, platformIntegration, AllGLFunctionsQueryable) + str << '\n'; + + const QList screens = QGuiApplication::screens(); + const int screenCount = screens.size(); + str << "\nScreens: " << screenCount << '\n'; + for (int s = 0; s < screenCount; ++s) { + const QScreen *screen = screens.at(s); + str << '#' << ' ' << s << " \"" << screen->name() << '"' + << " Depth: " << screen->depth() + << " Primary: " << (screen == QGuiApplication::primaryScreen() ? "yes" : "no") + << "\n Geometry: " << screen->geometry() << " Available: " << screen->availableGeometry(); + if (screen->geometry() != screen->virtualGeometry()) + str << "\n Virtual geometry: " << screen->virtualGeometry() << " Available: " << screen->availableVirtualGeometry(); + if (screen->virtualSiblings().size() > 1) + str << "\n " << screen->virtualSiblings().size() << " virtual siblings"; + str << "\n Physical size: " << screen->physicalSize() << " mm" + << " Refresh: " << screen->refreshRate() << " Hz" + << "\n Physical DPI: " << screen->physicalDotsPerInchX() + << ',' << screen->physicalDotsPerInchY() + << " Logical DPI: " << screen->logicalDotsPerInchX() + << ',' << screen->logicalDotsPerInchY() + << "\n DevicePixelRatio: " << screen->devicePixelRatio() + << " Primary orientation: " << screen->primaryOrientation() + << "\n Orientation: " << screen->orientation() + << " Native orientation: " << screen->nativeOrientation() + << " OrientationUpdateMask: " << screen->orientationUpdateMask() << '\n'; + } + + // On Windows, this will provide addition GPU info similar to the output of dxdiag. + const QVariant gpuInfoV = QGuiApplication::platformNativeInterface()->property("gpu"); + if (gpuInfoV.type() == QVariant::Map) { + const QString description = gpuInfoV.toMap().value(QStringLiteral("printable")).toString(); + if (!description.isEmpty()) + str << "\nGPU:\n" << description << "\n\n"; + } +} + +void tst_QOpenGlConfig::testConfiguration() +{ + QString result; + QTextStream str(&result); + dumpConfiguration(str); + + qDebug().noquote() << '\n' << result; +} + +static void dumpGlConfiguration(QOpenGLContext &context, QTextStream &str) +{ + str << "Type : "; +#ifdef QT_OPENGL_DYNAMIC + str << "Dynamic GL "; +#endif + switch (context.openGLModuleType()) { + case QOpenGLContext::LibGL: + str << "LibGL"; + break; + case QOpenGLContext::LibGLES: + str << "LibGLES"; + break; + } + QOpenGLFunctions functions(&context); + + str << "\nVendor : " << reinterpret_cast(functions.glGetString(GL_VENDOR)) + << "\nRenderer : " << reinterpret_cast(functions.glGetString(GL_RENDERER)) + << "\nVersion : " << reinterpret_cast(functions.glGetString(GL_VERSION)) + << "\nShading language : " << reinterpret_cast(functions.glGetString(GL_SHADING_LANGUAGE_VERSION)) + << "\nFormat : " << context.format(); + + QList extensionList = context.extensions().toList(); + std::sort(extensionList.begin(), extensionList.end()); + const int extensionCount = extensionList.size(); + str << "\n\nFound " << extensionCount << " extensions:\n"; + for (int e = 0; e < extensionCount; ++e) + str << ((e % 4) ? ' ' : '\n') << extensionList.at(e); +} + +void tst_QOpenGlConfig::testGlConfiguration() +{ + QString result; + QTextStream str(&result); + + QWindow window; + window.setSurfaceType(QSurface::OpenGLSurface); + window.create(); + QOpenGLContext context; + QVERIFY(context.create()); + QVERIFY(context.makeCurrent(&window)); + dumpGlConfiguration(context, str); + context.doneCurrent(); + + qDebug().noquote() << '\n' << result; +} + +QTEST_MAIN(tst_QOpenGlConfig) + +#include "tst_qopenglconfig.moc" From 392d8b5a75b4ac70b3dc4e856793771d86c50d82 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 Jan 2015 15:20:07 +0100 Subject: [PATCH 071/101] Windows: Fix screen changed emission for programmatic moves. Assign geometry in setGeometryDp() only when minimized as otherwise the variable will be set by the handling of the resize event triggered by setGeometry_sys()handleGeometryChange(). As it is, it suppresses the emission of screen change signals for programmatic move operations since the move is not detected. Change-Id: I5cd32bb16fd41dd720c16ddf84b88df642677af7 Task-number: QTBUG-44070 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 65bc9742e42..c2689543142 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1356,7 +1356,8 @@ void QWindowsWindow::setGeometryDp(const QRect &rectIn) const QMargins margins = frameMarginsDp(); rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top())); } - m_data.geometry = rect; + if (m_windowState == Qt::WindowMinimized) + m_data.geometry = rect; // Otherwise set by handleGeometryChange() triggered by event. if (m_data.hwnd) { // A ResizeEvent with resulting geometry will be sent. If we cannot // achieve that size (for example, window title minimal constraint), From c96b5d2b062e2757772a81927936e2a81be41c8e Mon Sep 17 00:00:00 2001 From: Daiwei Li Date: Thu, 22 Jan 2015 02:32:27 -0800 Subject: [PATCH 072/101] Cocoa: Keep menu invisible when adding it to a menubar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In MenuBar.qml, it's possible for __isNative to be set after visible on a child QQuickMenu. In that case, the qcocoamenu.mm will have set submenu to nil, only to be overridden in insertNativeMenu when __isNative is set. Change-Id: Id3c6bca03f937528d05b166cbd6a6d1011db43e8 Task-number: QTBUG-44168 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenubar.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index aceb9b619b1..0b465087827 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -100,7 +100,9 @@ void QCocoaMenuBar::insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu) menu->setMenuBar(this); syncMenu(static_cast(menu)); - [m_nativeMenu setSubmenu: menu->nsMenu() forItem: menu->nsMenuItem()]; + if (menu->isVisible()) { + [m_nativeMenu setSubmenu: menu->nsMenu() forItem: menu->nsMenuItem()]; + } } void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *before) From 10c62c894c25aa1224bc3441fd564430cf7c8103 Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Fri, 24 Oct 2014 12:57:09 -0700 Subject: [PATCH 073/101] CoreWLan: properly wait for scan thread to finish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Terminating the scan thread is leading to crashes. So was the previous solution to use wait(5000), since the scan thread may take longer than that. Task-number: QTBUG-36000 Change-Id: I5c37ba5ba3f5c156fca30f3dacaa998c15f76be8 Reviewed-by: Morten Johan Sørvig --- src/plugins/bearer/corewlan/qcorewlanengine.mm | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index 55847a04a4e..2b38409723a 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -430,7 +430,6 @@ QCoreWlanEngine::QCoreWlanEngine(QObject *parent) QCoreWlanEngine::~QCoreWlanEngine() { - scanThread->terminate(); scanThread->wait(); while (!foundConfigurations.isEmpty()) From c88e354993f8db3da741b1492f7578e9e0fdb07f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 21 Jan 2015 16:18:00 +0100 Subject: [PATCH 074/101] Windows: Rewrite font database to use delayed population. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-43774 Change-Id: I3b0b0ead0953b3b88a6d0092c694a2a00f70acf7 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Konstantin Ritt Reviewed-by: Tor Arne Vestbø --- .../windows/qwindowsfontdatabase.cpp | 93 +++++++++++-------- .../platforms/windows/qwindowsfontdatabase.h | 3 +- 2 files changed, 56 insertions(+), 40 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 246032dc948..9c26a227b82 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -946,9 +946,8 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet, } static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, - int type, LPARAM namesSetIn) + int type, LPARAM) { - typedef QSet StringSet; const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName); const uchar charSet = f->elfLogFont.lfCharSet; @@ -957,53 +956,71 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr // NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is // identical to a TEXTMETRIC except for the last four members, which we don't use // anyway - if (addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type)) - reinterpret_cast(namesSetIn)->insert(familyName); + addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type); // keep on enumerating return 1; } -void QWindowsFontDatabase::populateFontDatabase() +void QWindowsFontDatabase::populateFamily(const QString &familyName) { - m_families.clear(); - removeApplicationFonts(); - populate(); // Called multiple times. - // Work around EnumFontFamiliesEx() not listing the system font, see below. - const QString sysFontFamily = QGuiApplication::font().family(); - if (!m_families.contains(sysFontFamily)) - populate(sysFontFamily); -} - -/*! - \brief Populate font database using EnumFontFamiliesEx(). - - Normally, leaving the name empty should enumerate - all fonts, however, system fonts like "MS Shell Dlg 2" - are only found when specifying the name explicitly. -*/ - -void QWindowsFontDatabase::populate(const QString &family) - { - - qCDebug(lcQpaFonts) << __FUNCTION__ << m_families.size() << family; - + qCDebug(lcQpaFonts) << familyName; + if (familyName.size() >= LF_FACESIZE) { + qCWarning(lcQpaFonts) << "Unable to enumerate family '" << familyName << '\''; + return; + } HDC dummy = GetDC(0); LOGFONT lf; lf.lfCharSet = DEFAULT_CHARSET; - if (family.size() >= LF_FACESIZE) { - qWarning("%s: Unable to enumerate family '%s'.", - __FUNCTION__, qPrintable(family)); - return; - } - wmemcpy(lf.lfFaceName, reinterpret_cast(family.utf16()), - family.size() + 1); + familyName.toWCharArray(lf.lfFaceName); + lf.lfFaceName[familyName.size()] = 0; lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)&m_families, 0); + EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, 0, 0); ReleaseDC(0, dummy); } +namespace { +// Context for enumerating system fonts, records whether the default font has been encountered, +// which is normally not enumerated by EnumFontFamiliesEx(). +struct PopulateFamiliesContext +{ + PopulateFamiliesContext(const QString &f) : systemDefaultFont(f), seenSystemDefaultFont(false) {} + + QString systemDefaultFont; + bool seenSystemDefaultFont; +}; +} // namespace + +static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *, int, LPARAM lparam) +{ + // the "@family" fonts are just the same as "family". Ignore them. + const wchar_t *faceNameW = f->elfLogFont.lfFaceName; + if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) { + const QString faceName = QString::fromWCharArray(faceNameW); + QPlatformFontDatabase::registerFontFamily(faceName); + PopulateFamiliesContext *context = reinterpret_cast(lparam); + if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont) + context->seenSystemDefaultFont = true; + } + return 1; // continue +} + +void QWindowsFontDatabase::populateFontDatabase() +{ + removeApplicationFonts(); + HDC dummy = GetDC(0); + LOGFONT lf; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfFaceName[0] = 0; + lf.lfPitchAndFamily = 0; + PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family()); + EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)populateFontFamilies, reinterpret_cast(&context), 0); + ReleaseDC(0, dummy); + // Work around EnumFontFamiliesEx() not listing the system font. + if (!context.seenSystemDefaultFont) + QPlatformFontDatabase::registerFontFamily(context.systemDefaultFont); +} + typedef QSharedPointer QWindowsFontEngineDataPtr; #ifndef QT_NO_THREAD @@ -1365,7 +1382,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, // Fonts based on files are added via populate, as they will show up in font enumeration. for (int j = 0; j < families.count(); ++j) - populate(families.at(j)); + populateFamily(families.at(j)); } m_applicationFonts << font; @@ -1645,7 +1662,7 @@ QStringList QWindowsFontDatabase::fallbacksForFamily(const QString &family, QFon result.append(QWindowsFontDatabase::extraTryFontsForFamily(family)); qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint - << script << result << m_families.size(); + << script << result; return result; } diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h index 4abf2d703e8..8a682e6bec2 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h @@ -70,6 +70,7 @@ public: ~QWindowsFontDatabase(); void populateFontDatabase() Q_DECL_OVERRIDE; + void populateFamily(const QString &familyName) Q_DECL_OVERRIDE; QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) Q_DECL_OVERRIDE; QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE; QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) Q_DECL_OVERRIDE; @@ -99,9 +100,7 @@ public: static QString familyForStyleHint(QFont::StyleHint styleHint); private: - void populate(const QString &family = QString()); void removeApplicationFonts(); - QSet m_families; struct WinApplicationFont { HANDLE handle; From eb92a531c0bb237613f3f4948048e61af83dad77 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 20 Jan 2015 11:17:02 +0100 Subject: [PATCH 075/101] QWindowContainer: Restrict check for negative position to child windows. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, the code triggers for top level windows in setups with multimonitors where the primary screen is on the right and the left monitor has negative coordinates. Task-number: QTBUG-43879 Task-number: QTBUG-38475 Change-Id: Ied3ee6dc59bd784e11db22031d2090cc6f42ef8b Reviewed-by: Jan Arve Sæther --- src/widgets/kernel/qwindowcontainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 34cfb2d99f3..5460a43ef49 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -64,7 +64,7 @@ public: void updateGeometry() { Q_Q(QWindowContainer); - if (q->geometry().bottom() <= 0 || q->geometry().right() <= 0) + if (!q->isWindow() && (q->geometry().bottom() <= 0 || q->geometry().right() <= 0)) /* Qt (e.g. QSplitter) sometimes prefer to hide a widget by *not* calling setVisible(false). This is often done by setting its coordinates to a sufficiently negative value so that its clipped outside the parent. Since a QWindow is not clipped From 912f1ebaad29e5a0b8acba48691a565ba56c6b9e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Jan 2015 16:39:12 +0100 Subject: [PATCH 076/101] Windows: Pass geometry in device-independent pixel when determining screen. Fixes the emission of QWindow::screenChanged() when running with QT_DEVICE_PIXEL_RATIO != 1. QPlatformScreen::screenForGeometry() takes device-independent pixel. Task-number: QTBUG-44070 Change-Id: I963ecf62743d06784d62bc2f467e09fe5474e57f Reviewed-by: Alessandro Portale --- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index c2689543142..0216b40e3e3 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1432,7 +1432,7 @@ void QWindowsWindow::handleGeometryChange() fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true); } if (previousGeometry.topLeft() != m_data.geometry.topLeft()) { - QPlatformScreen *newScreen = screenForGeometry(m_data.geometry); + QPlatformScreen *newScreen = screenForGeometry(geometryDip); if (newScreen != screen()) QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); } From b85b78f17d3d18887b409a3ce9d2f2c71ae68844 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 27 Jan 2015 16:53:48 +0100 Subject: [PATCH 077/101] Suppress Ctrl/Ctrl+Shift keypresses in line/text edits. Ctrl/Ctrl+Shift should not cause any characters to be input (as opposed to AltGr(Alt+Ctrl) as used on German keyboards). Extend the tests in QLineEdit and QPlainTextEdit to check the modifiers, remove test from QTextEdit since it is handled by QWidgetTextControl. Task-number: QTBUG-35734 Change-Id: Ie0004fac68cf840c68247f27547e84b021355cd2 Reviewed-by: Gatis Paeglis --- src/widgets/widgets/qwidgetlinecontrol.cpp | 5 ++- src/widgets/widgets/qwidgettextcontrol.cpp | 6 ++++ .../widgets/qlineedit/tst_qlineedit.cpp | 35 ++++++++++++++----- .../qplaintextedit/tst_qplaintextedit.cpp | 33 ++++++++++++++--- .../widgets/qtextedit/tst_qtextedit.cpp | 7 ---- 5 files changed, 65 insertions(+), 21 deletions(-) diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 7033eeea227..86a830a9f92 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1879,7 +1879,10 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) unknown = false; } - if (unknown && !isReadOnly()) { + // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards + if (unknown && !isReadOnly() + && event->modifiers() != Qt::ControlModifier + && event->modifiers() != (Qt::ControlModifier | Qt::ShiftModifier)) { QString t = event->text(); if (!t.isEmpty() && t.at(0).isPrint()) { insert(t); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 8c48533a036..2e1e87be72d 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1339,6 +1339,12 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e) process: { + // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards + if (e->modifiers() == Qt::ControlModifier + || e->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) { + e->ignore(); + return; + } QString text = e->text(); if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) { if (overwriteMode diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index fec79326c89..5b467f4f176 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -249,6 +249,7 @@ private slots: void editInvalidText(); + void charWithAltOrCtrlModifier_data(); void charWithAltOrCtrlModifier(); void inlineCompletion(); @@ -3224,19 +3225,35 @@ void tst_QLineEdit::editInvalidText() testWidget->setValidator(0); } +Q_DECLARE_METATYPE(Qt::KeyboardModifiers) + +void tst_QLineEdit::charWithAltOrCtrlModifier_data() +{ + QTest::addColumn("modifiers"); + QTest::addColumn("textExpected"); + QTest::newRow("no-modifiers") << Qt::KeyboardModifiers() << true; + // Ctrl, Ctrl+Shift: No text (QTBUG-35734) + QTest::newRow("ctrl") << Qt::KeyboardModifiers(Qt::ControlModifier) + << false; + QTest::newRow("ctrl-shift") << Qt::KeyboardModifiers(Qt::ShiftModifier | Qt::ControlModifier) + << false; + QTest::newRow("alt") << Qt::KeyboardModifiers(Qt::AltModifier) << true; + // Alt-Ctrl (Alt-Gr on German keyboards, Task 129098): Expect text + QTest::newRow("alt-ctrl") << (Qt::AltModifier | Qt::ControlModifier) << true; +} + void tst_QLineEdit::charWithAltOrCtrlModifier() { + QFETCH(Qt::KeyboardModifiers, modifiers); + QFETCH(bool, textExpected); + QLineEdit *testWidget = ensureTestWidget(); testWidget->clear(); - QCOMPARE(testWidget->text(), QString("")); - QTest::keyPress(testWidget, Qt::Key_Plus); - QCOMPARE(testWidget->text(), QString("+")); - QTest::keyPress(testWidget, Qt::Key_Plus, Qt::ControlModifier); - QCOMPARE(testWidget->text(), QString("++")); - QTest::keyPress(testWidget, Qt::Key_Plus, Qt::AltModifier); - QCOMPARE(testWidget->text(), QString("+++")); - QTest::keyPress(testWidget, Qt::Key_Plus, Qt::AltModifier | Qt::ControlModifier); - QCOMPARE(testWidget->text(), QString("++++")); + QVERIFY(testWidget->text().isEmpty()); + + QTest::keyPress(testWidget, Qt::Key_Plus, modifiers); + const QString expectedText = textExpected ? QLatin1String("+") : QString(); + QCOMPARE(testWidget->text(), expectedText); } void tst_QLineEdit::leftKeyOnSelectedText() diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index cf495e22387..390b99c6e7a 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -99,7 +99,8 @@ private slots: #ifndef QT_NO_CLIPBOARD void copyAndSelectAllInReadonly(); #endif - void ctrlAltInput(); + void charWithAltOrCtrlModifier_data(); + void charWithAltOrCtrlModifier(); void noPropertiesOnDefaultTextEditCharFormat(); void setPlainTextShouldEmitTextChangedOnce(); void overwriteMode(); @@ -691,10 +692,34 @@ void tst_QPlainTextEdit::copyAndSelectAllInReadonly() } #endif -void tst_QPlainTextEdit::ctrlAltInput() +Q_DECLARE_METATYPE(Qt::KeyboardModifiers) + +// Test how QWidgetTextControlPrivate (used in QPlainTextEdit, QTextEdit) +// handles input with modifiers. +void tst_QPlainTextEdit::charWithAltOrCtrlModifier_data() { - QTest::keyClick(ed, Qt::Key_At, Qt::ControlModifier | Qt::AltModifier); - QCOMPARE(ed->toPlainText(), QString("@")); + QTest::addColumn("modifiers"); + QTest::addColumn("textExpected"); + + QTest::newRow("no-modifiers") << Qt::KeyboardModifiers() << true; + // Ctrl, Ctrl+Shift: No text (QTBUG-35734) + QTest::newRow("ctrl") << Qt::KeyboardModifiers(Qt::ControlModifier) + << false; + QTest::newRow("ctrl-shift") << Qt::KeyboardModifiers(Qt::ShiftModifier | Qt::ControlModifier) + << false; + QTest::newRow("alt") << Qt::KeyboardModifiers(Qt::AltModifier) << true; + // Alt-Ctrl (Alt-Gr on German keyboards, Task 129098): Expect text + QTest::newRow("alt-ctrl") << (Qt::AltModifier | Qt::ControlModifier) << true; +} + +void tst_QPlainTextEdit::charWithAltOrCtrlModifier() +{ + QFETCH(Qt::KeyboardModifiers, modifiers); + QFETCH(bool, textExpected); + + QTest::keyClick(ed, Qt::Key_At, modifiers); + const QString expectedText = textExpected ? QLatin1String("@") : QString(); + QCOMPARE(ed->toPlainText(), expectedText); } void tst_QPlainTextEdit::noPropertiesOnDefaultTextEditCharFormat() diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 8a82ee433d8..220185c04fc 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -122,7 +122,6 @@ private slots: #ifndef QT_NO_CLIPBOARD void copyAndSelectAllInReadonly(); #endif - void ctrlAltInput(); void noPropertiesOnDefaultTextEditCharFormat(); void setPlainTextShouldUseCurrentCharFormat(); void setPlainTextShouldEmitTextChangedOnce(); @@ -1042,12 +1041,6 @@ void tst_QTextEdit::copyAndSelectAllInReadonly() } #endif -void tst_QTextEdit::ctrlAltInput() -{ - QTest::keyClick(ed, Qt::Key_At, Qt::ControlModifier | Qt::AltModifier); - QCOMPARE(ed->toPlainText(), QString("@")); -} - void tst_QTextEdit::noPropertiesOnDefaultTextEditCharFormat() { // there should be no properties set on the default/initial char format From cd7a36d341c84f2595a33ceeb6ac7458978f30e1 Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Thu, 29 Jan 2015 21:35:37 +0100 Subject: [PATCH 078/101] QHeaderView: check that length is correct and fix restoring Qt4 state. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When multiple sections were grouped together, sectionItem.size was the total size of grouped sections, not the size of one section. Length is supposed to be equal to the section items length, but the state saved might be corrupted. Task-number: QTBUG-40462 Change-Id: I401a1583dd30880ccf5b4c105a237d6563f212e8 Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qheaderview.cpp | 77 +++++++++++++------ .../itemviews/qheaderview/tst_qheaderview.cpp | 31 ++++++++ 2 files changed, 85 insertions(+), 23 deletions(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index beade163394..fe99f7a5e0b 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3641,6 +3641,17 @@ bool QHeaderViewPrivate::read(QDataStream &in) QVector visualIndicesIn; QVector logicalIndicesIn; QHash hiddenSectionSizeIn; + bool movableSectionsIn; + bool clickableSectionsIn; + bool highlightSelectedIn; + bool stretchLastSectionIn; + bool cascadingResizingIn; + int stretchSectionsIn; + int contentsSectionsIn; + int defaultSectionSizeIn; + int minimumSectionSizeIn; + QVector sectionItemsIn; + in >> orient; in >> order; @@ -3662,6 +3673,39 @@ bool QHeaderViewPrivate::read(QDataStream &in) if (in.status() != QDataStream::Ok || lengthIn < 0) return false; + in >> movableSectionsIn; + in >> clickableSectionsIn; + in >> highlightSelectedIn; + in >> stretchLastSectionIn; + in >> cascadingResizingIn; + in >> stretchSectionsIn; + in >> contentsSectionsIn; + in >> defaultSectionSizeIn; + in >> minimumSectionSizeIn; + + in >> align; + + in >> global; + + in >> sectionItemsIn; + // In Qt4 we had a vector of spans where one span could hold information on more sections. + // Now we have an itemvector where one items contains information about one section + // For backward compatibility with Qt4 we do the following + QVector newSectionItems; + for (int u = 0; u < sectionItemsIn.count(); ++u) { + int count = sectionItemsIn.at(u).tmpDataStreamSectionCount; + if (count > 0) + sectionItemsIn[u].size /= count; + for (int n = 0; n < count; ++n) + newSectionItems.append(sectionItemsIn[u]); + } + + int sectionItemsLengthTotal = 0; + foreach (const SectionItem §ion, newSectionItems) + sectionItemsLengthTotal += section.size; + if (sectionItemsLengthTotal != lengthIn) + return false; + orientation = static_cast(orient); sortIndicatorOrder = static_cast(order); sortIndicatorSection = sortIndicatorSectionIn; @@ -3671,32 +3715,19 @@ bool QHeaderViewPrivate::read(QDataStream &in) hiddenSectionSize = hiddenSectionSizeIn; length = lengthIn; - in >> movableSections; - in >> clickableSections; - in >> highlightSelected; - in >> stretchLastSection; - in >> cascadingResizing; - in >> stretchSections; - in >> contentsSections; - in >> defaultSectionSize; - in >> minimumSectionSize; + movableSections = movableSectionsIn; + clickableSections = clickableSectionsIn; + highlightSelected = highlightSelectedIn; + stretchLastSection = stretchLastSectionIn; + cascadingResizing = cascadingResizingIn; + stretchSections = stretchSectionsIn; + contentsSections = contentsSectionsIn; + defaultSectionSize = defaultSectionSizeIn; + minimumSectionSize = minimumSectionSizeIn; - in >> align; defaultAlignment = Qt::Alignment(align); + globalResizeMode = static_cast(global); - in >> global; - globalResizeMode = (QHeaderView::ResizeMode)global; - - in >> sectionItems; - // In Qt4 we had a vector of spans where one span could hold information on more sections. - // Now we have an itemvector where one items contains information about one section - // For backward compatibility with Qt4 we do the following - QVector newSectionItems; - for (int u = 0; u < sectionItems.count(); ++u) { - int count = sectionItems.at(u).tmpDataStreamSectionCount; - for (int n = 0; n < count; ++n) - newSectionItems.append(sectionItems[u]); - } sectionItems = newSectionItems; setHiddenSectionsFromBitVector(sectionHidden); recalcSectionStartPos(); diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 408e98b8732..e632af12626 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -1646,6 +1646,37 @@ void tst_QHeaderView::saveRestore() QVERIFY(s1 == s2); QVERIFY(!h2.restoreState(QByteArrayLiteral("Garbage"))); + + // QTBUG-40462 + // Setting from Qt4, where information about multiple sections were grouped together in one + // sectionItem object + QByteArray settings_qt4 = + QByteArray::fromHex("000000ff00000000000000010000000100000000010000000000000000000000000000" + "0000000003e80000000a0101000100000000000000000000000064ffffffff00000081" + "0000000000000001000003e80000000a00000000"); + QVERIFY(h2.restoreState(settings_qt4)); + int sectionItemsLengthTotal = 0; + for (int i = 0; i < h2.count(); ++i) + sectionItemsLengthTotal += h2.sectionSize(i); + QVERIFY(sectionItemsLengthTotal == h2.length()); + + // Buggy setting where sum(sectionItems) != length. Check false is returned and this corrupted + // state isn't restored + QByteArray settings_buggy_length = + QByteArray::fromHex("000000ff000000000000000100000000000000050100000000000000000000000a4000" + "000000010000000600000258000000fb0000000a010100010000000000000000000000" + "0064ffffffff00000081000000000000000a000000d30000000100000000000000c800" + "000001000000000000008000000001000000000000005c00000001000000000000003c" + "0000000100000000000002580000000100000000000000000000000100000000000002" + "580000000100000000000002580000000100000000000003c000000001000000000000" + "03e8"); + int old_length = h2.length(); + QByteArray old_state = h2.saveState(); + // Check setting is correctly recognized as corrupted + QVERIFY(!h2.restoreState(settings_buggy_length)); + // Check nothing has been actually restored + QVERIFY(h2.length() == old_length); + QVERIFY(h2.saveState() == old_state); } void tst_QHeaderView::defaultSectionSizeTest() From 9718cb330cb479ec6e91f1f10c5ee9097fa2f4fb Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 29 Jan 2015 12:13:53 +0100 Subject: [PATCH 079/101] CMake: Fix QObject::connect failing on ARM We need PIE, doesn't matter if reduce_relocations is used or not Change-Id: I9a359b9d4443a6059980cd4c48058132ec4267fe Reviewed-by: Simon Hausmann Reviewed-by: Olivier Goffart (Woboq GmbH) --- mkspecs/features/create_cmake.prf | 2 -- src/corelib/Qt5CoreConfigExtras.cmake.in | 2 -- 2 files changed, 4 deletions(-) diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 3b0e03755d0..9f7ba46c3c5 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -171,8 +171,6 @@ contains(CONFIG, plugin) { return() } -unix:contains(QT_CONFIG, reduce_relocations):CMAKE_ADD_FPIE_FLAGS = "true" - CMAKE_MKSPEC = $$[QMAKE_XSPEC] CMAKE_MODULE_DEPS = $$cmakeModuleList($$sort_depends(QT.$${MODULE}.depends, QT.)) diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 9bda70ec07c..4387bedc447 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -66,14 +66,12 @@ list(APPEND Qt5Core_INCLUDE_DIRS ${_qt5_corelib_extra_includes}) set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5_corelib_extra_includes}) set(_qt5_corelib_extra_includes) -!!IF !isEmpty(CMAKE_ADD_FPIE_FLAGS) # Targets using Qt need to use the POSITION_INDEPENDENT_CODE property. The # Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module # macro to add it. set(Qt5_POSITION_INDEPENDENT_CODE True) set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\") set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIE\") -!!ENDIF !!IF !isEmpty(QT_NAMESPACE) list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE) From f562244f33dc0e7068cc651ee558597d9597b299 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Wed, 21 Jan 2015 14:55:30 +0200 Subject: [PATCH 080/101] Fix argv parameter to main() on Windows Task-number: QTBUG-44050 Change-Id: I5b7ddec9d66158d8075ab091b01e883520e5414e Reviewed-by: Friedemann Kleint --- src/winmain/qtmain_win.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/winmain/qtmain_win.cpp b/src/winmain/qtmain_win.cpp index 778ddee64b0..25b79543ba0 100644 --- a/src/winmain/qtmain_win.cpp +++ b/src/winmain/qtmain_win.cpp @@ -105,9 +105,10 @@ extern "C" int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR /*cmdParamarg*/, int wchar_t **argvW = CommandLineToArgvW(GetCommandLineW(), &argc); if (!argvW) return -1; - char **argv = new char *[argc]; + char **argv = new char *[argc + 1]; for (int i = 0; i < argc; ++i) argv[i] = wideToMulti(CP_ACP, argvW[i]); + argv[argc] = Q_NULLPTR; LocalFree(argvW); const int exitCode = main(argc, argv); for (int i = 0; i < argc; ++i) From cc4c684e03ce85c1920afedd6c5efe5ab8822e4a Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 30 Jan 2015 15:30:59 +0200 Subject: [PATCH 081/101] Overwrite QMAKE_DEFAULT_XXXDIRS values. If we set ANDROID_NDK_PLATFORM env variable, QMAKE_DEFAULT_XXXDIRS still contains old ANDROID_PLATFORM, so we need to overwrite it. Change-Id: I917e24caa11bd589966b3fb11be3a9f3c4370b3e Reviewed-by: Oswald Buddenhagen Reviewed-by: Eskil Abrahamsen Blomfeldt --- mkspecs/android-g++/qmake.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkspecs/android-g++/qmake.conf b/mkspecs/android-g++/qmake.conf index b0fea502067..26730de3036 100644 --- a/mkspecs/android-g++/qmake.conf +++ b/mkspecs/android-g++/qmake.conf @@ -205,3 +205,6 @@ QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 !exists($$NDK_ROOT): error("You need to set the ANDROID_NDK_ROOT environment variable to point to your Android NDK.") load(qt_config) + +QMAKE_DEFAULT_LIBDIRS = $$QMAKE_LIBDIR +QMAKE_DEFAULT_INCDIRS = $$QMAKE_INCDIR From 3fc27e7835b0a058c991c115cea53a4377f556fa Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 29 Jan 2015 17:25:31 +0100 Subject: [PATCH 082/101] fix env variable setup on unix for testcases when DESTDIR is set prepend the 'cd' command only after prepending the variables, as otherwise they'd apply to the cd command only. Task-number: QTBUG-44183 Change-Id: Ibf96a16ce2c9cd9c0e80ca3cd5433e64ec19b136 Reviewed-by: Jake Petroules --- mkspecs/features/testcase.prf | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/testcase.prf b/mkspecs/features/testcase.prf index 6656d1b8986..770afa33865 100644 --- a/mkspecs/features/testcase.prf +++ b/mkspecs/features/testcase.prf @@ -21,9 +21,6 @@ debug_and_release:debug_and_release_target { TEST_TARGET_DIR = $$relative_path($$absolute_path($$DESTDIR, $$OUT_PWD), $$absolute_path($$TESTRUN_CWD, $$OUT_PWD)) } -!isEmpty(TESTRUN_CWD):!contains(TESTRUN_CWD,^\\./?): \ - check.commands = cd $$shell_path($$TESTRUN_CWD) && - # Allow for a custom test runner script check.commands += $(TESTRUNNER) @@ -46,6 +43,10 @@ check.commands += $(TESTARGS) # Add environment for non-installed builds qtAddTargetEnv(check.commands, QT) +# This must happen after adding the environment. +!isEmpty(TESTRUN_CWD):!contains(TESTRUN_CWD, ^\\./?): \ + check.commands = cd $$shell_path($$TESTRUN_CWD) && $$check.commands + # If the test is marked as insignificant, discard the exit code insignificant_test:check.commands = -$${check.commands} From 1b329bfc79d34d7859e27a1fc2aa6eb58e690dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 22 Jan 2015 14:59:19 +0100 Subject: [PATCH 083/101] Cocoa: Don't crash on no target window. findEventTargetWindow() will return 0 if m_window is a top-level window with Qt::WindowTransparentForInput set. Change-Id: I413dabf2a8993b0522653c4e586bb304b642f3ed Task-number: QTBUG-44013 Reviewed-by: Timur Pocheptsov Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 771b4648055..5d3befa25b4 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1824,6 +1824,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]); QWindow *target = findEventTargetWindow(m_window); + if (!target) + return NSDragOperationNone; // update these so selecting move/copy/link works QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers: [[NSApp currentEvent] modifierFlags]]; @@ -1843,6 +1845,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin - (void)draggingExited:(id )sender { QWindow *target = findEventTargetWindow(m_window); + if (!target) + return; NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil]; QPoint qt_windowPoint(windowPoint.x, windowPoint.y); @@ -1855,6 +1859,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin - (BOOL)performDragOperation:(id )sender { QWindow *target = findEventTargetWindow(m_window); + if (!target) + return false; NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil]; QPoint qt_windowPoint(windowPoint.x, windowPoint.y); @@ -1880,6 +1886,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin Q_UNUSED(img); Q_UNUSED(operation); QWindow *target = findEventTargetWindow(m_window); + if (!target) + return; // keep our state, and QGuiApplication state (buttons member) in-sync, // or future mouse events will be processed incorrectly From 5bd41b850f65b8054d94b58b787704bb45ede16c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 2 Feb 2015 11:37:41 +0100 Subject: [PATCH 084/101] Correct inplace conversion methods from RGBA8888 formats The methods for inplace conversion from RGBA to ARGB was misplaced by one step causing conversion to RGB16 to get an invalid method. Change-Id: I3b2b4cffe993705c48613eec7d9b7c6213f57fc2 Reviewed-by: Gunnar Sletta --- src/gui/image/qimage_conversions.cpp | 6 +++--- tests/auto/gui/image/qimage/tst_qimage.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 858a0d9f210..b2681f42614 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -2520,7 +2520,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, - 0, + convert_RGBA_to_ARGB_inplace, convert_RGBA_to_ARGB_inplace, convert_RGBA_to_ARGB_inplace, 0, @@ -2543,7 +2543,6 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, - 0, convert_RGBA_to_ARGB_inplace, convert_RGBA_to_ARGB_PM_inplace, 0, @@ -2557,6 +2556,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, + 0, 0, 0, 0, 0 }, // Format_RGBA8888 { @@ -2566,7 +2566,6 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, - 0, convert_RGBA_to_ARGB_inplace, 0, 0, @@ -2579,6 +2578,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, + 0, 0, 0, 0, 0 }, // Format_RGBA8888_Premultiplied { diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 1fef747399f..ed1d9156708 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -2462,6 +2462,8 @@ void tst_QImage::inplaceConversion_data() QTest::newRow("Format_RGB666 -> Format_RGB888") << QImage::Format_RGB666 << QImage::Format_RGB888; QTest::newRow("Format_ARGB8565_Premultiplied, Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8565_Premultiplied << QImage::Format_ARGB8555_Premultiplied; QTest::newRow("Format_ARGB4444_Premultiplied, Format_RGB444") << QImage::Format_ARGB4444_Premultiplied << QImage::Format_RGB444; + QTest::newRow("Format_RGBA8888 -> RGB16") << QImage::Format_RGBA8888 << QImage::Format_RGB16; + QTest::newRow("Format_RGBA8888_Premultiplied -> RGB16") << QImage::Format_RGBA8888_Premultiplied << QImage::Format_RGB16; } void tst_QImage::inplaceConversion() @@ -2480,6 +2482,7 @@ void tst_QImage::inplaceConversion() const uchar* originalPtr = image.constScanLine(0); QImage imageConverted = std::move(image).convertToFormat(dest_format); + QCOMPARE(imageConverted.format(), dest_format); for (int i = 0; i < imageConverted.height(); ++i) { for (int j = 0; j < imageConverted.width(); ++j) { QRgb convertedColor = imageConverted.pixel(j,i); @@ -2487,8 +2490,8 @@ void tst_QImage::inplaceConversion() QCOMPARE(qGreen(convertedColor) & 0xF0, i * 16); } } - - QCOMPARE(imageConverted.constScanLine(0), originalPtr); + if (image.depth() == imageConverted.depth()) + QCOMPARE(imageConverted.constScanLine(0), originalPtr); #endif } From a2bcf43eb974d6ca725c11e06f1621db1d488892 Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Mon, 2 Feb 2015 12:43:59 -0800 Subject: [PATCH 085/101] Set dpr of QImage in QOpenGLWidget grabFramebuffer The QImage returned from grabFramebuffer should have the dpr of the source. Change-Id: Iafeabc1ab4e032fc28b73307104917ba3e898ad5 Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qopenglwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index db116b070cd..12e054626ca 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -758,6 +758,7 @@ QImage QOpenGLWidgetPrivate::grabFramebuffer() resolveSamples(); q->makeCurrent(); QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatio(), false, false); + res.setDevicePixelRatio(q->devicePixelRatio()); return res; } From 276de71be7309601963c87d0f3a658ae399d98e7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 4 Feb 2015 11:14:08 +0100 Subject: [PATCH 086/101] Handle failure of Windows XP theme painting functions for PE_FrameWindow. QWindowsXPStylePrivate::buffer() can fail due to CreateDIBSection() failing for large sizes. Introduce a bool return for the QWindowsXPStylePrivate::drawBackground() helpers and fall back to QWindowsStyle:::drawPrimitive() should that happen for PE_FrameWindow in QWindowsXPStyle::drawPrimitive(). Task-number: QTBUG-44282 Change-Id: I122d84576455bbad8e6639022da5bf64f79aed3a Reviewed-by: Joerg Bornemann --- src/widgets/styles/qwindowsxpstyle.cpp | 45 +++++++++++++++--------- src/widgets/styles/qwindowsxpstyle_p_p.h | 6 ++-- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index c1f7b599b38..a16e44cbaae 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -696,16 +696,18 @@ bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels) - Painter does not have an HDC - Theme part is flipped (mirrored horizontally) else use drawBackgroundDirectly(). + \note drawBackgroundThruNativeBuffer() can return false for large + sizes due to buffer()/CreateDIBSection() failing. */ -void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) +bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) { if (themeData.rect.isEmpty()) - return; + return true; QPainter *painter = themeData.painter; Q_ASSERT_X(painter != 0, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter"); if (!painter || !painter->isActive()) - return; + return false; painter->save(); @@ -741,13 +743,9 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) } const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0); - if (dc) { - drawBackgroundDirectly(themeData); - } else { - drawBackgroundThruNativeBuffer(themeData); - } - + const bool result = dc ? drawBackgroundDirectly(themeData) : drawBackgroundThruNativeBuffer(themeData); painter->restore(); + return result; } /*! \internal @@ -755,7 +753,7 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) Do not use this if you need to perform other transformations on the resulting data. */ -void QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData) +bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData) { QPainter *painter = themeData.painter; HDC dc = 0; @@ -830,6 +828,7 @@ void QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData) } SelectClipRgn(dc, 0); DeleteObject(hrgn); + return true; } /*! \internal @@ -840,7 +839,7 @@ void QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData) flips (horizonal mirroring only, vertical are handled by the theme engine). */ -void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeData) +bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeData) { QPainter *painter = themeData.painter; QRect rect = themeData.rect; @@ -964,7 +963,7 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa QImage img; if (!haveCachedPixmap) { // If the pixmap is not cached, generate it! ------------------------- if (!buffer(w, h)) // Ensure a buffer of at least (w, h) in size - return; + return false; HDC dc = bufferHDC(); // Clear the buffer @@ -1017,7 +1016,7 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa memset(&data, 0, sizeof(data)); data.dataValid = true; alphaCache.insert(key, data); - return; + return true; } hasAlpha = hasAlphaChannel(rect); if (!hasAlpha && partIsTransparent) @@ -1132,6 +1131,7 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa data.hadInvalidAlpha = wasAlphaFixed; alphaCache.insert(key, data); } + return true; } @@ -1860,18 +1860,29 @@ case PE_Frame: if (!theme.isValid()) break; + // May fail due to too-large buffers for large widgets, fall back to Windows style. theme.rect = QRect(option->rect.x(), option->rect.y()+fwidth, option->rect.x()+fwidth, option->rect.height()-fwidth); theme.partId = WP_FRAMELEFT; - d->drawBackground(theme); + if (!d->drawBackground(theme)) { + QWindowsStyle::drawPrimitive(pe, option, p, widget); + return; + } theme.rect = QRect(option->rect.width()-fwidth, option->rect.y()+fwidth, fwidth, option->rect.height()-fwidth); theme.partId = WP_FRAMERIGHT; - d->drawBackground(theme); + if (!d->drawBackground(theme)) { + QWindowsStyle::drawPrimitive(pe, option, p, widget); + return; + } theme.rect = QRect(option->rect.x(), option->rect.height()-fwidth, option->rect.width(), fwidth); theme.partId = WP_FRAMEBOTTOM; - d->drawBackground(theme); + if (!d->drawBackground(theme)) { + QWindowsStyle::drawPrimitive(pe, option, p, widget); + return; + } theme.rect = QRect(option->rect.x(), option->rect.y(), option->rect.width(), option->rect.y()+fwidth); theme.partId = WP_CAPTION; - d->drawBackground(theme); + if (!d->drawBackground(theme)) + QWindowsStyle::drawPrimitive(pe, option, p, widget); return; } break; diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index 5027588c939..3bc4a7cd661 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -398,9 +398,9 @@ public: QRegion region(XPThemeData &themeData); void setTransparency(QWidget *widget, XPThemeData &themeData); - void drawBackground(XPThemeData &themeData); - void drawBackgroundThruNativeBuffer(XPThemeData &themeData); - void drawBackgroundDirectly(XPThemeData &themeData); + bool drawBackground(XPThemeData &themeData); + bool drawBackgroundThruNativeBuffer(XPThemeData &themeData); + bool drawBackgroundDirectly(XPThemeData &themeData); bool hasAlphaChannel(const QRect &rect); bool fixAlphaChannel(const QRect &rect); From b1b262559cb73904ab642d38bb9ffeb515776de2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 4 Feb 2015 11:24:20 +0100 Subject: [PATCH 087/101] QWindowsXPStylePrivate::buffer(): Improve warnings. Task-number: QTBUG-44282 Change-Id: If617db5c6eae410042394f20855892a2c564e808 Reviewed-by: Joerg Bornemann --- src/widgets/styles/qwindowsxpstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index a16e44cbaae..78f80714615 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -505,13 +505,13 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h) nullBitmap = (HBITMAP)SelectObject(bufferDC, bufferBitmap); if (!bufferBitmap) { - qErrnoWarning("QWindowsXPStylePrivate::buffer(w,h), failed to create dibsection"); + qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() failed.", w, h); bufferW = 0; bufferH = 0; return 0; } if (!bufferPixels) { - qErrnoWarning("QWindowsXPStylePrivate::buffer(w,h), did not allocate pixel data"); + qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() did not allocate pixel data.", w, h); bufferW = 0; bufferH = 0; return 0; From 2e1a76a594c19d23263bb6dae616588eaaf602e3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 4 Feb 2015 09:05:27 +0100 Subject: [PATCH 088/101] Streamline code in QDesktopWidget. Task-number: QTBUG-44070 Task-number: QTBUG-44213 Change-Id: Icbf0547eb521b9f3fcc725066ee4903226ecc630 Reviewed-by: Joerg Bornemann --- src/widgets/kernel/qdesktopwidget.cpp | 35 +++++++++++---------------- src/widgets/kernel/qdesktopwidget_p.h | 2 +- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index 67264133efb..6698c13270f 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -72,29 +72,22 @@ void QDesktopWidgetPrivate::_q_updateScreens() const QList screenList = QGuiApplication::screens(); const int targetLength = screenList.length(); const int oldLength = screens.length(); - int currentLength = oldLength; // Add or remove screen widgets as necessary - if(currentLength > targetLength) { - QDesktopScreenWidget *screen; - while (currentLength-- > targetLength) { - screen = screens.takeLast(); - delete screen; - } - } - else if (currentLength < targetLength) { - while (currentLength < targetLength) { - QScreen *qScreen = screenList.at(currentLength); - QDesktopScreenWidget *screenWidget = new QDesktopScreenWidget(currentLength++); - screenWidget->setGeometry(qScreen->geometry()); - QObject::connect(qScreen, SIGNAL(geometryChanged(QRect)), - q, SLOT(_q_updateScreens()), Qt::QueuedConnection); - QObject::connect(qScreen, SIGNAL(availableGeometryChanged(QRect)), - q, SLOT(_q_availableGeometryChanged()), Qt::QueuedConnection); - QObject::connect(qScreen, SIGNAL(destroyed()), - q, SLOT(_q_updateScreens()), Qt::QueuedConnection); - screens.append(screenWidget); - } + while (screens.size() > targetLength) + delete screens.takeLast(); + + for (int currentLength = screens.size(); currentLength < targetLength; ++currentLength) { + QScreen *qScreen = screenList.at(currentLength); + QDesktopScreenWidget *screenWidget = new QDesktopScreenWidget(currentLength); + screenWidget->setGeometry(qScreen->geometry()); + QObject::connect(qScreen, SIGNAL(geometryChanged(QRect)), + q, SLOT(_q_updateScreens()), Qt::QueuedConnection); + QObject::connect(qScreen, SIGNAL(availableGeometryChanged(QRect)), + q, SLOT(_q_availableGeometryChanged()), Qt::QueuedConnection); + QObject::connect(qScreen, SIGNAL(destroyed()), + q, SLOT(_q_updateScreens()), Qt::QueuedConnection); + screens.append(screenWidget); } QRegion virtualGeometry; diff --git a/src/widgets/kernel/qdesktopwidget_p.h b/src/widgets/kernel/qdesktopwidget_p.h index 62f4d8ed6fa..9cd57e7110a 100644 --- a/src/widgets/kernel/qdesktopwidget_p.h +++ b/src/widgets/kernel/qdesktopwidget_p.h @@ -65,7 +65,7 @@ class QDesktopWidgetPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QDesktopWidget) public: - ~QDesktopWidgetPrivate() {foreach(QDesktopScreenWidget *s, screens) delete s; } + ~QDesktopWidgetPrivate() { qDeleteAll(screens); } void _q_updateScreens(); void _q_availableGeometryChanged(); From 83a3292342f70ba3bdc636c38031c6a1a74646c3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 4 Feb 2015 01:16:35 +0100 Subject: [PATCH 089/101] QPair: work around std::move not being constexpr in C++11 Use a static_cast instead. This is not 100% equivalent, since it's missing remove_reference<>, which we don't want to depend on and whose emulation in qtypetraits.h is missing rvalue support. That will be fixed in dev. Change-Id: Ib03754c81c904932943d3a5415b54ff107f4719d Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qpair.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index b2217e4dd0d..76b7abd2638 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -56,7 +56,9 @@ struct QPair { first = p.first; second = p.second; return *this; } #ifdef Q_COMPILER_RVALUE_REFS template - Q_DECL_CONSTEXPR QPair(QPair &&p) : first(std::move(p.first)), second(std::move(p.second)) {} + Q_DECL_CONSTEXPR QPair(QPair &&p) + // can't use std::move here as it's not constexpr in C++11: + : first(static_cast(p.first)), second(static_cast(p.second)) {} template QPair &operator=(QPair &&p) { first = std::move(p.first); second = std::move(p.second); return *this; } From dcedbce99a28a0a07c664ac264820412406a963e Mon Sep 17 00:00:00 2001 From: Antonio Lotti Date: Wed, 17 Dec 2014 15:55:09 +0100 Subject: [PATCH 090/101] Windows : fix call to LookupAccountNameW The call to LookupAccountNameW from advapi32 was rewritten following the example: http://msdn.microsoft.com/en-us/library/aa392742%28v=vs.85%29.aspx This prevents the generation of a garbage pointer when accessing QWindowsSystemProxy::init() for Qt compiled as 64bit library with MinGW-w64. Task-number: QTBUG-39874 Task-number: QTBUG-38145 Change-Id: I620b2fa64941f84838f9a386851480285336e8d1 Reviewed-by: Friedemann Kleint Reviewed-by: Richard J. Moore --- src/network/kernel/qnetworkproxy_win.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp index da2c020a656..f2176d664d6 100644 --- a/src/network/kernel/qnetworkproxy_win.cpp +++ b/src/network/kernel/qnetworkproxy_win.cpp @@ -130,10 +130,17 @@ static bool currentProcessIsService() DWORD size = UNLEN; if (ptrGetUserName(userName, &size)) { SID_NAME_USE type = SidTypeUser; - DWORD dummy = MAX_PATH; - wchar_t dummyStr[MAX_PATH] = L""; - PSID psid = 0; - if (ptrLookupAccountName(NULL, userName, &psid, &dummy, dummyStr, &dummy, &type)) + DWORD sidSize = 0; + DWORD domainSize = 0; + // first call is to get the correct size + bool bRet = ptrLookupAccountName(NULL, userName, NULL, &sidSize, NULL, &domainSize, &type); + if (bRet == FALSE && ERROR_INSUFFICIENT_BUFFER != GetLastError()) + return false; + QVarLengthArray buff(sidSize); + QVarLengthArray domainName(domainSize); + // second call to LookupAccountNameW actually gets the SID + // both the pointer to the buffer and the pointer to the domain name should not be NULL + if (ptrLookupAccountName(NULL, userName, buff.data(), &sidSize, domainName.data(), &domainSize, &type)) return type != SidTypeUser; //returns true if the current user is not a user } } From 6a607aa7aa56ddf4323aa78d64925192494befb8 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 28 Jan 2015 10:44:38 +0100 Subject: [PATCH 091/101] Do not specifically mention features supported since XP We do not support Windows older versions in the first place ... Change-Id: I2cd3135f1b7f2dac6929c07624ea9373f4ac0ff1 Reviewed-by: Oswald Buddenhagen --- src/network/kernel/qnetworkinterface.cpp | 3 +-- src/network/socket/qlocalsocket.cpp | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index b21bcee5850..7bdfae0d0df 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -353,8 +353,7 @@ void QNetworkAddressEntry::setBroadcast(const QHostAddress &newBroadcast) Not all operating systems support reporting all features. Only the IPv4 addresses are guaranteed to be listed by this class in all platforms. In particular, IPv6 address listing is only supported - on Windows XP and more recent versions, Linux, MacOS X and the - BSDs. + on Windows, Linux, OS X and the BSDs. \sa QNetworkAddressEntry */ diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index 164117e84f7..c1beedd53e8 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -56,9 +56,6 @@ QT_BEGIN_NAMESPACE waitForReadyRead(), waitForBytesWritten(), and waitForDisconnected() which blocks until the operation is complete or the timeout expires. - \note This feature is not supported on versions of Windows earlier than - Windows XP. - \sa QLocalServer */ From df3ffeec15cd20c249cb6ffb2d235526a05722a5 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 4 Feb 2015 15:12:36 +0100 Subject: [PATCH 092/101] QProcess/Win: fix sporadic crash QProcessPrivate::_q_processDied() was potentially called twice if there was a slot connected to readyRead() that called processEvents(), because the processFinishedNotifier was still enabled when readyRead() was emitted. This led to a null pointer access in findExitCode. Change-Id: I4b796b81f050dc46bb9469602984accaa6ebfa28 Task-number: QTBUG-33731 Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 2 +- src/corelib/io/qprocess_win.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index a2340507773..939cecfb445 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1044,9 +1044,9 @@ bool QProcessPrivate::_q_processDied() return false; #endif #ifdef Q_OS_WIN - drainOutputPipes(); if (processFinishedNotifier) processFinishedNotifier->setEnabled(false); + drainOutputPipes(); #endif // the process may have died before it got a chance to report that it was diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index ee6b7e13f46..9e60daa5b47 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -785,6 +785,7 @@ bool QProcessPrivate::waitForFinished(int msecs) void QProcessPrivate::findExitCode() { DWORD theExitCode; + Q_ASSERT(pid); if (GetExitCodeProcess(pid->hProcess, &theExitCode)) { exitCode = theExitCode; crashed = (exitCode == 0xf291 // our magic number, see killProcess From 239f67f158c55d3eb88348a53b87fa272402c733 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Jan 2015 16:57:20 +0100 Subject: [PATCH 093/101] Do not close popup widgets when showing a widget embedded into QGraphicsView. Disable top-level widget code path for embedded widget in the show helper. Task-number: QTBUG-43780 Change-Id: I574e07130e5e68a019a426cee3fde982f3883720 Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qwidget.cpp | 13 +++++-- .../tst_qgraphicsproxywidget.cpp | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 453a7ca5370..d8b8b151c2e 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -7738,10 +7738,17 @@ void QWidgetPrivate::show_helper() + const bool isWindow = q->isWindow(); +#ifndef QT_NO_GRAPHICSVIEW + bool isEmbedded = isWindow && q->graphicsProxyWidget() != Q_NULLPTR; +#else + bool isEmbedded = false; +#endif + // popup handling: new popups and tools need to be raised, and // existing popups must be closed. Also propagate the current // windows's KeyboardFocusChange status. - if (q->isWindow()) { + if (isWindow && !isEmbedded) { if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) { q->raise(); if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange)) @@ -7756,10 +7763,8 @@ void QWidgetPrivate::show_helper() // Automatic embedding of child windows of widgets already embedded into // QGraphicsProxyWidget when they are shown the first time. - bool isEmbedded = false; #ifndef QT_NO_GRAPHICSVIEW - if (q->isWindow()) { - isEmbedded = q->graphicsProxyWidget() ? true : false; + if (isWindow) { if (!isEmbedded && !bypassGraphicsProxyWidget(q)) { QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget()); if (ancestorProxy) { diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 66d0f64ceb2..5aea845f90d 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -175,6 +175,7 @@ private slots: void windowFrameMargins(); void QTBUG_6986_sendMouseEventToAlienWidget(); void mapToGlobal(); + void QTBUG_43780_visibility(); }; // Subclass that exposes the protected functions. @@ -278,6 +279,8 @@ void tst_QGraphicsProxyWidget::initTestCase() // Disable menu animations to prevent the alpha widget from getting in the way // in actionsContextMenu(). QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false); + // Disable combo for QTBUG_43780_visibility()/Windows Vista. + QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false); } // This will be called after the last test function is executed. @@ -3687,5 +3690,41 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 .arg(embeddedCenterGlobal.x()).arg(embeddedCenterGlobal.y()))); } +// QTBUG_43780: Embedded widgets have isWindow()==true but showing them should not +// trigger the top-level widget code path of show() that closes all popups +// (for example combo popups). +void tst_QGraphicsProxyWidget::QTBUG_43780_visibility() +{ + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + const QSize size = availableGeometry.size() / 4; + QWidget mainWindow; + QVBoxLayout *layout = new QVBoxLayout(&mainWindow); + QComboBox *combo = new QComboBox(&mainWindow); + combo->addItems(QStringList() << "i1" << "i2" << "i3"); + layout->addWidget(combo); + QGraphicsScene *scene = new QGraphicsScene(&mainWindow); + QGraphicsView *view = new QGraphicsView(scene, &mainWindow); + layout->addWidget(view); + mainWindow.setWindowTitle(QTest::currentTestFunction()); + mainWindow.resize(size); + mainWindow.move(availableGeometry.topLeft() + + QPoint(availableGeometry.width() - size.width(), + availableGeometry.height() - size.height()) / 2); + QLabel *label = new QLabel(QTest::currentTestFunction()); + scene->addWidget(label); + label->hide(); + mainWindow.show(); + combo->setFocus(); + mainWindow.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainWindow)); + combo->showPopup(); + QWidget *comboPopup = combo->view()->window(); + QVERIFY(comboPopup); + QVERIFY(QTest::qWaitForWindowExposed(comboPopup)); + label->show(); + QTRY_VERIFY(label->isVisible()); + QVERIFY(comboPopup->isVisible()); +} + QTEST_MAIN(tst_QGraphicsProxyWidget) #include "tst_qgraphicsproxywidget.moc" From 3c24dddaf963026c6e3cd90dd7d538dfa8044c83 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 5 Feb 2015 14:05:21 +0100 Subject: [PATCH 094/101] SSL NPN negotiation: Do not abort on unmatched protocols ... but choose HTTP/1.1 and continue connecting anyhow. According to the NPN spec, actually we should choose SPDY: "In the event that the client doesn't support any of server's protocols, or the server doesn't advertise any, it SHOULD select the first protocol that it supports." However, some tested servers did not advertise anything and did not support SPDY, so blindly trying the newest protocol would fail. We are conservative in that case and choose HTTP. Task-number: QTBUG-40714 Change-Id: Ia8aaf01fea74e13d9e4416306f85f1890b25559e Reviewed-by: Richard J. Moore --- .../access/qhttpnetworkconnectionchannel.cpp | 7 ++--- src/network/ssl/qsslsocket_openssl.cpp | 20 ++++++++----- tests/manual/qnetworkreply/main.cpp | 29 +++++++++++++++++++ 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index d24fb159e25..9f63280bf8d 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -931,7 +931,8 @@ void QHttpNetworkConnectionChannel::_q_encrypted() if (!protocolHandler) { switch (sslSocket->sslConfiguration().nextProtocolNegotiationStatus()) { - case QSslConfiguration::NextProtocolNegotiationNegotiated: { + case QSslConfiguration::NextProtocolNegotiationNegotiated: /* fall through */ + case QSslConfiguration::NextProtocolNegotiationUnsupported: { QByteArray nextProtocol = sslSocket->sslConfiguration().nextNegotiatedProtocol(); if (nextProtocol == QSslConfiguration::NextProtocolHttp1_1) { // fall through to create a QHttpProtocolHandler @@ -953,10 +954,6 @@ void QHttpNetworkConnectionChannel::_q_encrypted() // re-queue requests from SPDY queue to HTTP queue, if any requeueSpdyRequests(); break; - case QSslConfiguration::NextProtocolNegotiationUnsupported: - emitFinishedWithError(QNetworkReply::SslHandshakeFailedError, - "chosen Next Protocol Negotiation value unsupported"); - break; default: emitFinishedWithError(QNetworkReply::SslHandshakeFailedError, "detected unknown Next Protocol Negotiation protocol"); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 8833e3fdd8f..0e1a3e53c94 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1518,14 +1518,20 @@ void QSslSocketBackendPrivate::continueHandshake() } #if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) - const unsigned char *proto = 0; - unsigned int proto_len = 0; - q_SSL_get0_next_proto_negotiated(ssl, &proto, &proto_len); - if (proto_len) - configuration.nextNegotiatedProtocol = QByteArray(reinterpret_cast(proto), proto_len); - else - configuration.nextNegotiatedProtocol.clear(); + configuration.nextProtocolNegotiationStatus = sslContextPointer->npnContext().status; + if (sslContextPointer->npnContext().status == QSslConfiguration::NextProtocolNegotiationUnsupported) { + // we could not agree -> be conservative and use HTTP/1.1 + configuration.nextNegotiatedProtocol = QByteArrayLiteral("http/1.1"); + } else { + const unsigned char *proto = 0; + unsigned int proto_len = 0; + q_SSL_get0_next_proto_negotiated(ssl, &proto, &proto_len); + if (proto_len) + configuration.nextNegotiatedProtocol = QByteArray(reinterpret_cast(proto), proto_len); + else + configuration.nextNegotiatedProtocol.clear(); + } #endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ... connectionEncrypted = true; diff --git a/tests/manual/qnetworkreply/main.cpp b/tests/manual/qnetworkreply/main.cpp index 9d199c3755b..08a9df11445 100644 --- a/tests/manual/qnetworkreply/main.cpp +++ b/tests/manual/qnetworkreply/main.cpp @@ -69,6 +69,7 @@ private slots: void proxyAuthentication_data(); void proxyAuthentication(); void authentication(); + void npnWithEmptyList(); // QTBUG-40714 protected slots: void spdyReplyFinished(); // only used by spdyMultipleRequestsPerHost test @@ -577,6 +578,34 @@ void tst_qnetworkreply::authentication() QVERIFY(statusCode >= 200 && statusCode < 400); } +void tst_qnetworkreply::npnWithEmptyList() // QTBUG-40714 +{ +#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) && OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) + + // The server does not send a list of Next Protocols, so we test + // that we continue anyhow and it works + + m_manager.clearAccessCache(); + + QUrl url(QStringLiteral("https://www.ossifrage.net/")); + QNetworkRequest request(url); + request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, QVariant(true)); + QNetworkReply *reply = m_manager.get(request); + QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + + QTestEventLoop::instance().enterLoop(15); + QVERIFY(!QTestEventLoop::instance().timeout()); + + int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + QVERIFY(statusCode == 200); + + QCOMPARE(reply->sslConfiguration().nextProtocolNegotiationStatus(), + QSslConfiguration::NextProtocolNegotiationUnsupported); +#else + QSKIP("Qt built withouth OpenSSL, or the OpenSSL version is too old"); +#endif // defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) ... +} + QTEST_MAIN(tst_qnetworkreply) #include "main.moc" From 612953a626ec21b8518ee23a4f5268b566cf41e5 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 29 Jan 2015 16:22:08 +0100 Subject: [PATCH 095/101] xcb: delay showing tray icon window until it is embedded Otherwise there is a race condition: when the tray implementation gets around to embedding the window, if it was already shown, it will be unmapped, embedded, and then remapped. Some tray implementations will resize the tray icon to 1 pixel wide in that case. We also never want to show a window that was intended for the tray in any other location, so it's better that it remain invisible until we are sure it is embedded. Task-number: QTBUG-31762 Task-number: QTBUG-35658 Task-number: QTBUG-32811 Change-Id: Id324b0bfded0f8258ff1686a223cb2c069827d42 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 4fd71f1635f..96c5663d83e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -755,6 +755,9 @@ void QXcbWindow::show() if (connection()->time() != XCB_TIME_CURRENT_TIME) updateNetWmUserTime(connection()->time()); + if (window()->objectName() == QLatin1String("QSystemTrayIconSysWindow")) + return; // defer showing until XEMBED_EMBEDDED_NOTIFY + Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); if (QGuiApplication::modalWindow() == window()) @@ -2338,7 +2341,10 @@ void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event) switch (event->data.data32[1]) { case XEMBED_WINDOW_ACTIVATE: case XEMBED_WINDOW_DEACTIVATE: + break; case XEMBED_EMBEDDED_NOTIFY: + Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); + m_screen->windowShown(this); break; case XEMBED_FOCUS_IN: Qt::FocusReason reason; From dd4b09ae1aed3dd20c46ec240a43d70dc13f1ee4 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 6 Feb 2015 00:07:29 +0100 Subject: [PATCH 096/101] Fix QLineF Detailed Description Currently angle() is used in place of angleTo() to describe the difference with intersect. This patch fixes that. Task-number: QTBUG-44309 Change-Id: Idfc521932247f76fe15fd980ff8e87e52feec1f1 Reviewed-by: Sze Howe Koh --- src/corelib/tools/qline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index 4561f831c86..9feb697aad8 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -334,7 +334,7 @@ QDataStream &operator>>(QDataStream &stream, QLine &line) or a null line. The intersect() function determines the IntersectType for this - line and a given line, while the angle() function returns the + line and a given line, while the angleTo() function returns the angle between the lines. In addition, the unitVector() function returns a line that has the same starting point as this line, but with a length of only 1, while the normalVector() function returns From 6246e142a48dd66a8cba4ac2846276db5da952ed Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 25 Jan 2015 23:36:08 +0100 Subject: [PATCH 097/101] Improve QTextDocument::setPlainText/Html doc related to undo stack This patch aims to improve the documentation of setPlainText/setHtml to let the user know that the undo stack is cleared when both these function are called. Change-Id: I079f9f1dd407387941777ebbc7b5a7bc6dc005ec Reviewed-by: Konstantin Ritt Reviewed-by: Sze Howe Koh --- src/gui/text/qtextdocument.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index ea2b794febf..77e0fec80d0 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1171,7 +1171,7 @@ QString QTextDocument::toPlainText() const /*! Replaces the entire contents of the document with the given plain - \a text. + \a text. The undo/redo history is reset when this function is called. \sa setHtml() */ @@ -1189,7 +1189,8 @@ void QTextDocument::setPlainText(const QString &text) /*! Replaces the entire contents of the document with the given - HTML-formatted text in the \a html string. + HTML-formatted text in the \a html string. The undo/redo history + is reset when this function is called. The HTML formatting is respected as much as possible; for example, "bold text" will produce text where the first word has a font From 4805714b0f5d5584fd390067b6c092ca5ee7f482 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 26 Jan 2015 16:22:48 +0100 Subject: [PATCH 098/101] QIcon: Fix that HiDPI image was not found with QRC alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using images in QRC and giving the 1x and 2x image files respective aliases but without any file extension (for example 'myimage' and 'myimage@2x'), then QIcon would fail to find the 2x variant. Task-number: QTBUG-44049 Change-Id: I400bf6d22aeefe0aa351c68e473bf24ac2a36471 Reviewed-by: Morten Johan Sørvig --- src/gui/image/qicon.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 6f6bf158c82..86d9c02c6eb 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1026,13 +1026,13 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State // Check if a "@2x" file exists and add it. static bool disable2xImageLoading = !qgetenv("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING").isEmpty(); if (!disable2xImageLoading && qApp->devicePixelRatio() > 1.0) { + QString at2xfileName = fileName; int dotIndex = fileName.lastIndexOf(QLatin1Char('.')); - if (dotIndex != -1) { - QString at2xfileName = fileName; - at2xfileName.insert(dotIndex, QStringLiteral("@2x")); - if (QFile::exists(at2xfileName)) - d->engine->addFile(at2xfileName, size, mode, state); - } + if (dotIndex == -1) /* no dot */ + dotIndex = fileName.size(); /* append */ + at2xfileName.insert(dotIndex, QStringLiteral("@2x")); + if (QFile::exists(at2xfileName)) + d->engine->addFile(at2xfileName, size, mode, state); } } From b3fc5e1ea3eb4fe838ac716aaca4efaa5de5a814 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 4 Feb 2015 13:23:26 +0100 Subject: [PATCH 099/101] Improve handling of screens in QWidgets. Historically, the screen number of a QWidget was stored in QTLWExtra::screenIndex which came in via the Q_WS_QWS platform. The variable contained the screen number of the QDesktopScreenWidget and the desired screen number for widget creation (from parent widget or desktop parent widgets) and was not updated according to widget geometry or when the associated QWindow moved to another screen. Storing the screen number is problematic in Qt 5 since it may change when the list of QScreens in QGuiApplication is rearranged. This change renames it to initialScreen and changes its usage to only contain a screen number when a screen is requested by parenting on a desktop widget or reparenting. A value of -1 indicates no screen is requested and the number should be deduced from the geometry. For the usage in QDesktopScreenWidget, add a method to determine the number via index in the list of QDesktopWidget. Task-number: QTBUG-44070 Task-number: QTBUG-44213 Change-Id: I153d19073ad4b0fd14ef3d24caa6d3e76f350e82 Reviewed-by: Andy Shaw Reviewed-by: Shawn Rutledge Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qdesktopwidget.cpp | 9 +++++- src/widgets/kernel/qdesktopwidget_p.h | 6 ++-- src/widgets/kernel/qwidget.cpp | 40 +++++++++++++++------------ src/widgets/kernel/qwidget_p.h | 2 +- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index 6698c13270f..563707b0212 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -39,6 +39,13 @@ QT_BEGIN_NAMESPACE +int QDesktopScreenWidget::screenNumber() const +{ + const QDesktopWidgetPrivate *desktopWidgetP + = static_cast(qt_widget_private(QApplication::desktop())); + return desktopWidgetP->screens.indexOf(const_cast(this)); +} + const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const { if (!widget) { @@ -79,7 +86,7 @@ void QDesktopWidgetPrivate::_q_updateScreens() for (int currentLength = screens.size(); currentLength < targetLength; ++currentLength) { QScreen *qScreen = screenList.at(currentLength); - QDesktopScreenWidget *screenWidget = new QDesktopScreenWidget(currentLength); + QDesktopScreenWidget *screenWidget = new QDesktopScreenWidget; screenWidget->setGeometry(qScreen->geometry()); QObject::connect(qScreen, SIGNAL(geometryChanged(QRect)), q, SLOT(_q_updateScreens()), Qt::QueuedConnection); diff --git a/src/widgets/kernel/qdesktopwidget_p.h b/src/widgets/kernel/qdesktopwidget_p.h index 9cd57e7110a..29daaa4f976 100644 --- a/src/widgets/kernel/qdesktopwidget_p.h +++ b/src/widgets/kernel/qdesktopwidget_p.h @@ -53,12 +53,12 @@ QT_BEGIN_NAMESPACE class QDesktopScreenWidget : public QWidget { Q_OBJECT public: - QDesktopScreenWidget(int screenNumber = -1) : QWidget(0, Qt::Desktop) + QDesktopScreenWidget() : QWidget(Q_NULLPTR, Qt::Desktop) { setVisible(false); - QTLWExtra *topData = d_func()->topData(); - topData->screenIndex = screenNumber; } + + int screenNumber() const; }; class QDesktopWidgetPrivate : public QWidgetPrivate { diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index d8b8b151c2e..27d45ccea6e 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -35,7 +35,7 @@ #include "qapplication_p.h" #include "qbrush.h" #include "qcursor.h" -#include "qdesktopwidget.h" +#include "qdesktopwidget_p.h" #include "qevent.h" #include "qhash.h" #include "qlayout.h" @@ -1111,9 +1111,10 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) if (allWidgets) allWidgets->insert(q); - QWidget *desktopWidget = 0; + int targetScreen = -1; if (parentWidget && parentWidget->windowType() == Qt::Desktop) { - desktopWidget = parentWidget; + const QDesktopScreenWidget *sw = qobject_cast(parentWidget); + targetScreen = sw ? sw->screenNumber() : 0; parentWidget = 0; } @@ -1133,10 +1134,10 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) xinfo = desktopWidget->d_func()->xinfo; } #endif - if (desktopWidget) { - const int screen = desktopWidget->d_func()->topData()->screenIndex; + if (targetScreen >= 0) { + topData()->initialScreenIndex = targetScreen; if (QWindow *window = q->windowHandle()) - window->setScreen(QGuiApplication::screens().value(screen, 0)); + window->setScreen(QGuiApplication::screens().value(targetScreen, Q_NULLPTR)); } data.fstrut_dirty = true; @@ -1414,8 +1415,15 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO win->setGeometry(q->geometry()); else win->resize(q->size()); - if (win->isTopLevel()) - win->setScreen(QGuiApplication::screens().value(topData()->screenIndex, 0)); + if (win->isTopLevel()) { + int screenNumber = topData()->initialScreenIndex; + topData()->initialScreenIndex = -1; + if (screenNumber < 0) { + screenNumber = q->windowType() != Qt::Desktop + ? QApplication::desktop()->screenNumber(q) : 0; + } + win->setScreen(QGuiApplication::screens().value(screenNumber, Q_NULLPTR)); + } QSurfaceFormat format = win->requestedFormat(); if ((flags & Qt::Window) && win->surfaceType() != QSurface::OpenGLSurface @@ -1715,7 +1723,7 @@ void QWidgetPrivate::createTLExtra() x->embedded = 0; x->window = 0; x->shareContext = 0; - x->screenIndex = 0; + x->initialScreenIndex = -1; #ifdef Q_WS_MAC x->wasMaximized = false; #endif // Q_WS_MAC @@ -10503,9 +10511,8 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) if (newparent && newparent->windowType() == Qt::Desktop) { // make sure the widget is created on the same screen as the // programmer specified desktop widget - - // get the desktop's screen number - targetScreen = newparent->window()->d_func()->topData()->screenIndex; + const QDesktopScreenWidget *sw = qobject_cast(newparent); + targetScreen = sw ? sw->screenNumber() : 0; newparent = 0; } @@ -10537,7 +10544,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) f |= Qt::Window; if (targetScreen == -1) { if (parent) - targetScreen = q->parentWidget()->window()->d_func()->topData()->screenIndex; + targetScreen = QApplication::desktop()->screenNumber(q->parentWidget()->window()); } } @@ -10581,12 +10588,11 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) // move the window to the selected screen if (!newparent && targetScreen != -1) { - if (maybeTopData()) - maybeTopData()->screenIndex = targetScreen; // only if it is already created - if (q->testAttribute(Qt::WA_WState_Created)) { + if (q->testAttribute(Qt::WA_WState_Created)) q->windowHandle()->setScreen(QGuiApplication::screens().value(targetScreen, 0)); - } + else + topData()->initialScreenIndex = targetScreen; } } diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index b3552cba685..85e1cf93d61 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -212,7 +212,7 @@ struct QTLWExtra { #endif QWidgetWindow *window; QOpenGLContext *shareContext; - quint32 screenIndex; // index in qplatformscreenlist + int initialScreenIndex; // Screen number when passing a QDesktop[Screen]Widget as parent. }; struct QWExtra { From b444769840b2497f1295bca0694fe59aa78bb551 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Sat, 24 Jan 2015 21:26:06 +0200 Subject: [PATCH 100/101] Don't crash with invalid QModelIndex or when QTreeWidgetItem is NULL in mimeData() Change-Id: I0a9abaa05cf136eadf222d3e7d102930719b84ff Reviewed-by: David Faure --- src/gui/itemmodels/qstandarditemmodel.cpp | 23 +++++++++---------- src/widgets/itemviews/qtreewidget.cpp | 12 +++++++++- .../tst_qstandarditemmodel.cpp | 8 +++++++ .../itemviews/qtreewidget/tst_qtreewidget.cpp | 11 +++++++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 44ee710268f..eae2b419e36 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -2942,9 +2942,13 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const itemsSet.reserve(indexes.count()); stack.reserve(indexes.count()); for (int i = 0; i < indexes.count(); ++i) { - QStandardItem *item = itemFromIndex(indexes.at(i)); - itemsSet << item; - stack.push(item); + if (QStandardItem *item = itemFromIndex(indexes.at(i))) { + itemsSet << item; + stack.push(item); + } else { + qWarning() << "QStandardItemModel::mimeData: No item associated with invalid index"; + return 0; + } } //remove duplicates childrens @@ -2978,16 +2982,11 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const //stream everything recursively while (!stack.isEmpty()) { QStandardItem *item = stack.pop(); - if(itemsSet.contains(item)) { //if the item is selection 'top-level', strem its position + if (itemsSet.contains(item)) //if the item is selection 'top-level', stream its position stream << item->row() << item->column(); - } - if(item) { - stream << *item << item->columnCount() << item->d_ptr->children.count(); - stack += item->d_ptr->children; - } else { - QStandardItem dummy; - stream << dummy << 0 << 0; - } + + stream << *item << item->columnCount() << item->d_ptr->children.count(); + stack += item->d_ptr->children; } data->setData(format, encoded); diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 7378b9979a1..769a5b97b9f 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -3273,8 +3273,18 @@ QMimeData *QTreeWidget::mimeData(const QList items) const QList indexes; for (int i = 0; i < items.count(); ++i) { QTreeWidgetItem *item = items.at(i); + if (!item) { + qWarning() << "QTreeWidget::mimeData: Null-item passed"; + return 0; + } + for (int c = 0; c < item->values.count(); ++c) { - indexes << indexFromItem(item, c); + const QModelIndex index = indexFromItem(item, c); + if (!index.isValid()) { + qWarning() << "QTreeWidget::mimeData: No index associated with item :" << item; + return 0; + } + indexes << index; } } return d->model->QAbstractItemModel::mimeData(indexes); diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index cde6141a714..10dedfaf957 100644 --- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -129,6 +129,7 @@ private slots: void removeRowsAndColumns(); void itemRoleNames(); + void getMimeDataWithInvalidModelIndex(); private: QAbstractItemModel *m_model; @@ -1671,6 +1672,13 @@ void tst_QStandardItemModel::itemRoleNames() VERIFY_MODEL } +void tst_QStandardItemModel::getMimeDataWithInvalidModelIndex() +{ + QStandardItemModel model; + QTest::ignoreMessage(QtWarningMsg, "QStandardItemModel::mimeData: No item associated with invalid index"); + QMimeData *data = model.mimeData(QModelIndexList() << QModelIndex()); + QVERIFY(!data); +} QTEST_MAIN(tst_QStandardItemModel) #include "tst_qstandarditemmodel.moc" diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index c1331d62e12..bdeaaf38db6 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -49,6 +49,9 @@ class CustomTreeWidget : public QTreeWidget public: QModelIndex indexFromItem(QTreeWidgetItem *item, int column = 0) const { return QTreeWidget::indexFromItem(item, column); } + + QMimeData * mimeData(const QList items) const + { return QTreeWidget::mimeData(items); } }; class tst_QTreeWidget : public QObject @@ -157,6 +160,7 @@ private slots: void setChildIndicatorPolicy(); void task20345_sortChildren(); + void getMimeDataWithInvalidItem(); public slots: void itemSelectionChanged(); @@ -3368,6 +3372,13 @@ void tst_QTreeWidget::task20345_sortChildren() QVERIFY(1); } +void tst_QTreeWidget::getMimeDataWithInvalidItem() +{ + CustomTreeWidget w; + QTest::ignoreMessage(QtWarningMsg, "QTreeWidget::mimeData: Null-item passed"); + QMimeData *md = w.mimeData(QList() << Q_NULLPTR); + QVERIFY(!md); +} QTEST_MAIN(tst_QTreeWidget) #include "tst_qtreewidget.moc" From 0d990b9ca117514fe83f53b39f25d6272304f2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A5re=20S=C3=A4rs?= Date: Thu, 22 Jan 2015 22:40:37 +0200 Subject: [PATCH 101/101] Fix Meta+... shortcuts on XCB If the window contains a widget that accepts text input, a Meta+... shortcut will be interpreted as if no modifier was pressed. This fix enables the usage of Meta+... shortcuts for the XCB platform plugin. Change-Id: I80034b7e6bbbf18471c86fc77320d5038f5740be Task-number: QTBUG-43572 Reviewed-by: Aleix Pol Gonzalez Reviewed-by: Milian Wolff Reviewed-by: David Edmundson Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 5fb745717b9..85fef3912cc 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -933,7 +933,7 @@ xkb_keysym_t QXcbKeyboard::lookupLatinKeysym(xkb_keycode_t keycode) const QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const { // turn off the modifier bits which doesn't participate in shortcuts - Qt::KeyboardModifiers notNeeded = Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier; + Qt::KeyboardModifiers notNeeded = Qt::KeypadModifier | Qt::GroupSwitchModifier; Qt::KeyboardModifiers modifiers = event->modifiers() &= ~notNeeded; // create a fresh kb state and test against the relevant modifier combinations struct xkb_state *kb_state = xkb_state_new(xkb_keymap); @@ -963,10 +963,12 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const xkb_mod_index_t shiftMod = xkb_keymap_mod_get_index(xkb_keymap, "Shift"); 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"); + xkb_mod_index_t metaMod = xkb_keymap_mod_get_index(xkb_keymap, "Meta"); Q_ASSERT(shiftMod < 32); Q_ASSERT(altMod < 32); Q_ASSERT(controlMod < 32); + Q_ASSERT(metaMod < 32); xkb_mod_mask_t depressed; int qtKey = 0; @@ -987,6 +989,8 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const depressed |= (1 << shiftMod); if (neededMods & Qt::ControlModifier) depressed |= (1 << controlMod); + if (neededMods & Qt::MetaModifier) + depressed |= (1 << metaMod); xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods, 0, 0, lockedLayout); sym = xkb_state_key_get_one_sym(kb_state, keycode); }