From a5cded843f495b4276a8289b1324778d97bed5ba Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 11 Feb 2019 10:52:06 +0100 Subject: [PATCH 001/154] Avoid creating wide images with negative bytesPerLine The QImage API can not handle images with more bytes per line than what an integer can hold. Fixes: QTBUG-73731 Fixes: QTBUG-73732 Change-Id: Ieed6fec7645661fd58d8d25335f806faaa1bb3e9 Reviewed-by: Thiago Macieira --- src/gui/image/qimage.cpp | 11 +++++++++-- src/gui/image/qimage.h | 4 ++++ src/gui/image/qimage_p.h | 6 ++++++ tests/auto/gui/image/qimage/tst_qimage.cpp | 20 ++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 9897c3aa6f..3e18ca6528 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -124,7 +124,7 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format) int height = size.height(); int depth = qt_depthForFormat(format); auto params = calculateImageParameters(width, height, depth); - if (params.bytesPerLine < 0) + if (!params.isValid()) return nullptr; QScopedPointer d(new QImageData); @@ -781,7 +781,7 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm const int depth = qt_depthForFormat(format); auto params = calculateImageParameters(width, height, depth); - if (params.totalSize < 0) + if (!params.isValid()) return nullptr; if (bpl > 0) { @@ -1484,10 +1484,17 @@ qsizetype QImage::sizeInBytes() const \sa scanLine() */ +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +qsizetype QImage::bytesPerLine() const +{ + return d ? d->bytes_per_line : 0; +} +#else int QImage::bytesPerLine() const { return d ? d->bytes_per_line : 0; } +#endif /*! diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 4b7a3b1ead..6505fd5845 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -227,7 +227,11 @@ public: uchar *scanLine(int); const uchar *scanLine(int) const; const uchar *constScanLine(int) const; +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + qsizetype bytesPerLine() const; +#else int bytesPerLine() const; +#endif bool valid(int x, int y) const; bool valid(const QPoint &pt) const; diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index e3a6c53833..a0a3b5406e 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -109,6 +109,7 @@ struct Q_GUI_EXPORT QImageData { // internal image data struct ImageSizeParameters { qsizetype bytesPerLine; qsizetype totalSize; + bool isValid() const { return bytesPerLine > 0 && totalSize > 0; } }; static ImageSizeParameters calculateImageParameters(qsizetype width, qsizetype height, qsizetype depth); }; @@ -135,6 +136,11 @@ QImageData::calculateImageParameters(qsizetype width, qsizetype height, qsizetyp qsizetype dummy; if (mul_overflow(height, qsizetype(sizeof(uchar *)), &dummy)) return invalid; // why is this here? +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + // Disallow images where width * depth calculations might overflow + if (width > (INT_MAX - 31) / depth) + return invalid; +#endif return { bytes_per_line, total_size }; } diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index eded206d37..6bc27a6e16 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -230,6 +230,8 @@ private slots: void convertColorTable(); + void wideImage(); + #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void toWinHBITMAP_data(); void toWinHBITMAP(); @@ -3535,6 +3537,24 @@ void tst_QImage::convertColorTable() QCOMPARE(rgb32.pixel(0,0), 0xffffffff); } +void tst_QImage::wideImage() +{ + // QTBUG-73731 and QTBUG-73732 + QImage i(538994187, 2, QImage::Format_ARGB32); + QImage i2(32, 32, QImage::Format_ARGB32); + i2.fill(Qt::white); + + // Test that it doesn't crash: + QPainter painter(&i); + // With the composition mode is SourceOver out it's an invalid write + // With the composition mode is Source it's an invalid read + painter.drawImage(0, 0, i2); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.drawImage(0, 0, i2); + + // Qt6: Test that it actually works on 64bit architectures. +} + #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) QT_BEGIN_NAMESPACE Q_GUI_EXPORT HBITMAP qt_imageToWinHBITMAP(const QImage &p, int hbitmapFormat = 0); From 1366c4f04645d74e83847687adcf61ecfa20b3d2 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 18 Feb 2019 10:44:21 +0100 Subject: [PATCH 002/154] androiddeployqt: Do not check for stdcpp-path in auxiliary mode Fixes: QBS-1429 Change-Id: I189bc42fdee5e63f55705084247fbfc4448a6b65 Reviewed-by: Joerg Bornemann --- src/tools/androiddeployqt/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 712a8091fb..6f08238bcc 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -891,7 +891,7 @@ bool readInputFile(Options *options) options->extraPlugins = extraPlugins.toString().split(QLatin1Char(',')); } - { + if (!options->auxMode) { const QJsonValue stdcppPath = jsonObject.value(QStringLiteral("stdcpp-path")); if (stdcppPath.isUndefined()) { fprintf(stderr, "No stdcpp-path defined in json file.\n"); From 93a78799c3df7c8859b2d9addad45bb4a535dc97 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 13 Feb 2019 23:26:55 +0800 Subject: [PATCH 003/154] Fix compilation with icc, converting between egl's and gl's Error types Each has two constructors from the other, one copying the other moving; and this leads to an ambiguous overload when converting Texture::onDestroy()'s gl::error to the egl::Error that gl::Context::onDestroy() returns. Passing the value through a temporary prevents the move-constructor from being attempted and saves the day. Thanks to Ville Voutilainen for suggesting the fix. Fixes: QTBUG-73698 Change-Id: I628173399a73cee2e253201bc3e8d3e6477a2fbf Reviewed-by: Oliver Wolff Reviewed-by: Edward Welbourne --- src/3rdparty/angle/src/libANGLE/Context.cpp | 3 +- src/3rdparty/angle/src/libANGLE/Stream.cpp | 8 +- src/3rdparty/angle/src/libANGLE/Texture.cpp | 3 +- .../libANGLE/renderer/d3d/d3d9/Renderer9.cpp | 3 +- ...with-icc-converting-between-egl-s-an.patch | 93 +++++++++++++++++++ 5 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 src/angle/patches/0013-Fix-compilation-with-icc-converting-between-egl-s-an.patch diff --git a/src/3rdparty/angle/src/libANGLE/Context.cpp b/src/3rdparty/angle/src/libANGLE/Context.cpp index f638beda58..84f7936feb 100644 --- a/src/3rdparty/angle/src/libANGLE/Context.cpp +++ b/src/3rdparty/angle/src/libANGLE/Context.cpp @@ -451,7 +451,8 @@ egl::Error Context::onDestroy(const egl::Display *display) for (auto &zeroTexture : mZeroTextures) { - ANGLE_TRY(zeroTexture.second->onDestroy(this)); + auto result = zeroTexture.second->onDestroy(this); + ANGLE_TRY(egl::Error(result)); zeroTexture.second.set(this, nullptr); } mZeroTextures.clear(); diff --git a/src/3rdparty/angle/src/libANGLE/Stream.cpp b/src/3rdparty/angle/src/libANGLE/Stream.cpp index 68279976b7..e384c7d486 100644 --- a/src/3rdparty/angle/src/libANGLE/Stream.cpp +++ b/src/3rdparty/angle/src/libANGLE/Stream.cpp @@ -192,8 +192,9 @@ Error Stream::consumerAcquire(const gl::Context *context) { if (mPlanes[i].texture != nullptr) { - ANGLE_TRY(mPlanes[i].texture->acquireImageFromStream( - context, mProducerImplementation->getGLFrameDescription(i))); + auto result = mPlanes[i].texture->acquireImageFromStream( + context, mProducerImplementation->getGLFrameDescription(i)); + ANGLE_TRY(Error(result)); } } @@ -213,7 +214,8 @@ Error Stream::consumerRelease(const gl::Context *context) { if (mPlanes[i].texture != nullptr) { - ANGLE_TRY(mPlanes[i].texture->releaseImageFromStream(context)); + auto result = mPlanes[i].texture->releaseImageFromStream(context); + ANGLE_TRY(Error(result)); } } diff --git a/src/3rdparty/angle/src/libANGLE/Texture.cpp b/src/3rdparty/angle/src/libANGLE/Texture.cpp index da92e65916..7447604fe6 100644 --- a/src/3rdparty/angle/src/libANGLE/Texture.cpp +++ b/src/3rdparty/angle/src/libANGLE/Texture.cpp @@ -550,7 +550,8 @@ Error Texture::onDestroy(const Context *context) { if (mBoundSurface) { - ANGLE_TRY(mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER)); + auto result = mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER); + ANGLE_TRY(Error(result)); mBoundSurface = nullptr; } if (mBoundStream) diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp index 75c6298868..b583273641 100644 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp @@ -376,7 +376,8 @@ egl::Error Renderer9::initializeDevice() ASSERT(!mBlit); mBlit = new Blit9(this); - ANGLE_TRY(mBlit->initialize()); + auto result = mBlit->initialize(); + ANGLE_TRY(egl::Error(result)); ASSERT(!mVertexDataManager && !mIndexDataManager); mVertexDataManager = new VertexDataManager(this); diff --git a/src/angle/patches/0013-Fix-compilation-with-icc-converting-between-egl-s-an.patch b/src/angle/patches/0013-Fix-compilation-with-icc-converting-between-egl-s-an.patch new file mode 100644 index 0000000000..6d3b1cac08 --- /dev/null +++ b/src/angle/patches/0013-Fix-compilation-with-icc-converting-between-egl-s-an.patch @@ -0,0 +1,93 @@ +From 2d8118620d4871f74a3ddca233529ff540384477 Mon Sep 17 00:00:00 2001 +From: Yuhang Zhao <2546789017@qq.com> +Date: Wed, 13 Feb 2019 23:26:55 +0800 +Subject: [PATCH] Fix compilation with icc, converting between egl's and gl's + Error types + +Each has two constructors from the other, one copying the other +moving; and this leads to an ambiguous overload when converting +Texture::onDestroy()'s gl::error to the egl::Error that +gl::Context::onDestroy() returns. Passing the value through a +temporary prevents the move-constructor from being attempted and saves +the day. Thanks to Ville Voutilainen for suggesting the fix. + +Fixes: QTBUG-73698 +Change-Id: I628173399a73cee2e253201bc3e8d3e6477a2fbf +--- + src/3rdparty/angle/src/libANGLE/Context.cpp | 3 ++- + src/3rdparty/angle/src/libANGLE/Stream.cpp | 8 +++++--- + src/3rdparty/angle/src/libANGLE/Texture.cpp | 3 ++- + .../angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp | 3 ++- + 4 files changed, 11 insertions(+), 6 deletions(-) + +diff --git a/src/3rdparty/angle/src/libANGLE/Context.cpp b/src/3rdparty/angle/src/libANGLE/Context.cpp +index f638beda58..84f7936feb 100644 +--- a/src/3rdparty/angle/src/libANGLE/Context.cpp ++++ b/src/3rdparty/angle/src/libANGLE/Context.cpp +@@ -451,7 +451,8 @@ egl::Error Context::onDestroy(const egl::Display *display) + + for (auto &zeroTexture : mZeroTextures) + { +- ANGLE_TRY(zeroTexture.second->onDestroy(this)); ++ auto result = zeroTexture.second->onDestroy(this); ++ ANGLE_TRY(egl::Error(result)); + zeroTexture.second.set(this, nullptr); + } + mZeroTextures.clear(); +diff --git a/src/3rdparty/angle/src/libANGLE/Stream.cpp b/src/3rdparty/angle/src/libANGLE/Stream.cpp +index 68279976b7..e384c7d486 100644 +--- a/src/3rdparty/angle/src/libANGLE/Stream.cpp ++++ b/src/3rdparty/angle/src/libANGLE/Stream.cpp +@@ -192,8 +192,9 @@ Error Stream::consumerAcquire(const gl::Context *context) + { + if (mPlanes[i].texture != nullptr) + { +- ANGLE_TRY(mPlanes[i].texture->acquireImageFromStream( +- context, mProducerImplementation->getGLFrameDescription(i))); ++ auto result = mPlanes[i].texture->acquireImageFromStream( ++ context, mProducerImplementation->getGLFrameDescription(i)); ++ ANGLE_TRY(Error(result)); + } + } + +@@ -213,7 +214,8 @@ Error Stream::consumerRelease(const gl::Context *context) + { + if (mPlanes[i].texture != nullptr) + { +- ANGLE_TRY(mPlanes[i].texture->releaseImageFromStream(context)); ++ auto result = mPlanes[i].texture->releaseImageFromStream(context); ++ ANGLE_TRY(Error(result)); + } + } + +diff --git a/src/3rdparty/angle/src/libANGLE/Texture.cpp b/src/3rdparty/angle/src/libANGLE/Texture.cpp +index da92e65916..7447604fe6 100644 +--- a/src/3rdparty/angle/src/libANGLE/Texture.cpp ++++ b/src/3rdparty/angle/src/libANGLE/Texture.cpp +@@ -550,7 +550,8 @@ Error Texture::onDestroy(const Context *context) + { + if (mBoundSurface) + { +- ANGLE_TRY(mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER)); ++ auto result = mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER); ++ ANGLE_TRY(Error(result)); + mBoundSurface = nullptr; + } + if (mBoundStream) +diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +index 75c6298868..b583273641 100644 +--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp ++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +@@ -376,7 +376,8 @@ egl::Error Renderer9::initializeDevice() + + ASSERT(!mBlit); + mBlit = new Blit9(this); +- ANGLE_TRY(mBlit->initialize()); ++ auto result = mBlit->initialize(); ++ ANGLE_TRY(egl::Error(result)); + + ASSERT(!mVertexDataManager && !mIndexDataManager); + mVertexDataManager = new VertexDataManager(this); +-- +2.20.1.windows.1 + From 655e8623afed01de63ce43f55227fb019e800fe9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 Feb 2019 11:45:13 +0100 Subject: [PATCH 004/154] Fix QSplashscreen positioning on Android Android does not use QPlatformWindow::initialGeometry(), so the underlying assumption of 56e92dfdf255231aff0034d2e197fd096da7f0c0 was wrong. Try to explicitly find a screen and default to primary. Fixes: QTBUG-73794 Change-Id: Iba3e70657a60babfcedf751335ca55cb971a4f99 Reviewed-by: Oliver Wolff --- src/widgets/widgets/qsplashscreen.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index 4af4f90119..bf6bf1c7c9 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -289,8 +289,7 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap) // 1) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on // QSplashScreen(QWidget *, QPixmap). // 2) If a widget with associated QWindow is found, use that -// 3) When nothing can be found, do not position the widget, allowing for -// QPlatformWindow::initialGeometry() to center it over the cursor +// 3) When nothing can be found, try to center it over the cursor static inline int screenNumberOf(const QDesktopScreenWidget *dsw) { @@ -307,7 +306,15 @@ const QScreen *QSplashScreenPrivate::screenFor(const QWidget *w) if (QWindow *window = p->windowHandle()) return window->screen(); } - return nullptr; +#if QT_CONFIG(cursor) + // Note: We could rely on QPlatformWindow::initialGeometry() to center it + // over the cursor, but not all platforms (namely Android) use that. + if (QGuiApplication::screens().size() > 1) { + if (auto screenAtCursor = QGuiApplication::screenAt(QCursor::pos())) + return screenAtCursor; + } +#endif // cursor + return QGuiApplication::primaryScreen(); } void QSplashScreenPrivate::setPixmap(const QPixmap &p, const QScreen *screen) From 0f163887b526d00ccdcead907dde042aa370fc16 Mon Sep 17 00:00:00 2001 From: Juha Karjalainen Date: Tue, 19 Feb 2019 13:57:47 +0200 Subject: [PATCH 005/154] Fix blacklisting tst_QTimer::basic_chrono() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Blacklisting did not work as blacklist should have contained osx instead macos Change-Id: Ifd76a38d371ccce545eb5df030aaa819b00a5b48 Reviewed-by: Jędrzej Nowacki --- tests/auto/corelib/kernel/qtimer/BLACKLIST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/kernel/qtimer/BLACKLIST b/tests/auto/corelib/kernel/qtimer/BLACKLIST index c31e15f171..16cbab4587 100644 --- a/tests/auto/corelib/kernel/qtimer/BLACKLIST +++ b/tests/auto/corelib/kernel/qtimer/BLACKLIST @@ -2,4 +2,4 @@ windows osx [basic_chrono] -macos +osx From d6d80ff2e925c5c52de498535cfdb808b3bd3670 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 21 Feb 2019 16:43:58 +0100 Subject: [PATCH 006/154] Automatic resources: Fix tooling support The files to be put into an auto-generated qrc file must not simply disappear, because IDE users still need to have them in the project tree. So we add them to OTHER_FILES now. Task-number: QTCREATORBUG-20103 Task-number: QTCREATORBUG-20104 Change-Id: I8a9136491f975def7c33385e375c407815ad269a Reviewed-by: hjk Reviewed-by: Joerg Bornemann --- mkspecs/features/resources.prf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index bb2a55b93d..b4e0db6445 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -28,6 +28,7 @@ for(resource, RESOURCES) { !exists($$absolute_path($$resource, $$_PRO_FILE_PWD_)): \ warning("Failure to find: $$resource") qmake_immediate.files += $$resource + OTHER_FILES *= $$resource } RESOURCES -= $$resource next() @@ -57,6 +58,7 @@ for(resource, RESOURCES) { alias = $$relative_path($$file, $$abs_base) resource_file_content += \ "$$xml_escape($$file)" + OTHER_FILES *= $$file } } From 90959f7080d0d6d9953f0bc5fa7ac01a3e82e85f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 25 Feb 2019 12:08:21 +0100 Subject: [PATCH 007/154] Add all library dependencies for static OpenSSL builds on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Static builds of OpenSSL can now be linked with -openssl-linked without passing additional library dependencies like user32 or advapi32. Fixes: QTBUG-73205 Change-Id: I66c13096b0a1466c1e6dfbd014123e18655270e6 Reviewed-by: Mårten Nordheim Reviewed-by: Timur Pocheptsov --- src/network/configure.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/configure.json b/src/network/configure.json index f3e18662aa..2c005f0efb 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -84,11 +84,11 @@ "sources": [ { "type": "openssl" }, { - "libs": "-lssleay32 -llibeay32", + "libs": "-lssleay32 -llibeay32 -lUser32 -lWs2_32 -lAdvapi32 -lGdi32", "condition": "config.win32" }, { - "libs": "-llibssl -llibcrypto", + "libs": "-llibssl -llibcrypto -lUser32 -lWs2_32 -lAdvapi32 -lCrypt32", "condition": "config.msvc" }, { From 96f6cab22cab252cbe7a98bbeadde95497e0bd75 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 26 Feb 2019 10:38:58 +0100 Subject: [PATCH 008/154] Blacklist nouveau and llvmpipe for multithreading After removing Mesa drivers from being blank blacklisted, we still need to blacklist nouveau specifically due to their lack of proper locking: https://bugs.freedesktop.org/show_bug.cgi?id=91632 llvmpipe is similarly blacklisted for now, as we lack enough information to know if the underlying issue behind QTCREATORBUG-10666 has been solved. Fixes: QTBUG-73715 Change-Id: I1a60b562cd9db94fa8462b922d6bfeebf0088dc5 Reviewed-by: Laszlo Agocs --- .../xcb_glx/qglxintegration.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index d42a33c22b..476de6d1e5 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -652,6 +652,12 @@ static const char *qglx_threadedgl_blacklist_renderer[] = { 0 }; +static const char *qglx_threadedgl_blacklist_vendor[] = { + "llvmpipe", // QTCREATORBUG-10666 + "nouveau", // https://bugs.freedesktop.org/show_bug.cgi?id=91632 + nullptr +}; + void QGLXContext::queryDummyContext() { if (m_queriedDummyContext) @@ -710,6 +716,18 @@ void QGLXContext::queryDummyContext() } } } + if (const char *vendor = (const char *) glGetString(GL_VENDOR)) { + for (int i = 0; qglx_threadedgl_blacklist_vendor[i]; ++i) { + if (strstr(vendor, qglx_threadedgl_blacklist_vendor[i]) != 0) { + qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: " + "blacklisted vendor \"" + << qglx_threadedgl_blacklist_vendor[i] + << "\""; + m_supportsThreading = false; + break; + } + } + } if (glxvendor && m_supportsThreading) { // Blacklist Mesa drivers due to QTCREATORBUG-10875 (crash in creator), From 01f5d41a406b7baf1cb01692c870e5084fc11b1f Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 20 Feb 2019 13:30:52 +0100 Subject: [PATCH 009/154] Make tst_QUdpSocket::lincLocalIPv6 less sadistic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It fails on CI (Windows 10). Given our qabstractsocket disables read notifications/stops emitting readyRead if it already has pending data (unbuffered, aka UDP socket type) - make sure we do not suffer from this. The change does not affect the test's logic (unless the logic was to fail), it just makes it more fail-proof. Change-Id: I6c9b7ded20478f675260872a2a7032b4f356f197 Fixes: QTBUG-73884 Reviewed-by: Edward Welbourne Reviewed-by: Mårten Nordheim (cherry picked from commit d3eb9e944ac73f238b8716bb25b8051377bba946) Reviewed-by: Timur Pocheptsov --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 8ebb27e58c..707c1acf48 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1640,15 +1640,14 @@ void tst_QUdpSocket::linkLocalIPv6() sockets << s; } - QUdpSocket neutral; - QVERIFY(neutral.bind(QHostAddress(QHostAddress::AnyIPv6))); - QSignalSpy neutralReadSpy(&neutral, SIGNAL(readyRead())); - QByteArray testData("hello"); foreach (QUdpSocket *s, sockets) { + QUdpSocket neutral; + QVERIFY(neutral.bind(QHostAddress(QHostAddress::AnyIPv6))); + QSignalSpy neutralReadSpy(&neutral, SIGNAL(readyRead())); + QSignalSpy spy(s, SIGNAL(readyRead())); - neutralReadSpy.clear(); QVERIFY(s->writeDatagram(testData, s->localAddress(), neutral.localPort())); QTRY_VERIFY(neutralReadSpy.count() > 0); //note may need to accept a firewall prompt From e8d3306c8f86bf21648693521d8be91bb8f1335e Mon Sep 17 00:00:00 2001 From: Antti Kokko Date: Wed, 20 Feb 2019 15:21:30 +0200 Subject: [PATCH 010/154] Add changes file for Qt 5.12.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Done-with: Thiago Macieira Change-Id: Ia8c265403aa557be180eaa634474fb5f96a52b9f Reviewed-by: Edward Welbourne Reviewed-by: Tor Arne Vestbø Reviewed-by: Thiago Macieira --- dist/changes-5.12.2 | 105 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 dist/changes-5.12.2 diff --git a/dist/changes-5.12.2 b/dist/changes-5.12.2 new file mode 100644 index 0000000000..dc61d135a7 --- /dev/null +++ b/dist/changes-5.12.2 @@ -0,0 +1,105 @@ +Qt 5.12.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.12.0 through 5.12.1. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + + - QtTestLib: + * [QTBUG-72928] Blacklisting of tests will be taken into account for + XPASS and XFAIL. A blacklisted test that causes an XPASS will no + longer be a fail. + +**************************************************************************** +* QtCore * +**************************************************************************** + + - [QTBUG-72885] Fixed a number of warnings with Clang or Clang-Tidy in + Qt headers related to alignment of Qt private classes. + + - QDate, QTime and QDateTime; + * [QTBUG-51208] Corrected documentation of how non-placeholder + characters are handled in format patterns passed to toString(). + + - QCoreApplication: + * [QTBUG-57171] Fixed an out-of-bounds access if the translatable + string passed to tr() ended in '%'. + + - QFileInfo: + * [QTBUG-72644] Fixed a bug that would cause QFileInfo to report an + link incorrectly as a non-link. + + - QLocale: + * Fixed a crash if qDebug() is used after main() has exited. + * [QTBUG-73403] Fixed a race condition in getting the system locale + (possible regression from Qt 5.11.x) + + - QSysInfo: + * Fixed a bug on BSD systems in getting the machineUniqueId(). + * Fixed a bug on Windows in 32-bit applications getting the + machineUniqueId() when the OS is 64-bit. + + - QWaitCondition: + * Fixed handling of wait(QDeadlineTimer::Forever) on 32-bit platforms. + +**************************************************************************** +* QtWidgets * +**************************************************************************** + + - ItemViews: + * Fixed a regression with wrongly drawn centered/right aligned item + texts + +**************************************************************************** +* Third-Party Code * +**************************************************************************** + + - libpng was updated to version 1.6.36 + +**************************************************************************** +* Freetype * +**************************************************************************** + + - Upgraded bundled Freetype version to 2.9.1. This also adds support for + the latest emoji font in use on Android 9. + +**************************************************************************** +* Android * +**************************************************************************** + + - Added the --no-strip command line option to androiddeployqt. + + - qmake: + * Can now set the version name and code for Android using + ANDROID_VERSION_NAME and ANDROID_VERSION_CODE respectively in the pro + file. + +**************************************************************************** +* Windows * +**************************************************************************** + + - Fixed an issue where loading fonts from files or data would sometimes + mistakenly classify them as oblique. + +**************************************************************************** +* qmake * +**************************************************************************** + + - [QTBUG-27079] A new feature "cmdline" was added that implies "CONFIG += + console" and "CONFIG -= app_bundle". From 856fb1ab44722f5165fb6b5dec0bd748006acd10 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 5 Mar 2019 10:49:10 +0100 Subject: [PATCH 011/154] xcb: check for nullptr when reading AT_SPI_BUS property We always have to check the return value of xcb_get_property(), but this code did not do it. These xcb functions do not check for validity of the pointer, so we have to make sure that we pass-in something valid: void * xcb_get_property_value (const xcb_get_property_reply_t *R) { return (void *) (R + 1); } int xcb_get_property_value_length (const xcb_get_property_reply_t *R) { return (R->value_len * (R->format / 8)); } Fixes: QTBUG-74067 Change-Id: Iabbc81e6079d96c7314d16dd78783de07f9ad629 Reviewed-by: Mikhail Svetkin Reviewed-by: Frederik Gladhorn --- src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 524af5a2a7..6f3584f509 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -412,12 +412,15 @@ void *QXcbNativeInterface::atspiBus() auto reply = Q_XCB_REPLY(xcb_get_property, defaultConnection->xcb_connection(), false, defaultConnection->rootWindow(), atspiBusAtom, XCB_ATOM_STRING, 0, 128); - Q_ASSERT(!reply->bytes_after); + if (!reply) + return nullptr; + char *data = (char *)xcb_get_property_value(reply.get()); int length = xcb_get_property_value_length(reply.get()); return new QByteArray(data, length); } - return 0; + + return nullptr; } void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time) From 77a4915bf900aac0c96260018c0a4ccfbdd7c094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 30 Jan 2019 13:14:38 +0100 Subject: [PATCH 012/154] macOS: Add IOSurface based backingstore for layer-backed views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The naïve approach used for layer-backing in the past caused a detach of the backingstore QImage on each beginPaint, since the image was assigned to the layer via a CGImageRef that participated in the QImage implicit sharing (and had to, so we couldn't get around that). We now use IOSurfaces, wrapped in a QPlatformGraphicsBuffer abstraction. The surfaces can be assigned to the layer's content the same way images could, but allows us to reason more closely about whether or a buffer is in use, and increases the chance that we will have a zero-copy path to the screen. Unless the window has requested a surface format with single buffering we use a dynamic swap chain of buffers. In most situations there will be two buffers in play, one assigned to the layer and one ready to paint to, but during resize and some other situations the buffers will grow temporarily to accommodate the increased back-pressure. Since QBackingStore is documented as having single-buffer behavior, we take care to persist content between the buffers before every swap. By doing this before swapping, instead of before each paint, we can avoid preserving areas that will be painted to anyways, and will in many situations (such as blinking cursors e.g.) end up not persisting anything. The RasterGL surface case is handled by reading out the buffer data and doing a manual texture upload. In the future we can support direct texture access via CGLTexImageIOSurface2D, but this requires QPlatformBackingStore::composeAndFlush to learn how to support other targets than GL_TEXTURE_2D, as CGLTexImageIOSurface2D only works with GL_TEXTURE_RECTANGLE_ARB targets. Fixes: QTBUG-48763 Fixes: QTBUG-72360 Fixes: QTBUG-71162 Change-Id: Ica12f69b244e54d0fd31c929730d15657c286af8 Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qplatformgraphicsbuffer.h | 2 + src/plugins/platforms/cocoa/cocoa.pro | 4 +- .../platforms/cocoa/qcocoabackingstore.h | 52 +- .../platforms/cocoa/qcocoabackingstore.mm | 569 ++++++++++++++---- .../platforms/cocoa/qcocoaintegration.mm | 11 +- .../cocoa/qiosurfacegraphicsbuffer.h | 77 +++ .../cocoa/qiosurfacegraphicsbuffer.mm | 188 ++++++ .../platforms/cocoa/qnsview_drawing.mm | 7 + 8 files changed, 784 insertions(+), 126 deletions(-) create mode 100644 src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h create mode 100644 src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm diff --git a/src/gui/kernel/qplatformgraphicsbuffer.h b/src/gui/kernel/qplatformgraphicsbuffer.h index 0aeef946e6..11566e1201 100644 --- a/src/gui/kernel/qplatformgraphicsbuffer.h +++ b/src/gui/kernel/qplatformgraphicsbuffer.h @@ -71,12 +71,14 @@ public: TextureAccess = 0x04, HWCompositor = 0x08 }; + Q_ENUM(AccessType); Q_DECLARE_FLAGS(AccessTypes, AccessType); enum Origin { OriginBottomLeft, OriginTopLeft }; + Q_ENUM(Origin); virtual ~QPlatformGraphicsBuffer(); diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 8d65cf328f..083b7c1655 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -33,6 +33,7 @@ SOURCES += main.mm \ qcocoaintrospection.mm \ qcocoakeymapper.mm \ qcocoamimetypes.mm \ + qiosurfacegraphicsbuffer.mm \ messages.cpp HEADERS += qcocoaintegration.h \ @@ -67,6 +68,7 @@ HEADERS += qcocoaintegration.h \ qcocoaintrospection.h \ qcocoakeymapper.h \ messages.h \ + qiosurfacegraphicsbuffer.h \ qcocoamimetypes.h qtConfig(opengl.*) { @@ -81,7 +83,7 @@ qtConfig(vulkan) { RESOURCES += qcocoaresources.qrc -LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -lcups +LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups QT += \ core-private gui-private \ diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h index b4cd506513..508f24d578 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.h +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h @@ -44,13 +44,16 @@ #include +#include +#include "qiosurfacegraphicsbuffer.h" + QT_BEGIN_NAMESPACE -class QCocoaBackingStore : public QRasterBackingStore +class QNSWindowBackingStore : public QRasterBackingStore { public: - QCocoaBackingStore(QWindow *window); - ~QCocoaBackingStore(); + QNSWindowBackingStore(QWindow *window); + ~QNSWindowBackingStore(); void flush(QWindow *, const QRegion &, const QPoint &) override; @@ -60,6 +63,49 @@ private: void redrawRoundedBottomCorners(CGRect) const; }; +class QCALayerBackingStore : public QPlatformBackingStore +{ +public: + QCALayerBackingStore(QWindow *window); + ~QCALayerBackingStore(); + + void resize(const QSize &size, const QRegion &staticContents) override; + + void beginPaint(const QRegion ®ion) override; + QPaintDevice *paintDevice() override; + void endPaint() override; + + void flush(QWindow *, const QRegion &, const QPoint &) override; + void composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, + QPlatformTextureList *textures, bool translucentBackground) override; + + QPlatformGraphicsBuffer *graphicsBuffer() const override; + +private: + QSize m_requestedSize; + QRegion m_paintedRegion; + + class GraphicsBuffer : public QIOSurfaceGraphicsBuffer + { + public: + GraphicsBuffer(const QSize &size, qreal devicePixelRatio, + const QPixelFormat &format, QCFType colorSpace); + + QRegion dirtyRegion; // In unscaled coordinates + QImage *asImage(); + + private: + qreal m_devicePixelRatio; + QImage m_image; + }; + + void ensureBackBuffer(); + bool recreateBackBufferIfNeeded(); + bool prepareForFlush(); + + std::list> m_buffers; +}; + QT_END_NAMESPACE #endif diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 81a0a7d040..8e4e928bc5 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -42,24 +42,28 @@ #include "qcocoawindow.h" #include "qcocoahelpers.h" +#include + +#include + QT_BEGIN_NAMESPACE -QCocoaBackingStore::QCocoaBackingStore(QWindow *window) +QNSWindowBackingStore::QNSWindowBackingStore(QWindow *window) : QRasterBackingStore(window) { } -QCocoaBackingStore::~QCocoaBackingStore() +QNSWindowBackingStore::~QNSWindowBackingStore() { } -bool QCocoaBackingStore::windowHasUnifiedToolbar() const +bool QNSWindowBackingStore::windowHasUnifiedToolbar() const { Q_ASSERT(window()->handle()); return static_cast(window()->handle())->m_drawContentBorderGradient; } -QImage::Format QCocoaBackingStore::format() const +QImage::Format QNSWindowBackingStore::format() const { if (windowHasUnifiedToolbar()) return QImage::Format_ARGB32_Premultiplied; @@ -78,7 +82,7 @@ QImage::Format QCocoaBackingStore::format() const coordinates, and the \a offset will be the child window's offset in relation to the backingstore's top level window. */ -void QCocoaBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) +void QNSWindowBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { if (m_image.isNull()) return; @@ -103,131 +107,113 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo qCDebug(lcQpaBackingStore) << "Flushing" << region << "of" << view << qPrintable(targetViewDescription); } + // Normally a NSView is drawn via drawRect, as part of the display cycle in the + // main runloop, via setNeedsDisplay and friends. AppKit will lock focus on each + // individual view, starting with the top level and then traversing any subviews, + // calling drawRect for each of them. This pull model results in expose events + // sent to Qt, which result in drawing to the backingstore and flushing it. + // Qt may also decide to paint and flush the backingstore via e.g. timers, + // or other events such as mouse events, in which case we're in a push model. + // If there is no focused view, it means we're in the latter case, and need + // to manually flush the NSWindow after drawing to its graphic context. + const bool drawingOutsideOfDisplayCycle = ![NSView focusView]; + + // We also need to ensure the flushed view has focus, so that the graphics + // context is set up correctly (coordinate system, clipping, etc). Outside + // of the normal display cycle there is no focused view, as explained above, + // so we have to handle it manually. There's also a corner case inside the + // normal display cycle due to way QWidgetBackingStore composits native child + // widgets, where we'll get a flush of a native child during the drawRect of + // its parent/ancestor, and the parent/ancestor being the one locked by AppKit. + // In this case we also need to lock and unlock focus manually. + const bool shouldHandleViewLockManually = [NSView focusView] != view; + if (shouldHandleViewLockManually && ![view lockFocusIfCanDraw]) { + qWarning() << "failed to lock focus of" << view; + return; + } + + const qreal devicePixelRatio = m_image.devicePixelRatio(); + + // If the flushed window is a content view, and we're filling the drawn area + // completely, or it doesn't have a window background we need to preserve, + // we can get away with copying instead of blending the backing store. + QCocoaWindow *cocoaWindow = static_cast(window->handle()); + const NSCompositingOperation compositingOperation = cocoaWindow->isContentView() + && (cocoaWindow->isOpaque() || view.window.backgroundColor == NSColor.clearColor) + ? NSCompositingOperationCopy : NSCompositingOperationSourceOver; + +#ifdef QT_DEBUG + static bool debugBackingStoreFlush = [[NSUserDefaults standardUserDefaults] + boolForKey:@"QtCocoaDebugBackingStoreFlush"]; +#endif + + // ------------------------------------------------------------------------- + + // The current contexts is typically a NSWindowGraphicsContext, but can be + // NSBitmapGraphicsContext e.g. when debugging the view hierarchy in Xcode. + // If we need to distinguish things here in the future, we can use e.g. + // [NSGraphicsContext drawingToScreen], or the attributes of the context. + NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext]; + Q_ASSERT_X(graphicsContext, "QCocoaBackingStore", + "Focusing the view should give us a current graphics context"); + // Prevent potentially costly color conversion by assigning the display color space // to the backingstore image. This does not copy the underlying image data. CGColorSpaceRef displayColorSpace = view.window.screen.colorSpace.CGColorSpace; QCFType cgImage = CGImageCreateCopyWithColorSpace( QCFType(m_image.toCGImage()), displayColorSpace); - if (view.layer) { - // In layer-backed mode, locking focus on a view does not give the right - // view transformation, and doesn't give us a graphics context to render - // via when drawing outside of the display cycle. Instead we tell AppKit - // that we want to update the layer's content, via [NSView wantsUpdateLayer], - // which result in AppKit not creating a backingstore for each layer, and - // we then directly set the layer's backingstore (content) to our backingstore, - // masked to the part of the subview that is relevant. - // FIXME: Figure out if there's a way to do partial updates - view.layer.contents = (__bridge id)static_cast(cgImage); - if (view != topLevelView) { - const CGSize topLevelSize = topLevelView.bounds.size; - view.layer.contentsRect = CGRectApplyAffineTransform( - [view convertRect:view.bounds toView:topLevelView], - // The contentsRect is in unit coordinate system - CGAffineTransformMakeScale(1.0 / topLevelSize.width, 1.0 / topLevelSize.height)); - } - } else { - // Normally a NSView is drawn via drawRect, as part of the display cycle in the - // main runloop, via setNeedsDisplay and friends. AppKit will lock focus on each - // individual view, starting with the top level and then traversing any subviews, - // calling drawRect for each of them. This pull model results in expose events - // sent to Qt, which result in drawing to the backingstore and flushing it. - // Qt may also decide to paint and flush the backingstore via e.g. timers, - // or other events such as mouse events, in which case we're in a push model. - // If there is no focused view, it means we're in the latter case, and need - // to manually flush the NSWindow after drawing to its graphic context. - const bool drawingOutsideOfDisplayCycle = ![NSView focusView]; + // Create temporary image to use for blitting, without copying image data + NSImage *backingStoreImage = [[[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize] autorelease]; - // We also need to ensure the flushed view has focus, so that the graphics - // context is set up correctly (coordinate system, clipping, etc). Outside - // of the normal display cycle there is no focused view, as explained above, - // so we have to handle it manually. There's also a corner case inside the - // normal display cycle due to way QWidgetBackingStore composits native child - // widgets, where we'll get a flush of a native child during the drawRect of - // its parent/ancestor, and the parent/ancestor being the one locked by AppKit. - // In this case we also need to lock and unlock focus manually. - const bool shouldHandleViewLockManually = [NSView focusView] != view; - if (shouldHandleViewLockManually && ![view lockFocusIfCanDraw]) { - qWarning() << "failed to lock focus of" << view; - return; - } - - const qreal devicePixelRatio = m_image.devicePixelRatio(); - - // If the flushed window is a content view, and we're filling the drawn area - // completely, or it doesn't have a window background we need to preserve, - // we can get away with copying instead of blending the backing store. - QCocoaWindow *cocoaWindow = static_cast(window->handle()); - const NSCompositingOperation compositingOperation = cocoaWindow->isContentView() - && (cocoaWindow->isOpaque() || view.window.backgroundColor == NSColor.clearColor) - ? NSCompositingOperationCopy : NSCompositingOperationSourceOver; - -#ifdef QT_DEBUG - static bool debugBackingStoreFlush = [[NSUserDefaults standardUserDefaults] - boolForKey:@"QtCocoaDebugBackingStoreFlush"]; -#endif - - // ------------------------------------------------------------------------- - - // The current contexts is typically a NSWindowGraphicsContext, but can be - // NSBitmapGraphicsContext e.g. when debugging the view hierarchy in Xcode. - // If we need to distinguish things here in the future, we can use e.g. - // [NSGraphicsContext drawingToScreen], or the attributes of the context. - NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext]; - Q_ASSERT_X(graphicsContext, "QCocoaBackingStore", - "Focusing the view should give us a current graphics context"); - - // Create temporary image to use for blitting, without copying image data - NSImage *backingStoreImage = [[[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize] autorelease]; - - QRegion clippedRegion = region; - for (QWindow *w = window; w; w = w->parent()) { - if (!w->mask().isEmpty()) { - clippedRegion &= w == window ? w->mask() - : w->mask().translated(window->mapFromGlobal(w->mapToGlobal(QPoint(0, 0)))); - } - } - - for (const QRect &viewLocalRect : clippedRegion) { - QPoint backingStoreOffset = viewLocalRect.topLeft() + offset; - QRect backingStoreRect(backingStoreOffset * devicePixelRatio, viewLocalRect.size() * devicePixelRatio); - if (graphicsContext.flipped) // Flip backingStoreRect to match graphics context - backingStoreRect.moveTop(m_image.height() - (backingStoreRect.y() + backingStoreRect.height())); - - CGRect viewRect = viewLocalRect.toCGRect(); - - if (windowHasUnifiedToolbar()) - NSDrawWindowBackground(viewRect); - - [backingStoreImage drawInRect:viewRect fromRect:backingStoreRect.toCGRect() - operation:compositingOperation fraction:1.0 respectFlipped:YES hints:nil]; - -#ifdef QT_DEBUG - if (Q_UNLIKELY(debugBackingStoreFlush)) { - [[NSColor colorWithCalibratedRed:drand48() green:drand48() blue:drand48() alpha:0.3] set]; - [NSBezierPath fillRect:viewRect]; - - if (drawingOutsideOfDisplayCycle) { - [[[NSColor magentaColor] colorWithAlphaComponent:0.5] set]; - [NSBezierPath strokeLineFromPoint:viewLocalRect.topLeft().toCGPoint() - toPoint:viewLocalRect.bottomRight().toCGPoint()]; - } - } -#endif - } - - // ------------------------------------------------------------------------- - - if (shouldHandleViewLockManually) - [view unlockFocus]; - - if (drawingOutsideOfDisplayCycle) { - redrawRoundedBottomCorners([view convertRect:region.boundingRect().toCGRect() toView:nil]); - [view.window flushWindow]; + QRegion clippedRegion = region; + for (QWindow *w = window; w; w = w->parent()) { + if (!w->mask().isEmpty()) { + clippedRegion &= w == window ? w->mask() + : w->mask().translated(window->mapFromGlobal(w->mapToGlobal(QPoint(0, 0)))); } } - // Done flushing to either CALayer or NSWindow backingstore + for (const QRect &viewLocalRect : clippedRegion) { + QPoint backingStoreOffset = viewLocalRect.topLeft() + offset; + QRect backingStoreRect(backingStoreOffset * devicePixelRatio, viewLocalRect.size() * devicePixelRatio); + if (graphicsContext.flipped) // Flip backingStoreRect to match graphics context + backingStoreRect.moveTop(m_image.height() - (backingStoreRect.y() + backingStoreRect.height())); + + CGRect viewRect = viewLocalRect.toCGRect(); + + if (windowHasUnifiedToolbar()) + NSDrawWindowBackground(viewRect); + + [backingStoreImage drawInRect:viewRect fromRect:backingStoreRect.toCGRect() + operation:compositingOperation fraction:1.0 respectFlipped:YES hints:nil]; + +#ifdef QT_DEBUG + if (Q_UNLIKELY(debugBackingStoreFlush)) { + [[NSColor colorWithCalibratedRed:drand48() green:drand48() blue:drand48() alpha:0.3] set]; + [NSBezierPath fillRect:viewRect]; + + if (drawingOutsideOfDisplayCycle) { + [[[NSColor magentaColor] colorWithAlphaComponent:0.5] set]; + [NSBezierPath strokeLineFromPoint:viewLocalRect.topLeft().toCGPoint() + toPoint:viewLocalRect.bottomRight().toCGPoint()]; + } + } +#endif + } + + // ------------------------------------------------------------------------- + + if (shouldHandleViewLockManually) + [view unlockFocus]; + + if (drawingOutsideOfDisplayCycle) { + redrawRoundedBottomCorners([view convertRect:region.boundingRect().toCGRect() toView:nil]); + [view.window flushWindow]; + } + + + // Done flushing to NSWindow backingstore QCocoaWindow *topLevelCocoaWindow = static_cast(topLevelWindow->handle()); if (Q_UNLIKELY(topLevelCocoaWindow->m_needsInvalidateShadow)) { @@ -251,7 +237,7 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo https://trac.webkit.org/changeset/85376/webkit */ -void QCocoaBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const +void QNSWindowBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const { #if !defined(QT_APPLE_NO_PRIVATE_APIS) Q_ASSERT(this->window()->handle()); @@ -285,4 +271,345 @@ void QCocoaBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const #endif } +// ---------------------------------------------------------------------------- + +// https://stackoverflow.com/a/52722575/2761869 +template +struct backwards_t { + R r; + constexpr auto begin() const { using std::rbegin; return rbegin(r); } + constexpr auto begin() { using std::rbegin; return rbegin(r); } + constexpr auto end() const { using std::rend; return rend(r); } + constexpr auto end() { using std::rend; return rend(r); } +}; +template +constexpr backwards_t backwards(R&& r) { return {std::forward(r)}; } + +QCALayerBackingStore::QCALayerBackingStore(QWindow *window) + : QPlatformBackingStore(window) +{ + qCDebug(lcQpaBackingStore) << "Creating QCALayerBackingStore for" << window; + m_buffers.resize(1); +} + +QCALayerBackingStore::~QCALayerBackingStore() +{ +} + +void QCALayerBackingStore::resize(const QSize &size, const QRegion &staticContents) +{ + qCDebug(lcQpaBackingStore) << "Resize requested to" << size; + + if (!staticContents.isNull()) + qCWarning(lcQpaBackingStore) << "QCALayerBackingStore does not support static contents"; + + m_requestedSize = size; +} + +void QCALayerBackingStore::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); + + QMacAutoReleasePool pool; + + qCInfo(lcQpaBackingStore) << "Beginning paint of" << region << "into backingstore of" << m_requestedSize; + + ensureBackBuffer(); // Find an unused back buffer, or reserve space for a new one + + const bool bufferWasRecreated = recreateBackBufferIfNeeded(); + + m_buffers.back()->lock(QPlatformGraphicsBuffer::SWWriteAccess); + + // Although undocumented, QBackingStore::beginPaint expects the painted region + // to be cleared before use if the window has a surface format with an alpha. + // Fresh IOSurfaces are already cleared, so we don't need to clear those. + if (!bufferWasRecreated && window()->format().hasAlpha()) { + qCDebug(lcQpaBackingStore) << "Clearing" << region << "before use"; + QPainter painter(m_buffers.back()->asImage()); + painter.setCompositionMode(QPainter::CompositionMode_Source); + for (const QRect &rect : region) + painter.fillRect(rect, Qt::transparent); + } + + m_paintedRegion += region; +} + +void QCALayerBackingStore::ensureBackBuffer() +{ + if (window()->format().swapBehavior() == QSurfaceFormat::SingleBuffer) + return; + + // The current back buffer may have been assigned to a layer in a previous flush, + // but we deferred the swap. Do it now if the surface has been picked up by CA. + if (m_buffers.back() && m_buffers.back()->isInUse() && m_buffers.back() != m_buffers.front()) { + qCInfo(lcQpaBackingStore) << "Back buffer has been picked up by CA, swapping to front"; + std::swap(m_buffers.back(), m_buffers.front()); + } + + if (Q_UNLIKELY(lcQpaBackingStore().isDebugEnabled())) { + // ┌───────┬───────┬───────┬─────┬──────┐ + // │ front ┊ spare ┊ spare ┊ ... ┊ back │ + // └───────┴───────┴───────┴─────┴──────┘ + for (const auto &buffer : m_buffers) { + qCDebug(lcQpaBackingStore).nospace() << " " + << (buffer == m_buffers.front() ? "front" : + buffer == m_buffers.back() ? " back" : + "spare" + ) << ": " << buffer.get(); + } + } + + // Ensure our back buffer is ready to draw into. If not, find a buffer that + // is not in use, or reserve space for a new buffer if none can be found. + for (auto &buffer : backwards(m_buffers)) { + if (!buffer || !buffer->isInUse()) { + // Buffer is okey to use, swap if necessary + if (buffer != m_buffers.back()) + std::swap(buffer, m_buffers.back()); + qCDebug(lcQpaBackingStore) << "Using back buffer" << m_buffers.back().get(); + + static const int kMaxSwapChainDepth = 3; + if (m_buffers.size() > kMaxSwapChainDepth) { + qCDebug(lcQpaBackingStore) << "Reducing swap chain depth to" << kMaxSwapChainDepth; + m_buffers.erase(std::next(m_buffers.begin(), 1), std::prev(m_buffers.end(), 2)); + } + + break; + } else if (buffer == m_buffers.front()) { + // We've exhausted the available buffers, make room for a new one + const int swapChainDepth = m_buffers.size() + 1; + qCDebug(lcQpaBackingStore) << "Available buffers exhausted, increasing swap chain depth to" << swapChainDepth; + m_buffers.resize(swapChainDepth); + break; + } + } + + Q_ASSERT(!m_buffers.back() || !m_buffers.back()->isInUse()); +} + +// Disabled until performance issue on 5K iMac Pro has been investigated further, +// as rounding up during resize will typically result in full screen buffer sizes +// and low frame rate also for smaller window sizes. +#define USE_LAZY_BUFFER_ALLOCATION_DURING_LIVE_WINDOW_RESIZE 0 + +bool QCALayerBackingStore::recreateBackBufferIfNeeded() +{ + const qreal devicePixelRatio = window()->devicePixelRatio(); + QSize requestedBufferSize = m_requestedSize * devicePixelRatio; + + const NSView *backingStoreView = static_cast(window()->handle())->view(); + Q_UNUSED(backingStoreView); + + auto bufferSizeMismatch = [&](const QSize requested, const QSize actual) { +#if USE_LAZY_BUFFER_ALLOCATION_DURING_LIVE_WINDOW_RESIZE + if (backingStoreView.inLiveResize) { + // Prevent over-eager buffer allocation during window resize by reusing larger buffers + return requested.width() > actual.width() || requested.height() > actual.height(); + } +#endif + return requested != actual; + }; + + if (!m_buffers.back() || bufferSizeMismatch(requestedBufferSize, m_buffers.back()->size())) { +#if USE_LAZY_BUFFER_ALLOCATION_DURING_LIVE_WINDOW_RESIZE + if (backingStoreView.inLiveResize) { + // Prevent over-eager buffer allocation during window resize by rounding up + QSize nativeScreenSize = window()->screen()->geometry().size() * devicePixelRatio; + requestedBufferSize = QSize(qNextPowerOfTwo(requestedBufferSize.width()), + qNextPowerOfTwo(requestedBufferSize.height())).boundedTo(nativeScreenSize); + } +#endif + + qCInfo(lcQpaBackingStore) << "Creating surface of" << requestedBufferSize + << "based on requested" << m_requestedSize << "and dpr =" << devicePixelRatio; + + static auto pixelFormat = QImage::toPixelFormat(QImage::Format_ARGB32_Premultiplied); + + NSView *view = static_cast(window()->handle())->view(); + auto colorSpace = QCFType::constructFromGet(view.window.screen.colorSpace.CGColorSpace); + + m_buffers.back().reset(new GraphicsBuffer(requestedBufferSize, devicePixelRatio, pixelFormat, colorSpace)); + return true; + } + + return false; +} + +QPaintDevice *QCALayerBackingStore::paintDevice() +{ + Q_ASSERT(m_buffers.back()); + return m_buffers.back()->asImage(); +} + +void QCALayerBackingStore::endPaint() +{ + qCInfo(lcQpaBackingStore) << "Paint ended with painted region" << m_paintedRegion; + m_buffers.back()->unlock(); +} + +void QCALayerBackingStore::flush(QWindow *flushedWindow, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(region); + Q_UNUSED(offset); + + if (!prepareForFlush()) + return; + + QMacAutoReleasePool pool; + + NSView *backingStoreView = static_cast(window()->handle())->view(); + NSView *flushedView = static_cast(flushedWindow->handle())->view(); + + id backBufferSurface = (__bridge id)m_buffers.back()->surface(); + if (flushedView.layer.contents == backBufferSurface) { + // We've managed to paint to the back buffer again before Core Animation had time + // to flush the transaction and persist the layer changes to the window server. + // The layer already knows about the back buffer, and we don't need to re-apply + // it to pick up the surface changes, so bail out early. + qCInfo(lcQpaBackingStore).nospace() << "Skipping flush of " << flushedView + << ", layer already reflects back buffer"; + return; + } + + // Trigger a new display cycle if there isn't one. This ensures that our layer updates + // are committed as part of a display-cycle instead of on the next runloop pass. This + // means CA won't try to throttle us if we flush too fast, and we'll coalesce our flush + // with other pending view and layer updates. + backingStoreView.window.viewsNeedDisplay = YES; + + if (window()->format().swapBehavior() == QSurfaceFormat::SingleBuffer) { + // The private API [CALayer reloadValueForKeyPath:@"contents"] would be preferable, + // but barring any side effects or performance issues we opt for the hammer for now. + flushedView.layer.contents = nil; + } + + qCInfo(lcQpaBackingStore) << "Flushing" << backBufferSurface + << "to" << flushedView.layer << "of" << flushedView; + + flushedView.layer.contents = backBufferSurface; + + if (flushedView != backingStoreView) { + const CGSize backingStoreSize = backingStoreView.bounds.size; + flushedView.layer.contentsRect = CGRectApplyAffineTransform( + [flushedView convertRect:flushedView.bounds toView:backingStoreView], + // The contentsRect is in unit coordinate system + CGAffineTransformMakeScale(1.0 / backingStoreSize.width, 1.0 / backingStoreSize.height)); + } + + // Since we may receive multiple flushes before a new frame is started, we do not + // swap any buffers just yet. Instead we check in the next beginPaint if the layer's + // surface is in use, and if so swap to an unused surface as the new back buffer. + + // Note: Ideally CoreAnimation would mark a surface as in use the moment we assign + // it to a layer, but as that's not the case we may end up painting to the same back + // buffer once more if we are painting faster than CA can ship the surfaces over to + // the window server. +} + +void QCALayerBackingStore::composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, + QPlatformTextureList *textures, bool translucentBackground) +{ + if (!prepareForFlush()) + return; + + QPlatformBackingStore::composeAndFlush(window, region, offset, textures, translucentBackground); +} + +QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const +{ + return m_buffers.back().get(); +} + +bool QCALayerBackingStore::prepareForFlush() +{ + if (!m_buffers.back()) { + qCWarning(lcQpaBackingStore) << "Tried to flush backingstore without painting to it first"; + return false; + } + + // Update dirty state of buffers based on what was painted. The back buffer will be + // less dirty, since we painted to it, while other buffers will become more dirty. + // This allows us to minimize copies between front and back buffers on swap in the + // cases where the painted region overlaps with the previous frame (front buffer). + for (const auto &buffer : m_buffers) { + if (buffer == m_buffers.back()) + buffer->dirtyRegion -= m_paintedRegion; + else + buffer->dirtyRegion += m_paintedRegion; + } + + // After painting, the back buffer is only guaranteed to have content for the painted + // region, and may still have dirty areas that need to be synced up with the front buffer, + // if we have one. We know that the front buffer is always up to date. + if (!m_buffers.back()->dirtyRegion.isEmpty() && m_buffers.front() != m_buffers.back()) { + QRegion preserveRegion = m_buffers.back()->dirtyRegion; + qCDebug(lcQpaBackingStore) << "Preserving" << preserveRegion << "from front to back buffer"; + + m_buffers.front()->lock(QPlatformGraphicsBuffer::SWReadAccess); + const QImage *frontBuffer = m_buffers.front()->asImage(); + + const QRect frontSurfaceBounds(QPoint(0, 0), m_buffers.front()->size()); + const qreal sourceDevicePixelRatio = frontBuffer->devicePixelRatio(); + + m_buffers.back()->lock(QPlatformGraphicsBuffer::SWWriteAccess); + QPainter painter(m_buffers.back()->asImage()); + painter.setCompositionMode(QPainter::CompositionMode_Source); + + // Let painter operate in device pixels, to make it easier to compare coordinates + const qreal targetDevicePixelRatio = painter.device()->devicePixelRatio(); + painter.scale(1.0 / targetDevicePixelRatio, 1.0 / targetDevicePixelRatio); + + for (const QRect &rect : preserveRegion) { + QRect sourceRect(rect.topLeft() * sourceDevicePixelRatio, rect.size() * sourceDevicePixelRatio); + QRect targetRect(rect.topLeft() * targetDevicePixelRatio, rect.size() * targetDevicePixelRatio); + +#ifdef QT_DEBUG + if (Q_UNLIKELY(!frontSurfaceBounds.contains(sourceRect.bottomRight()))) { + qCWarning(lcQpaBackingStore) << "Front buffer too small to preserve" + << QRegion(sourceRect).subtracted(frontSurfaceBounds); + } +#endif + painter.drawImage(targetRect, *frontBuffer, sourceRect); + } + + m_buffers.back()->unlock(); + m_buffers.front()->unlock(); + + // The back buffer is now completely in sync, ready to be presented + m_buffers.back()->dirtyRegion = QRegion(); + } + + // Prepare for another round of painting + m_paintedRegion = QRegion(); + + return true; +} + +// ---------------------------------------------------------------------------- + +QCALayerBackingStore::GraphicsBuffer::GraphicsBuffer(const QSize &size, qreal devicePixelRatio, + const QPixelFormat &format, QCFType colorSpace) + : QIOSurfaceGraphicsBuffer(size, format, colorSpace) + , dirtyRegion(0, 0, size.width() / devicePixelRatio, size.height() / devicePixelRatio) + , m_devicePixelRatio(devicePixelRatio) +{ +} + +QImage *QCALayerBackingStore::GraphicsBuffer::asImage() +{ + if (m_image.isNull()) { + qCDebug(lcQpaBackingStore) << "Setting up paint device for" << this; + CFRetain(surface()); + m_image = QImage(data(), size().width(), size().height(), + bytesPerLine(), QImage::toImageFormat(format()), + QImageCleanupFunction(CFRelease), surface()); + m_image.setDevicePixelRatio(m_devicePixelRatio); + } + + Q_ASSERT_X(m_image.constBits() == data(), "QCALayerBackingStore", + "IOSurfaces should have have a fixed location in memory once created"); + + return &m_image; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index affbee35b7..6d6c66e242 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -407,7 +407,16 @@ QPlatformOpenGLContext *QCocoaIntegration::createPlatformOpenGLContext(QOpenGLCo QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *window) const { - return new QCocoaBackingStore(window); + QCocoaWindow *platformWindow = static_cast(window->handle()); + if (!platformWindow) { + qWarning() << window << "must be created before being used with a backingstore"; + return nullptr; + } + + if (platformWindow->view().layer) + return new QCALayerBackingStore(window); + else + return new QNSWindowBackingStore(window); } QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h new file mode 100644 index 0000000000..872773cb7a --- /dev/null +++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QIOSURFACEGRAPHICSBUFFER_H +#define QIOSURFACEGRAPHICSBUFFER_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QIOSurfaceGraphicsBuffer : public QPlatformGraphicsBuffer +{ +public: + QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType colorSpace); + ~QIOSurfaceGraphicsBuffer(); + + const uchar *data() const override; + uchar *data() override; + int bytesPerLine() const override; + + IOSurfaceRef surface(); + bool isInUse() const; + +protected: + bool doLock(AccessTypes access, const QRect &rect) override; + void doUnlock() override; + +private: + QCFType m_surface; + + friend QDebug operator<<(QDebug, const QIOSurfaceGraphicsBuffer *); +}; + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug, const QIOSurfaceGraphicsBuffer *); +#endif + +QT_END_NAMESPACE + +#endif // QIOSURFACEGRAPHICSBUFFER_H diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm new file mode 100644 index 0000000000..a367487e85 --- /dev/null +++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qiosurfacegraphicsbuffer.h" + +#include +#include + +#include +#include + +// CGColorSpaceCopyPropertyList is available on 10.12 and above, +// but was only added in the 10.14 SDK, so declare it just in case. +extern "C" CFPropertyListRef CGColorSpaceCopyPropertyList(CGColorSpaceRef space); + +QT_BEGIN_NAMESPACE + +Q_LOGGING_CATEGORY(lcQpaIOSurface, "qt.qpa.backingstore.iosurface"); + +QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType colorSpace) + : QPlatformGraphicsBuffer(size, format) +{ + const size_t width = size.width(); + const size_t height = size.height(); + + Q_ASSERT(width <= IOSurfaceGetPropertyMaximum(kIOSurfaceWidth)); + Q_ASSERT(height <= IOSurfaceGetPropertyMaximum(kIOSurfaceHeight)); + + static const char bytesPerElement = 4; + + const size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerElement); + const size_t totalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * bytesPerRow); + + NSDictionary *options = @{ + (id)kIOSurfaceWidth: @(width), + (id)kIOSurfaceHeight: @(height), + (id)kIOSurfacePixelFormat: @(unsigned('BGRA')), + (id)kIOSurfaceBytesPerElement: @(bytesPerElement), + (id)kIOSurfaceBytesPerRow: @(bytesPerRow), + (id)kIOSurfaceAllocSize: @(totalBytes), + }; + + m_surface = IOSurfaceCreate((CFDictionaryRef)options); + Q_ASSERT(m_surface); + + Q_ASSERT(size_t(bytesPerLine()) == bytesPerRow); + Q_ASSERT(size_t(byteCount()) == totalBytes); + + if (colorSpace) { + IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"), + QCFType(CGColorSpaceCopyPropertyList(colorSpace))); + } +} + +QIOSurfaceGraphicsBuffer::~QIOSurfaceGraphicsBuffer() +{ +} + +const uchar *QIOSurfaceGraphicsBuffer::data() const +{ + return (const uchar *)IOSurfaceGetBaseAddress(m_surface); +} + +uchar *QIOSurfaceGraphicsBuffer::data() +{ + return (uchar *)IOSurfaceGetBaseAddress(m_surface); +} + +int QIOSurfaceGraphicsBuffer::bytesPerLine() const +{ + return IOSurfaceGetBytesPerRow(m_surface); +} + +IOSurfaceRef QIOSurfaceGraphicsBuffer::surface() +{ + return m_surface; +} + +bool QIOSurfaceGraphicsBuffer::isInUse() const +{ + return IOSurfaceIsInUse(m_surface); +} + +IOSurfaceLockOptions lockOptionsForAccess(QPlatformGraphicsBuffer::AccessTypes access) +{ + IOSurfaceLockOptions lockOptions = 0; + if (!(access & QPlatformGraphicsBuffer::SWWriteAccess)) + lockOptions |= kIOSurfaceLockReadOnly; + return lockOptions; +} + +bool QIOSurfaceGraphicsBuffer::doLock(AccessTypes access, const QRect &rect) +{ + Q_UNUSED(rect); + Q_ASSERT(!isLocked()); + + qCDebug(lcQpaIOSurface) << "Locking" << this << "for" << access; + + // FIXME: Teach QPlatformBackingStore::composeAndFlush about non-2D texture + // targets, so that we can use CGLTexImageIOSurface2D to support TextureAccess. + if (access & (TextureAccess | HWCompositor)) + return false; + + auto lockOptions = lockOptionsForAccess(access); + + // Try without read-back first + lockOptions |= kIOSurfaceLockAvoidSync; + kern_return_t ret = IOSurfaceLock(m_surface, lockOptions, nullptr); + if (ret == kIOSurfaceSuccess) + return true; + + if (ret == kIOReturnCannotLock) { + qCWarning(lcQpaIOSurface) << "Locking of" << this << "requires read-back"; + lockOptions ^= kIOSurfaceLockAvoidSync; + ret = IOSurfaceLock(m_surface, lockOptions, nullptr); + } + + if (ret != kIOSurfaceSuccess) { + qCWarning(lcQpaIOSurface) << "Failed to lock" << this << ret; + return false; + } + + return true; +} + +void QIOSurfaceGraphicsBuffer::doUnlock() +{ + qCDebug(lcQpaIOSurface) << "Unlocking" << this << "from" << isLocked(); + + auto lockOptions = lockOptionsForAccess(isLocked()); + bool success = IOSurfaceUnlock(m_surface, lockOptions, nullptr) == kIOSurfaceSuccess; + Q_ASSERT_X(success, "QIOSurfaceGraphicsBuffer", "Unlocking surface should succeed"); +} + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QIOSurfaceGraphicsBuffer *graphicsBuffer) +{ + QDebugStateSaver saver(debug); + debug.nospace(); + debug << "QIOSurfaceGraphicsBuffer(" << (const void *)graphicsBuffer; + if (graphicsBuffer) { + debug << ", surface=" << graphicsBuffer->m_surface; + debug << ", size=" << graphicsBuffer->size(); + debug << ", isLocked=" << bool(graphicsBuffer->isLocked()); + debug << ", isInUse=" << graphicsBuffer->isInUse(); + } + debug << ')'; + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm index e9af90a45c..0cebc8d98d 100644 --- a/src/plugins/platforms/cocoa/qnsview_drawing.mm +++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm @@ -163,6 +163,13 @@ return NSViewLayerContentsRedrawDuringViewResize; } +- (NSViewLayerContentsPlacement)layerContentsPlacement +{ + // Always place the layer at top left without any automatic scaling, + // so that we can re-use larger layers when resizing a window down. + return NSViewLayerContentsPlacementTopLeft; +} + - (void)updateMetalLayerDrawableSize:(CAMetalLayer *)layer { CGSize drawableSize = layer.bounds.size; From 9b72613512a36a0ab0ec5d58f0f34016d959a9c1 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 12 Mar 2019 10:48:05 +0200 Subject: [PATCH 013/154] Fix link error on linux On debian buster (using gcc 8.2) I'm getting link error: ...86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libEGL.so /usr/bin/ld: .obj/qxcbeglintegration.o:(.data.rel+0x8b8): undefined reference to `typeinfo for QXcbBasicConnection' Change-Id: I4c2b5aad8eac44737982d68f46fbc80e3b830668 Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbconnection_basic.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.h b/src/plugins/platforms/xcb/qxcbconnection_basic.h index ca91f7fa45..6e407a5f80 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_basic.h +++ b/src/plugins/platforms/xcb/qxcbconnection_basic.h @@ -40,6 +40,7 @@ #define QXCBBASICCONNECTION_H #include "qxcbatom.h" +#include "qxcbexport.h" #include #include @@ -55,7 +56,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQpaXcb) -class QXcbBasicConnection : public QObject +class Q_XCB_EXPORT QXcbBasicConnection : public QObject { Q_OBJECT public: From 50f3f8f6bb8f5482c713480fad80421760184216 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Mar 2019 08:34:01 +0100 Subject: [PATCH 014/154] Use High DPI pixmaps in prominent examples and tests Set AA_UseHighDpiPixmaps. Task-number: QTBUG-52622 Change-Id: Ic4373a9c94952f50bc1ad36bcc0dec850efc124a Reviewed-by: Robert Loehning Reviewed-by: Richard Moe Gustavsen --- examples/widgets/desktop/systray/main.cpp | 2 ++ examples/widgets/dialogs/classwizard/main.cpp | 2 ++ examples/widgets/dialogs/licensewizard/main.cpp | 2 ++ examples/widgets/dialogs/standarddialogs/main.cpp | 1 + examples/widgets/dialogs/trivialwizard/trivialwizard.cpp | 2 ++ tests/manual/dialogs/main.cpp | 4 ++++ 6 files changed, 13 insertions(+) diff --git a/examples/widgets/desktop/systray/main.cpp b/examples/widgets/desktop/systray/main.cpp index 49b0e10412..d981415b44 100644 --- a/examples/widgets/desktop/systray/main.cpp +++ b/examples/widgets/desktop/systray/main.cpp @@ -59,6 +59,8 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(systray); + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication app(argc, argv); if (!QSystemTrayIcon::isSystemTrayAvailable()) { diff --git a/examples/widgets/dialogs/classwizard/main.cpp b/examples/widgets/dialogs/classwizard/main.cpp index 72eb1ae6ec..03ffe97a23 100644 --- a/examples/widgets/dialogs/classwizard/main.cpp +++ b/examples/widgets/dialogs/classwizard/main.cpp @@ -59,6 +59,8 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(classwizard); + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication app(argc, argv); #ifndef QT_NO_TRANSLATION diff --git a/examples/widgets/dialogs/licensewizard/main.cpp b/examples/widgets/dialogs/licensewizard/main.cpp index 025b79243c..ed46e792d0 100644 --- a/examples/widgets/dialogs/licensewizard/main.cpp +++ b/examples/widgets/dialogs/licensewizard/main.cpp @@ -59,6 +59,8 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(licensewizard); + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication app(argc, argv); #ifndef QT_NO_TRANSLATION diff --git a/examples/widgets/dialogs/standarddialogs/main.cpp b/examples/widgets/dialogs/standarddialogs/main.cpp index 150d07318e..a0cded4f47 100644 --- a/examples/widgets/dialogs/standarddialogs/main.cpp +++ b/examples/widgets/dialogs/standarddialogs/main.cpp @@ -59,6 +59,7 @@ int main(int argc, char *argv[]) { + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication app(argc, argv); QGuiApplication::setApplicationDisplayName(Dialog::tr("Standard Dialogs")); diff --git a/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp b/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp index fe49bf6304..ce13a59b0c 100644 --- a/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp +++ b/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp @@ -123,6 +123,8 @@ QWizardPage *createConclusionPage() int main(int argc, char *argv[]) //! [9] //! [11] { + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication app(argc, argv); #ifndef QT_NO_TRANSLATION diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp index 2676ceeb52..07df8f5cf4 100644 --- a/tests/manual/dialogs/main.cpp +++ b/tests/manual/dialogs/main.cpp @@ -126,6 +126,10 @@ void MainWindow::aboutDialog() int main(int argc, char *argv[]) { +#if QT_VERSION >= 0x050600 + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif + for (int a = 1; a < argc; ++a) { if (!qstrcmp(argv[a], "-n")) { qDebug("AA_DontUseNativeDialogs"); From c0b265662e618f0d953ed2c389bad9f50ac24f7f Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Mon, 15 Oct 2018 20:36:06 +0300 Subject: [PATCH 015/154] QTranslator: avoid unhandled exception Add std::nothrow param to avoid exception and to check pointer against nullptr. Change-Id: I505abb1ca15b8c10a80b0cd3784a6b0c4c6bcc1c Reviewed-by: Edward Welbourne Reviewed-by: Oswald Buddenhagen Reviewed-by: Allan Sandfeld Jensen --- src/corelib/kernel/qtranslator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 744bbfbff5..929554f6bc 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -72,6 +72,7 @@ #endif #include +#include #include "qobject_p.h" @@ -592,7 +593,7 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo #endif // QT_USE_MMAP if (!ok) { - d->unmapPointer = new char[d->unmapLength]; + d->unmapPointer = new (std::nothrow) char[d->unmapLength]; if (d->unmapPointer) { file.seek(0); qint64 readResult = file.read(d->unmapPointer, d->unmapLength); From 5dd4f18cef4fb9ae1e121622c793396e7f132924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Wed, 13 Mar 2019 15:55:01 +0100 Subject: [PATCH 016/154] Improve documentation for opaque resize in QSplitter This also fixes the documentation for QStyle::SH_Splitter_OpaqueResize Change-Id: If8afb52ae300e9735a8bc6b065327f17d67f4323 Reviewed-by: Paul Wicking --- src/widgets/styles/qstyle.cpp | 4 ++-- src/widgets/widgets/qsplitter.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index ac4fb7fbd1..97ec1d3f19 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1971,8 +1971,8 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SH_Widget_Animate Deprecated. Use \l{SH_Widget_Animation_Duration} instead. - \value SH_Splitter_OpaqueResize Determines if resizing is opaque - This enum value has been introduced in Qt 5.2 + \value SH_Splitter_OpaqueResize Determines if widgets are resized dynamically (opaquely) while + interactively moving the splitter. This enum value was introduced in Qt 5.2. \value SH_TabBar_ChangeCurrentDelay Determines the delay before the current tab is changed while dragging over the tabbar, in milliseconds. This diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index 9e38c8f18a..3b516f36b6 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -161,11 +161,10 @@ Qt::Orientation QSplitterHandle::orientation() const /*! - Returns \c true if widgets are resized dynamically (opaquely), otherwise - returns \c false. This value is controlled by the QSplitter. + Returns \c true if widgets are resized dynamically (opaquely) while interactively moving the + splitter. Otherwise returns \c false. This value is controlled by the QSplitter. \sa QSplitter::opaqueResize() - */ bool QSplitterHandle::opaqueResize() const { @@ -1483,7 +1482,8 @@ int QSplitter::closestLegalPosition(int pos, int index) /*! \property QSplitter::opaqueResize - \brief whether resizing is opaque + Returns \c true if widgets are resized dynamically (opaquely) while interactively moving the + splitter. Otherwise returns \c false. The default resize behavior is style dependent (determined by the SH_Splitter_OpaqueResize style hint). However, you can override it From 9f9ed383c6910ddfdccc7115b2f8787ba25dd2f6 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 27 Feb 2019 20:42:17 +0100 Subject: [PATCH 017/154] Replace LDEBUG with categorized logging in QTextDocumentLayout(Private) This adds four new logging categories: qt.text.drawing, qt.text.hittest, qt.text.layout and qt.text.layout.table Task-number: QTBUG-72457 Change-Id: Ifbfd6d16231c7f4ba664bc521699e44f98310f77 Reviewed-by: Lars Knoll --- src/gui/text/qtextdocumentlayout.cpp | 81 +++++++++++++--------------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 323253c70d..2e1a2b5bff 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -58,23 +58,17 @@ #include #include #include "private/qfunctions_p.h" +#include #include -// #define LAYOUT_DEBUG - -#ifdef LAYOUT_DEBUG -#define LDEBUG qDebug() -#define INC_INDENT debug_indent += " " -#define DEC_INDENT debug_indent = debug_indent.left(debug_indent.length()-2) -#else -#define LDEBUG if(0) qDebug() -#define INC_INDENT do {} while(0) -#define DEC_INDENT do {} while(0) -#endif - QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcDraw, "qt.text.drawing") +Q_LOGGING_CATEGORY(lcHit, "qt.text.hittest") +Q_LOGGING_CATEGORY(lcLayout, "qt.text.layout") +Q_LOGGING_CATEGORY(lcTable, "qt.text.layout.table") + // ################ should probably add frameFormatChange notification! struct QTextLayoutStruct; @@ -583,16 +577,16 @@ QTextDocumentLayoutPrivate::hitTest(QTextFrame *frame, const QFixedPoint &point, QTextFrame *rootFrame = docPrivate->rootFrame(); -// LDEBUG << "checking frame" << frame->firstPosition() << "point=" << point -// << "position" << fd->position << "size" << fd->size; + qCDebug(lcHit) << "checking frame" << frame->firstPosition() << "point=" << point.toPointF() + << "position" << fd->position.toPointF() << "size" << fd->size.toSizeF(); if (frame != rootFrame) { if (relativePoint.y < 0 || relativePoint.x < 0) { *position = frame->firstPosition() - 1; -// LDEBUG << "before pos=" << *position; + qCDebug(lcHit) << "before pos=" << *position; return PointBefore; } else if (relativePoint.y > fd->size.height || relativePoint.x > fd->size.width) { *position = frame->lastPosition() + 1; -// LDEBUG << "after pos=" << *position; + qCDebug(lcHit) << "after pos=" << *position; return PointAfter; } } @@ -666,8 +660,6 @@ QTextDocumentLayoutPrivate::HitPoint QTextDocumentLayoutPrivate::hitTest(QTextFrame::Iterator it, HitPoint hit, const QFixedPoint &p, int *position, QTextLayout **l, Qt::HitTestAccuracy accuracy) const { - INC_INDENT; - for (; !it.atEnd(); ++it) { QTextFrame *c = it.currentFrame(); HitPoint hp; @@ -693,8 +685,7 @@ QTextDocumentLayoutPrivate::hitTest(QTextFrame::Iterator it, HitPoint hit, const } } - DEC_INDENT; -// LDEBUG << "inside=" << hit << " pos=" << *position; + qCDebug(lcHit) << "inside=" << hit << " pos=" << *position; return hit; } @@ -741,15 +732,14 @@ QTextDocumentLayoutPrivate::hitTest(const QTextBlock &bl, const QFixedPoint &poi QTextLayout *tl = bl.layout(); QRectF textrect = tl->boundingRect(); textrect.translate(tl->position()); -// LDEBUG << " checking block" << bl.position() << "point=" << point -// << " tlrect" << textrect; + qCDebug(lcHit) << " checking block" << bl.position() << "point=" << point.toPointF() << " tlrect" << textrect; *position = bl.position(); if (point.y.toReal() < textrect.top()) { -// LDEBUG << " before pos=" << *position; + qCDebug(lcHit) << " before pos=" << *position; return PointBefore; } else if (point.y.toReal() > textrect.bottom()) { *position += bl.length(); -// LDEBUG << " after pos=" << *position; + qCDebug(lcHit) << " after pos=" << *position; return PointAfter; } @@ -781,7 +771,7 @@ QTextDocumentLayoutPrivate::hitTest(const QTextBlock &bl, const QFixedPoint &poi } *position += off; -// LDEBUG << " inside=" << hit << " pos=" << *position; + qCDebug(lcHit) << " inside=" << hit << " pos=" << *position; return hit; } @@ -944,8 +934,7 @@ void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *pain || off.x() > context.clip.right() || off.x() + fd->size.width.toReal() < context.clip.left())) return; -// LDEBUG << debug_indent << "drawFrame" << frame->firstPosition() << "--" << frame->lastPosition() << "at" << offset; -// INC_INDENT; + qCDebug(lcDraw) << "drawFrame" << frame->firstPosition() << "--" << frame->lastPosition() << "at" << offset; // if the cursor is /on/ a table border we may need to repaint it // afterwards, as we usually draw the decoration first @@ -1076,8 +1065,6 @@ void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *pain painter->setPen(oldPen); } -// DEC_INDENT; - return; } @@ -1280,7 +1267,7 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain r.translate(offset + tl->position()); if (!bl.isVisible() || (context.clip.isValid() && (r.bottom() < context.clip.y() || r.top() > context.clip.bottom()))) return; -// LDEBUG << debug_indent << "drawBlock" << bl.position() << "at" << offset << "br" << tl->boundingRect(); + qCDebug(lcDraw) << "drawBlock" << bl.position() << "at" << offset << "br" << tl->boundingRect(); QTextBlockFormat blockFormat = bl.blockFormat(); @@ -1512,7 +1499,7 @@ QTextLayoutStruct QTextDocumentLayoutPrivate::layoutCell(QTextTable *t, const QT int layoutFrom, int layoutTo, QTextTableData *td, QFixed absoluteTableY, bool withPageBreaks) { - LDEBUG << "layoutCell"; + qCDebug(lcTable) << "layoutCell"; QTextLayoutStruct layoutStruct; layoutStruct.frame = t; layoutStruct.minimumWidth = 0; @@ -1587,7 +1574,7 @@ QTextLayoutStruct QTextDocumentLayoutPrivate::layoutCell(QTextTable *t, const QT QRectF QTextDocumentLayoutPrivate::layoutTable(QTextTable *table, int layoutFrom, int layoutTo, QFixed parentY) { - LDEBUG << "layoutTable"; + qCDebug(lcTable) << "layoutTable from" << layoutFrom << "to" << layoutTo << "parentY" << parentY; QTextTableData *td = static_cast(data(table)); Q_ASSERT(td->sizeDirty); const int rows = table->rows(); @@ -1709,6 +1696,7 @@ recalc_minmax_widths: if (length.type() == QTextLength::FixedLength) { td->minWidths[i] = td->widths[i] = qMax(scaleToDevice(QFixed::fromReal(length.rawValue())), td->minWidths.at(i)); remainingWidth -= td->widths.at(i); + qCDebug(lcTable) << "column" << i << "has width constraint" << td->minWidths.at(i) << "px, remaining width now" << remainingWidth; } else if (length.type() == QTextLength::PercentageLength) { totalPercentage += QFixed::fromReal(length.rawValue()); } else if (length.type() == QTextLength::VariableLength) { @@ -1716,6 +1704,7 @@ recalc_minmax_widths: td->widths[i] = td->minWidths.at(i); remainingWidth -= td->minWidths.at(i); + qCDebug(lcTable) << "column" << i << "has variable width, min" << td->minWidths.at(i) << "remaining width now" << remainingWidth; } totalMinWidth += td->minWidths.at(i); } @@ -1735,6 +1724,8 @@ recalc_minmax_widths: } else { td->widths[i] = td->minWidths.at(i); } + qCDebug(lcTable) << "column" << i << "has width constraint" << columnWidthConstraints.at(i).rawValue() + << "%, allocated width" << td->widths[i] << "remaining width now" << remainingWidth; remainingWidth -= td->widths.at(i); } } @@ -1978,9 +1969,12 @@ relayout: td->minimumWidth += rightMargin - td->border; td->maximumWidth = td->columnPositions.at(0); - for (int i = 0; i < columns; ++i) + for (int i = 0; i < columns; ++i) { if (td->maxWidths.at(i) != QFIXED_MAX) td->maximumWidth += td->maxWidths.at(i) + 2 * td->border + cellSpacing; + qCDebug(lcTable) << "column" << i << "has final width" << td->widths.at(i).toReal() + << "min" << td->minWidths.at(i).toReal() << "max" << td->maxWidths.at(i).toReal(); + } td->maximumWidth += rightMargin - td->border; td->updateTableSize(); @@ -2052,9 +2046,8 @@ void QTextDocumentLayoutPrivate::positionFloat(QTextFrame *frame, QTextLine *cur QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, int layoutTo, QFixed parentY) { - LDEBUG << "layoutFrame (pre)"; + qCDebug(lcLayout, "layoutFrame (%d--%d), parent=%p", f->firstPosition(), f->lastPosition(), f->parentFrame()); Q_ASSERT(data(f)->sizeDirty); -// qDebug("layouting frame (%d--%d), parent=%p", f->firstPosition(), f->lastPosition(), f->parentFrame()); QTextFrameFormat fformat = f->frameFormat(); @@ -2076,9 +2069,8 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, int layoutTo, QFixed frameWidth, QFixed frameHeight, QFixed parentY) { - LDEBUG << "layoutFrame from=" << layoutFrom << "to=" << layoutTo; + qCDebug(lcLayout, "layoutFrame (%d--%d), parent=%p", f->firstPosition(), f->lastPosition(), f->parentFrame()); Q_ASSERT(data(f)->sizeDirty); -// qDebug("layouting frame (%d--%d), parent=%p", f->firstPosition(), f->lastPosition(), f->parentFrame()); QTextFrameData *fd = data(f); QFixed newContentsWidth; @@ -2165,8 +2157,8 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in layoutStruct.maximumWidth = QFIXED_MAX; layoutStruct.fullLayout = fullLayout || (fd->oldContentsWidth != newContentsWidth); layoutStruct.updateRect = QRectF(QPointF(0, 0), QSizeF(qreal(INT_MAX), qreal(INT_MAX))); - LDEBUG << "layoutStruct: x_left" << layoutStruct.x_left << "x_right" << layoutStruct.x_right - << "fullLayout" << layoutStruct.fullLayout; + qCDebug(lcLayout) << "layoutStruct: x_left" << layoutStruct.x_left << "x_right" << layoutStruct.x_right + << "fullLayout" << layoutStruct.fullLayout; fd->oldContentsWidth = newContentsWidth; layoutStruct.pageHeight = QFixed::fromReal(document->pageSize().height()); @@ -2220,7 +2212,7 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, QFixed width) { - LDEBUG << "layoutFlow from=" << layoutFrom << "to=" << layoutTo; + qCDebug(lcLayout) << "layoutFlow from=" << layoutFrom << "to=" << layoutTo; QTextFrameData *fd = data(layoutStruct->frame); fd->currentLayoutStruct = layoutStruct; @@ -2578,9 +2570,8 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi QTextLayout *tl = bl.layout(); const int blockLength = bl.length(); - LDEBUG << "layoutBlock from=" << layoutFrom << "to=" << layoutTo; - -// qDebug() << "layoutBlock; width" << layoutStruct->x_right - layoutStruct->x_left << "(maxWidth is btw" << tl->maximumWidth() << ')'; + qCDebug(lcLayout) << "layoutBlock from=" << layoutFrom << "to=" << layoutTo + << "; width" << layoutStruct->x_right - layoutStruct->x_left << "(maxWidth is btw" << tl->maximumWidth() << ')'; if (previousBlockFormat) { qreal margin = qMax(blockFormat.topMargin(), previousBlockFormat->bottomMargin()); @@ -2612,7 +2603,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi // force relayout if we cross a page boundary || (layoutStruct->pageHeight != QFIXED_MAX && layoutStruct->absoluteY() + QFixed::fromReal(tl->boundingRect().height()) > layoutStruct->pageBottom)) { - LDEBUG << " do layout"; + qCDebug(lcLayout) << "do layout"; QTextOption option = docPrivate->defaultTextOption; option.setTextDirection(dir); option.setTabs( blockFormat.tabPositions() ); @@ -2741,7 +2732,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi const int cnt = tl->lineCount(); QFixed bottom; for (int i = 0; i < cnt; ++i) { - LDEBUG << "going to move text line" << i; + qCDebug(lcLayout) << "going to move text line" << i; QTextLine line = tl->lineAt(i); layoutStruct->contentsWidth = qMax(layoutStruct->contentsWidth, QFixed::fromReal(line.x() + tl->lineAt(i).naturalTextWidth()) + totalRightMargin); From 12aafa294a75329d667068e4229a21d8ae7e94e0 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Fri, 15 Mar 2019 12:16:41 +0100 Subject: [PATCH 018/154] Avoid warning about the deprecation of QString::QString(const char*) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the warning: ‘QString::QString(const char*)’ is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations] return new QEglFSKmsEglDevice(this, screenConfig(), deviceName); ^ Change-Id: I36654f40219bf0f487e70cf2900d3f30335d4fc1 Reviewed-by: Mårten Nordheim --- .../eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index ab39af6b80..ecdfb352ab 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -260,7 +260,7 @@ QKmsDevice *QEglFSKmsEglDeviceIntegration::createDevice() if (Q_UNLIKELY(!deviceName)) qFatal("Failed to query device name from EGLDevice"); - return new QEglFSKmsEglDevice(this, screenConfig(), deviceName); + return new QEglFSKmsEglDevice(this, screenConfig(), QLatin1String(deviceName)); } bool QEglFSKmsEglDeviceIntegration::query_egl_device() From adaa3acc7418ba212d403bc5f79a2d6fbd0af0ed Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Fri, 15 Mar 2019 12:02:18 +0100 Subject: [PATCH 019/154] Use Q_UNUSED(updateRect) when building without QT_BUILD_INTERNAL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3e5292bc09ae53bee5f8bb8c7c1922d1a20b2e10 Reviewed-by: Mårten Nordheim --- .../widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 55139ff99a..28df3a3c38 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -4075,6 +4075,8 @@ void tst_QGraphicsView::update() QTRY_COMPARE(view.lastUpdateRegions.at(0), QRegion(updateRect) & viewportRect); } QTRY_VERIFY(!viewPrivate->fullUpdatePending); +#else + Q_UNUSED(updateRect); #endif } From cac487f051350ce0d5b2c9dbea0d330b6085e9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 6 Mar 2019 13:38:35 +0100 Subject: [PATCH 020/154] wasm: QNAM: support relative urls We can pass these through to to the browser, which will resolve them relative to the current html file. Task-number: QTBUG-74289 Change-Id: I595f30456de55da4f1432fb997d381940f51c5f9 Reviewed-by: Lorn Potter --- src/network/access/qnetworkaccessmanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 62c915908b..50b9488594 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1390,7 +1390,8 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera QString scheme = req.url().scheme(); #ifdef Q_OS_WASM - if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) { + // Support http, https, and relateive urls + if (scheme == QLatin1String("http") || scheme == QLatin1String("https") || scheme.isEmpty()) { QNetworkReplyWasmImpl *reply = new QNetworkReplyWasmImpl(this); QNetworkReplyWasmImplPrivate *priv = reply->d_func(); priv->manager = this; From e59ba35f1b1954062266164f7b802076dc152c7b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 18 Mar 2019 08:27:22 +0100 Subject: [PATCH 021/154] Wasm: Add workaround for Emscripten compiler again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This work around was added directly to the generated files at some point, and never to the generator it seems. So to avoid removing the workaround again when we regenerate the next time, we need to add it. Task-number: QTBUG-74511 Change-Id: Ided1bd949234ba82df61c55891646823e7f72e80 Reviewed-by: Morten Johan Sørvig --- util/unicode/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 00c69de008..1dbfa2cef0 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -798,6 +798,9 @@ static const char *property_string = " signed short mirrorDiff : 16;\n" " ushort lowerCaseSpecial : 1;\n" " signed short lowerCaseDiff : 15;\n" + "#ifdef Q_OS_WASM\n" + " unsigned char : 0; //wasm 64 packing trick\n" + "#endif\n" " ushort upperCaseSpecial : 1;\n" " signed short upperCaseDiff : 15;\n" " ushort titleCaseSpecial : 1;\n" @@ -806,6 +809,9 @@ static const char *property_string = " signed short caseFoldDiff : 15;\n" " ushort unicodeVersion : 8; /* 5 used */\n" " ushort nfQuickCheck : 8;\n" // could be narrowed + "#ifdef Q_OS_WASM\n" + " unsigned char : 0; //wasm 64 packing trick\n" + "#endif\n" " ushort graphemeBreakClass : 5; /* 5 used */\n" " ushort wordBreakClass : 5; /* 5 used */\n" " ushort sentenceBreakClass : 8; /* 4 used */\n" From 01380dc2673d1aecc3e216fff84da76223e447d7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 15 Mar 2019 13:04:22 +0100 Subject: [PATCH 022/154] Remove broken code from unicode generator The current state produces uncompilable code. Change-Id: I9a68b61866a4a416335ed4d7204c58122803fb1c Reviewed-by: Eskil Abrahamsen Blomfeldt --- util/unicode/main.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 1dbfa2cef0..22a4405ca9 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -2476,10 +2476,6 @@ static QByteArray createPropertyInfo() out += ", "; out += QByteArray::number( p.lowerCaseDiff ); out += ", "; - out += "#ifdef Q_OS_WASM \n"; -// " unsigned char : 0; //wasm 64 packing trick QTBUG-65259\n" - out += "#endif \n"; - out += ", "; // " ushort upperCaseSpecial : 1;\n" // " signed short upperCaseDiff : 15;\n" out += QByteArray::number( p.upperCaseSpecial ); @@ -2504,10 +2500,6 @@ static QByteArray createPropertyInfo() // " ushort nfQuickCheck : 8;\n" out += QByteArray::number( p.nfQuickCheck ); out += ", "; - out += "#ifdef Q_OS_WASM \n"; -// " unsigned char : 0; //wasm 64 packing trick QTBUG-65259\n" - out += "#endif \n"; - out += ", "; // " ushort graphemeBreakClass : 5; /* 5 used */\n" // " ushort wordBreakClass : 5; /* 5 used */\n" // " ushort sentenceBreakClass : 8; /* 4 used */\n" From 1320b2f64412f0d86bd09c66c22df845e13a94a1 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 17 Oct 2018 14:54:43 +0200 Subject: [PATCH 023/154] Fix memory leak when unregistering a gesture recognizer When a gesture was unrecognized, then it would add itself to the obsolete gestures hash. This was cleaned up only on application exit, but as the unregister call happens whenever a widget that had registered gestures was deleted then the hash could grow quite considerably. In order to ensure the original intention of the code here, we only call unregisterGestureRecognizer() when there is a QGestureManager in place to call it on. Otherwise it would create a memory leak in itself. Change-Id: I2342f3f737b28be4af7ed531d83f02197eb66c0e Reviewed-by: Richard Moe Gustavsen --- src/widgets/kernel/qgesturemanager.cpp | 5 ----- src/widgets/kernel/qgesturerecognizer.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index c4188044cf..891858b035 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -143,11 +143,6 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { QList list = m_recognizers.values(type); - while (QGestureRecognizer *recognizer = m_recognizers.take(type)) { - // ensuring an entry exists causes the recognizer to be deleted on destruction of the manager - auto &gestures = m_obsoleteGestures[recognizer]; - Q_UNUSED(gestures); - } foreach (QGesture *g, m_gestureToRecognizer.keys()) { QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { diff --git a/src/widgets/kernel/qgesturerecognizer.cpp b/src/widgets/kernel/qgesturerecognizer.cpp index 65c46a5e56..75d091ce4e 100644 --- a/src/widgets/kernel/qgesturerecognizer.cpp +++ b/src/widgets/kernel/qgesturerecognizer.cpp @@ -41,6 +41,7 @@ #include "private/qgesture_p.h" #include "private/qgesturemanager_p.h" +#include "private/qapplication_p.h" #ifndef QT_NO_GESTURES @@ -231,6 +232,11 @@ Qt::GestureType QGestureRecognizer::registerRecognizer(QGestureRecognizer *recog */ void QGestureRecognizer::unregisterRecognizer(Qt::GestureType type) { + auto qAppPriv = QApplicationPrivate::instance(); + if (!qAppPriv) + return; + if (!qAppPriv->gestureManager) + return; QGestureManager::instance()->unregisterGestureRecognizer(type); } From dc753374478d751c7c124030429e90d058934f9f Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 21 Dec 2018 15:53:57 +0100 Subject: [PATCH 024/154] Windows QPA: Make the expected screen be in sync with the geometry changes When the window moves to a new screen then we should ensure the screen is updated at that point with the new size so it can account for any scaling changes. This reverts f1ec81b543fe1d5090acff298e24faf10a7bac63. Change-Id: I2be3aab677c4677841a07beaaf373f498483b320 Fixes: QTBUG-72504 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 2c0ffc9b26..2abd1eef8b 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1758,15 +1758,12 @@ void QWindowsWindow::checkForScreenChanged() QPlatformScreen *currentScreen = screen(); const auto &screenManager = QWindowsContext::instance()->screenManager(); - // QTBUG-62971: When dragging a window by its border, detect by mouse position - // to prevent it from oscillating between screens when it resizes - const QWindowsScreen *newScreen = testFlag(ResizeMoveActive) - ? screenManager.screenAtDp(QWindowsCursor::mousePosition()) - : screenManager.screenForHwnd(m_data.hwnd); + const QWindowsScreen *newScreen = screenManager.screenForHwnd(m_data.hwnd); if (newScreen != nullptr && newScreen != currentScreen) { qCDebug(lcQpaWindows).noquote().nospace() << __FUNCTION__ << ' ' << window() << " \"" << currentScreen->name() << "\"->\"" << newScreen->name() << '"'; + setFlag(SynchronousGeometryChangeEvent); QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); } } @@ -1785,11 +1782,14 @@ void QWindowsWindow::handleGeometryChange() fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true); } + const bool wasSync = testFlag(SynchronousGeometryChangeEvent); checkForScreenChanged(); if (testFlag(SynchronousGeometryChangeEvent)) QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); + if (!wasSync) + clearFlag(SynchronousGeometryChangeEvent); qCDebug(lcQpaEvents) << __FUNCTION__ << this << window() << m_data.geometry; } From 01e1df90a7debd333314720fdd5cf6cd9964d796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 14 Mar 2019 00:36:34 +0100 Subject: [PATCH 025/154] Move screen maintenance functions from QPlatformIntegration to QWSI QWindowSystemInterface is the de facto API for any plumbing going from the platform plugin to QtGui. Having the functions as protected members of QPlatformIntegration was idiosyncratic, and resulted in awkward workarounds to be able to call the functions from outside of the QPlatformIntegration subclass. The functions in QPlatformIntegration have been left in, but deprecated so that platform plugins outside of qtbase have a chance to move over to the new QWSI API before they are removed. Change-Id: I327fec460db6b0faaf0ae2a151c20aa30dbe7182 Reviewed-by: Gatis Paeglis --- src/gui/kernel/qplatformintegration.cpp | 58 +++-------------- src/gui/kernel/qplatformintegration.h | 12 ++-- src/gui/kernel/qplatformscreen.cpp | 5 +- src/gui/kernel/qscreen.h | 1 + src/gui/kernel/qwindowsysteminterface.cpp | 64 +++++++++++++++++++ src/gui/kernel/qwindowsysteminterface.h | 4 ++ .../android/qandroidplatformintegration.cpp | 2 +- .../platforms/bsdfb/qbsdfbintegration.cpp | 5 +- .../platforms/cocoa/qcocoaintegration.mm | 6 +- .../platforms/directfb/qdirectfb_egl.cpp | 3 +- .../directfb/qdirectfbintegration.cpp | 3 +- .../eglfs/api/qeglfsdeviceintegration.cpp | 4 +- .../platforms/eglfs/api/qeglfsintegration.cpp | 12 +--- .../platforms/eglfs/api/qeglfsintegration_p.h | 3 - .../eglfs_emu/qeglfsemulatorintegration.cpp | 6 +- .../eglfs_kms_support/qeglfskmsdevice.cpp | 2 +- .../platforms/haiku/qhaikuintegration.cpp | 5 +- .../integrity/qintegrityfbintegration.cpp | 6 +- src/plugins/platforms/ios/qiosintegration.h | 4 -- src/plugins/platforms/ios/qiosintegration.mm | 4 +- src/plugins/platforms/ios/qiosscreen.mm | 10 +-- .../platforms/linuxfb/qlinuxfbintegration.cpp | 5 +- .../platforms/minimal/qminimalintegration.cpp | 3 +- .../minimalegl/qminimaleglintegration.cpp | 5 +- .../mirclient/qmirclientintegration.cpp | 7 +- .../offscreen/qoffscreenintegration.cpp | 3 +- .../platforms/openwfd/qopenwfdintegration.cpp | 11 +--- .../platforms/openwfd/qopenwfdintegration.h | 2 - .../platforms/openwfd/qopenwfdport.cpp | 4 +- src/plugins/platforms/qnx/qqnxintegration.cpp | 6 +- src/plugins/platforms/vnc/qvncintegration.cpp | 5 +- .../platforms/wasm/qwasmintegration.cpp | 4 +- .../platforms/windows/qwindowsintegration.h | 3 - .../platforms/windows/qwindowsscreen.cpp | 8 +-- .../platforms/winrt/qwinrtintegration.cpp | 4 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 3 +- .../platforms/xcb/qxcbconnection_screens.cpp | 12 ++-- src/plugins/platforms/xcb/qxcbintegration.h | 2 - 38 files changed, 159 insertions(+), 147 deletions(-) diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 7d1fcd4eeb..ac4d12b024 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -463,37 +463,16 @@ QList QPlatformIntegration::possibleKeys(const QKeyEvent *) const } /*! - Should be called by the implementation whenever a new screen is added. - - The first screen added will be the primary screen, used for default-created - windows, GL contexts, and other resources unless otherwise specified. - - This adds the screen to QGuiApplication::screens(), and emits the - QGuiApplication::screenAdded() signal. - - The screen should be deleted by calling QPlatformIntegration::destroyScreen(). + \deprecated Use QWindowSystemInterface::handleScreenAdded instead. */ void QPlatformIntegration::screenAdded(QPlatformScreen *ps, bool isPrimary) { - QScreen *screen = new QScreen(ps); - - if (isPrimary) { - QGuiApplicationPrivate::screen_list.prepend(screen); - } else { - QGuiApplicationPrivate::screen_list.append(screen); - } - emit qGuiApp->screenAdded(screen); - - if (isPrimary) - emit qGuiApp->primaryScreenChanged(screen); + QWindowSystemInterface::handleScreenAdded(ps, isPrimary); } /*! - Just removes the screen, call destroyScreen instead. - - \sa destroyScreen() + \deprecated Use QWindowSystemInterface::handleScreenRemoved instead. */ - void QPlatformIntegration::removeScreen(QScreen *screen) { const bool wasPrimary = (!QGuiApplicationPrivate::screen_list.isEmpty() && QGuiApplicationPrivate::screen_list.at(0) == screen); @@ -504,38 +483,19 @@ void QPlatformIntegration::removeScreen(QScreen *screen) } /*! - Should be called by the implementation whenever a screen is removed. - - This removes the screen from QGuiApplication::screens(), and deletes it. - - Failing to call this and manually deleting the QPlatformScreen instead may - lead to a crash due to a pure virtual call. + \deprecated Use QWindowSystemInterface::handleScreenRemoved instead. */ -void QPlatformIntegration::destroyScreen(QPlatformScreen *screen) +void QPlatformIntegration::destroyScreen(QPlatformScreen *platformScreen) { - QScreen *qScreen = screen->screen(); - removeScreen(qScreen); - delete qScreen; - delete screen; + QWindowSystemInterface::handleScreenRemoved(platformScreen); } /*! - Should be called whenever the primary screen changes. - - When the screen specified as primary changes, this method will notify - QGuiApplication and emit the QGuiApplication::primaryScreenChanged signal. - */ - + \deprecated Use QWindowSystemInterface::handlePrimaryScreenChanged instead. +*/ void QPlatformIntegration::setPrimaryScreen(QPlatformScreen *newPrimary) { - QScreen* newPrimaryScreen = newPrimary->screen(); - int idx = QGuiApplicationPrivate::screen_list.indexOf(newPrimaryScreen); - Q_ASSERT(idx >= 0); - if (idx == 0) - return; - - QGuiApplicationPrivate::screen_list.swap(0, idx); - emit qGuiApp->primaryScreenChanged(newPrimaryScreen); + QWindowSystemInterface::handlePrimaryScreenChanged(newPrimary); } QStringList QPlatformIntegration::themeNames() const diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index efb1481f6d..1179daeb32 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -190,7 +190,9 @@ public: #endif virtual void setApplicationIcon(const QIcon &icon) const; - void removeScreen(QScreen *screen); +#if QT_DEPRECATED_SINCE(5, 12) + QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenRemoved") void removeScreen(QScreen *screen); +#endif virtual void beep() const; @@ -199,9 +201,11 @@ public: #endif protected: - void screenAdded(QPlatformScreen *screen, bool isPrimary = false); - void destroyScreen(QPlatformScreen *screen); - void setPrimaryScreen(QPlatformScreen *newPrimary); +#if QT_DEPRECATED_SINCE(5, 12) + QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenAdded") void screenAdded(QPlatformScreen *screen, bool isPrimary = false); + QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenRemoved") void destroyScreen(QPlatformScreen *screen); + QT_DEPRECATED_X("Use QWindowSystemInterface::handlePrimaryScreenChanged") void setPrimaryScreen(QPlatformScreen *newPrimary); +#endif }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index b7b312e89e..21ae75ba8f 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -61,8 +61,11 @@ QPlatformScreen::~QPlatformScreen() { Q_D(QPlatformScreen); if (d->screen) { - qWarning("Manually deleting a QPlatformScreen. Call QPlatformIntegration::destroyScreen instead."); + qWarning("Manually deleting a QPlatformScreen. Call QWindowSystemInterface::handleScreenRemoved instead."); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QGuiApplicationPrivate::platformIntegration()->removeScreen(d->screen); +QT_WARNING_POP delete d->screen; } } diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index 8c9b16e08e..14392d3036 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -169,6 +169,7 @@ private: friend class QPlatformIntegration; friend class QPlatformScreen; friend class QHighDpiScaling; + friend class QWindowSystemInterface; }; #ifndef QT_NO_DEBUG_STREAM diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 7067ece1d8..b0f2869128 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -780,6 +780,70 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleTouchCancelEvent, QWindow *window, ulong QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } +/*! + Should be called by the implementation whenever a new screen is added. + + The first screen added will be the primary screen, used for default-created + windows, GL contexts, and other resources unless otherwise specified. + + This adds the screen to QGuiApplication::screens(), and emits the + QGuiApplication::screenAdded() signal. + + The screen should be deleted by calling QWindowSystemInterface::handleScreenRemoved(). +*/ +void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrimary) +{ + QScreen *screen = new QScreen(ps); + + if (isPrimary) + QGuiApplicationPrivate::screen_list.prepend(screen); + else + QGuiApplicationPrivate::screen_list.append(screen); + + emit qGuiApp->screenAdded(screen); + + if (isPrimary) + emit qGuiApp->primaryScreenChanged(screen); +} + +/*! + Should be called by the implementation whenever a screen is removed. + + This removes the screen from QGuiApplication::screens(), and deletes it. + + Failing to call this and manually deleting the QPlatformScreen instead may + lead to a crash due to a pure virtual call. +*/ +void QWindowSystemInterface::handleScreenRemoved(QPlatformScreen *platformScreen) +{ +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + QGuiApplicationPrivate::platformIntegration()->removeScreen(platformScreen->screen()); +QT_WARNING_POP + + // Important to keep this order since the QSceen doesn't own the platform screen + delete platformScreen->screen(); + delete platformScreen; +} + +/*! + Should be called whenever the primary screen changes. + + When the screen specified as primary changes, this method will notify + QGuiApplication and emit the QGuiApplication::primaryScreenChanged signal. + */ +void QWindowSystemInterface::handlePrimaryScreenChanged(QPlatformScreen *newPrimary) +{ + QScreen *newPrimaryScreen = newPrimary->screen(); + int indexOfScreen = QGuiApplicationPrivate::screen_list.indexOf(newPrimaryScreen); + Q_ASSERT(indexOfScreen >= 0); + if (indexOfScreen == 0) + return; + + QGuiApplicationPrivate::screen_list.swap(0, indexOfScreen); + emit qGuiApp->primaryScreenChanged(newPrimaryScreen); +} + void QWindowSystemInterface::handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation orientation) { QWindowSystemInterfacePrivate::ScreenOrientationEvent *e = diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 1dde9130ac..bf98c33a1a 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -233,6 +233,10 @@ public: static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result); // Changes to the screen + static void handleScreenAdded(QPlatformScreen *screen, bool isPrimary = false); + static void handleScreenRemoved(QPlatformScreen *screen); + static void handlePrimaryScreenChanged(QPlatformScreen *newPrimary); + static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation); static void handleScreenGeometryChange(QScreen *screen, const QRect &newGeometry, const QRect &newAvailableGeometry); static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 763b294660..e0c437be27 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -173,7 +173,7 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ qFatal("Could not bind GL_ES API"); m_primaryScreen = new QAndroidPlatformScreen(); - screenAdded(m_primaryScreen); + QWindowSystemInterface::handleScreenAdded(m_primaryScreen); m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, m_defaultPhysicalSizeHeight)); m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); diff --git a/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp b/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp index 6a7d445e69..e4c90d26af 100644 --- a/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp +++ b/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #if QT_CONFIG(tslib) #include @@ -69,13 +70,13 @@ QBsdFbIntegration::QBsdFbIntegration(const QStringList ¶mList) QBsdFbIntegration::~QBsdFbIntegration() { - destroyScreen(m_primaryScreen.take()); + QWindowSystemInterface::handleScreenRemoved(m_primaryScreen.take()); } void QBsdFbIntegration::initialize() { if (m_primaryScreen->initialize()) - screenAdded(m_primaryScreen.data()); + QWindowSystemInterface::handleScreenAdded(m_primaryScreen.data()); else qWarning("bsdfb: Failed to initialize screen"); diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 6d6c66e242..fb3d05d3e4 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -244,7 +244,7 @@ QCocoaIntegration::~QCocoaIntegration() // Delete screens in reverse order to avoid crash in case of multiple screens while (!mScreens.isEmpty()) { - destroyScreen(mScreens.takeLast()); + QWindowSystemInterface::handleScreenRemoved(mScreens.takeLast()); } clearToolbars(); @@ -304,7 +304,7 @@ void QCocoaIntegration::updateScreens() screen = new QCocoaScreen(i); mScreens.append(screen); qCDebug(lcQpaScreen) << "Adding" << screen; - screenAdded(screen); + QWindowSystemInterface::handleScreenAdded(screen); } siblings << screen; } @@ -321,7 +321,7 @@ void QCocoaIntegration::updateScreens() // Prevent stale references to NSScreen during destroy screen->m_screenIndex = -1; qCDebug(lcQpaScreen) << "Removing" << screen; - destroyScreen(screen); + QWindowSystemInterface::handleScreenRemoved(screen); } } diff --git a/src/plugins/platforms/directfb/qdirectfb_egl.cpp b/src/plugins/platforms/directfb/qdirectfb_egl.cpp index dad553c890..d3c95f0b65 100644 --- a/src/plugins/platforms/directfb/qdirectfb_egl.cpp +++ b/src/plugins/platforms/directfb/qdirectfb_egl.cpp @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -248,7 +249,7 @@ QPlatformOpenGLContext *QDirectFbIntegrationEGL::createPlatformOpenGLContext(QOp void QDirectFbIntegrationEGL::initializeScreen() { m_primaryScreen.reset(new QDirectFbScreenEGL(0)); - screenAdded(m_primaryScreen.data()); + QWindowSystemInterface::handleScreenAdded(m_primaryScreen.data()); } bool QDirectFbIntegrationEGL::hasCapability(QPlatformIntegration::Capability cap) const diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index cdf340da7a..73e308da53 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -56,6 +56,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -113,7 +114,7 @@ void QDirectFbIntegration::initializeDirectFB() void QDirectFbIntegration::initializeScreen() { m_primaryScreen.reset(new QDirectFbScreen(0)); - screenAdded(m_primaryScreen.data()); + QWindowSystemInterface::handleScreenAdded(m_primaryScreen.data()); } void QDirectFbIntegration::initializeInput() diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp index 0a3a37863a..81bad45cd2 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp @@ -200,10 +200,8 @@ void QEglFSDeviceIntegration::screenInit() void QEglFSDeviceIntegration::screenDestroy() { QGuiApplication *app = qGuiApp; - QEglFSIntegration *platformIntegration = static_cast( - QGuiApplicationPrivate::platformIntegration()); while (!app->screens().isEmpty()) - platformIntegration->removeScreen(app->screens().constLast()->handle()); + QWindowSystemInterface::handleScreenRemoved(app->screens().constLast()->handle()); } QSizeF QEglFSDeviceIntegration::physicalScreenSize() const diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp index 8ccb0ef2cd..48469b0f8c 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp @@ -120,16 +120,6 @@ QEglFSIntegration::QEglFSIntegration() initResources(); } -void QEglFSIntegration::addScreen(QPlatformScreen *screen, bool isPrimary) -{ - screenAdded(screen, isPrimary); -} - -void QEglFSIntegration::removeScreen(QPlatformScreen *screen) -{ - destroyScreen(screen); -} - void QEglFSIntegration::initialize() { qt_egl_device_integration()->platformInit(); @@ -147,7 +137,7 @@ void QEglFSIntegration::initialize() m_vtHandler.reset(new QFbVtHandler); if (qt_egl_device_integration()->usesDefaultScreen()) - addScreen(new QEglFSScreen(display())); + QWindowSystemInterface::handleScreenAdded(new QEglFSScreen(display())); else qt_egl_device_integration()->screenInit(); diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h index 4b4585d33c..898b322834 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h @@ -103,9 +103,6 @@ public: QFbVtHandler *vtHandler() { return m_vtHandler.data(); } - void addScreen(QPlatformScreen *screen, bool isPrimary = false); - void removeScreen(QPlatformScreen *screen); - private: EGLNativeDisplayType nativeDisplay() const; void createInputHandlers(); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorintegration.cpp index 5e2708e958..cb7844aff0 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorintegration.cpp @@ -45,6 +45,8 @@ #include #include +#include + #include #include #include @@ -80,8 +82,6 @@ bool QEglFSEmulatorIntegration::usesDefaultScreen() void QEglFSEmulatorIntegration::screenInit() { - QEglFSIntegration *integration = static_cast(QGuiApplicationPrivate::platformIntegration()); - // Use qgsGetDisplays() call to retrieve the available screens from the Emulator if (getDisplays) { QByteArray displaysInfo = getDisplays(); @@ -93,7 +93,7 @@ void QEglFSEmulatorIntegration::screenInit() QJsonArray screenArray = displaysDocument.array(); for (auto screenValue : screenArray) { if (screenValue.isObject()) - integration->addScreen(new QEglFSEmulatorScreen(screenValue.toObject())); + QWindowSystemInterface::handleScreenAdded(new QEglFSEmulatorScreen(screenValue.toObject())); } } } else { diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp index b073577797..4f0b0d7725 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp @@ -58,7 +58,7 @@ void QEglFSKmsDevice::registerScreen(QPlatformScreen *screen, QEglFSKmsScreen *s = static_cast(screen); s->setVirtualPosition(virtualPos); s->setVirtualSiblings(virtualSiblings); - static_cast(QGuiApplicationPrivate::platformIntegration())->addScreen(s, isPrimary); + QWindowSystemInterface::handleScreenAdded(s, isPrimary); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/haiku/qhaikuintegration.cpp b/src/plugins/platforms/haiku/qhaikuintegration.cpp index 8bd2171794..44df6ae8f5 100644 --- a/src/plugins/platforms/haiku/qhaikuintegration.cpp +++ b/src/plugins/platforms/haiku/qhaikuintegration.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -81,12 +82,12 @@ QHaikuIntegration::QHaikuIntegration(const QStringList ¶meters) m_services = new QHaikuServices; // notify system about available screen - screenAdded(m_screen); + QWindowSystemInterface::handleScreenAdded(m_screen); } QHaikuIntegration::~QHaikuIntegration() { - destroyScreen(m_screen); + QWindowSystemInterface::handleScreenRemoved(m_screen); m_screen = nullptr; delete m_services; diff --git a/src/plugins/platforms/integrity/qintegrityfbintegration.cpp b/src/plugins/platforms/integrity/qintegrityfbintegration.cpp index ae802bb1fa..3ad31dc562 100644 --- a/src/plugins/platforms/integrity/qintegrityfbintegration.cpp +++ b/src/plugins/platforms/integrity/qintegrityfbintegration.cpp @@ -51,7 +51,7 @@ #include #include - +#include QT_BEGIN_NAMESPACE @@ -64,13 +64,13 @@ QIntegrityFbIntegration::QIntegrityFbIntegration(const QStringList ¶mList) QIntegrityFbIntegration::~QIntegrityFbIntegration() { - destroyScreen(m_primaryScreen); + QWindowSystemInterface::handleScreenRemoved(m_primaryScreen); } void QIntegrityFbIntegration::initialize() { if (m_primaryScreen->initialize()) - screenAdded(m_primaryScreen); + QWindowSystemInterface::handleScreenAdded(m_primaryScreen); else qWarning("integrityfb: Failed to initialize screen"); diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h index 818250fcee..eeb44b54d3 100644 --- a/src/plugins/platforms/ios/qiosintegration.h +++ b/src/plugins/platforms/ios/qiosintegration.h @@ -92,10 +92,6 @@ public: QPlatformAccessibility *accessibility() const override; #endif - // Called from Objective-C class QIOSScreenTracker, which can't be friended - void addScreen(QPlatformScreen *screen) { screenAdded(screen); } - void destroyScreen(QPlatformScreen *screen) { QPlatformIntegration::destroyScreen(screen); } - void beep() const override; static QIOSIntegration *instance(); diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index bec8354fcc..9eca0eaad3 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -107,7 +107,7 @@ void QIOSIntegration::initialize() } for (UIScreen *screen in screens) - addScreen(new QIOSScreen(screen)); + QWindowSystemInterface::handleScreenAdded(new QIOSScreen(screen)); // Depends on a primary screen being present m_inputContext = new QIOSInputContext; @@ -143,7 +143,7 @@ QIOSIntegration::~QIOSIntegration() m_inputContext = 0; foreach (QScreen *screen, QGuiApplication::screens()) - destroyScreen(screen->handle()); + QWindowSystemInterface::handleScreenRemoved(screen->handle()); delete m_platformServices; m_platformServices = 0; diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 4f753be21a..9aba658479 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -50,6 +50,7 @@ #include #include +#include #include @@ -105,10 +106,10 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen) + (void)screenConnected:(NSNotification*)notification { - QIOSIntegration *integration = QIOSIntegration::instance(); - Q_ASSERT_X(integration, Q_FUNC_INFO, "Screen connected before QIOSIntegration creation"); + Q_ASSERT_X(QIOSIntegration::instance(), Q_FUNC_INFO, + "Screen connected before QIOSIntegration creation"); - integration->addScreen(new QIOSScreen([notification object])); + QWindowSystemInterface::handleScreenAdded(new QIOSScreen([notification object])); } + (void)screenDisconnected:(NSNotification*)notification @@ -116,8 +117,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen) QIOSScreen *screen = qtPlatformScreenFor([notification object]); Q_ASSERT_X(screen, Q_FUNC_INFO, "Screen disconnected that we didn't know about"); - QIOSIntegration *integration = QIOSIntegration::instance(); - integration->destroyScreen(screen); + QWindowSystemInterface::handleScreenRemoved(screen); } + (void)screenModeChanged:(NSNotification*)notification diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index 9e38900bcd..68843aa4c5 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -54,6 +54,7 @@ #include #include +#include #if QT_CONFIG(libinput) #include @@ -89,13 +90,13 @@ QLinuxFbIntegration::QLinuxFbIntegration(const QStringList ¶mList) QLinuxFbIntegration::~QLinuxFbIntegration() { - destroyScreen(m_primaryScreen); + QWindowSystemInterface::handleScreenRemoved(m_primaryScreen); } void QLinuxFbIntegration::initialize() { if (m_primaryScreen->initialize()) - screenAdded(m_primaryScreen); + QWindowSystemInterface::handleScreenAdded(m_primaryScreen); else qWarning("linuxfb: Failed to initialize screen"); diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index 0c04608fca..f457f69f11 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #if defined(Q_OS_WINRT) @@ -108,7 +109,7 @@ QMinimalIntegration::QMinimalIntegration(const QStringList ¶meters) mPrimaryScreen->mDepth = 32; mPrimaryScreen->mFormat = QImage::Format_ARGB32_Premultiplied; - screenAdded(mPrimaryScreen); + QWindowSystemInterface::handleScreenAdded(mPrimaryScreen); } QMinimalIntegration::~QMinimalIntegration() diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp index da58441d67..a0d35a80cd 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp @@ -58,6 +58,7 @@ #include #include #include +#include // this is where EGL headers are pulled in, make sure it is last #include "qminimaleglscreen.h" @@ -90,7 +91,7 @@ protected: QMinimalEglIntegration::QMinimalEglIntegration() : mFontDb(new QGenericUnixFontDatabase()), mScreen(new QMinimalEglScreen(EGL_DEFAULT_DISPLAY)) { - screenAdded(mScreen); + QWindowSystemInterface::handleScreenAdded(mScreen); #ifdef QEGL_EXTRA_DEBUG qWarning("QMinimalEglIntegration\n"); @@ -99,7 +100,7 @@ QMinimalEglIntegration::QMinimalEglIntegration() QMinimalEglIntegration::~QMinimalEglIntegration() { - destroyScreen(mScreen); + QWindowSystemInterface::handleScreenRemoved(mScreen); delete mFontDb; } diff --git a/src/plugins/platforms/mirclient/qmirclientintegration.cpp b/src/plugins/platforms/mirclient/qmirclientintegration.cpp index eef96ee3de..d2b1dbee0d 100644 --- a/src/plugins/platforms/mirclient/qmirclientintegration.cpp +++ b/src/plugins/platforms/mirclient/qmirclientintegration.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -149,12 +150,12 @@ void QMirClientClientIntegration::initialize() // Init the ScreenObserver mScreenObserver.reset(new QMirClientScreenObserver(mMirConnection)); connect(mScreenObserver.data(), &QMirClientScreenObserver::screenAdded, - [this](QMirClientScreen *screen) { this->screenAdded(screen); }); + [this](QMirClientScreen *screen) { QWindowSystemInterface::handleScreenAdded(screen); }); connect(mScreenObserver.data(), &QMirClientScreenObserver::screenRemoved, this, &QMirClientClientIntegration::destroyScreen); Q_FOREACH (auto screen, mScreenObserver->screens()) { - screenAdded(screen); + QWindowSystemInterface::handleScreenAdded(screen); } // Initialize input. @@ -392,7 +393,7 @@ void QMirClientClientIntegration::destroyScreen(QMirClientScreen *screen) #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) delete screen; #else - QPlatformIntegration::destroyScreen(screen); + QWindowSystemInterface::handleScreenRemoved(screen); #endif } diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp index 9815be16a3..ef3b0dd3ff 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include @@ -117,7 +118,7 @@ QOffscreenIntegration::QOffscreenIntegration() #endif m_services.reset(new QPlatformServices); - screenAdded(new QOffscreenScreen); + QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen); } QOffscreenIntegration::~QOffscreenIntegration() diff --git a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp index 4850ca2e45..c5dc40a206 100644 --- a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -135,13 +136,3 @@ QPlatformPrinterSupport * QOpenWFDIntegration::printerSupport() const { return mPrinterSupport; } - -void QOpenWFDIntegration::addScreen(QOpenWFDScreen *screen) -{ - screenAdded(screen); -} - -void QOpenWFDIntegration::destroyScreen(QOpenWFDScreen *screen) -{ - QPlatformIntegration::destroyScreen(screen); -} diff --git a/src/plugins/platforms/openwfd/qopenwfdintegration.h b/src/plugins/platforms/openwfd/qopenwfdintegration.h index 1ce1001bed..444aaccaaf 100644 --- a/src/plugins/platforms/openwfd/qopenwfdintegration.h +++ b/src/plugins/platforms/openwfd/qopenwfdintegration.h @@ -68,8 +68,6 @@ public: QPlatformPrinterSupport *printerSupport() const; - void addScreen(QOpenWFDScreen *screen); - void destroyScreen(QOpenWFDScreen *screen); private: QList mScreens; QListmDevices; diff --git a/src/plugins/platforms/openwfd/qopenwfdport.cpp b/src/plugins/platforms/openwfd/qopenwfdport.cpp index 33254fe83c..34b4439958 100644 --- a/src/plugins/platforms/openwfd/qopenwfdport.cpp +++ b/src/plugins/platforms/openwfd/qopenwfdport.cpp @@ -133,7 +133,7 @@ void QOpenWFDPort::attach() wfdBindPipelineToPort(mDevice->handle(),mPort,mPipeline); mScreen = new QOpenWFDScreen(this); - mDevice->integration()->addScreen(mScreen); + QWindowSystemInterface::handleScreenAdded(mScreen); mAttached = true; } @@ -145,7 +145,7 @@ void QOpenWFDPort::detach() mAttached = false; mOn = false; - mDevice->integration()->destroyScreen(mScreen); + QWindowSystemInterface::handleScreenRemoved(mScreen); wfdDestroyPipeline(mDevice->handle(),mPipeline); mPipelineId = WFD_INVALID_PIPELINE_ID; diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index a996e765c4..a45dcabeb7 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -649,7 +649,7 @@ void QQnxIntegration::createDisplay(screen_display_t display, bool isPrimary) { QQnxScreen *screen = new QQnxScreen(m_screenContext, display, isPrimary); m_screens.append(screen); - screenAdded(screen); + QWindowSystemInterface::handleScreenAdded(screen); screen->adjustOrientation(); QObject::connect(m_screenEventHandler, SIGNAL(newWindowCreated(void*)), @@ -669,14 +669,14 @@ void QQnxIntegration::removeDisplay(QQnxScreen *screen) Q_CHECK_PTR(screen); Q_ASSERT(m_screens.contains(screen)); m_screens.removeAll(screen); - destroyScreen(screen); + QWindowSystemInterface::handleScreenRemoved(screen); } void QQnxIntegration::destroyDisplays() { qIntegrationDebug(); Q_FOREACH (QQnxScreen *screen, m_screens) { - QPlatformIntegration::destroyScreen(screen); + QWindowSystemInterface::handleScreenRemoved(screen); } m_screens.clear(); } diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 1e2cf6292c..c7a796464a 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -77,13 +78,13 @@ QVncIntegration::QVncIntegration(const QStringList ¶mList) QVncIntegration::~QVncIntegration() { delete m_server; - destroyScreen(m_primaryScreen); + QWindowSystemInterface::handleScreenRemoved(m_primaryScreen); } void QVncIntegration::initialize() { if (m_primaryScreen->initialize()) - screenAdded(m_primaryScreen); + QWindowSystemInterface::handleScreenAdded(m_primaryScreen); else qWarning("vnc: Failed to initialize screen"); diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index 1be909f0a0..3829043d07 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -78,7 +78,7 @@ QWasmIntegration::QWasmIntegration() globalHtml5Integration = this; updateQScreenAndCanvasRenderSize(); - screenAdded(m_screen); + QWindowSystemInterface::handleScreenAdded(m_screen); emscripten_set_resize_callback(0, (void *)this, 1, uiEvent_cb); m_eventTranslator = new QWasmEventTranslator; @@ -93,7 +93,7 @@ QWasmIntegration::QWasmIntegration() QWasmIntegration::~QWasmIntegration() { delete m_compositor; - destroyScreen(m_screen); + QWindowSystemInterface::handleScreenRemoved(m_screen); delete m_fontDb; delete m_eventTranslator; } diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index da86852766..e28b2c2fb3 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -107,9 +107,6 @@ public: static QWindowsIntegration *instance() { return m_instance; } - inline void emitScreenAdded(QPlatformScreen *s, bool isPrimary = false) { screenAdded(s, isPrimary); } - inline void emitDestroyScreen(QPlatformScreen *s) { destroyScreen(s); } - unsigned options() const; void beep() const override; diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index a161dc46e9..0520f88935 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -121,7 +121,7 @@ BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM QWindowsScreenData data; if (monitorData(hMonitor, &data)) { WindowsScreenDataList *result = reinterpret_cast(p); - // QPlatformIntegration::screenAdded() documentation specifies that first + // QWindowSystemInterface::handleScreenAdded() documentation specifies that first // added screen will be the primary screen, so order accordingly. // Note that the side effect of this policy is that there is no way to change primary // screen reported by Qt, unless we want to delete all existing screens and add them @@ -521,7 +521,7 @@ void QWindowsScreenManager::removeScreen(int index) if (movedWindowCount) QWindowSystemInterface::flushWindowSystemEvents(); } - QWindowsIntegration::instance()->emitDestroyScreen(m_screens.takeAt(index)); + QWindowSystemInterface::handleScreenRemoved(m_screens.takeAt(index)); } /*! @@ -541,7 +541,7 @@ bool QWindowsScreenManager::handleScreenChanges() } else { QWindowsScreen *newScreen = new QWindowsScreen(newData); m_screens.push_back(newScreen); - QWindowsIntegration::instance()->emitScreenAdded(newScreen, + QWindowSystemInterface::handleScreenAdded(newScreen, newData.flags & QWindowsScreenData::PrimaryScreen); qCDebug(lcQpaWindows) << "New Monitor: " << newData; } // exists @@ -561,7 +561,7 @@ void QWindowsScreenManager::clearScreens() { // Delete screens in reverse order to avoid crash in case of multiple screens while (!m_screens.isEmpty()) - QWindowsIntegration::instance()->emitDestroyScreen(m_screens.takeLast()); + QWindowSystemInterface::handleScreenRemoved(m_screens.takeLast()); } const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp index 78cbc3aec3..27d3746933 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.cpp +++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp @@ -133,7 +133,7 @@ QWinRTIntegration::QWinRTIntegration() : d_ptr(new QWinRTIntegrationPrivate) }); d->inputContext.reset(new QWinRTInputContext(d->mainScreen)); - screenAdded(d->mainScreen); + QWindowSystemInterface::handleScreenAdded(d->mainScreen); d->platformServices = new QWinRTServices; d->clipboard = new QWinRTClipboard; #if QT_CONFIG(accessibility) @@ -154,7 +154,7 @@ QWinRTIntegration::~QWinRTIntegration() Q_ASSERT_SUCCEEDED(hr); } - destroyScreen(d->mainScreen); + QWindowSystemInterface::handleScreenRemoved(d->mainScreen); Windows::Foundation::Uninitialize(); } diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 29acf0e86d..0d71a5a552 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -146,10 +146,9 @@ QXcbConnection::~QXcbConnection() if (m_eventQueue) delete m_eventQueue; - QXcbIntegration *integration = QXcbIntegration::instance(); // Delete screens in reverse order to avoid crash in case of multiple screens while (!m_screens.isEmpty()) - integration->destroyScreen(m_screens.takeLast()); + QWindowSystemInterface::handleScreenRemoved(m_screens.takeLast()); while (!m_virtualDesktops.isEmpty()) delete m_virtualDesktops.takeLast(); diff --git a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp index 9aba996bb9..4e631beb25 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp @@ -44,6 +44,8 @@ #include #include +#include + #include void QXcbConnection::xrandrSelectEvents() @@ -211,7 +213,7 @@ void QXcbConnection::updateScreen(QXcbScreen *screen, const xcb_randr_output_cha m_screens.swap(0, idx); } screen->virtualDesktop()->setPrimaryScreen(screen); - QXcbIntegration::instance()->setPrimaryScreen(screen); + QWindowSystemInterface::handlePrimaryScreenChanged(screen); } } } @@ -234,7 +236,7 @@ QXcbScreen *QXcbConnection::createScreen(QXcbVirtualDesktop *virtualDesktop, m_screens.append(screen); } virtualDesktop->addScreen(screen); - QXcbIntegration::instance()->screenAdded(screen, screen->isPrimary()); + QWindowSystemInterface::handleScreenAdded(screen, screen->isPrimary()); return screen; } @@ -261,10 +263,10 @@ void QXcbConnection::destroyScreen(QXcbScreen *screen) const int idx = m_screens.indexOf(newPrimary); if (idx > 0) m_screens.swap(0, idx); - QXcbIntegration::instance()->setPrimaryScreen(newPrimary); + QWindowSystemInterface::handlePrimaryScreenChanged(newPrimary); } - QXcbIntegration::instance()->destroyScreen(screen); + QWindowSystemInterface::handleScreenRemoved(screen); } } @@ -406,7 +408,7 @@ void QXcbConnection::initializeScreens() // Push the screens to QGuiApplication for (QXcbScreen *screen : qAsConst(m_screens)) { qCDebug(lcQpaScreen) << "adding" << screen << "(Primary:" << screen->isPrimary() << ")"; - QXcbIntegration::instance()->screenAdded(screen, screen->isPrimary()); + QWindowSystemInterface::handleScreenAdded(screen, screen->isPrimary()); } qCDebug(lcQpaScreen) << "primary output is" << qAsConst(m_screens).first()->name(); diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index f13e232291..571726c354 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -137,8 +137,6 @@ private: QScopedPointer m_services; - friend class QXcbConnection; // access QPlatformIntegration::screenAdded() - mutable QByteArray m_wmClass; const char *m_instanceName; bool m_canGrab; From d2dff76a4fc2c28bf204db183230ffa1b86cbf43 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 18 Mar 2019 09:51:35 +0100 Subject: [PATCH 026/154] Replace instances of - with _ when generating the function name As - cannot be used in a function name but can still be used as part of the TARGET, then we need to make sure that it is replaced to avoid a compile problem. Change-Id: I0b2e465310206e2522ce59235b1592517817d3e2 Reviewed-by: Joerg Bornemann --- mkspecs/features/resources.prf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index b4e0db6445..fa8ff1fb58 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -75,9 +75,11 @@ for(resource, RESOURCES) { } !isEmpty(RESOURCES):contains(TEMPLATE, .*lib):plugin:static { - resource_init_function = $$lower($$basename(TARGET))_plugin_resource_init + pluginBaseName = $$basename(TARGET) + pluginName = $$lower($$replace(pluginBaseName, [-], _)) + resource_init_function = $${pluginName}_plugin_resource_init DEFINES += "QT_PLUGIN_RESOURCE_INIT_FUNCTION=$$resource_init_function" - RESOURCE_INIT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_plugin_resources.cpp + RESOURCE_INIT_CPP = $$OUT_PWD/$${pluginName}_plugin_resources.cpp GENERATED_SOURCES += $$RESOURCE_INIT_CPP QMAKE_DISTCLEAN += $$RESOURCE_INIT_CPP From fda57bbb32c7c08e750f9ed82d30d95052f927b5 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 18 Mar 2019 14:32:48 +0100 Subject: [PATCH 027/154] QTemporaryFile: Return early if the passed in QFile cannot be opened Change-Id: I97f00163c24f74d31e1b41ec7337f72600bda2d5 Reviewed-by: Friedemann Kleint Reviewed-by: Mikhail Svetkin Reviewed-by: Thiago Macieira --- src/corelib/io/qtemporaryfile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 35bb465a04..ced08a9a87 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -908,8 +908,8 @@ QTemporaryFile *QTemporaryFile::createNativeFile(QFile &file) qint64 old_off = 0; if(wasOpen) old_off = file.pos(); - else - file.open(QIODevice::ReadOnly); + else if (!file.open(QIODevice::ReadOnly)) + return nullptr; //dump data QTemporaryFile *ret = new QTemporaryFile; if (ret->open()) { From 2bafd997ee515d3b6a6a8fb030e1265a4713713e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 13 Mar 2019 15:45:38 +0100 Subject: [PATCH 028/154] Don't quit when last QWindow is destroyed, wait for it to close MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Destroying windows happens independently of closing them, e.g. when a window is moved from one screen to another non-sibling screen. The logic for quitting the application should apply to the actual closing of a window, as documented. Change-Id: I2226aff29278aa6fbf054a0994a320eb53196e9e Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qwindow.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index f1e08826a8..453aa1ed83 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1910,9 +1910,6 @@ void QWindowPrivate::destroy() resizeEventPending = true; receivedExpose = false; exposed = false; - - if (wasVisible) - maybeQuitOnLastWindowClosed(); } /*! @@ -2301,8 +2298,17 @@ bool QWindow::event(QEvent *ev) #endif case QEvent::Close: - if (ev->isAccepted()) + if (ev->isAccepted()) { + Q_D(QWindow); + bool wasVisible = isVisible(); destroy(); + if (wasVisible) { + // FIXME: This check for visibility is a workaround for both QWidgetWindow + // and QWindow having logic to emit lastWindowClosed, and possibly quit the + // application. We should find a better way to handle this. + d->maybeQuitOnLastWindowClosed(); + } + } break; case QEvent::Expose: From 3ca05b2a2e80863202bdb6a225f72debbb28b8fe Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 19 Mar 2019 08:48:47 +0100 Subject: [PATCH 029/154] Wasm: Build with Qt's freetype, png and zlib Compilation breaks on Windows and macOS hosts with USE_ZLIB=1. In addition, it turns out that the versions of the libraries in Emscripten Ports are outdated. Since we have newer versions of these libraries in Qt already, we will just use those. This is a revert of 70b558ad5b7972178b990b33cbd73694775b265f. Task-number: QTQAINFRA-2835 Change-Id: Ic2642b7d319a3447fd08843657eb0535255e0449 Reviewed-by: Lorn Potter --- mkspecs/wasm-emscripten/qmake.conf | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/mkspecs/wasm-emscripten/qmake.conf b/mkspecs/wasm-emscripten/qmake.conf index 855d84c039..c80f2bfb92 100644 --- a/mkspecs/wasm-emscripten/qmake.conf +++ b/mkspecs/wasm-emscripten/qmake.conf @@ -32,15 +32,6 @@ EMCC_COMMON_LFLAGS = \ --bind \ -s \"BINARYEN_TRAP_MODE=\'clamp\'\" -EMCC_USE_PORTS_FLAGS = \ - -s USE_FREETYPE=1 \ - -s USE_ZLIB=1 - -# libpng does not build for WASM_OBJECT_FILES=1, see -# https://github.com/emscripten-core/emscripten/issues/8143 -equals(WASM_OBJECT_FILES, 0):\ - EMCC_USE_PORTS_FLAGS += -s USE_LIBPNG=1 - # The -s arguments can also be used with release builds, # but are here in debug for clarity. EMCC_COMMON_LFLAGS_DEBUG = \ @@ -87,9 +78,6 @@ QMAKE_COMPILER += emscripten QMAKE_CC = emcc QMAKE_CXX = em++ -QMAKE_CFLAGS += $$EMCC_USE_PORTS_FLAGS -QMAKE_CXXFLAGS += $$EMCC_USE_PORTS_FLAGS - QMAKE_LINK = $$QMAKE_CXX QMAKE_LINK_SHLIB = $$QMAKE_CXX QMAKE_LINK_C = $$QMAKE_CC From 75b3c471b3acea8fd0531dc38913181b1bcd941d Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 18 Mar 2019 17:11:15 +0800 Subject: [PATCH 030/154] win32-clang-msvc: qmake.conf: Fix alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I62bff5e10c0dfb45078a9ff5a2378f251c6596aa Reviewed-by: Mårten Nordheim --- mkspecs/win32-clang-msvc/qmake.conf | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mkspecs/win32-clang-msvc/qmake.conf b/mkspecs/win32-clang-msvc/qmake.conf index c639ad6f3d..4b9cac3e22 100644 --- a/mkspecs/win32-clang-msvc/qmake.conf +++ b/mkspecs/win32-clang-msvc/qmake.conf @@ -13,19 +13,19 @@ QMAKE_CFLAGS_SSE4_1 = -msse4.1 QMAKE_CFLAGS_SSE4_2 = -msse4.2 QMAKE_CFLAGS_AVX = -mavx QMAKE_CFLAGS_AVX2 = -mavx2 -QMAKE_CFLAGS_F16C = -mf16c -QMAKE_CFLAGS_RDRND = -mrdrnd -QMAKE_CFLAGS_AVX512F = -mavx512f -QMAKE_CFLAGS_AVX512ER = -mavx512er -QMAKE_CFLAGS_AVX512CD = -mavx512cd -QMAKE_CFLAGS_AVX512PF = -mavx512pf -QMAKE_CFLAGS_AVX512DQ = -mavx512dq -QMAKE_CFLAGS_AVX512BW = -mavx512bw -QMAKE_CFLAGS_AVX512VL = -mavx512vl +QMAKE_CFLAGS_F16C = -mf16c +QMAKE_CFLAGS_RDRND = -mrdrnd +QMAKE_CFLAGS_AVX512F = -mavx512f +QMAKE_CFLAGS_AVX512ER = -mavx512er +QMAKE_CFLAGS_AVX512CD = -mavx512cd +QMAKE_CFLAGS_AVX512PF = -mavx512pf +QMAKE_CFLAGS_AVX512DQ = -mavx512dq +QMAKE_CFLAGS_AVX512BW = -mavx512bw +QMAKE_CFLAGS_AVX512VL = -mavx512vl QMAKE_CFLAGS_AVX512IFMA = -mavx512ifma QMAKE_CFLAGS_AVX512VBMI = -mavx512vbmi -QMAKE_CFLAGS_AESNI = -maes -QMAKE_CFLAGS_SHANI = -msha +QMAKE_CFLAGS_AESNI = -maes +QMAKE_CFLAGS_SHANI = -msha QMAKE_COMPILER += clang_cl llvm From b4b8ea6181760ac3005868ed2f3b711ca29ca774 Mon Sep 17 00:00:00 2001 From: Timo Aarnipuro Date: Fri, 1 Feb 2019 15:20:20 +0200 Subject: [PATCH 031/154] configure: Allow libraries to be defined with exact filename INTEGRITY compiler searches for exact filename if the -l argument already contains .a suffix. GNU linker uses exact filename if -l argument begins with a colon. Change-Id: I62be8f1e6b9c7dc7eaa5ab3d4bfc55460d729737 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_configure.prf | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index e845bf1577..62ad972796 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -540,7 +540,15 @@ defineTest(qtConfResolveLibs) { } else: contains(l, "^-l.*") { lib = $$replace(l, "^-l", ) lcan = - unix { + integrity:contains(lib, "^.*\\.a") { + # INTEGRITY compiler searches for exact filename + # if -l argument has .a suffix + lcan += $${lib} + } else: contains(lib, "^:.*") { + # Use exact filename when -l:filename syntax is used. + lib ~= s/^:// + lcan += $${lib} + } else: unix { # Under UNIX, we look for actual shared libraries, in addition # to static ones. shexts = $$QMAKE_EXTENSION_SHLIB $$QMAKE_EXTENSIONS_AUX_SHLIB From 7c506150a52031877145daceb032ccb882fd0a1b Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 19 Mar 2019 18:13:23 +0300 Subject: [PATCH 032/154] Force font antialiasing with highdpi scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fonts look ugly when they are drawn scaled without antialiasing. Change-Id: I64268db5b37d4bc763ffa23632aca2eaac5d8eae Reviewed-by: Morten Johan Sørvig --- .../fontdatabases/fontconfig/qfontconfigdatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index aa8f9a892a..e545d54ec2 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -908,7 +908,7 @@ QFont QFontconfigDatabase::defaultFont() const void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef &fontDef) const { bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias); - bool forcedAntialiasSetting = !antialias; + bool forcedAntialiasSetting = !antialias || QHighDpiScaling::isActive(); const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); bool useXftConf = false; From c808a6978b0e99086b1e42b565afe957d7295a9d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 1 Mar 2019 15:37:08 +0100 Subject: [PATCH 033/154] Add a means to handle dynamically created qmldir files This will enable modules like QtWebView which needs to generate its qmldir at qmake time since it changes depending on whether QtWebEngine is available or not. This ensures that it is not created in the sources directory and in the build directory and correctly picked up. Task-number: QTBUG-65092 Change-Id: Iac628b97145d29778f554510e8e07102d588df64 Reviewed-by: Joerg Bornemann --- mkspecs/features/qml_module.prf | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/qml_module.prf b/mkspecs/features/qml_module.prf index bd84ce597a..dbf5b74355 100644 --- a/mkspecs/features/qml_module.prf +++ b/mkspecs/features/qml_module.prf @@ -13,7 +13,14 @@ equals(TEMPLATE, app): TEMPLATE = aux isEmpty(TARGETPATH): error("Must set TARGETPATH (QML import name)") -qmldir_file = $$_PRO_FILE_PWD_/qmldir +!isEmpty(DYNAMIC_QMLDIR) { + qmldir_path = $$OUT_PWD + write_file($${qmldir_path}/qmldir, DYNAMIC_QMLDIR)|error("Aborting.") +} else { + qmldir_path = $$_PRO_FILE_PWD_ +} + +qmldir_file = $${qmldir_path}/qmldir fq_qml_files = for(qmlf, QML_FILES): fq_qml_files += $$absolute_path($$qmlf, $$_PRO_FILE_PWD_) @@ -42,13 +49,20 @@ builtin_resources { } # Install rules -qmldir.base = $$_PRO_FILE_PWD_ +qmldir.base = $$qmldir_path # Tools need qmldir and plugins.qmltypes always installed on the file system -qmldir.files = $$qmldir_file $$fq_aux_qml_files + +qmldir.files = $$qmldir_file install_qml_files: qmldir.files += $$fq_qml_files qmldir.path = $$[QT_INSTALL_QML]/$$TARGETPATH INSTALLS += qmldir +qmlfiles.base = $$_PRO_FILE_PWD_ +qmlfiles.files = $$fq_aux_qml_files +install_qml_files: qmlfiles.files += $$fq_qml_files +qmlfiles.path = $${qmldir.path} +INSTALLS += qmlfiles + !debug_and_release|!build_all|CONFIG(release, debug|release) { !prefix_build { COPIES += qmldir From 2abd969ef6f5841526c48da2e54fe47a001e8d69 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 12 Mar 2019 09:03:13 +0100 Subject: [PATCH 034/154] tst_qmake: Keep the source dir clean Copy the test data into a temporary directory and do all the work there without tainting the source directory. More importantly, do not pull in any settings from the Qt build to test what actual users will encounter. Change-Id: I793b86bfadb7597efb47c8f2d3fc863384c78a79 Reviewed-by: Oliver Wolff --- tests/auto/tools/qmake/testcompiler.cpp | 4 +- tests/auto/tools/qmake/testcompiler.h | 3 +- .../subdirs/simple_dll/simple_dll.pro | 1 - tests/auto/tools/qmake/tst_qmake.cpp | 86 +++++++++++++++---- 4 files changed, 75 insertions(+), 19 deletions(-) diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index da76b3f2ca..3276d97354 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -67,7 +67,9 @@ static QString targetName( BuildType buildMode, const QString& target, const QSt break; case Dll: // dll targetName.prepend("lib"); - targetName.append("." + version + ".dylib"); + if (!version.isEmpty()) + targetName.append('.' + version); + targetName.append(".dylib"); break; case Lib: // lib targetName.prepend("lib"); diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h index a46c9b6b6a..d3fe6d88f8 100644 --- a/tests/auto/tools/qmake/testcompiler.h +++ b/tests/auto/tools/qmake/testcompiler.h @@ -60,7 +60,8 @@ public: // executes a make in the specified workPath, with an optional target (eg. install) bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false ); // checks if the executable exists in destDir - bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ); + bool exists(const QString &destDir, const QString &exeName, BuildType buildType, + const QString &version = QString()); // removes the makefile bool removeMakefile( const QString &workPath ); // removes the project file specified by 'project' on the 'workPath' diff --git a/tests/auto/tools/qmake/testdata/subdirs/simple_dll/simple_dll.pro b/tests/auto/tools/qmake/testdata/subdirs/simple_dll/simple_dll.pro index 4e362bb918..d13f49bb89 100644 --- a/tests/auto/tools/qmake/testdata/subdirs/simple_dll/simple_dll.pro +++ b/tests/auto/tools/qmake/testdata/subdirs/simple_dll/simple_dll.pro @@ -6,7 +6,6 @@ DEFINES += SIMPLEDLL_MAKEDLL HEADERS = simple.h SOURCES = simple.cpp -VERSION = 1.0.0 INCLUDEPATH += . tmp MOC_DIR = tmp OBJECTS_DIR = tmp diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 10aabcf196..2b822e682f 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -30,9 +30,11 @@ #include "testcompiler.h" +#include +#include #include #include -#include +#include #if defined(DEBUG_BUILD) # define DIR_INFIX "debug/" @@ -46,8 +48,12 @@ class tst_qmake : public QObject { Q_OBJECT +public: + tst_qmake(); + private slots: void initTestCase(); + void cleanupTestCase(); void cleanup(); void simple_app(); void simple_app_shadowbuild(); @@ -78,11 +84,41 @@ private slots: private: TestCompiler test_compiler; + QTemporaryDir tempWorkDir; QString base_path; + const QString origCurrentDirPath; }; +tst_qmake::tst_qmake() + : tempWorkDir(QDir::tempPath() + "/tst_qmake"), + origCurrentDirPath(QDir::currentPath()) +{ +} + +static void copyDir(const QString &sourceDirPath, const QString &targetDirPath) +{ + QDir currentDir; + QDirIterator dit(sourceDirPath, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden); + while (dit.hasNext()) { + dit.next(); + const QString targetPath = targetDirPath + QLatin1Char('/') + dit.fileName(); + currentDir.mkpath(targetPath); + copyDir(dit.filePath(), targetPath); + } + + QDirIterator fit(sourceDirPath, QDir::Files | QDir::Hidden); + while (fit.hasNext()) { + fit.next(); + const QString targetPath = targetDirPath + QLatin1Char('/') + fit.fileName(); + QFile::remove(targetPath); // allowed to fail + QFile src(fit.filePath()); + QVERIFY2(src.copy(targetPath), qPrintable(src.errorString())); + } +} + void tst_qmake::initTestCase() { + QVERIFY2(tempWorkDir.isValid(), qPrintable(tempWorkDir.errorString())); QString binpath = QLibraryInfo::location(QLibraryInfo::BinariesPath); QString cmd = QString("%1/qmake").arg(binpath); #ifdef Q_CC_MSVC @@ -99,13 +135,31 @@ void tst_qmake::initTestCase() #else test_compiler.setBaseCommands( "make", cmd ); #endif - //Detect the location of the testdata - QString subProgram = QLatin1String("testdata/simple_app/main.cpp"); - base_path = QFINDTESTDATA(subProgram); - if (base_path.lastIndexOf(subProgram) > 0) - base_path = base_path.left(base_path.lastIndexOf(subProgram)); - else - base_path = QCoreApplication::applicationDirPath(); + const QString testDataSubDir = QStringLiteral("testdata"); + const QString subProgram = testDataSubDir + QLatin1String("/simple_app/main.cpp"); + QString testDataPath = QFINDTESTDATA(subProgram); + if (!testDataPath.endsWith(subProgram)) + QFAIL("Cannot find test data directory."); + testDataPath.chop(subProgram.length() - testDataSubDir.length()); + + QString userWorkDir = qgetenv("TST_QMAKE_BUILD_DIR"); + if (userWorkDir.isEmpty()) { + base_path = tempWorkDir.path(); + } else { + if (!QFile::exists(userWorkDir)) { + QFAIL(qUtf8Printable(QStringLiteral("TST_QMAKE_BUILD_DIR %1 does not exist.") + .arg(userWorkDir))); + } + base_path = userWorkDir; + } + + copyDir(testDataPath, base_path + QLatin1Char('/') + testDataSubDir); +} + +void tst_qmake::cleanupTestCase() +{ + // On Windows, ~QTemporaryDir fails to remove the directory if we're still in there. + QDir::setCurrent(origCurrentDirPath); } void tst_qmake::cleanup() @@ -205,12 +259,12 @@ void tst_qmake::subdirs() D.remove( workDir + "/simple_dll/Makefile"); QVERIFY( test_compiler.qmake( workDir, "subdirs" )); QVERIFY( test_compiler.make( workDir )); - QVERIFY( test_compiler.exists( workDir + "/simple_app/dest dir", "simple app", Exe, "1.0.0" )); - QVERIFY( test_compiler.exists( workDir + "/simple_dll/dest dir", "simple dll", Dll, "1.0.0" )); + QVERIFY( test_compiler.exists(workDir + "/simple_app/dest dir", "simple app", Exe)); + QVERIFY( test_compiler.exists(workDir + "/simple_dll/dest dir", "simple dll", Dll)); QVERIFY( test_compiler.makeClean( workDir )); // Should still exist after a make clean - QVERIFY( test_compiler.exists( workDir + "/simple_app/dest dir", "simple app", Exe, "1.0.0" )); - QVERIFY( test_compiler.exists( workDir + "/simple_dll/dest dir", "simple dll", Dll, "1.0.0" )); + QVERIFY( test_compiler.exists(workDir + "/simple_app/dest dir", "simple app", Exe)); + QVERIFY( test_compiler.exists(workDir + "/simple_dll/dest dir", "simple dll", Dll)); // Since subdirs templates do not have a make dist clean, we should clean up ourselves // properly QVERIFY( test_compiler.makeDistClean( workDir )); @@ -500,8 +554,8 @@ void tst_qmake::resources() QVERIFY(test_compiler.qmake(workDir, "resources")); { - QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_pro_file.qrc"); - QVERIFY(qrcFile.exists()); + QFile qrcFile(workDir + '/' + DIR_INFIX "qmake_pro_file.qrc"); + QVERIFY2(qrcFile.exists(), qPrintable(qrcFile.fileName())); QVERIFY(qrcFile.open(QFile::ReadOnly)); QByteArray qrcXml = qrcFile.readAll(); QVERIFY(qrcXml.contains("alias=\"resources.pro\"")); @@ -509,7 +563,7 @@ void tst_qmake::resources() } { - QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_subdir.qrc"); + QFile qrcFile(workDir + '/' + DIR_INFIX "qmake_subdir.qrc"); QVERIFY(qrcFile.exists()); QVERIFY(qrcFile.open(QFile::ReadOnly)); QByteArray qrcXml = qrcFile.readAll(); @@ -517,7 +571,7 @@ void tst_qmake::resources() } { - QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_qmake_immediate.qrc"); + QFile qrcFile(workDir + '/' + DIR_INFIX "qmake_qmake_immediate.qrc"); QVERIFY(qrcFile.exists()); QVERIFY(qrcFile.open(QFile::ReadOnly)); QByteArray qrcXml = qrcFile.readAll(); From f48a76bbbfb5823fb98d17a042bb00ad7c9da174 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 20 Mar 2019 10:10:28 +0100 Subject: [PATCH 035/154] Revert "Fix compilation with icc, converting between egl's and gl's Error types" The patch causes an Assert on close and thus cannot be used as is. I do not have ICC available to try to come up with an alternative solution so the patch is reverted for the time being. This reverts commit 93a78799c3df7c8859b2d9addad45bb4a535dc97. Fixes: QTBUG-74467 Change-Id: Ic572dfa667a479686675eb3f9066d133657b4499 Reviewed-by: Friedemann Kleint Reviewed-by: Yuhang Zhao <2546789017@qq.com> --- src/3rdparty/angle/src/libANGLE/Context.cpp | 3 +- src/3rdparty/angle/src/libANGLE/Stream.cpp | 8 +- src/3rdparty/angle/src/libANGLE/Texture.cpp | 3 +- .../libANGLE/renderer/d3d/d3d9/Renderer9.cpp | 3 +- ...with-icc-converting-between-egl-s-an.patch | 93 ------------------- 5 files changed, 6 insertions(+), 104 deletions(-) delete mode 100644 src/angle/patches/0013-Fix-compilation-with-icc-converting-between-egl-s-an.patch diff --git a/src/3rdparty/angle/src/libANGLE/Context.cpp b/src/3rdparty/angle/src/libANGLE/Context.cpp index 84f7936feb..f638beda58 100644 --- a/src/3rdparty/angle/src/libANGLE/Context.cpp +++ b/src/3rdparty/angle/src/libANGLE/Context.cpp @@ -451,8 +451,7 @@ egl::Error Context::onDestroy(const egl::Display *display) for (auto &zeroTexture : mZeroTextures) { - auto result = zeroTexture.second->onDestroy(this); - ANGLE_TRY(egl::Error(result)); + ANGLE_TRY(zeroTexture.second->onDestroy(this)); zeroTexture.second.set(this, nullptr); } mZeroTextures.clear(); diff --git a/src/3rdparty/angle/src/libANGLE/Stream.cpp b/src/3rdparty/angle/src/libANGLE/Stream.cpp index e384c7d486..68279976b7 100644 --- a/src/3rdparty/angle/src/libANGLE/Stream.cpp +++ b/src/3rdparty/angle/src/libANGLE/Stream.cpp @@ -192,9 +192,8 @@ Error Stream::consumerAcquire(const gl::Context *context) { if (mPlanes[i].texture != nullptr) { - auto result = mPlanes[i].texture->acquireImageFromStream( - context, mProducerImplementation->getGLFrameDescription(i)); - ANGLE_TRY(Error(result)); + ANGLE_TRY(mPlanes[i].texture->acquireImageFromStream( + context, mProducerImplementation->getGLFrameDescription(i))); } } @@ -214,8 +213,7 @@ Error Stream::consumerRelease(const gl::Context *context) { if (mPlanes[i].texture != nullptr) { - auto result = mPlanes[i].texture->releaseImageFromStream(context); - ANGLE_TRY(Error(result)); + ANGLE_TRY(mPlanes[i].texture->releaseImageFromStream(context)); } } diff --git a/src/3rdparty/angle/src/libANGLE/Texture.cpp b/src/3rdparty/angle/src/libANGLE/Texture.cpp index 7447604fe6..da92e65916 100644 --- a/src/3rdparty/angle/src/libANGLE/Texture.cpp +++ b/src/3rdparty/angle/src/libANGLE/Texture.cpp @@ -550,8 +550,7 @@ Error Texture::onDestroy(const Context *context) { if (mBoundSurface) { - auto result = mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER); - ANGLE_TRY(Error(result)); + ANGLE_TRY(mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER)); mBoundSurface = nullptr; } if (mBoundStream) diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp index b583273641..75c6298868 100644 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp @@ -376,8 +376,7 @@ egl::Error Renderer9::initializeDevice() ASSERT(!mBlit); mBlit = new Blit9(this); - auto result = mBlit->initialize(); - ANGLE_TRY(egl::Error(result)); + ANGLE_TRY(mBlit->initialize()); ASSERT(!mVertexDataManager && !mIndexDataManager); mVertexDataManager = new VertexDataManager(this); diff --git a/src/angle/patches/0013-Fix-compilation-with-icc-converting-between-egl-s-an.patch b/src/angle/patches/0013-Fix-compilation-with-icc-converting-between-egl-s-an.patch deleted file mode 100644 index 6d3b1cac08..0000000000 --- a/src/angle/patches/0013-Fix-compilation-with-icc-converting-between-egl-s-an.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 2d8118620d4871f74a3ddca233529ff540384477 Mon Sep 17 00:00:00 2001 -From: Yuhang Zhao <2546789017@qq.com> -Date: Wed, 13 Feb 2019 23:26:55 +0800 -Subject: [PATCH] Fix compilation with icc, converting between egl's and gl's - Error types - -Each has two constructors from the other, one copying the other -moving; and this leads to an ambiguous overload when converting -Texture::onDestroy()'s gl::error to the egl::Error that -gl::Context::onDestroy() returns. Passing the value through a -temporary prevents the move-constructor from being attempted and saves -the day. Thanks to Ville Voutilainen for suggesting the fix. - -Fixes: QTBUG-73698 -Change-Id: I628173399a73cee2e253201bc3e8d3e6477a2fbf ---- - src/3rdparty/angle/src/libANGLE/Context.cpp | 3 ++- - src/3rdparty/angle/src/libANGLE/Stream.cpp | 8 +++++--- - src/3rdparty/angle/src/libANGLE/Texture.cpp | 3 ++- - .../angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp | 3 ++- - 4 files changed, 11 insertions(+), 6 deletions(-) - -diff --git a/src/3rdparty/angle/src/libANGLE/Context.cpp b/src/3rdparty/angle/src/libANGLE/Context.cpp -index f638beda58..84f7936feb 100644 ---- a/src/3rdparty/angle/src/libANGLE/Context.cpp -+++ b/src/3rdparty/angle/src/libANGLE/Context.cpp -@@ -451,7 +451,8 @@ egl::Error Context::onDestroy(const egl::Display *display) - - for (auto &zeroTexture : mZeroTextures) - { -- ANGLE_TRY(zeroTexture.second->onDestroy(this)); -+ auto result = zeroTexture.second->onDestroy(this); -+ ANGLE_TRY(egl::Error(result)); - zeroTexture.second.set(this, nullptr); - } - mZeroTextures.clear(); -diff --git a/src/3rdparty/angle/src/libANGLE/Stream.cpp b/src/3rdparty/angle/src/libANGLE/Stream.cpp -index 68279976b7..e384c7d486 100644 ---- a/src/3rdparty/angle/src/libANGLE/Stream.cpp -+++ b/src/3rdparty/angle/src/libANGLE/Stream.cpp -@@ -192,8 +192,9 @@ Error Stream::consumerAcquire(const gl::Context *context) - { - if (mPlanes[i].texture != nullptr) - { -- ANGLE_TRY(mPlanes[i].texture->acquireImageFromStream( -- context, mProducerImplementation->getGLFrameDescription(i))); -+ auto result = mPlanes[i].texture->acquireImageFromStream( -+ context, mProducerImplementation->getGLFrameDescription(i)); -+ ANGLE_TRY(Error(result)); - } - } - -@@ -213,7 +214,8 @@ Error Stream::consumerRelease(const gl::Context *context) - { - if (mPlanes[i].texture != nullptr) - { -- ANGLE_TRY(mPlanes[i].texture->releaseImageFromStream(context)); -+ auto result = mPlanes[i].texture->releaseImageFromStream(context); -+ ANGLE_TRY(Error(result)); - } - } - -diff --git a/src/3rdparty/angle/src/libANGLE/Texture.cpp b/src/3rdparty/angle/src/libANGLE/Texture.cpp -index da92e65916..7447604fe6 100644 ---- a/src/3rdparty/angle/src/libANGLE/Texture.cpp -+++ b/src/3rdparty/angle/src/libANGLE/Texture.cpp -@@ -550,7 +550,8 @@ Error Texture::onDestroy(const Context *context) - { - if (mBoundSurface) - { -- ANGLE_TRY(mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER)); -+ auto result = mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER); -+ ANGLE_TRY(Error(result)); - mBoundSurface = nullptr; - } - if (mBoundStream) -diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp -index 75c6298868..b583273641 100644 ---- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp -+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp -@@ -376,7 +376,8 @@ egl::Error Renderer9::initializeDevice() - - ASSERT(!mBlit); - mBlit = new Blit9(this); -- ANGLE_TRY(mBlit->initialize()); -+ auto result = mBlit->initialize(); -+ ANGLE_TRY(egl::Error(result)); - - ASSERT(!mVertexDataManager && !mIndexDataManager); - mVertexDataManager = new VertexDataManager(this); --- -2.20.1.windows.1 - From b0145f029cdde7ae8475b85a20099f115879496e Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 18 Mar 2019 16:03:59 +0300 Subject: [PATCH 036/154] Handle device pixel ratio in QIconLoaderEngine::paint() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QIcon::paint() paints blurry icons on HighDPI screens. In particular, it is called by QCommonStyle to paint icons for CE_ItemViewItem's. Change-Id: Iffe6bd01a8756e617656195ef63fe13c968e0832 Reviewed-by: Morten Johan Sørvig --- src/gui/image/qiconloader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index a9adde8c8d..1d0c93f26f 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -629,7 +629,10 @@ void QIconLoaderEngine::ensureLoaded() void QIconLoaderEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) { - QSize pixmapSize = rect.size(); + const qreal dpr = !qApp->testAttribute(Qt::AA_UseHighDpiPixmaps) ? + qreal(1.0) : painter->device()->devicePixelRatioF(); + + QSize pixmapSize = rect.size() * dpr; painter->drawPixmap(rect, pixmap(pixmapSize, mode, state)); } From 26462f9c4c31a691cf98526c4cea23afee79bcc6 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 7 Mar 2019 09:54:30 +0100 Subject: [PATCH 037/154] X11PaintEngine: Don't use system clip for non-system painting When painting into a pixmap, we would apply the system clip, which is a rectangle that starts at the position of the current widget relative to the window. If the widget was not positioned at (0,0), we would therefore clip the top left part of the drawing when drawing into a pixmap, which is obviously not intentional. The solution is in accordance with how it is done in e.g. the OpenGL paint engine, where useSystemClip is set to true only if we are drawing to a widget. The system clip should otherwise be ignored, so we do that in the X11 paint engine as well. Task-number: QTBUG-70387 Change-Id: I9cad26019970280a8a452dc6f1015d229120cac5 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../xcb/nativepainting/qbackingstore_x11.cpp | 4 ++++ .../xcb/nativepainting/qpaintengine_x11.cpp | 10 +++++++--- .../platforms/xcb/nativepainting/qpixmap_x11.cpp | 14 ++++++++++++++ .../platforms/xcb/nativepainting/qpixmap_x11_p.h | 5 ++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/xcb/nativepainting/qbackingstore_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qbackingstore_x11.cpp index ed482e5dae..bbc156fc53 100644 --- a/src/plugins/platforms/xcb/nativepainting/qbackingstore_x11.cpp +++ b/src/plugins/platforms/xcb/nativepainting/qbackingstore_x11.cpp @@ -192,6 +192,10 @@ bool QXcbNativeBackingStore::scroll(const QRegion &area, int dx, int dy) void QXcbNativeBackingStore::beginPaint(const QRegion ®ion) { + QX11PlatformPixmap *x11pm = qt_x11Pixmap(m_pixmap); + if (x11pm) + x11pm->setIsBackingStore(true); + #if QT_CONFIG(xrender) if (m_translucentBackground) { const QVector xrects = qt_region_to_xrectangles(region); diff --git a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp index a3e6cedecd..d43b273f4d 100644 --- a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp +++ b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp @@ -200,6 +200,7 @@ public: uint has_pattern : 1; uint has_alpha_pen : 1; uint has_alpha_brush : 1; + uint use_sysclip : 1; uint render_hints; const QXcbX11Info *xinfo; @@ -701,6 +702,9 @@ bool QX11PaintEngine::begin(QPaintDevice *pdev) d->xlibMaxLinePoints = 32762; // a safe number used to avoid, call to XMaxRequestSize(d->dpy) - 3; d->opacity = 1; + QX11PlatformPixmap *x11pm = paintDevice()->devType() == QInternal::Pixmap ? qt_x11Pixmap(*static_cast(paintDevice())) : nullptr; + d->use_sysclip = paintDevice()->devType() == QInternal::Widget || (x11pm ? x11pm->isBackingStore() : false); + // Set up the polygon clipper. Note: This will only work in // polyline mode as long as we have a buffer zone, since a // polyline may be clipped into several non-connected polylines. @@ -1472,7 +1476,7 @@ void QX11PaintEngine::updatePen(const QPen &pen) } if (!d->has_clipping) { // if clipping is set the paintevent clip region is merged with the clip region - QRegion sysClip = systemClip(); + QRegion sysClip = d->use_sysclip ? systemClip() : QRegion(); if (!sysClip.isEmpty()) x11SetClipRegion(d->dpy, d->gc, 0, d->picture, sysClip); else @@ -1603,7 +1607,7 @@ void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin) vals.fill_style = s; XChangeGC(d->dpy, d->gc_brush, mask, &vals); if (!d->has_clipping) { - QRegion sysClip = systemClip(); + QRegion sysClip = d->use_sysclip ? systemClip() : QRegion(); if (!sysClip.isEmpty()) x11SetClipRegion(d->dpy, d->gc_brush, 0, d->picture, sysClip); else @@ -2223,7 +2227,7 @@ void QX11PaintEngine::updateMatrix(const QTransform &mtx) void QX11PaintEngine::updateClipRegion_dev(const QRegion &clipRegion, Qt::ClipOperation op) { Q_D(QX11PaintEngine); - QRegion sysClip = systemClip(); + QRegion sysClip = d->use_sysclip ? systemClip() : QRegion(); if (op == Qt::NoClip) { d->has_clipping = false; d->crgn = sysClip; diff --git a/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp index 86c87e5e30..b1ce39f363 100644 --- a/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp +++ b/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp @@ -1772,6 +1772,20 @@ XID QX11PlatformPixmap::createBitmapFromImage(const QImage &image) return hd; } +bool QX11PlatformPixmap::isBackingStore() const +{ + return (flags & IsBackingStore); +} + +void QX11PlatformPixmap::setIsBackingStore(bool on) +{ + if (on) + flags |= IsBackingStore; + else { + flags &= ~IsBackingStore; + } +} + #if QT_CONFIG(xrender) void QX11PlatformPixmap::convertToARGB32(bool preserveContents) { diff --git a/src/plugins/platforms/xcb/nativepainting/qpixmap_x11_p.h b/src/plugins/platforms/xcb/nativepainting/qpixmap_x11_p.h index 7392cbfccf..9c0ba98300 100644 --- a/src/plugins/platforms/xcb/nativepainting/qpixmap_x11_p.h +++ b/src/plugins/platforms/xcb/nativepainting/qpixmap_x11_p.h @@ -90,6 +90,8 @@ public: void convertToARGB32(bool preserveContents = true); #endif + bool isBackingStore() const; + void setIsBackingStore(bool on); private: friend class QX11PaintEngine; friend const QXcbX11Info &qt_x11Info(const QPixmap &pixmap); @@ -110,7 +112,8 @@ private: Uninitialized = 0x1, Readonly = 0x2, InvertedWhenBoundToTexture = 0x4, - GlSurfaceCreatedWithAlpha = 0x8 + GlSurfaceCreatedWithAlpha = 0x8, + IsBackingStore = 0x10 }; uint flags; From 12978d4ad03af753130ba7c40b6203491cd86cd5 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 18 Mar 2019 14:02:26 +0100 Subject: [PATCH 038/154] Android: Support for separate landscape/portrait splash screens To get appropriate aspect ratios for the splash screen, you usually need separate drawables for the portrait and landscape versions. We support this by adding two new meta data entries that can be used. If they are not available, we will fall back to the generic one, so we are still compatible with existing AndroidManifest.xmls. [ChangeLog][Android] Added entries in the AndroidManifest.xml for specific portrait and landscape splash screens. If one is present for the current orientation, it will be preferred over the generic one. Task-number: QTBUG-74029 Change-Id: I5ffea56320aef85f62f21a59df4d077b4163a65a Reviewed-by: Andy Shaw --- .../qtproject/qt5/android/QtActivityDelegate.java | 13 ++++++++++--- src/android/templates/AndroidManifest.xml | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index 350c6eee96..5fef1eccad 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -744,11 +744,19 @@ public class QtActivityDelegate } m_layout = new QtLayout(m_activity, startApplication); + int orientation = m_activity.getResources().getConfiguration().orientation; + try { ActivityInfo info = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(), PackageManager.GET_META_DATA); - if (info.metaData.containsKey("android.app.splash_screen_drawable")) { + + String splashScreenKey = "android.app.splash_screen_drawable_" + + (orientation == Configuration.ORIENTATION_LANDSCAPE ? "landscape" : "portrait"); + if (!info.metaData.containsKey(splashScreenKey)) + splashScreenKey = "android.app.splash_screen_drawable"; + + if (info.metaData.containsKey(splashScreenKey)) { m_splashScreenSticky = info.metaData.containsKey("android.app.splash_screen_sticky") && info.metaData.getBoolean("android.app.splash_screen_sticky"); - int id = info.metaData.getInt("android.app.splash_screen_drawable"); + int id = info.metaData.getInt(splashScreenKey); m_splashScreen = new ImageView(m_activity); m_splashScreen.setImageDrawable(m_activity.getResources().getDrawable(id)); m_splashScreen.setScaleType(ImageView.ScaleType.FIT_XY); @@ -768,7 +776,6 @@ public class QtActivityDelegate new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - int orientation = m_activity.getResources().getConfiguration().orientation; int rotation = m_activity.getWindowManager().getDefaultDisplay().getRotation(); boolean rot90 = (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270); boolean currentlyLandscape = (orientation == Configuration.ORIENTATION_LANDSCAPE); diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml index cb97002560..b5b26758d9 100644 --- a/src/android/templates/AndroidManifest.xml +++ b/src/android/templates/AndroidManifest.xml @@ -52,6 +52,12 @@ + + + From 24358aaf72e94cc0c20cb6a8af8683a9c202a51a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 20 Mar 2019 14:30:54 +0100 Subject: [PATCH 039/154] Handle when XVisuals lose the alpha channel of the FBConfig Sometimes the XVisual for an FBConfig have no alpha data, and thus won't work when an alpha channel is required. Fixes: QTBUG-74578 Change-Id: Idf05cbfcaea5edf667035939e9bc5d5df2172eec Reviewed-by: Laszlo Agocs --- src/platformsupport/glxconvenience/qglxconvenience.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index 40521ef6da..6458454336 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -223,6 +223,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format continue; } + QXlibPointer visual(glXGetVisualFromFBConfig(display, candidate)); int actualRed; int actualGreen; int actualBlue; @@ -231,7 +232,8 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format glXGetFBConfigAttrib(display, candidate, GLX_GREEN_SIZE, &actualGreen); glXGetFBConfigAttrib(display, candidate, GLX_BLUE_SIZE, &actualBlue); glXGetFBConfigAttrib(display, candidate, GLX_ALPHA_SIZE, &actualAlpha); - + // Sometimes the visuals don't have a depth that includes the alpha channel. + actualAlpha = qMin(actualAlpha, visual->depth - actualRed - actualGreen - actualBlue); if (requestedRed && actualRed < requestedRed) continue; From 905e40abb4e257f718147bb9c22a8d19dde29a46 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 19 Mar 2019 17:53:43 +0100 Subject: [PATCH 040/154] QDialog: be more specific on how to replace deprecated functions QDialog::setOrientation/setExtension() was marked as deprecated without a suggestion on how to replace those functions. Therefore add a suggestion (taken from the documentation) now. Change-Id: I13b2af2264064ca1c7c034cf6b920caaadcee113 Reviewed-by: Edward Welbourne Reviewed-by: Shawn Rutledge Reviewed-by: Richard Moe Gustavsen --- src/widgets/dialogs/qdialog.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h index ce57ce5de7..ce2194a1de 100644 --- a/src/widgets/dialogs/qdialog.h +++ b/src/widgets/dialogs/qdialog.h @@ -70,10 +70,10 @@ public: void setVisible(bool visible) override; #if QT_DEPRECATED_SINCE(5, 13) - QT_DEPRECATED void setOrientation(Qt::Orientation orientation); - QT_DEPRECATED Qt::Orientation orientation() const; - QT_DEPRECATED void setExtension(QWidget* extension); - QT_DEPRECATED QWidget* extension() const; + QT_DEPRECATED_X("Use show/hide on the affected widget instead") void setOrientation(Qt::Orientation orientation); + QT_DEPRECATED_X("Use show/hide on the affected widget instead") Qt::Orientation orientation() const; + QT_DEPRECATED_X("Use show/hide on the affected widget instead") void setExtension(QWidget* extension); + QT_DEPRECATED_X("Use show/hide on the affected widget instead") QWidget* extension() const; #endif QSize sizeHint() const override; @@ -98,7 +98,7 @@ public Q_SLOTS: virtual void reject(); #if QT_DEPRECATED_SINCE(5, 13) - QT_DEPRECATED void showExtension(bool); + QT_DEPRECATED_X("Use show/hide on the affected widget instead") void showExtension(bool); #endif protected: From 1d5f9fcc8a14e4826943a913fe22e819a0837b80 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 19 Mar 2019 17:22:45 +0100 Subject: [PATCH 041/154] Handle quotes in .prl files Do remove quotes around libraries before trying to parse them. This patch is a follow-up to eda28621f6c1a68774719f, and fixes an issue on Windows where e.g. Qt5AxServer.prl contains entries like "-lole32" Fixes: QTBUG-73475 Change-Id: I3d1353de618328a0d44bacd4dbd6aba8fc66b1b7 Reviewed-by: Kyle Edwards Reviewed-by: Joerg Bornemann --- mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index d6773d6e98..b643e5edf9 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -62,6 +62,7 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura set(_search_paths) string(REPLACE \"\\$\\$[QT_INSTALL_LIBS]\" \"${_qt5_install_libs}\" _static_depends \"${_static_depends}\") foreach(_flag ${_static_depends}) + string(REPLACE \"\\\"\" \"\" _flag ${_flag}) if(_flag MATCHES \"^-l(.*)$\") # Handle normal libraries passed as -lfoo set(_lib \"${CMAKE_MATCH_1}\") From 58a87609a6c963416e2483e57e6f2a80552ec945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Thu, 21 Mar 2019 15:11:48 +0200 Subject: [PATCH 042/154] Extend blacklisting of tst_gestures from RHEL 7.4 to 7.6 Task-number: QTBUG-52523 Change-Id: I726a17e30b47781c1a5385e6220cce88c5a6fe2d Reviewed-by: Liang Qi --- tests/auto/other/gestures/BLACKLIST | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST index 269bac5750..c465ff316e 100644 --- a/tests/auto/other/gestures/BLACKLIST +++ b/tests/auto/other/gestures/BLACKLIST @@ -1,5 +1,6 @@ [] rhel-7.4 +rhel-7.6 ubuntu-18.04 [customGesture] # QTBUG-67254 From e8a990c67467d60d4b95a94c1b763284e331adcf Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Mon, 11 Mar 2019 11:22:02 +0100 Subject: [PATCH 043/154] Fix aliased font rendering in native xcb mode Freetype creates 1bpp bitmaps in msb order, while XRender expects lsb order. Change-Id: If8dd8e07c424df2d135f56f1ce105ef94963f536 Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../platforms/xcb/nativepainting/qpaintengine_x11.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp index d43b273f4d..6ddcec0256 100644 --- a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp +++ b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp @@ -2645,6 +2645,13 @@ bool QXRenderGlyphCache::addGlyphs(const QTextItemInt &ti, if (glyph == 0 || glyph->format != glyphFormat()) return false; + if (glyph->format == QFontEngine::Format_Mono) { + // Must convert bitmap from msb to lsb bit order + QImage img(glyph->data, glyph->width, glyph->height, QImage::Format_Mono); + img = img.convertToFormat(QImage::Format_MonoLSB); + memcpy(glyph->data, img.constBits(), static_cast(img.sizeInBytes())); + } + set->setGlyph(glyphs[i], spp, glyph); Q_ASSERT(glyph->data || glyph->width == 0 || glyph->height == 0); From c45f2eab8553a40d7185ed95b4ab3e45e95c8d70 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Mar 2019 15:35:10 +0100 Subject: [PATCH 044/154] Silence the item model tests Introduce a logging category for the qDebug()-output. Add a meta type registration for QList, fixing numerous warnings like: WARN : tst_QItemModel::remove(QStandardItemModel:invalid start, valid count 5) QSignalSpy: Unable to handle parameter 'parents' of type 'QList' of method 'layoutChanged', use qRegisterMetaType to register it. Fix a Clang warning about potential misuse of operator , Task-number: QTBUG-73864 Change-Id: I60998403a44f5df8767926951ee13d1ed1e93c37 Reviewed-by: David Faure --- .../qidentityproxymodel/tst_qidentityproxymodel.cpp | 5 ++++- tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp | 3 ++- .../tst_qsortfilterproxymodel.cpp | 6 ++++-- .../tst_qsortfilterproxymodel.h | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index 262c6dd9c8..c76052a38b 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -32,10 +32,13 @@ #include #include #include +#include #include "dynamictreemodel.h" #include "qidentityproxymodel.h" +Q_LOGGING_CATEGORY(lcItemModels, "qt.corelib.tests.itemmodels") + class DataChangedModel : public QAbstractListModel { public: @@ -390,7 +393,7 @@ void dump(QAbstractItemModel* model, QString const& indent = " - ", QModelIndex for (auto row = 0; row < model->rowCount(parent); ++row) { auto idx = model->index(row, 0, parent); - qDebug() << (indent + idx.data().toString()); + qCDebug(lcItemModels) << (indent + idx.data().toString()); dump(model, indent + "- ", idx); } } diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index 7cd220e684..af52852b99 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -125,6 +125,7 @@ private: tst_QItemModel::tst_QItemModel() { qRegisterMetaType(); + qRegisterMetaType>(); } void tst_QItemModel::init() @@ -181,7 +182,7 @@ void tst_QItemModel::nonDestructiveBasicTest() currentModel->hasChildren(QModelIndex()); currentModel->hasIndex(0, 0); currentModel->headerData(0, Qt::Horizontal); - currentModel->index(0,0), QModelIndex(); + currentModel->index(0,0); currentModel->itemData(QModelIndex()); QVariant cache; currentModel->match(QModelIndex(), -1, cache); diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp index 82cd26971b..50e87f21ac 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp @@ -38,6 +38,8 @@ #include +Q_LOGGING_CATEGORY(lcItemModels, "qt.corelib.tests.itemmodels") + // Testing get/set functions void tst_QSortFilterProxyModel::getSetCheck() { @@ -4277,7 +4279,7 @@ public: QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override { // QTBUG-44962: Would we always expect the parent to belong to the model - qDebug() << parent.model() << this; + qCDebug(lcItemModels) << parent.model() << this; Q_ASSERT(!parent.isValid() || parent.model() == this); quintptr parentId = (parent.isValid()) ? parent.internalId() : 0; @@ -4363,7 +4365,7 @@ void tst_QSortFilterProxyModel::sourceLayoutChangeLeavesValidPersistentIndexes() // The use of qDebug here makes sufficient use of the heap to // cause corruption at runtime with normal use on linux (before // the fix). valgrind confirms the fix. - qDebug() << persistentIndex.parent(); + qCDebug(lcItemModels) << persistentIndex.parent(); QVERIFY(persistentIndex.parent().isValid()); } diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h index 82d4b7344e..d598a60932 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h @@ -186,4 +186,6 @@ private: Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint) +Q_DECLARE_LOGGING_CATEGORY(lcItemModels) + #endif // TST_QSORTFILTERPROXYMODEL_H From a1c37462eebddf4ad7bc3192f1f3e9a3f7292b19 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Mar 2019 11:24:48 +0100 Subject: [PATCH 045/154] Windows: Fix tooltip flicker on GL surfaces QPlatformWindow::initialGeometry() would assign a default height to the initial geometry of the QRollEffectClassWindow since it has height of 0. This causes the obtained geometry to not match and subsequently a geometry change being sent synchronously. Introduce a new flag QWindowPrivate::resizeAutomatic similar to the existing QWindowPrivate::positionAutomatic to prevent assigning a default size and pass through the geometry as is where required. Fixes: QTBUG-74176 Change-Id: I70c66490838a2c4dfe200ec86094d28bd984dd03 Reviewed-by: Kati Kankaanpaa Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qplatformwindow.cpp | 7 ++++--- src/gui/kernel/qwindow_p.h | 4 ++++ src/plugins/platforms/windows/qwindowswindow.cpp | 3 ++- src/widgets/kernel/qwidget.cpp | 7 ++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 50f05721f7..24cfd32ace 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -708,10 +708,11 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, const QScreen *screen = effectiveScreen(w); if (!screen) return initialGeometry; + const auto *wp = qt_window_private(const_cast(w)); QRect rect(QHighDpi::fromNativePixels(initialGeometry, w)); - rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight)); - if (qt_window_private(const_cast(w))->positionAutomatic - && w->type() != Qt::Popup) { + if (wp->resizeAutomatic) + rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight)); + if (wp->positionAutomatic && w->type() != Qt::Popup) { const QRect availableGeometry = screen->availableGeometry(); // Center unless the geometry ( + unknown window frame) is too large for the screen). if (rect.height() < (availableGeometry.height() * 8) / 9 diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index bf5e645114..af1233a9e2 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -90,6 +90,7 @@ public: , receivedExpose(false) , positionPolicy(WindowFrameExclusive) , positionAutomatic(true) + , resizeAutomatic(true) , contentOrientation(Qt::PrimaryOrientation) , opacity(qreal(1.0)) , minimumSize(0, 0) @@ -155,6 +156,8 @@ public: virtual void processSafeAreaMarginsChanged() {}; bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; } + void setAutomaticPositionAndResizeEnabled(bool a) + { positionAutomatic = resizeAutomatic = a; } static QWindowPrivate *get(QWindow *window) { return window->d_func(); } @@ -178,6 +181,7 @@ public: bool receivedExpose; PositionPolicy positionPolicy; bool positionAutomatic; + bool resizeAutomatic; Qt::ScreenOrientation contentOrientation; qreal opacity; QRegion mask; diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 2abd1eef8b..0376e363f3 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1132,7 +1132,8 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, // TODO: No concept of WA_wasMoved yet that would indicate a // CW_USEDEFAULT unless set. For now, assume that 0,0 means 'default' // for toplevels. - if (geometry.isValid()) { + if (geometry.isValid() + || !qt_window_private(const_cast(w))->resizeAutomatic) { frameX = geometry.x(); frameY = geometry.y(); const QMargins effectiveMargins = margins + customMargins; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 332eee9c03..2c84ff7161 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1543,14 +1543,19 @@ void QWidgetPrivate::createTLSysExtra() extra->topextra->window->setMaximumSize(QSize(extra->maxw, extra->maxh)); if (extra->topextra->opacity != 255 && q->isWindow()) extra->topextra->window->setOpacity(qreal(extra->topextra->opacity) / qreal(255)); + + const bool isTipLabel = q->inherits("QTipLabel"); + const bool isAlphaWidget = !isTipLabel && q->inherits("QAlphaWidget"); #ifdef Q_OS_WIN // Pass on native parent handle for Widget embedded into Active X. const QVariant activeXNativeParentHandle = q->property(activeXNativeParentHandleProperty); if (activeXNativeParentHandle.isValid()) extra->topextra->window->setProperty(activeXNativeParentHandleProperty, activeXNativeParentHandle); - if (q->inherits("QTipLabel") || q->inherits("QAlphaWidget")) + if (isTipLabel || isAlphaWidget) extra->topextra->window->setProperty("_q_windowsDropShadow", QVariant(true)); #endif + if (isTipLabel || isAlphaWidget || q->inherits("QRollEffect")) + qt_window_private(extra->topextra->window)->setAutomaticPositionAndResizeEnabled(false); } } From 4daf5204babc62a7ae58b6de5c09c527f81ea27c Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 20 Mar 2019 15:45:02 +0100 Subject: [PATCH 046/154] Cocoa: Clear the shortcut used when hiding a native menu entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shortcut needs to be cleared if the native menu entry is being hidden due to the fact it was changed. Otherwise it will not show the shortcut anymore as it sees it as in-use. Change-Id: Ifb10db855766e4de71db06ea006f6d63497f3193 Fixes: QTBUG-74113 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenu.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 7b96fca3f9..f34988721d 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -250,6 +250,9 @@ void QCocoaMenu::syncMenuItem_helper(QPlatformMenuItem *menuItem, bool menubarUp if (wasMerged) { oldItem.enabled = NO; oldItem.hidden = YES; + oldItem.keyEquivalent = @""; + oldItem.keyEquivalentModifierMask = NSEventModifierFlagCommand; + } else { [m_nativeMenu removeItem:oldItem]; } From 7148dfc67ff20c1c625d203aa47b574b3aaa5db1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 18 Mar 2019 07:46:15 -0700 Subject: [PATCH 047/154] Accept that glibc's statx() falls back for us So we don't need to have a high kernel requirement on its account. I needed to introduce a configure-time check because we need to include a header to get the __GLIBC__ macro, but we can't include any header in assembler until we know it's glibc (we need to know that the header is assembler-safe). glibc, uClibc and MUSL do provide an assembler-safe features.h, but Bionic does not. And we need to know that it's glibc's implementation, since the fallback was not required. The other three libraries may not implement such a thing when they get around to adding the system call. Fixes: QTBUG-74526 Change-Id: I1004b4b819774c4c9296fffd158d14da98bf571c Reviewed-by: Fabian Vogt Reviewed-by: Simon Hausmann --- src/corelib/configure.json | 16 ++++++++++++++++ src/corelib/global/minimum-linux_p.h | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/corelib/configure.json b/src/corelib/configure.json index a22a7459bd..5f5a00a64f 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -374,6 +374,16 @@ ] } }, + "glibc": { + "label": "GNU libc", + "type": "compile", + "test": { + "include": "stdlib.h", + "main": [ + "return __GLIBC__;" + ] + } + }, "inotify": { "label": "inotify", "type": "compile", @@ -593,6 +603,12 @@ "condition": "libs.glib", "output": [ "privateFeature", "feature" ] }, + "glibc": { + "label": "GNU libc", + "autoDetect": "config.linux", + "condition": "tests.glibc", + "output": [ "privateFeature" ] + }, "iconv": { "label": "iconv", "purpose": "Provides internationalization on Unix.", diff --git a/src/corelib/global/minimum-linux_p.h b/src/corelib/global/minimum-linux_p.h index 9c074e13ba..5112015663 100644 --- a/src/corelib/global/minimum-linux_p.h +++ b/src/corelib/global/minimum-linux_p.h @@ -78,7 +78,11 @@ QT_BEGIN_NAMESPACE * - statx 4.11 QT_CONFIG(statx) */ -#if QT_CONFIG(statx) +#if QT_CONFIG(statx) && !QT_CONFIG(glibc) +// if using glibc, the statx() function in sysdeps/unix/sysv/linux/statx.c +// falls back to stat() for us. +// (Using QT_CONFIG(glibc) instead of __GLIBC__ because the macros aren't +// defined in assembler mode) # define MINLINUX_MAJOR 4 # define MINLINUX_MINOR 11 # define MINLINUX_PATCH 0 From 66fc17eb5c40568032ece0621c1ba0ffbf230b78 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 14 Mar 2019 20:21:20 -0700 Subject: [PATCH 048/154] Examples: properly parse more than one element in maps and lists Change-Id: I46363e5b8944459e8c48fffd158c03bca4b7394e Reviewed-by: Edward Welbourne Reviewed-by: Ulf Hermann --- examples/corelib/serialization/convert/xmlconverter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/corelib/serialization/convert/xmlconverter.cpp b/examples/corelib/serialization/convert/xmlconverter.cpp index 62908273ce..e62801bf76 100644 --- a/examples/corelib/serialization/convert/xmlconverter.cpp +++ b/examples/corelib/serialization/convert/xmlconverter.cpp @@ -70,7 +70,7 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options static QVariantList listFromXml(QXmlStreamReader &xml, Converter::Options options) { QVariantList list; - while (!xml.atEnd() && !xml.isEndElement()) { + while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == QLatin1String("list"))) { xml.readNext(); switch (xml.tokenType()) { case QXmlStreamReader::StartElement: @@ -107,7 +107,7 @@ static QVariantList listFromXml(QXmlStreamReader &xml, Converter::Options option static VariantOrderedMap::value_type mapEntryFromXml(QXmlStreamReader &xml, Converter::Options options) { QVariant key, value; - while (!xml.atEnd() && !xml.isEndElement()) { + while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == QLatin1String("entry"))) { xml.readNext(); switch (xml.tokenType()) { case QXmlStreamReader::StartElement: @@ -150,7 +150,7 @@ static QVariant mapFromXml(QXmlStreamReader &xml, Converter::Options options) QVariantMap map1; VariantOrderedMap map2; - while (!xml.atEnd() && !xml.isEndElement()) { + while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == QLatin1String("map"))) { xml.readNext(); switch (xml.tokenType()) { case QXmlStreamReader::StartElement: From 4d77c37522b51861037f0ec3ee9d4d13951672ff Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 18 Mar 2019 16:21:26 +0100 Subject: [PATCH 049/154] QMacStyle - make focus ring less transparent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit But only for the 'Light' theme. For "Dark" the system color fits well (without our rather strange and random 0.5 we set for some reason). Change-Id: Ic5c8372913515611a567090f82852ffc7ca14eb7 Fixes: QTBUG-74095 Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 13ef98b840..979f70ece5 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1227,11 +1227,17 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRectF &targetRect, int Q_UNREACHABLE(); } - const auto focusRingColor = qt_mac_toQColor(NSColor.keyboardFocusIndicatorColor.CGColor); + auto focusRingColor = qt_mac_toQColor(NSColor.keyboardFocusIndicatorColor.CGColor); + if (!qt_mac_applicationIsInDarkMode()) { + // This color already has alpha ~ 0.25, this value is too small - the ring is + // very pale and nothing like the native one. 0.39 makes it better (not ideal + // anyway). The color seems to be correct in dark more without any modification. + focusRingColor.setAlphaF(0.39); + } p->save(); p->setRenderHint(QPainter::Antialiasing); - p->setOpacity(0.5); + if (cw.type == SegmentedControl_First) { // TODO Flip left-right } From 7c14233ec6539828cb0545188e47f726d0056094 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Thu, 21 Mar 2019 09:07:57 +0200 Subject: [PATCH 050/154] Bump version Change-Id: I26f71350c0dee57bc6c765ece411700144100f42 Reviewed-by: Jani Heikkinen --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 6c2b67442a..124e265eb4 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ CONFIG += warning_clean QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) -MODULE_VERSION = 5.12.2 +MODULE_VERSION = 5.12.3 From 0211774c6803b6d530ab2b804ab310f733567dfe Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 Mar 2019 11:49:55 +0100 Subject: [PATCH 051/154] Silence QMainWindow test Set object names on the widgets in restoreState(), fixing: QWARN : tst_QMainWindow::restoreState() QMainWindow::saveState(): 'objectName' not set for QDockWidget 0x7ffcb45e5e00 '; QWARN : tst_QMainWindow::restoreState() QMainWindow::saveState(): 'objectName' not set for QToolBar 0x7ffcb45e5dd0 '' QWARN : tst_QMainWindow::restoreState() QMainWindow::saveState(): 'objectName' not set for QDockWidget 0x7ffcb45e5e00 '; QWARN : tst_QMainWindow::restoreState() QMainWindow::saveState(): 'objectName' not set for QToolBar 0x7ffcb45e5dd0 '' Task-number: QTBUG-74242 Change-Id: I19f19e93de9df00d001b820a31836ce0b3cd2877 Reviewed-by: Richard Moe Gustavsen --- tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 1acf07301c..ea96322654 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -1343,8 +1343,10 @@ void tst_QMainWindow::restoreState() { QMainWindow mw; QToolBar tb(&mw); + tb.setObjectName(QLatin1String("toolBar")); mw.addToolBar(Qt::TopToolBarArea, &tb); QDockWidget dw(&mw); + dw.setObjectName(QLatin1String("dock")); mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); QByteArray state; From 1119cd4ece6555be82212b273d05d581bffb79d1 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 21 Mar 2019 16:10:09 +0100 Subject: [PATCH 052/154] Correct a misguided assertion in QTzTimeZonePrivate Without ICU, the TZ-DB backend for time-zones tripped over an assertion when running tst_QTimeZone::stressTest(), which happened to probe a zone between its last transition and the first transition of a POSIX rule that followed it. The code assumed there was no interval between these two; apparently, there can be. Change-Id: I3d0ad41fec0a255db2f9bfac54d33aa9b83938e8 Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_tz.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index bed62a02bd..fa4ec031fa 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -1022,8 +1022,10 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecs [beforeMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { return at.atMSecsSinceEpoch < beforeMSecsSinceEpoch; }); - Q_ASSERT(it > posixTrans.cbegin()); - return *--it; + if (it > posixTrans.cbegin()) + return *--it; + // else: it fell between the last transition and the first of the POSIX rule. + return dataForTzTransition(m_tranTimes.last()); } // Otherwise if we can find a valid tran then use its rule From 03fadc26e7617aece89949bc7d0acf50f6f050a9 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 21 Mar 2019 15:07:48 +0100 Subject: [PATCH 053/154] Fix broken data for time-zones with no transitions While an invalid time-zone shall have no transitions, so may various constant zones, like UTC. The TZ data may include only the POSIX rule for such a zone, in which case we should use it, even if there are no transitions. Broke out a piece of repeated code as a common method, in the process, since I was complicating it further. Added test for the case that revealed this; and made sure we see a warning if any of the checkOffset() tests gets skipped because its zone is unsupported. Fixes: QTBUG-74614 Change-Id: Ic8e039a2a9b3f4e0f567585682a94f4b494b558d Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_p.h | 1 + src/corelib/tools/qtimezoneprivate_tz.cpp | 46 +++++++++---------- .../corelib/tools/qtimezone/tst_qtimezone.cpp | 4 ++ 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h index c9a5726216..24a9a00f11 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/tools/qtimezoneprivate_p.h @@ -331,6 +331,7 @@ public: private: void init(const QByteArray &ianaId); + QVector getPosixTransitions(qint64 msNear) const; Data dataForTzTransition(QTzTransitionTime tran) const; QVector m_tranTimes; diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index fa4ec031fa..f75a61977d 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -943,19 +943,21 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::dataForTzTransition(QTzTransitionTime return data; } +QVector QTzTimeZonePrivate::getPosixTransitions(qint64 msNear) const +{ + const int year = QDateTime::fromMSecsSinceEpoch(msNear, Qt::UTC).date().year(); + // The Data::atMSecsSinceEpoch of the single entry if zone is constant: + qint64 atTime = m_tranTimes.isEmpty() ? msNear : m_tranTimes.last().atMSecsSinceEpoch; + return calculatePosixTransitions(m_posixRule, year - 1, year + 1, atTime); +} + QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const { - // If we have no rules (so probably an invalid tz), return invalid data: - if (!m_tranTimes.size()) - return invalidData(); - - // If the required time is after the last transition and we have a POSIX rule then use it - if (m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch + // If the required time is after the last transition (or there were none) + // and we have a POSIX rule then use it: + if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch) && !m_posixRule.isEmpty() && forMSecsSinceEpoch >= 0) { - const int year = QDateTime::fromMSecsSinceEpoch(forMSecsSinceEpoch, Qt::UTC).date().year(); - QVector posixTrans = - calculatePosixTransitions(m_posixRule, year - 1, year + 1, - m_tranTimes.last().atMSecsSinceEpoch); + QVector posixTrans = getPosixTransitions(forMSecsSinceEpoch); auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(), [forMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { return at.atMSecsSinceEpoch <= forMSecsSinceEpoch; @@ -986,13 +988,11 @@ bool QTzTimeZonePrivate::hasTransitions() const QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSinceEpoch) const { - // If the required time is after the last transition and we have a POSIX rule then use it - if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch + // If the required time is after the last transition (or there were none) + // and we have a POSIX rule then use it: + if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch) && !m_posixRule.isEmpty() && afterMSecsSinceEpoch >= 0) { - const int year = QDateTime::fromMSecsSinceEpoch(afterMSecsSinceEpoch, Qt::UTC).date().year(); - QVector posixTrans = - calculatePosixTransitions(m_posixRule, year - 1, year + 1, - m_tranTimes.last().atMSecsSinceEpoch); + QVector posixTrans = getPosixTransitions(afterMSecsSinceEpoch); auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(), [afterMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { return at.atMSecsSinceEpoch <= afterMSecsSinceEpoch; @@ -1011,21 +1011,19 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSince QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const { - // If the required time is after the last transition and we have a POSIX rule then use it - if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch + // If the required time is after the last transition (or there were none) + // and we have a POSIX rule then use it: + if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch) && !m_posixRule.isEmpty() && beforeMSecsSinceEpoch > 0) { - const int year = QDateTime::fromMSecsSinceEpoch(beforeMSecsSinceEpoch, Qt::UTC).date().year(); - QVector posixTrans = - calculatePosixTransitions(m_posixRule, year - 1, year + 1, - m_tranTimes.last().atMSecsSinceEpoch); + QVector posixTrans = getPosixTransitions(beforeMSecsSinceEpoch); auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(), [beforeMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { return at.atMSecsSinceEpoch < beforeMSecsSinceEpoch; }); if (it > posixTrans.cbegin()) return *--it; - // else: it fell between the last transition and the first of the POSIX rule. - return dataForTzTransition(m_tranTimes.last()); + // It fell between the last transition (if any) and the first of the POSIX rule: + return m_tranTimes.isEmpty() ? invalidData() : dataForTzTransition(m_tranTimes.last()); } // Otherwise if we can find a valid tran then use its rule diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index a25fd39693..eff9835776 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -539,6 +539,8 @@ void tst_QTimeZone::checkOffset_data() int year, month, day, hour, min, sec; int std, dst; } table[] = { + // Zone with no transitions (QTBUG-74614, when TZ backend uses minimalist data) + { "Etc/UTC", "epoch", 1970, 1, 1, 0, 0, 0, 0, 0 }, // Kiev: regression test for QTBUG-64122 (on MS): { "Europe/Kiev", "summer", 2017, 10, 27, 12, 0, 0, 2 * 3600, 3600 }, { "Europe/Kiev", "winter", 2017, 10, 29, 12, 0, 0, 2 * 3600, 0 } @@ -551,6 +553,8 @@ void tst_QTimeZone::checkOffset_data() << QDateTime(QDate(entry.year, entry.month, entry.day), QTime(entry.hour, entry.min, entry.sec), zone) << entry.dst + entry.std << entry.std << entry.dst; + } else { + qWarning("Skipping %s@%s test as zone is invalid", entry.zone, entry.nick); } } } From b01248ebbd42dd05d45fa655852169978beec40e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Mar 2019 11:32:53 +0100 Subject: [PATCH 054/154] Fix tree recursion in QAbstractItemModel::match() Recurse down the sibling at column 0 of the index instead down the index. Change-Id: Ie78d8b28eab7438ca3f83ee0df177115ca82806e Fixes: QTBUG-73864 Reviewed-by: David Faure --- src/corelib/itemmodels/qabstractitemmodel.cpp | 14 ++++--- .../tst_qsortfilterproxymodel.cpp | 39 +++++++++++++++++++ .../tst_qsortfilterproxymodel.h | 1 + 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index e816add91d..83dcf68314 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -2360,6 +2360,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, bool wrap = flags & Qt::MatchWrap; bool allHits = (hits == -1); QString text; // only convert to a string if it is needed + const int column = start.column(); QModelIndex p = parent(start); int from = start.row(); int to = rowCount(p); @@ -2367,7 +2368,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, // iterates twice if wrapping for (int i = 0; (wrap && i < 2) || (!wrap && i < 1); ++i) { for (int r = from; (r < to) && (allHits || result.count() < hits); ++r) { - QModelIndex idx = index(r, start.column(), p); + QModelIndex idx = index(r, column, p); if (!idx.isValid()) continue; QVariant v = data(idx, role); @@ -2406,10 +2407,13 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, result.append(idx); } } - if (recurse && hasChildren(idx)) { // search the hierarchy - result += match(index(0, idx.column(), idx), role, - (text.isEmpty() ? value : text), - (allHits ? -1 : hits - result.count()), flags); + if (recurse) { + const auto parent = column != 0 ? idx.sibling(idx.row(), 0) : idx; + if (hasChildren(parent)) { // search the hierarchy + result += match(index(0, column, parent), role, + (text.isEmpty() ? value : text), + (allHits ? -1 : hits - result.count()), flags); + } } } // prepare for the next iteration diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp index 50e87f21ac..ccce5a44e5 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp @@ -2363,6 +2363,45 @@ void tst_QSortFilterProxyModel::match() QCOMPARE(indexes.at(i).row(), expectedProxyItems.at(i)); } +QList createStandardItemList(const QString &prefix, int n) +{ + QList result; + for (int i = 0; i < n; ++i) + result.append(new QStandardItem(prefix + QString::number(i))); + return result; +} + +// QTBUG-73864, recursive search in a tree model. + +void tst_QSortFilterProxyModel::matchTree() +{ + QStandardItemModel model(0, 2); + // Header00 Header01 + // Header10 Header11 + // Item00 Item01 + // Item10 Item11 + model.appendRow(createStandardItemList(QLatin1String("Header0"), 2)); + auto headerRow = createStandardItemList(QLatin1String("Header1"), 2); + model.appendRow(headerRow); + headerRow.first()->appendRow(createStandardItemList(QLatin1String("Item0"), 2)); + headerRow.first()->appendRow(createStandardItemList(QLatin1String("Item1"), 2)); + + auto item11 = model.match(model.index(1, 1), Qt::DisplayRole, QLatin1String("Item11"), 20, + Qt::MatchRecursive).value(0); + QVERIFY(item11.isValid()); + QCOMPARE(item11.data().toString(), QLatin1String("Item11")); + + // Repeat in proxy model + QSortFilterProxyModel proxy; + proxy.setSourceModel(&model); + auto proxyItem11 = proxy.match(proxy.index(1, 1), Qt::DisplayRole, QLatin1String("Item11"), 20, + Qt::MatchRecursive).value(0); + QVERIFY(proxyItem11.isValid()); + QCOMPARE(proxyItem11.data().toString(), QLatin1String("Item11")); + + QCOMPARE(proxy.mapToSource(proxyItem11).internalId(), item11.internalId()); +} + void tst_QSortFilterProxyModel::insertIntoChildrenlessItem() { QStandardItemModel model; diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h index d598a60932..8ae97165b8 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h @@ -109,6 +109,7 @@ private slots: void selectionFilteredOut(); void match_data(); void match(); + void matchTree(); void insertIntoChildrenlessItem(); void invalidateMappedChildren(); void insertRowIntoFilteredParent(); From 85a9009f258e130a7bd4aaaa252724ea5fb58e79 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 15 Mar 2019 11:01:31 +0100 Subject: [PATCH 055/154] QPixmap: More safe failing if qApp is not a QGuiApplication It can happen that QDataStream is fed a QVariant that contains a QPixmap representation, that will make the application crash when trying to restore it This is specially important for cases in which applications expose dbus interfaces with QVariantMaps Change-Id: Ife4feaef30f30e7e27d88464bd6b2a247f743123 Reported-by: Fabian Vogt Reviewed-by: Fabian Vogt Reviewed-by: Mitch Curtis Reviewed-by: Thiago Macieira --- src/gui/image/qpixmap.cpp | 15 ++++ .../qdatastream_core_pixmap.pro | 4 ++ .../tst_qdatastream_core_pixmap.cpp | 68 +++++++++++++++++++ .../corelib/serialization/serialization.pro | 1 + 4 files changed, 88 insertions(+) create mode 100644 tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro create mode 100644 tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index ea6697cc39..7e862e9826 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1543,6 +1543,11 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) if (image.isNull()) return QPixmap(); + if (Q_UNLIKELY(!qobject_cast(QCoreApplication::instance()))) { + qWarning("QPixmap::fromImage: QPixmap cannot be created without a QGuiApplication"); + return QPixmap(); + } + QScopedPointer data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); data->fromImage(image, flags); return QPixmap(data.take()); @@ -1565,6 +1570,11 @@ QPixmap QPixmap::fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags) if (image.isNull()) return QPixmap(); + if (Q_UNLIKELY(!qobject_cast(QCoreApplication::instance()))) { + qWarning("QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication"); + return QPixmap(); + } + QScopedPointer data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); data->fromImageInPlace(image, flags); return QPixmap(data.take()); @@ -1584,6 +1594,11 @@ QPixmap QPixmap::fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags) */ QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) { + if (Q_UNLIKELY(!qobject_cast(QCoreApplication::instance()))) { + qWarning("QPixmap::fromImageReader: QPixmap cannot be created without a QGuiApplication"); + return QPixmap(); + } + QScopedPointer data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); data->fromImageReader(imageReader, flags); return QPixmap(data.take()); diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro b/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro new file mode 100644 index 0000000000..7e003304af --- /dev/null +++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro @@ -0,0 +1,4 @@ +CONFIG += testcase +TARGET = tst_qdatastream_core_pixmap +QT += testlib +SOURCES = tst_qdatastream_core_pixmap.cpp diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp new file mode 100644 index 0000000000..c931016a61 --- /dev/null +++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +class tst_QDataStream : public QObject +{ +Q_OBJECT + +private slots: + void stream_with_pixmap(); + +}; + +void tst_QDataStream::stream_with_pixmap() +{ + // This is a QVariantMap with a 3x3 red QPixmap and two strings inside + const QByteArray ba = QByteArray::fromBase64("AAAAAwAAAAIAegAAAAoAAAAACgB0AGgAZQByAGUAAAACAHAAAABBAAAAAAGJUE5HDQoaCgAAAA1JSERSAAAAAwAAAAMIAgAAANlKIugAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAQSURBVAiZY/zPAAVMDJgsAB1bAQXZn5ieAAAAAElFTkSuQmCCAAAAAgBhAAAACgAAAAAKAGgAZQBsAGwAbw=="); + QImage dummy; // Needed to make sure qtGui is loaded + + QTest::ignoreMessage(QtWarningMsg, "QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication"); + + QVariantMap map; + QDataStream d(ba); + d.setVersion(QDataStream::Qt_5_12); + d >> map; + + QCOMPARE(map["a"].toString(), QString("hello")); + QCOMPARE(map["p"].value(), QPixmap()); // the pixmap is null because this is not a QGuiApplication + QCOMPARE(map["z"].toString(), QString("there")); +} + +QTEST_GUILESS_MAIN(tst_QDataStream) + +#include "tst_qdatastream_core_pixmap.moc" + diff --git a/tests/auto/corelib/serialization/serialization.pro b/tests/auto/corelib/serialization/serialization.pro index 9187de1bc5..9638178cdc 100644 --- a/tests/auto/corelib/serialization/serialization.pro +++ b/tests/auto/corelib/serialization/serialization.pro @@ -6,6 +6,7 @@ SUBDIRS = \ qcborvalue \ qcborvalue_json \ qdatastream \ + qdatastream_core_pixmap \ qtextstream \ qxmlstream From 9e61cec7915ca177e88bd685a3229f153ee7ab7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 19 Mar 2019 15:49:55 +0100 Subject: [PATCH 056/154] Network cache: Stop treating no-cache like no-store In the QNetworkAccessManager machinery we would treat "no-cache" as if it meant "don't cache" while in reality it means "don't return these cached elements without making sure they're up-to-date" At the same time as this change is made let's add test data for "no-store", which replaces the "no-cache" test data. Fixes: QTBUG-71896 Change-Id: Ieda98f3982884ccc839cac2420c777968c786f6e Reviewed-by: Timur Pocheptsov Reviewed-by: Mikhail Svetkin --- src/network/access/qabstractnetworkcache.cpp | 4 +-- .../access/qnetworkaccesscachebackend.cpp | 17 ++++++----- src/network/access/qnetworkreplyhttpimpl.cpp | 14 ++------- .../tst_qabstractnetworkcache.cpp | 9 ++++-- .../qnetworkreply/tst_qnetworkreply.cpp | 29 ++++++++++++++++++- 5 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/network/access/qabstractnetworkcache.cpp b/src/network/access/qabstractnetworkcache.cpp index 2b670b2cce..9afb99f23f 100644 --- a/src/network/access/qabstractnetworkcache.cpp +++ b/src/network/access/qabstractnetworkcache.cpp @@ -191,8 +191,8 @@ bool QNetworkCacheMetaData::isValid() const Some cache implementations can keep these cache items in memory for performance reasons, but for security reasons they should not be written to disk. - Specifically with http, documents marked with Pragma: no-cache, or have a Cache-control set to - no-store or no-cache or any https document that doesn't have "Cache-control: public" set will + Specifically with http, documents with Cache-control set to no-store or any + https document that doesn't have "Cache-control: public" set will set the saveToDisk to false. \sa setSaveToDisk() diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp index 0c9a88596d..22fdc5bb0b 100644 --- a/src/network/access/qnetworkaccesscachebackend.cpp +++ b/src/network/access/qnetworkaccesscachebackend.cpp @@ -87,15 +87,16 @@ bool QNetworkAccessCacheBackend::sendCacheContents() setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute)); // set the raw headers - QNetworkCacheMetaData::RawHeaderList rawHeaders = item.rawHeaders(); - QNetworkCacheMetaData::RawHeaderList::ConstIterator it = rawHeaders.constBegin(), - end = rawHeaders.constEnd(); - for ( ; it != end; ++it) { - if (it->first.toLower() == "cache-control" && - it->second.toLower().contains("must-revalidate")) { - return false; + const QNetworkCacheMetaData::RawHeaderList rawHeaders = item.rawHeaders(); + for (const auto &header : rawHeaders) { + if (header.first.toLower() == "cache-control") { + const QByteArray cacheControlValue = header.second.toLower(); + if (cacheControlValue.contains("must-revalidate") + || cacheControlValue.contains("no-cache")) { + return false; + } } - setRawHeader(it->first, it->second); + setRawHeader(header.first, header.second); } // handle a possible redirect diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index d4d3a21a7a..2d7649fa61 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -524,6 +524,8 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h QHash cacheControl = parseHttpOptionHeader(it->second); if (cacheControl.contains("must-revalidate")) return false; + if (cacheControl.contains("no-cache")) + return false; } QDateTime currentDateTime = QDateTime::currentDateTimeUtc(); @@ -1730,18 +1732,8 @@ QNetworkCacheMetaData QNetworkReplyHttpImplPrivate::fetchCacheMetaData(const QNe if (httpRequest.operation() == QHttpNetworkRequest::Get) { canDiskCache = true; - // 14.32 - // HTTP/1.1 caches SHOULD treat "Pragma: no-cache" as if the client - // had sent "Cache-Control: no-cache". - it = cacheHeaders.findRawHeader("pragma"); - if (it != cacheHeaders.rawHeaders.constEnd() - && it->second == "no-cache") - canDiskCache = false; - // HTTP/1.1. Check the Cache-Control header - if (cacheControl.contains("no-cache")) - canDiskCache = false; - else if (cacheControl.contains("no-store")) + if (cacheControl.contains("no-store")) canDiskCache = false; // responses to POST might be cacheable diff --git a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index 0da42b8b87..b8d9adf7a1 100644 --- a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -251,9 +251,14 @@ void tst_QAbstractNetworkCache::cacheControl_data() QTest::newRow("200-1") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol-expire.cgi" << false; QTest::newRow("200-2") << QNetworkRequest::AlwaysNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << AlwaysFalse; - QTest::newRow("200-3") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << false; + QTest::newRow("200-3") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << true; QTest::newRow("200-4") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?no-cache" << false; - QTest::newRow("200-5") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?no-cache" << false; + QTest::newRow("200-5") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?no-cache" << true; + + QTest::newRow("200-6") << QNetworkRequest::AlwaysNetwork << "httpcachetest_cachecontrol.cgi?no-store" << AlwaysFalse; + QTest::newRow("200-7") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?no-store" << false; + QTest::newRow("200-8") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?no-store" << false; + QTest::newRow("200-9") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?no-store" << false; QTest::newRow("304-0") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?max-age=1000" << true; diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 30b41da515..3876621983 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -3959,7 +3959,7 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data() "HTTP/1.0 200\r\n" "Connection: keep-alive\r\n" "Content-Type: text/plain\r\n" - "Cache-control: no-cache\r\n" + "Cache-control: no-store\r\n" "Content-length: 8\r\n" "\r\n" "Reloaded"; @@ -3985,6 +3985,33 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data() content.second = "Not-reloaded"; content.first.setLastModified(past); + // "no-cache" + rawHeaders.clear(); + rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1()) + << QNetworkCacheMetaData::RawHeader("Cache-control", "no-cache"); + content.first.setRawHeaders(rawHeaders); + content.first.setLastModified(past); + content.first.setExpirationDate(future); + + // "no-cache" does not mean "no cache", just that we must consult remote first + QTest::newRow("no-cache,200,always-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << QStringList() << false << true; + QTest::newRow("no-cache,200,prefer-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << false << true; + QTest::newRow("no-cache,200,prefer-cache") + << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << false << true; + // We're not allowed by the spec to deliver cached data without checking if it is still + // up-to-date. + QTest::newRow("no-cache,200,always-cache") + << reply200 << QString() << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false; + + QTest::newRow("no-cache,304,prefer-network") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << true << true; + QTest::newRow("no-cache,304,prefer-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << true; + QTest::newRow("no-cache,304,always-cache") + << reply304 << QString() << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false; + // // Set to expired // From 2f97a050bc43a7cdbee3219b7cfc4d703ef0a37e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Mar 2019 14:31:07 +0100 Subject: [PATCH 057/154] Add explanatory comment to QWindowPrivate::resizeAutomatic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amends a1c37462eebddf4ad7bc3192f1f3e9a3f7292b19. Task-number: QTBUG-74176 Change-Id: I24fa3e5d88e53e7efb8923fb4c55615a4f90abea Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qwindow_p.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index af1233a9e2..5103d97c6d 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -181,6 +181,10 @@ public: bool receivedExpose; PositionPolicy positionPolicy; bool positionAutomatic; + // resizeAutomatic suppresses resizing by QPlatformWindow::initialGeometry(). + // It also indicates that width/height=0 is acceptable (for example, for + // the QRollEffect widget) and is thus not cleared in setGeometry(). + // An alternative approach might be using -1,-1 as a default size. bool resizeAutomatic; Qt::ScreenOrientation contentOrientation; qreal opacity; From 7a64ffb7738dc975b5008800901c8cd8ab238a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 21 Mar 2019 12:01:51 +0100 Subject: [PATCH 058/154] Remove deprecated screen maintenance functions in QPlatformIntegration The logic for removing QScreens from QGuiApplicationPrivate has been moved into the QScreen destructor, similar to QWindow. Change-Id: I18ad57d8dcf9f765c47be7c082bf075af3ebe69c Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/gui/kernel/qplatformintegration.cpp | 38 ----------------------- src/gui/kernel/qplatformintegration.h | 10 ------ src/gui/kernel/qplatformscreen.cpp | 4 --- src/gui/kernel/qscreen.cpp | 20 +++++++----- src/gui/kernel/qwindowsysteminterface.cpp | 5 --- 5 files changed, 13 insertions(+), 64 deletions(-) diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 6ae6e4a528..490cfc6178 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -462,44 +462,6 @@ QList QPlatformIntegration::possibleKeys(const QKeyEvent *) const return QList(); } -/*! - \deprecated Use QWindowSystemInterface::handleScreenAdded instead. -*/ -void QPlatformIntegration::screenAdded(QPlatformScreen *ps, bool isPrimary) -{ - QWindowSystemInterface::handleScreenAdded(ps, isPrimary); -} - -/*! - \deprecated Use QWindowSystemInterface::handleScreenRemoved instead. -*/ -void QPlatformIntegration::removeScreen(QScreen *screen) -{ - const bool wasPrimary = (!QGuiApplicationPrivate::screen_list.isEmpty() && QGuiApplicationPrivate::screen_list.at(0) == screen); - QGuiApplicationPrivate::screen_list.removeOne(screen); - - QGuiApplicationPrivate::resetCachedDevicePixelRatio(); - - if (wasPrimary && qGuiApp && !QGuiApplicationPrivate::screen_list.isEmpty()) - emit qGuiApp->primaryScreenChanged(QGuiApplicationPrivate::screen_list.at(0)); -} - -/*! - \deprecated Use QWindowSystemInterface::handleScreenRemoved instead. -*/ -void QPlatformIntegration::destroyScreen(QPlatformScreen *platformScreen) -{ - QWindowSystemInterface::handleScreenRemoved(platformScreen); -} - -/*! - \deprecated Use QWindowSystemInterface::handlePrimaryScreenChanged instead. -*/ -void QPlatformIntegration::setPrimaryScreen(QPlatformScreen *newPrimary) -{ - QWindowSystemInterface::handlePrimaryScreenChanged(newPrimary); -} - QStringList QPlatformIntegration::themeNames() const { return QStringList(); diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 6950bbaf72..389b35dbc0 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -192,10 +192,6 @@ public: #endif virtual void setApplicationIcon(const QIcon &icon) const; -#if QT_DEPRECATED_SINCE(5, 12) - QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenRemoved") void removeScreen(QScreen *screen); -#endif - virtual void beep() const; #if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC) @@ -204,12 +200,6 @@ public: protected: QPlatformIntegration() = default; - -#if QT_DEPRECATED_SINCE(5, 12) - QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenAdded") void screenAdded(QPlatformScreen *screen, bool isPrimary = false); - QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenRemoved") void destroyScreen(QPlatformScreen *screen); - QT_DEPRECATED_X("Use QWindowSystemInterface::handlePrimaryScreenChanged") void setPrimaryScreen(QPlatformScreen *newPrimary); -#endif }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 21ae75ba8f..9c5876550a 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -62,10 +62,6 @@ QPlatformScreen::~QPlatformScreen() Q_D(QPlatformScreen); if (d->screen) { qWarning("Manually deleting a QPlatformScreen. Call QWindowSystemInterface::handleScreenRemoved instead."); -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - QGuiApplicationPrivate::platformIntegration()->removeScreen(d->screen); -QT_WARNING_POP delete d->screen; } } diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index f208eb02be..952023dd1b 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -106,9 +106,18 @@ void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen) */ QScreen::~QScreen() { - if (!qApp) + // Remove screen + const bool wasPrimary = QGuiApplication::primaryScreen() == this; + QGuiApplicationPrivate::screen_list.removeOne(this); + QGuiApplicationPrivate::resetCachedDevicePixelRatio(); + + if (!qGuiApp) return; + QScreen *newPrimaryScreen = QGuiApplication::primaryScreen(); + if (wasPrimary && newPrimaryScreen) + emit qGuiApp->primaryScreenChanged(newPrimaryScreen); + // Allow clients to manage windows that are affected by the screen going // away, before we fall back to moving them to the primary screen. emit qApp->screenRemoved(this); @@ -116,11 +125,8 @@ QScreen::~QScreen() if (QGuiApplication::closingDown()) return; - QScreen *primaryScreen = QGuiApplication::primaryScreen(); - if (this == primaryScreen) - return; - - bool movingFromVirtualSibling = primaryScreen && primaryScreen->handle()->virtualSiblings().contains(handle()); + bool movingFromVirtualSibling = newPrimaryScreen + && newPrimaryScreen->handle()->virtualSiblings().contains(handle()); // Move any leftover windows to the primary screen const auto allWindows = QGuiApplication::allWindows(); @@ -129,7 +135,7 @@ QScreen::~QScreen() continue; const bool wasVisible = window->isVisible(); - window->setScreen(primaryScreen); + window->setScreen(newPrimaryScreen); // Re-show window if moved from a virtual sibling screen. Otherwise // leave it up to the application developer to show the window. diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index ec6911b334..759671fbd7 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -818,11 +818,6 @@ void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrima */ void QWindowSystemInterface::handleScreenRemoved(QPlatformScreen *platformScreen) { -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - QGuiApplicationPrivate::platformIntegration()->removeScreen(platformScreen->screen()); -QT_WARNING_POP - // Important to keep this order since the QSceen doesn't own the platform screen delete platformScreen->screen(); delete platformScreen; From 9732ecc321daab06026f4496a6724d6bdbc0941a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Mar 2019 10:35:22 +0100 Subject: [PATCH 059/154] Manual dialog test: Fix deprecation warnings filedialogpanel.cpp:441:55: warning: 'bool QFileDialog::confirmOverwrite() const' is deprecated: Use !testOption(DontConfirmOverwrite) instead [-Wdeprecated-declarations] filedialogpanel.cpp:443:53: warning: 'bool QFileDialog::resolveSymlinks() const' is deprecated: Use !testOption(DontResolveSymlinks) instead [-Wdeprecated-declarations] printdialogpanel.cpp:708:62: warning: 'const QRect QDesktopWidget::availableGeometry(int) const' is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations] Change-Id: I087615b7e62b5fc11ec1063590fe55b2615f95fd Reviewed-by: Christian Ehrlicher --- tests/manual/dialogs/filedialogpanel.cpp | 4 ++-- tests/manual/dialogs/printdialogpanel.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp index e628dd2265..800baae45e 100644 --- a/tests/manual/dialogs/filedialogpanel.cpp +++ b/tests/manual/dialogs/filedialogpanel.cpp @@ -438,9 +438,9 @@ void FileDialogPanel::restoreDefaults() setComboBoxValue(m_viewMode, d.viewMode()); m_showDirsOnly->setChecked(d.testOption(QFileDialog::ShowDirsOnly)); m_allowedSchemes->setText(QString()); - m_confirmOverWrite->setChecked(d.confirmOverwrite()); + m_confirmOverWrite->setChecked(!d.testOption(QFileDialog::DontConfirmOverwrite)); m_nameFilterDetailsVisible->setChecked(!d.testOption(QFileDialog::HideNameFilterDetails)); - m_resolveSymLinks->setChecked(d.resolveSymlinks()); + m_resolveSymLinks->setChecked(!d.testOption(QFileDialog::DontResolveSymlinks)); m_readOnly->setChecked(d.isReadOnly()); m_native->setChecked(true); m_customDirIcons->setChecked(d.testOption(QFileDialog::DontUseCustomDirectoryIcons)); diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp index d999dbc30c..8d64d2f6a6 100644 --- a/tests/manual/dialogs/printdialogpanel.cpp +++ b/tests/manual/dialogs/printdialogpanel.cpp @@ -55,6 +55,10 @@ #include #include +#if QT_VERSION >= 0x050000 +# include +#endif + const FlagData printerModeComboData[] = { {"ScreenResolution", QPrinter::ScreenResolution}, @@ -705,7 +709,13 @@ void PrintDialogPanel::showPreviewDialog() { applySettings(m_printer.data()); PrintPreviewDialog dialog(m_printer.data(), this); - dialog.resize(QApplication::desktop()->availableGeometry().size() * 4/ 5); +#if QT_VERSION >= 0x050000 + const int screenNumber = QApplication::desktop()->screenNumber(this); + const QSize availableSize = QGuiApplication::screens().at(screenNumber)->availableSize(); +#else + const QSize availableSize = QApplication::desktop()->availableGeometry().size(); +#endif + dialog.resize(availableSize * 4/ 5); if (dialog.exec() == QDialog::Accepted) retrieveSettings(m_printer.data()); } From d8323376670fdc65e4a4a654def8b78b650bdbe7 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 13 Mar 2019 10:34:46 +0100 Subject: [PATCH 060/154] Fix detection of QMAKE_DEFAULT{INC|LIB}DIRS for gcc cross-builds The --sysroot flag is added to QMAKE_CXXFLAGS by the gcc-sysroot feature. However, when the makespec is reloaded, it can overwrite QMAKE_CXXFLAGS. Save QMAKE_CXXFLAGS before re-loading the mkspec and add it to the value from the makespec, like we do for CONFIG. Fixes: QTBUG-74326 Change-Id: Ie1fb713e2ffc9641d6db8c682bc5175581cd5b5f Reviewed-by: Oswald Buddenhagen Reviewed-by: Kai Koehne --- configure.pri | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.pri b/configure.pri index 629ca78ff1..131aa868c2 100644 --- a/configure.pri +++ b/configure.pri @@ -448,7 +448,9 @@ defineTest(reloadSpec) { $$[QT_HOST_DATA/src]/mkspecs/features/mac/toolchain.prf \ $$[QT_HOST_DATA/src]/mkspecs/features/toolchain.prf - _SAVED_CONFIG = $$CONFIG + saved_variables = CONFIG QMAKE_CXXFLAGS + for (name, saved_variables): \ + _SAVED_$$name = $$eval($$name) load(spec_pre) # qdevice.pri gets written too late (and we can't write it early # enough, as it's populated in stages, with later ones depending @@ -457,7 +459,8 @@ defineTest(reloadSpec) { eval($$l) include($$QMAKESPEC/qmake.conf) load(spec_post) - CONFIG += $$_SAVED_CONFIG + for (name, saved_variables): \ + $$name += $$eval(_SAVED_$$name) load(default_pre) # ensure pristine environment for configuration. again. From be6c70ed7f9a5fed98d44f9993492ab9d2fc16df Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 19 Mar 2019 13:34:52 +0100 Subject: [PATCH 061/154] macOS: Don't scale advances to 0 when stretch is AnyStretch If the stretch is set to AnyStretch, then this is taken to mean we should accept the font as it is. But on mac, there is a special code path to scale the advances since the shaper doesn't do it for us, and this neglected to check the stretch, thus it would scale the advances by 0%. This happened when loading a file directly in QRawFont and using this in a QTextLayout, since no part of the code path will attempt to calculate the stretch in that case. Reproducible in q3dsviewer in Qt 3D Runtime 2.3. Task-number: QT3DS-3132 Change-Id: I8f934f3fac41bf7a93c01cca0416d44003119907 Reviewed-by: Lars Knoll Reviewed-by: Konstantin Ritt Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qtextengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index a83ef95c79..22c93d7ec2 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1754,7 +1754,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, #ifdef Q_OS_DARWIN if (actualFontEngine->type() == QFontEngine::Mac) { - if (actualFontEngine->fontDef.stretch != 100) { + if (actualFontEngine->fontDef.stretch != 100 && actualFontEngine->fontDef.stretch != QFont::AnyStretch) { QFixed stretch = QFixed(int(actualFontEngine->fontDef.stretch)) / QFixed(100); for (uint i = 0; i < num_glyphs; ++i) g.advances[i] *= stretch; From ad67b5b3414bc9991610a55113372dc34e8b3bee Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Tue, 19 Mar 2019 08:27:24 +0100 Subject: [PATCH 062/154] doc: Remove incomplete information for QDataStream This document is bound to run out of sync with reality. Actually there are changes from Qt4.x missing. The streaming operators of the classes contain many if-then-else cases, making it difficult to represented in a plain text. With only a partial definition of the protocol, this document is useless to users, because they should not care how the actual protocol is implemented. Fixes: QTBUG-73386 Change-Id: I7fc4066ef8186d54dfd48445452c1a6d8bf371c3 Reviewed-by: Leena Miettinen Reviewed-by: Joerg Bornemann --- src/corelib/doc/src/datastreamformat.qdoc | 402 ++++------------------ 1 file changed, 58 insertions(+), 344 deletions(-) diff --git a/src/corelib/doc/src/datastreamformat.qdoc b/src/corelib/doc/src/datastreamformat.qdoc index 73ca51974d..d6b60f10ce 100644 --- a/src/corelib/doc/src/datastreamformat.qdoc +++ b/src/corelib/doc/src/datastreamformat.qdoc @@ -28,357 +28,71 @@ /*! \page datastreamformat.html \title Serializing Qt Data Types - \brief Representations of data types that can be serialized by QDataStream. + \brief List of data types that can be serialized by QDataStream. - The \l QDataStream allows you to serialize some of the Qt data types. - The table below lists the data types that QDataStream can serialize - and how they are represented. The format described below is - \l{QDataStream::setVersion()}{version 13}. + The \l QDataStream class allows you to serialize the Qt data types + listed in this section as of \l{QDataStream::setVersion()}{version 18}. It is always best to cast integers to a Qt integer type, such as - qint16 or quint32, when reading and writing. This ensures that + \l{qint16} or \l{quint32}, when reading and writing. This ensures that you always know exactly what size integers you are reading and writing, no matter what the underlying platform and architecture the application happens to be running on. - \table - \row \li bool - \li \list - \li boolean - \endlist - \row \li qint8 - \li \list - \li signed byte - \endlist - \row \li qint16 - \li \list - \li signed 16-bit integer - \endlist - \row \li qint32 - \li \list - \li signed 32-bit integer - \endlist - \row \li qint64 - \li \list - \li signed 64-bit integer - \endlist - \row \li quint8 - \li \list - \li unsigned byte - \endlist - \row \li quint16 - \li \list - \li unsigned 16-bit integer - \endlist - \row \li quint32 - \li \list - \li unsigned 32-bit integer - \endlist - \row \li quint64 - \li \list - \li unsigned 64-bit integer - \endlist - \row \li \c float - \li \list - \li 32-bit floating point number using the standard IEEE 754 format - \endlist - \row \li \c double - \li \list - \li 64-bit floating point number using the standard IEEE 754 format - \endlist - \row \li \c {const char *} - \li \list - \li The string length (quint32) - \li The string bytes, excluding the terminating 0 - \endlist - \row \li QBitArray - \li \list - \li The array size (quint32) - \li The array bits, i.e. (size + 7)/8 bytes - \endlist - \row \li QBrush - \li \list - \li The brush style (quint8) - \li The brush color (QColor) - \li If style is CustomPattern, the brush pixmap (QPixmap) - \endlist - \row \li QByteArray - \li \list - \li If the byte array is null: 0xFFFFFFFF (quint32) - \li Otherwise: the array size (quint32) followed by the array bytes, i.e. size bytes - \endlist - \row \li \l QColor - \li \list - \li Color spec (qint8) - \li Alpha value (quint16) - \li Red value (quint16) - \li Green value (quint16) - \li Blue value (quint16) - \li Pad value (quint16) - \endlist - \row \li QCursor - \li \list - \li Shape ID (qint16) - \li If shape is BitmapCursor: The bitmap (QPixmap), mask (QPixmap), and hot spot (QPoint) - \endlist - \row \li QDate - \li \list - \li Julian day (quint32) - \endlist - \row \li QDateTime - \li \list - \li Date (QDate) - \li Time (QTime) - \li The \l{Qt::TimeSpec}{time spec} - offsetFromUtc (qint32) if Qt::TimeSpec is offsetFromUtc - TimeZone(QTimeZone) if Qt::TimeSpec is TimeZone - \endlist - \row \li QEasingCurve - \li \list - \li type (quint8) - \li func (quint64) - \li hasConfig (bool) - \li If hasConfig is true then these fields follow: - \li list - \li period (double) - \li amplitude (double) - \li overshoot (double) - \endlist - \row \li QFont - \li \list - \li The family (QString) - \li The style name (QString) - \li The point size (double) - \li The pixel size (qint32) - \li The style hint (quint8) - \li The style strategy (quint16) - \li The char set (quint8) - \li The weight (quint8) - \li The font bits (quint8) - \li The font stretch (quint16) - \li The extended font bits (quint8) - \li The letter spacing (double) - \li The word spacing (double) - \li The hinting preference (quint8) - \endlist - \row \li QHash - \li \list - \li The number of items (quint32) - \li For all items, the key (Key) and value (T) - \endlist - \row \li QIcon - \li \list - \li The number of pixmap entries (quint32) - \li For all pixmap entries: - \list - \li The pixmap (QPixmap) - \li The file name (QString) - \li The pixmap size (QSize) - \li The \l{QIcon::Mode}{mode} (quint32) - \li The \l{QIcon::State}{state} (quint32) - \endlist - \endlist - \row \li QImage - \li \list - \li If the image is null a "null image" marker is saved; - otherwise the image is saved in PNG or BMP format (depending - on the stream version). If you want control of the format, - stream the image into a QBuffer (using QImageIOHandler/QImageIOPlugin) and stream - that. - \endlist - \row \li QKeySequence - \li \list - \li A QList, where each integer is a key in the key sequence - \endlist - \row \li QLinkedList - \li \list - \li The number of items (quint32) - \li The items (T) - \endlist - \row \li QList - \li \list - \li The number of items (quint32) - \li The items (T) - \endlist - \row \li QMap - \li \list - \li The number of items (quint32) - \li For all items, the key (Key) and value (T) - \endlist - \row \li QMargins - \li \list - \li left (int) - \li top (int) - \li right (int) - \li bottom (int) - \endlist - \row \li QMatrix - \li \list - \li m11 (double) - \li m12 (double) - \li m21 (double) - \li m22 (double) - \li dx (double) - \li dy (double) - \endlist - \row \li QMatrix4x4 - \li \list - \li m11 (float) - \li m12 (float) - \li m13 (float) - \li m14 (float) - \li m21 (float) - \li m22 (float) - \li m23 (float) - \li m24 (float) - \li m31 (float) - \li m32 (float) - \li m33 (float) - \li m34 (float) - \li m41 (float) - \li m42 (float) - \li m43 (float) - \li m44 (float) - \endlist - \row \li QPair - \li \list - \li first (T1) - \li second (T2) - \endlist - \row \li QPalette - \li The disabled, active, and inactive color groups, each of which consists - of the following: - \list - \li foreground (QBrush) - \li button (QBrush) - \li light (QBrush) - \li midlight (QBrush) - \li dark (QBrush) - \li mid (QBrush) - \li text (QBrush) - \li brightText (QBrush) - \li buttonText (QBrush) - \li base (QBrush) - \li background (QBrush) - \li shadow (QBrush) - \li highlight (QBrush) - \li highlightedText (QBrush) - \li link (QBrush) - \li linkVisited (QBrush) - \endlist - \row \li QPen - \li \list - \li The pen styles (quint8) - \li The pen width (quint16) - \li The pen color (QColor) - \endlist - \row \li QPicture - \li \list - \li The size of the picture data (quint32) - \li The raw bytes of picture data (char) - \endlist - \row \li QPixmap - \li \list - \li Save it as a PNG image. - \endlist - \row \li QPoint - \li \list - \li The x coordinate (qint32) - \li The y coordinate (qint32) - \endlist - \row \li QQuaternion - \li \list - \li The scalar component (float) - \li The x coordinate (float) - \li The y coordinate (float) - \li The z coordinate (float) - \endlist - \row \li QRect - \li \list - \li left (qint32) - \li top (qint32) - \li right (qint32) - \li bottom (qint32) - \endlist - \row \li QRegExp - \li \list - \li The regexp pattern (QString) - \li Case sensitivity (quint8) - \li Regular expression syntax (quint8) - \li Minimal matching (quint8) - \endlist - \row \li QRegularExpression - \li \list - \li The regular expression pattern (QString) - \li The pattern options (quint32) - \endlist - \row \li QRegion - \li \list - \li The size of the data, i.e. 8 + 16 * (number of rectangles) (quint32) - \li 10 (qint32) - \li The number of rectangles (quint32) - \li The rectangles in sequential order (QRect) - \endlist - \row \li QSize - \li \list - \li width (qint32) - \li height (qint32) - \endlist - \row \li QString - \li \list - \li If the string is null: 0xFFFFFFFF (quint32) - \li Otherwise: The string length in bytes (quint32) followed by the data in UTF-16 - \endlist - \row \li QTime - \li \list - \li Milliseconds since midnight (quint32) - \endlist - \row \li QTransform - \li \list - \li m11 (double) - \li m12 (double) - \li m13 (double) - \li m21 (double) - \li m22 (double) - \li m23 (double) - \li m31 (double) - \li m32 (double) - \li m33 (double) - \endlist - \row \li QUrl - \li \list - \li Holds an URL (QString) - \endlist - \row \li QVariant - \li \list - \li The type of the data (quint32) - \li The null flag (qint8) - \li The data of the specified type - \endlist - \row \li QVector2D - \li \list - \li the x coordinate (float) - \li the y coordinate (float) - \endlist - \row \li QVector3D - \li \list - \li the x coordinate (float) - \li the y coordinate (float) - \li the z coordinate (float) - \endlist - \row \li QVector4D - \li \list - \li the x coordinate (float) - \li the y coordinate (float) - \li the z coordinate (float) - \li the w coordinate (float) - \endlist - \row \li QVector - \li \list - \li The number of items (quint32) - \li The items (T) - \endlist - \endtable + \list + \li bool + \li \l{qint8} + \li \l{qint16} + \li \l{qint32} + \li \l{qint64} + \li \l{quint8} + \li \l{quint16} + \li \l{quint32} + \li \l{quint64} + \li \c float + \li \c double + \li \c {const char *} + \li QBitArray + \li QBrush + \li QByteArray + \li QColor + \li QCursor + \li QDate + \li QDateTime + \li QEasingCurve + \li QFont + \li QGenericMatrix + \li QHash + \li QIcon + \li QImage + \li QKeySequence + \li QLinkedList + \li QList + \li QMap + \li QMargins + \li QMatrix4x4 + \li QPair + \li QPalette + \li QPen + \li QPicture + \li QPixmap + \li QPoint + \li QQuaternion + \li QRect + \li QRegExp + \li QRegularExpression + \li QRegion + \li QSize + \li QString + \li QTime + \li QTransform + \li QUrl + \li QVariant + \li QVector2D + \li QVector3D + \li QVector4D + \li QVector + \endlist \sa {JSON Support in Qt} */ From 86fc0b0e88c3a798be292cf3979f0e05b105feeb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 Mar 2019 09:48:03 +0100 Subject: [PATCH 063/154] QDockWidgetPrivate: Use member initialization Task-number: QTBUG-74242 Change-Id: I9f243bf37c7685e38a4a961c1173d45925b1b0e3 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qdockwidget_p.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index 14d73e815f..03d7efce98 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -81,28 +81,21 @@ class QDockWidgetPrivate : public QWidgetPrivate }; public: - inline QDockWidgetPrivate() - : QWidgetPrivate(), state(0), - features(QDockWidget::DockWidgetClosable - | QDockWidget::DockWidgetMovable - | QDockWidget::DockWidgetFloatable), - allowedAreas(Qt::AllDockWidgetAreas), resizer(0) - { } - void init(); void _q_toggleView(bool); // private slot void _q_toggleTopLevel(); // private slot void updateButtons(); - DragState *state; + DragState *state = nullptr; - QDockWidget::DockWidgetFeatures features; - Qt::DockWidgetAreas allowedAreas; + QDockWidget::DockWidgetFeatures features = QDockWidget::DockWidgetClosable + | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable; + Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas; QFont font; #ifndef QT_NO_ACTION - QAction *toggleViewAction; + QAction *toggleViewAction = nullptr; #endif // QMainWindow *findMainWindow(QWidget *widget) const; @@ -129,7 +122,7 @@ public: bool isAnimating() const; private: - QWidgetResizeHandler *resizer; + QWidgetResizeHandler *resizer = nullptr; }; class Q_WIDGETS_EXPORT QDockWidgetLayout : public QLayout From 0590da532e3349715b0f35eca930ce3ff5588115 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 Mar 2019 10:29:13 +0100 Subject: [PATCH 064/154] QDockWidget: Store tab position when undocking Add a field remembering the tab position of the dock widget area to QDockWidgetPrivate and use that when grouping floating docks. Fixes: QTBUG-74242 Change-Id: I2a453080cb39dd4a5491976f1aeca70ae681682a Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qdockwidget.cpp | 28 +++++++++++++++-------- src/widgets/widgets/qdockwidget_p.h | 9 ++++++++ src/widgets/widgets/qmainwindowlayout.cpp | 27 +++++++++++++++++++++- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index ba8bd90da6..4041c730b8 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -67,18 +67,21 @@ extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); / // qmainwindow.cpp extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); -static inline QMainWindowLayout *qt_mainwindow_layout_from_dock(const QDockWidget *dock) +static const QMainWindow *mainwindow_from_dock(const QDockWidget *dock) { - const QWidget *p = dock->parentWidget(); - while (p) { - const QMainWindow *window = qobject_cast(p); - if (window) - return qt_mainwindow_layout(window); - p = p->parentWidget(); + for (const QWidget *p = dock->parentWidget(); p; p = p->parentWidget()) { + if (const QMainWindow *window = qobject_cast(p)) + return window; } return nullptr; } +static inline QMainWindowLayout *qt_mainwindow_layout_from_dock(const QDockWidget *dock) +{ + auto mainWindow = mainwindow_from_dock(dock); + return mainWindow ? qt_mainwindow_layout(mainWindow) : nullptr; +} + static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) { return (priv->features & feature) == feature; } @@ -839,8 +842,9 @@ void QDockWidgetPrivate::endDrag(bool abort) q->releaseMouse(); if (state->dragging) { - QMainWindowLayout *mwLayout = qt_mainwindow_layout_from_dock(q); - Q_ASSERT(mwLayout != 0); + const QMainWindow *mainWindow = mainwindow_from_dock(q); + Q_ASSERT(mainWindow != nullptr); + QMainWindowLayout *mwLayout = qt_mainwindow_layout(mainWindow); if (abort || !mwLayout->plug(state->widgetItem)) { if (hasFeature(this, QDockWidget::DockWidgetFloatable)) { @@ -861,8 +865,12 @@ void QDockWidgetPrivate::endDrag(bool abort) } else { setResizerActive(false); } - if (q->isFloating()) // Might not be floating when dragging a QDockWidgetGroupWindow + if (q->isFloating()) { // Might not be floating when dragging a QDockWidgetGroupWindow undockedGeometry = q->geometry(); +#if QT_CONFIG(tabwidget) + tabPosition = mwLayout->tabPosition(mainWindow->dockWidgetArea(q)); +#endif + } q->activateWindow(); } else { // The tab was not plugged back in the QMainWindow but the QDockWidget cannot diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index 03d7efce98..e224ba7143 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -57,6 +57,10 @@ #include "QtWidgets/qboxlayout.h" #include "QtWidgets/qdockwidget.h" +#if QT_CONFIG(tabwidget) +# include "QtWidgets/qtabwidget.h" +#endif + QT_REQUIRE_CONFIG(dockwidget); QT_BEGIN_NAMESPACE @@ -86,6 +90,11 @@ public: void _q_toggleTopLevel(); // private slot void updateButtons(); + +#if QT_CONFIG(tabwidget) + QTabWidget::TabPosition tabPosition = QTabWidget::North; +#endif + DragState *state = nullptr; QDockWidget::DockWidgetFeatures features = QDockWidget::DockWidgetClosable diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index ed054c7e9a..f54835f23b 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2525,6 +2525,30 @@ void QMainWindowLayout::updateGapIndicator() #endif // QT_CONFIG(rubberband) } +static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w) +{ + QTabBar::Shape result = QTabBar::RoundedSouth; +#if QT_CONFIG(tabwidget) + if (qobject_cast(w)) { + switch (static_cast(qt_widget_private(w))->tabPosition) { + case QTabWidget::North: + result = QTabBar::RoundedNorth; + break; + case QTabWidget::South: + result = QTabBar::RoundedSouth; + break; + case QTabWidget::West: + result = QTabBar::RoundedWest; + break; + case QTabWidget::East: + result = QTabBar::RoundedEast; + break; + } + } +#endif // tabwidget + return result; +} + void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) { if (!parentWidget()->isVisible() || parentWidget()->isMinimized() @@ -2573,8 +2597,9 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow(); // FIXME floatingTabs->setGeometry(dropTo->geometry()); QDockAreaLayoutInfo *info = floatingTabs->layoutInfo(); + const QTabBar::Shape shape = tabwidgetPositionToTabBarShape(dropTo); *info = QDockAreaLayoutInfo(&layoutState.dockAreaLayout.sep, QInternal::LeftDock, - Qt::Horizontal, QTabBar::RoundedSouth, + Qt::Horizontal, shape, static_cast(parentWidget())); info->tabbed = true; QLayout *parentLayout = dropTo->parentWidget()->layout(); From 4d11fc1d223f0f51c1d42ec52e54a836968d86fb Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 25 Mar 2019 12:20:08 +0100 Subject: [PATCH 065/154] qxkbcommon: use QMAKE_USE instead of QMAKE_USE_PRIVATE ... because API from qxkbcommon_p.h includes xkbcommon headers. When we use "QT += xkbcommon_support-private" in *.pro files, we should not explicitly require "QMAKE_USE += xkbcommon" in those projects. Change-Id: I21049034ce93bee13a1107723f26498c221f8ea4 Reviewed-by: Joerg Bornemann --- src/platformsupport/input/xkbcommon/xkbcommon.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/input/xkbcommon/xkbcommon.pro b/src/platformsupport/input/xkbcommon/xkbcommon.pro index 2f5d132b5c..22b16ae44a 100644 --- a/src/platformsupport/input/xkbcommon/xkbcommon.pro +++ b/src/platformsupport/input/xkbcommon/xkbcommon.pro @@ -7,7 +7,7 @@ CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII PRECOMPILED_HEADER = ../../../corelib/global/qt_pch.h -QMAKE_USE_PRIVATE += xkbcommon +QMAKE_USE += xkbcommon HEADERS += \ qxkbcommon_p.h From 9b6222598c990512c78bd42f55d7d6dc635c8b48 Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Mon, 25 Mar 2019 17:09:28 +0900 Subject: [PATCH 066/154] Calculate Qt::Key from keysym for IBus ForwardKeyEvent signal QKeyEvent instance requires Qt::Key but currently X11 keysym is assigned and the IBus QT module forwards the wrong key events. Now QXkbCommon::keysymToQtKey() can generate Qt::Key from keysym and forward the correct key events. Change-Id: I25f0a9e9319b4a5f42847f8592ad3a30f6c9349d Reviewed-by: Gatis Paeglis --- src/plugins/platforminputcontexts/ibus/ibus.pro | 2 +- .../ibus/qibusplatforminputcontext.cpp | 14 ++++++++++---- .../platforminputcontexts.pro | 11 ++++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforminputcontexts/ibus/ibus.pro b/src/plugins/platforminputcontexts/ibus/ibus.pro index 52836bb8b6..9ba2297e38 100644 --- a/src/plugins/platforminputcontexts/ibus/ibus.pro +++ b/src/plugins/platforminputcontexts/ibus/ibus.pro @@ -1,6 +1,6 @@ TARGET = ibusplatforminputcontextplugin -QT += dbus gui-private +QT += dbus gui-private xkbcommon_support-private SOURCES += $$PWD/qibusplatforminputcontext.cpp \ $$PWD/qibusproxy.cpp \ $$PWD/qibusproxyportal.cpp \ diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index 7e66439ea7..f2429f24ff 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -51,6 +51,8 @@ #include +#include + #include "qibusproxy.h" #include "qibusproxyportal.h" #include "qibusinputcontextproxy.h" @@ -335,14 +337,12 @@ void QIBusPlatformInputContext::forwardKeyEvent(uint keyval, uint keycode, uint if (!input) return; - if (debug) - qDebug() << "forwardKeyEvent" << keyval << keycode << state; - QEvent::Type type = QEvent::KeyPress; if (state & IBUS_RELEASE_MASK) type = QEvent::KeyRelease; state &= ~IBUS_RELEASE_MASK; + keycode += 8; Qt::KeyboardModifiers modifiers = Qt::NoModifier; if (state & IBUS_SHIFT_MASK) @@ -354,7 +354,13 @@ void QIBusPlatformInputContext::forwardKeyEvent(uint keyval, uint keycode, uint if (state & IBUS_META_MASK) modifiers |= Qt::MetaModifier; - QKeyEvent event(type, keyval, modifiers, QString(keyval)); + int qtcode = QXkbCommon::keysymToQtKey(keyval, modifiers); + QString text = QXkbCommon::lookupStringNoKeysymTransformations(keyval); + + if (debug) + qDebug() << "forwardKeyEvent" << keyval << keycode << state << modifiers << qtcode << text; + + QKeyEvent event(type, qtcode, modifiers, keycode, keyval, state, text); QCoreApplication::sendEvent(input, &event); } diff --git a/src/plugins/platforminputcontexts/platforminputcontexts.pro b/src/plugins/platforminputcontexts/platforminputcontexts.pro index 68f6792377..56a39a49e7 100644 --- a/src/plugins/platforminputcontexts/platforminputcontexts.pro +++ b/src/plugins/platforminputcontexts/platforminputcontexts.pro @@ -1,10 +1,11 @@ TEMPLATE = subdirs QT_FOR_CONFIG += gui-private -qtHaveModule(dbus) { -!mac:!win32:SUBDIRS += ibus +qtConfig(xkbcommon) { + SUBDIRS += compose + + qtHaveModule(dbus) { + !macos:!win32:SUBDIRS += ibus + } } -qtConfig(xkbcommon): SUBDIRS += compose - - From aec284dfc9179088e34fcb7e4bc9cbce71cb68db Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 25 Mar 2019 10:17:21 +0100 Subject: [PATCH 067/154] Doc: mention what is the suggested replacement for QSignalMapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0f230c8b59eae4b2b63a73b8223ed99545be44ec Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qsignalmapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qsignalmapper.cpp b/src/corelib/kernel/qsignalmapper.cpp index d56965281e..02a1281f92 100644 --- a/src/corelib/kernel/qsignalmapper.cpp +++ b/src/corelib/kernel/qsignalmapper.cpp @@ -61,7 +61,7 @@ public: /*! \class QSignalMapper \inmodule QtCore - \obsolete + \obsolete The recommended solution is connecting the signal to a lambda. \brief The QSignalMapper class bundles signals from identifiable senders. \ingroup objectmodel From efb74002c5da514eac31e0c11cefcdc02518db66 Mon Sep 17 00:00:00 2001 From: Yan Shapochnik Date: Thu, 21 Mar 2019 15:17:44 -0400 Subject: [PATCH 068/154] macOS: Use the correct text color for QPalette::ButtonText color role MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the text color displayed in the QToolBar on macOS Mojave dark mode Change-Id: Ic4415295e314a8fc1c4fbb58964386e0563b8d44 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoasystemsettings.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm index aef2c6cf48..9b6dc94d33 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm @@ -158,10 +158,13 @@ QHash qt_mac_createRolePalettes() pal.setColor(QPalette::Inactive, QPalette::WindowText, qc); pal.setColor(QPalette::Active, QPalette::HighlightedText, qc); pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Active, QPalette::ButtonText, qc); + pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc); qc = qt_mac_toQColor(mac_widget_colors[i].inactive); pal.setColor(QPalette::Disabled, QPalette::Text, qc); pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc); } if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) { From 2fedce8ed8451fd9b14bc214dc26e79b0d5ab7bd Mon Sep 17 00:00:00 2001 From: Yan Shapochnik Date: Thu, 21 Mar 2019 15:33:20 -0400 Subject: [PATCH 069/154] QMacStyle: Fix QTabWidget document mode on macOS Mojave dark mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix styling and positioning of QTabWidget tabs on macOS Mojave while using dark mode Change-Id: Ibe0c90b7625c4f4ff895083fefaade74305ba0ea Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 86 ++++++++++++++++++------- 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 979f70ece5..5cb945a46c 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -356,15 +356,44 @@ static const qreal titleBarButtonSpacing = 8; // active: window is active // selected: tab is selected // hovered: tab is hovered -static const QColor tabBarTabBackgroundActive(190, 190, 190); -static const QColor tabBarTabBackgroundActiveHovered(178, 178, 178); -static const QColor tabBarTabBackgroundActiveSelected(211, 211, 211); -static const QColor tabBarTabBackground(227, 227, 227); -static const QColor tabBarTabBackgroundSelected(246, 246, 246); -static const QColor tabBarTabLineActive(160, 160, 160); -static const QColor tabBarTabLineActiveHovered(150, 150, 150); -static const QColor tabBarTabLine(210, 210, 210); -static const QColor tabBarTabLineSelected(189, 189, 189); +bool isDarkMode() { return qt_mac_applicationIsInDarkMode(); } + +static const QColor lightTabBarTabBackgroundActive(190, 190, 190); +static const QColor darkTabBarTabBackgroundActive(38, 38, 38); +static const QColor tabBarTabBackgroundActive() { return isDarkMode() ? darkTabBarTabBackgroundActive : lightTabBarTabBackgroundActive; } + +static const QColor lightTabBarTabBackgroundActiveHovered(178, 178, 178); +static const QColor darkTabBarTabBackgroundActiveHovered(32, 32, 32); +static const QColor tabBarTabBackgroundActiveHovered() { return isDarkMode() ? darkTabBarTabBackgroundActiveHovered : lightTabBarTabBackgroundActiveHovered; } + +static const QColor lightTabBarTabBackgroundActiveSelected(211, 211, 211); +static const QColor darkTabBarTabBackgroundActiveSelected(52, 52, 52); +static const QColor tabBarTabBackgroundActiveSelected() { return isDarkMode() ? darkTabBarTabBackgroundActiveSelected : lightTabBarTabBackgroundActiveSelected; } + +static const QColor lightTabBarTabBackground(227, 227, 227); +static const QColor darkTabBarTabBackground(38, 38, 38); +static const QColor tabBarTabBackground() { return isDarkMode() ? darkTabBarTabBackground : lightTabBarTabBackground; } + +static const QColor lightTabBarTabBackgroundSelected(246, 246, 246); +static const QColor darkTabBarTabBackgroundSelected(52, 52, 52); +static const QColor tabBarTabBackgroundSelected() { return isDarkMode() ? darkTabBarTabBackgroundSelected : lightTabBarTabBackgroundSelected; } + +static const QColor lightTabBarTabLineActive(160, 160, 160); +static const QColor darkTabBarTabLineActive(90, 90, 90); +static const QColor tabBarTabLineActive() { return isDarkMode() ? darkTabBarTabLineActive : lightTabBarTabLineActive; } + +static const QColor lightTabBarTabLineActiveHovered(150, 150, 150); +static const QColor darkTabBarTabLineActiveHovered(90, 90, 90); +static const QColor tabBarTabLineActiveHovered() { return isDarkMode() ? darkTabBarTabLineActiveHovered : lightTabBarTabLineActiveHovered; } + +static const QColor lightTabBarTabLine(210, 210, 210); +static const QColor darkTabBarTabLine(90, 90, 90); +static const QColor tabBarTabLine() { return isDarkMode() ? darkTabBarTabLine : lightTabBarTabLine; } + +static const QColor lightTabBarTabLineSelected(189, 189, 189); +static const QColor darkTabBarTabLineSelected(90, 90, 90); +static const QColor tabBarTabLineSelected() { return isDarkMode() ? darkTabBarTabLineSelected : lightTabBarTabLineSelected; } + static const QColor tabBarCloseButtonBackgroundHovered(162, 162, 162); static const QColor tabBarCloseButtonBackgroundPressed(153, 153, 153); static const QColor tabBarCloseButtonBackgroundSelectedHovered(192, 192, 192); @@ -561,7 +590,7 @@ void drawTabShape(QPainter *p, const QStyleOptionTab *tabOpt, bool isUnified, in const bool active = (tabOpt->state & QStyle::State_Active); const bool selected = (tabOpt->state & QStyle::State_Selected); - const QRect bodyRect(1, 1, width - 2, height - 2); + const QRect bodyRect(1, 2, width - 2, height - 3); const QRect topLineRect(1, 0, width - 2, 1); const QRect bottomLineRect(1, height - 1, width - 2, 1); if (selected) { @@ -572,27 +601,27 @@ void drawTabShape(QPainter *p, const QStyleOptionTab *tabOpt, bool isUnified, in p->fillRect(tabRect, QColor(Qt::transparent)); p->restore(); } else if (active) { - p->fillRect(bodyRect, tabBarTabBackgroundActiveSelected); + p->fillRect(bodyRect, tabBarTabBackgroundActiveSelected()); // top line - p->fillRect(topLineRect, tabBarTabLineSelected); + p->fillRect(topLineRect, tabBarTabLineSelected()); } else { - p->fillRect(bodyRect, tabBarTabBackgroundSelected); + p->fillRect(bodyRect, tabBarTabBackgroundSelected()); } } else { // when the mouse is over non selected tabs they get a new color const bool hover = (tabOpt->state & QStyle::State_MouseOver); if (hover) { // fill body - p->fillRect(bodyRect, tabBarTabBackgroundActiveHovered); + p->fillRect(bodyRect, tabBarTabBackgroundActiveHovered()); // bottom line - p->fillRect(bottomLineRect, tabBarTabLineActiveHovered); + p->fillRect(bottomLineRect, isDarkMode() ? QColor(Qt::black) : tabBarTabLineActiveHovered()); } } // separator lines between tabs const QRect leftLineRect(0, 1, 1, height - 2); const QRect rightLineRect(width - 1, 1, 1, height - 2); - const QColor separatorLineColor = active ? tabBarTabLineActive : tabBarTabLine; + const QColor separatorLineColor = active ? tabBarTabLineActive() : tabBarTabLine(); p->fillRect(leftLineRect, separatorLineColor); p->fillRect(rightLineRect, separatorLineColor); } @@ -612,17 +641,20 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBase *tbb, const QWidget * // fill body const QRect bodyRect(0, 1, width, height - 1); - const QColor bodyColor = active ? tabBarTabBackgroundActive : tabBarTabBackground; + const QColor bodyColor = active ? tabBarTabBackgroundActive() : tabBarTabBackground(); p->fillRect(bodyRect, bodyColor); // top line const QRect topLineRect(0, 0, width, 1); - const QColor topLineColor = active ? tabBarTabLineActive : tabBarTabLine; + const QColor topLineColor = active ? tabBarTabLineActive() : tabBarTabLine(); p->fillRect(topLineRect, topLineColor); // bottom line const QRect bottomLineRect(0, height - 1, width, 1); - const QColor bottomLineColor = active ? tabBarTabLineActive : tabBarTabLine; + bool isDocument = false; + if (const QTabBar *tabBar = qobject_cast(w)) + isDocument = tabBar->documentMode(); + const QColor bottomLineColor = isDocument && isDarkMode() ? QColor(Qt::black) : active ? tabBarTabLineActive() : tabBarTabLine(); p->fillRect(bottomLineRect, bottomLineColor); } #endif @@ -3542,7 +3574,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (tbstyle == Qt::ToolButtonTextOnly || (tbstyle != Qt::ToolButtonTextOnly && !down)) { QPen pen = p->pen(); - QColor light = down ? Qt::black : Qt::white; + QColor light = down || isDarkMode() ? Qt::black : Qt::white; light.setAlphaF(0.375f); p->setPen(light); p->drawText(cr.adjusted(0, 1, 0, 1), alignment, tb->text); @@ -3964,6 +3996,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (!tabBar->tabTextColor(tabBar->currentIndex()).isValid()) myTab.palette.setColor(QPalette::WindowText, Qt::white); + if (myTab.documentMode && isDarkMode()) { + bool active = (myTab.state & State_Selected) && (myTab.state & State_Active); + myTab.palette.setColor(QPalette::WindowText, active ? Qt::white : Qt::gray); + } + int heightOffset = 0; if (verticalTabs) { heightOffset = -1; @@ -4450,16 +4487,17 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter p->fillRect(opt->rect, linearGrad); p->save(); + QRect toolbarRect = isDarkMode ? opt->rect.adjusted(0, 0, 0, 1) : opt->rect; if (opt->state & State_Horizontal) { p->setPen(isDarkMode ? darkModeSeparatorLine : mainWindowGradientBegin.lighter(114)); - p->drawLine(opt->rect.topLeft(), opt->rect.topRight()); + p->drawLine(toolbarRect.topLeft(), toolbarRect.topRight()); p->setPen(isDarkMode ? darkModeSeparatorLine :mainWindowGradientEnd.darker(114)); - p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight()); + p->drawLine(toolbarRect.bottomLeft(), toolbarRect.bottomRight()); } else { p->setPen(isDarkMode ? darkModeSeparatorLine : mainWindowGradientBegin.lighter(114)); - p->drawLine(opt->rect.topLeft(), opt->rect.bottomLeft()); + p->drawLine(toolbarRect.topLeft(), toolbarRect.bottomLeft()); p->setPen(isDarkMode ? darkModeSeparatorLine : mainWindowGradientEnd.darker(114)); - p->drawLine(opt->rect.topRight(), opt->rect.bottomRight()); + p->drawLine(toolbarRect.topRight(), toolbarRect.bottomRight()); } p->restore(); From 98b3321e6fcade5fa8c3d3f33de327a93d13b78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 22 Mar 2019 09:51:11 +0100 Subject: [PATCH 070/154] wasm: disable threaded rendering Enabling makes QtQuick to attempt to access window.devicePixelRatio [via QWasmWindow::devicePixelRatio()] from a web worker. Change-Id: I957df29060c7eb8c47d02bc67c8c5c2219b570f4 Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmintegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index 499a82adbd..486f4cb2b3 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -116,7 +116,7 @@ bool QWasmIntegration::hasCapability(QPlatformIntegration::Capability cap) const switch (cap) { case ThreadedPixmaps: return true; case OpenGL: return true; - case ThreadedOpenGL: return true; + case ThreadedOpenGL: return false; case RasterGLSurface: return false; // to enable this you need to fix qopenglwidget and quickwidget for wasm case MultipleWindows: return true; case WindowManagement: return true; From 945198fd237a83348feb4537d811565a2c2cd8e0 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Mon, 25 Mar 2019 12:13:48 +1000 Subject: [PATCH 071/154] wasm: update depreciated getElementById MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibef29f0fd2cb2012a05400a855cb4985f9164d92 Fixes: QTBUG-74601 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/wasm_shell.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wasm/wasm_shell.html b/src/plugins/platforms/wasm/wasm_shell.html index 39bb711b6b..6ad7886ed4 100644 --- a/src/plugins/platforms/wasm/wasm_shell.html +++ b/src/plugins/platforms/wasm/wasm_shell.html @@ -27,9 +27,9 @@