From 0f5ed788f295ccd1ecc8708ef846e957906d5b97 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 8 Mar 2019 10:36:12 +0100 Subject: [PATCH 01/16] Doc: fix some typos and missing doc for QScopeGuard Change-Id: Ifd492387abbffa551e08a6bcc01e248b8402254d Reviewed-by: Martin Smith --- src/corelib/tools/qscopeguard.qdoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/tools/qscopeguard.qdoc b/src/corelib/tools/qscopeguard.qdoc index 21b0bab9cfa..5a9b7fd2106 100644 --- a/src/corelib/tools/qscopeguard.qdoc +++ b/src/corelib/tools/qscopeguard.qdoc @@ -37,6 +37,12 @@ QT_BEGIN_NAMESPACE a scope. */ +/*! \fn template void QScopeGuard::dismiss() + + Disarms the scope guard, so that the function \e F will not be called at + the end of the scope. +*/ + /*! \fn template const QScopeGuard qScopeGuard(F f) \inmodule QtCore From 16b7afc4de02f291f7797ed21b4674431d5f55cd Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Tue, 12 Mar 2019 20:35:19 +0800 Subject: [PATCH 02/16] Fix win32-clang-g++ build Change-Id: Ide803de12736d545807a4ae650ff8f8bce5dccd8 Reviewed-by: Friedemann Kleint Reviewed-by: Joerg Bornemann --- configure.bat | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.bat b/configure.bat index 7cadd783ea4..c341f9c972f 100644 --- a/configure.bat +++ b/configure.bat @@ -161,6 +161,8 @@ if "%PLATFORM%" == "" ( set PLATFORM=win32-msvc ) else if not "%clang-cl.exe%" == "" ( set PLATFORM=win32-clang-msvc + ) else if not "%clang.exe%" == "" ( + set PLATFORM=win32-clang-g++ ) else if not "%g++.exe%" == "" ( set PLATFORM=win32-g++ ) else ( @@ -172,7 +174,7 @@ if not exist "%QTSRC%\mkspecs\%PLATFORM%\qmake.conf" ( echo Host platform '%PLATFORM%' is invalid. Aborting. >&2 exit /b 1 ) -if "%PLATFORM:win32-g++=%" == "%PLATFORM%" ( +if "%PLATFORM:g++=%" == "%PLATFORM%" ( if "%MAKE%" == "" ( if not "%jom.exe%" == "" ( set MAKE=jom From 6620f93a74af056743262193e92ced2037bc0979 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 5 Mar 2019 19:28:54 +0100 Subject: [PATCH 03/16] QOpenGLContext: fix docs about sharing FBOs cannot be shared. Streamline the remainder of the sentence. Change-Id: I654b23f86f4ee4ea2ca8e71958464d9f55394297 Reviewed-by: Martin Smith --- src/gui/kernel/qopenglcontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index be04513de66..9a6f879431d 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -313,7 +313,7 @@ QOpenGLContext *qt_gl_global_share_context() \section1 Context Resource Sharing - Resources, such as framebuffer objects, textures, and vertex buffer objects + Resources such as textures and vertex buffer objects can be shared between contexts. Use setShareContext() before calling create() to specify that the contexts should share these resources. QOpenGLContext internally keeps track of a QOpenGLContextGroup object which From d5bb757987f5f759e37ebac402dbb07c2af01f69 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 12 Mar 2019 16:04:10 +0100 Subject: [PATCH 04/16] Doc: Use nullptr in Signals & Slots Change-Id: I9b377e00ce177ae33972479bde11dd03061224d7 Reviewed-by: Paul Wicking --- src/corelib/doc/snippets/signalsandslots/lcdnumber.h | 2 +- src/corelib/doc/src/objectmodel/signalsandslots.qdoc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/doc/snippets/signalsandslots/lcdnumber.h b/src/corelib/doc/snippets/signalsandslots/lcdnumber.h index fbd31b08cf7..b311586e8f9 100644 --- a/src/corelib/doc/snippets/signalsandslots/lcdnumber.h +++ b/src/corelib/doc/snippets/signalsandslots/lcdnumber.h @@ -69,7 +69,7 @@ class LcdNumber : public QFrame //! [6] public: //! [6] //! [7] - LcdNumber(QWidget *parent = 0); + LcdNumber(QWidget *parent = nullptr); //! [7] //! [8] diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc index fcf091458ab..85fe4df2ce4 100644 --- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc +++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc @@ -330,7 +330,7 @@ arguments can have default values. Consider QObject::destroyed(): \code - void destroyed(QObject* = 0); + void destroyed(QObject* = nullptr); \endcode When a QObject is deleted, it emits this QObject::destroyed() @@ -339,7 +339,7 @@ A suitable slot signature might be: \code - void objectDestroyed(QObject* obj = 0); + void objectDestroyed(QObject* obj = nullptr); \endcode To connect the signal to the slot, we use QObject::connect(). From 0181e0e527cfdceb6fcae5c3c1c3db5b9c340562 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Mar 2019 22:16:21 -0800 Subject: [PATCH 05/16] Add a pair of functions to convert to and from Q/CborError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We've so far made our public API match the TinyCBOR error codes, so the conversion is trivial. Having the two functions allows us to change that, if it becomes necessary. It also effectively concentrates the Coverity warning about mixed enums in a single pair of functions. >>> CID 190307: Incorrect expression (MIXED_ENUMS) >>> Mixing enum types "CborError" and "QCborError::Code" for "err". Change-Id: Ifbadc62ac2d04a9a8952fffd1589e739c7a5b745 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/serialization/qcborstream.cpp | 25 +++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/corelib/serialization/qcborstream.cpp b/src/corelib/serialization/qcborstream.cpp index 264856b4bfb..7ccc0ff3a7e 100644 --- a/src/corelib/serialization/qcborstream.cpp +++ b/src/corelib/serialization/qcborstream.cpp @@ -413,6 +413,24 @@ QDebug operator<<(QDebug dbg, QCborKnownTags tag) support (internal limitation, but the error is not recoverable). */ +// Convert from CborError to QCborError. +// +// Centralized in a function in case we need to make more adjustments in the +// future. +static QCborError fromCborError(CborError err) +{ + return { QCborError::Code(int(err)) }; +} + +// Convert to CborError from QCborError. +// +// Centralized in a function in case we need to make more adjustments in the +// future. +static CborError toCborError(QCborError c) +{ + return CborError(int(c.c)); +} + /*! \variable QCborError::c \internal @@ -483,8 +501,8 @@ QString QCborError::toString() const return QStringLiteral("Internal limitation: unsupported type"); } - // get the error from TinyCBOR - CborError err = CborError(int(c)); + // get the error string from TinyCBOR + CborError err = toCborError(*this); return QString::fromLatin1(cbor_error_string(err)); } @@ -1823,8 +1841,7 @@ public: if (err != CborErrorUnexpectedEOF) corrupt = true; - // our error codes are the same (for now) - lastError = { QCborError::Code(err) }; + lastError = fromCborError(err); } void updateBufferAfterString(qsizetype offset, qsizetype size) From c21e2d5706ca50fb4fccf1eae70b76f0e278db99 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 9 Mar 2019 09:30:46 -0800 Subject: [PATCH 06/16] Doc: "UTF" -> "UTF-8" Change-Id: Ifbadc62ac2d04a9a8952fffd158a5a9ba87c30e0 Reviewed-by: Edward Welbourne --- src/corelib/serialization/qcborstream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/serialization/qcborstream.cpp b/src/corelib/serialization/qcborstream.cpp index 7ccc0ff3a7e..d062cff0670 100644 --- a/src/corelib/serialization/qcborstream.cpp +++ b/src/corelib/serialization/qcborstream.cpp @@ -404,7 +404,7 @@ QDebug operator<<(QDebug dbg, QCborKnownTags tag) \value IllegalSimpleType The CBOR stream contains a Simple Type encoded incorrectly (data is corrupt and the error is not recoverable). \value InvalidUtf8String The CBOR stream contains a text string that does not decode properly - as UTF (data is corrupt and the error is not recoverable). + as UTF-8 (data is corrupt and the error is not recoverable). \value DataTooLarge CBOR string, map or array is too big and cannot be parsed by Qt (internal limitation, but the error is not recoverable). \value NestingTooDeep Too many levels of arrays or maps encountered while processing the From 68a2b3d46a31167ae738f559b3b48d1db7f20dd0 Mon Sep 17 00:00:00 2001 From: Karim Pinter Date: Tue, 29 Jan 2019 16:05:06 +0200 Subject: [PATCH 07/16] QNX QPA: Add support for Qt Virtual Keyboard If the QT_IM_MODULE environment variable is set, then it loads the IM module accordingly, otherwise it is using the PPS one, if it is available. Task-number: QTBUG-54576 Change-Id: Icb8b474805053d8297029096365783c2cabc2cbc Reviewed-by: Samuli Piippo Reviewed-by: James McDonnell (cherry picked from commit 8a7c373f8e745427d5fe7afc08d698837b7b8f2b) Reviewed-by: Lars Knoll --- src/plugins/platforms/qnx/qqnxintegration.cpp | 25 +++++++++++++------ src/plugins/platforms/qnx/qqnxintegration.h | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index db797804076..a996e765c43 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -72,6 +72,9 @@ # endif #endif +#include +#include + #include "private/qgenericunixfontdatabase_p.h" #include "private/qgenericunixeventdispatcher_p.h" @@ -152,6 +155,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) , m_inputContext(0) , m_buttonsNotifier(new QQnxButtonEventNotifier()) #endif + , m_qpaInputContext(0) , m_services(0) , m_fontDatabase(new QGenericUnixFontDatabase()) , m_eventDispatcher(createUnixEventDispatcher()) @@ -194,13 +198,17 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) m_screenEventHandler->setScreenEventThread(m_screenEventThread); m_screenEventThread->start(); -#if QT_CONFIG(qqnx_pps) - // Create/start the keyboard class. - m_virtualKeyboard = new QQnxVirtualKeyboardPps(); + m_qpaInputContext = QPlatformInputContextFactory::create(); - // delay invocation of start() to the time the event loop is up and running - // needed to have the QThread internals of the main thread properly initialized - QMetaObject::invokeMethod(m_virtualKeyboard, "start", Qt::QueuedConnection); +#if QT_CONFIG(qqnx_pps) + if (!m_qpaInputContext) { + // Create/start the keyboard class. + m_virtualKeyboard = new QQnxVirtualKeyboardPps(); + + // delay invocation of start() to the time the event loop is up and running + // needed to have the QThread internals of the main thread properly initialized + QMetaObject::invokeMethod(m_virtualKeyboard, "start", Qt::QueuedConnection); + } #endif #if QT_CONFIG(qqnx_pps) @@ -281,6 +289,7 @@ QQnxIntegration::~QQnxIntegration() // Destroy input context delete m_inputContext; #endif + delete m_qpaInputContext; // Destroy the keyboard class. delete m_virtualKeyboard; @@ -397,13 +406,13 @@ QPlatformOpenGLContext *QQnxIntegration::createPlatformOpenGLContext(QOpenGLCont } #endif -#if QT_CONFIG(qqnx_pps) QPlatformInputContext *QQnxIntegration::inputContext() const { qIntegrationDebug(); + if (m_qpaInputContext) + return m_qpaInputContext; return m_inputContext; } -#endif void QQnxIntegration::moveToScreen(QWindow *window, int screen) { diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index 4a6f15fc088..366556dc4b3 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -153,6 +153,7 @@ private: QQnxInputContext *m_inputContext; QQnxButtonEventNotifier *m_buttonsNotifier; #endif + QPlatformInputContext *m_qpaInputContext; QQnxServices *m_services; QPlatformFontDatabase *m_fontDatabase; mutable QAbstractEventDispatcher *m_eventDispatcher; From b9c4add832f7d872d86e4383073e9b6e39220776 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Thu, 14 Mar 2019 10:19:09 +0800 Subject: [PATCH 08/16] Configure: add missing "clang.exe" This amends commit 16b7afc. Change-Id: I6c0e4b476035e4733e828724109b950d5b3a8dd6 Reviewed-by: Joerg Bornemann --- configure.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.bat b/configure.bat index c341f9c972f..79dcfe352dd 100644 --- a/configure.bat +++ b/configure.bat @@ -150,7 +150,7 @@ goto doneargs :doneargs rem Find various executables -for %%C in (clang-cl.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C +for %%C in (clang-cl.exe clang.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C rem Determine host spec From 85250da09d91117141815db6aa88d77b03fbb436 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Thu, 14 Mar 2019 10:28:30 +0800 Subject: [PATCH 09/16] Configure: simplify logic Replace hard-coded win32-msvc20XX mkspec names with a variable substitution expression. Change-Id: I4911cb3e169cd7603453d7c8a67a2a291d15c796 Reviewed-by: Joerg Bornemann --- configure.bat | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/configure.bat b/configure.bat index 79dcfe352dd..b34e146f5fd 100644 --- a/configure.bat +++ b/configure.bat @@ -125,11 +125,8 @@ goto doneargs :platform shift - if "%~1" == "win32-msvc2012" goto msvc - if "%~1" == "win32-msvc2013" goto msvc - if "%~1" == "win32-msvc2015" goto msvc - if "%~1" == "win32-msvc2017" goto msvc set PLATFORM=%~1 + if "%PLATFORM:~0,10%" == "win32-msvc" goto msvc goto nextarg :msvc echo. >&2 From 036fe49580d7470eeaa4c168845bdf2483946f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Turek?= Date: Fri, 22 Feb 2019 19:26:37 +0100 Subject: [PATCH 10/16] XCB: Fix clipboard breaking when timer wraps after 50 days xcb_timestamp_t is a 32-bit unsigned value in miliseconds, so it wraps after 49.7 days. When it happens, QXcbConnection::m_time stops updating and copy & paste in an application would not work until the application is restarted. This patch detects the timer wrap and allows m_time to wrap too. The fix was verified in KDE desktop with applications running for 51 days. Fixes: QTBUG-65145 Change-Id: I328c4179c1b1f71914adda6f9a0ca3991a7e808e Reviewed-by: Uli Schlachter Reviewed-by: Milian Wolff Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbconnection.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 47036ca257e..15537fede49 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -187,10 +187,10 @@ public: void addPeekFunc(PeekFunc f); inline xcb_timestamp_t time() const { return m_time; } - inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; } + inline void setTime(xcb_timestamp_t t) { if (timeGreaterThan(t, m_time)) m_time = t; } inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; } - inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; } + inline void setNetWmUserTime(xcb_timestamp_t t) { if (timeGreaterThan(t, m_netWmUserTime)) m_netWmUserTime = t; } xcb_timestamp_t getTimestamp(); xcb_window_t getSelectionOwner(xcb_atom_t atom) const; @@ -264,6 +264,8 @@ private: void destroyScreen(QXcbScreen *screen); void initializeScreens(); bool compressEvent(xcb_generic_event_t *event) const; + inline bool timeGreaterThan(xcb_timestamp_t a, xcb_timestamp_t b) const + { return static_cast(a - b) > 0 || b == XCB_CURRENT_TIME; } #if QT_CONFIG(xcb_xinput) void xi2SetupDevice(void *info, bool removeExisting = true); From 15f88a7c01007ae1962b83aefc5a536e16fcb446 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Mar 2019 13:32:34 +0100 Subject: [PATCH 11/16] Windows QPA: Output all adapters in diagnostics used by qtdiag Split up the code detecting the GPUs into small helpers. Add a QDirect3D9Handle class providing Direct3D9 functionality, add GpuDescription::detectAll() and add a QVariantList "gpuList" property to the native interface. Task-number: QTBUG-50371 Task-number: QTBUG-65882 Change-Id: I8673542d327837babc2ad8f507da76e8ff5524ea Reviewed-by: Oliver Wolff --- .../windows/qwindowsnativeinterface.cpp | 9 ++ .../windows/qwindowsnativeinterface.h | 2 + .../windows/qwindowsopengltester.cpp | 132 ++++++++++++------ .../platforms/windows/qwindowsopengltester.h | 2 + 4 files changed, 104 insertions(+), 41 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index 32eec322e85..ed945ec4b13 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -289,4 +289,13 @@ QVariant QWindowsNativeInterface::gpu() const return GpuDescription::detect().toVariant(); } +QVariant QWindowsNativeInterface::gpuList() const +{ + QVariantList result; + const auto gpus = GpuDescription::detectAll(); + for (const auto &gpu : gpus) + result.append(gpu.toVariant()); + return result; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h index d085a4afb31..e6f8aae8fbf 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.h +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h @@ -66,6 +66,7 @@ class QWindowsNativeInterface : public QPlatformNativeInterface Q_OBJECT Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose) Q_PROPERTY(QVariant gpu READ gpu STORED false) + Q_PROPERTY(QVariant gpuList READ gpuList STORED false) public: void *nativeResourceForIntegration(const QByteArray &resource) override; @@ -91,6 +92,7 @@ public: void setAsyncExpose(bool value); QVariant gpu() const; + QVariant gpuList() const; QVariantMap windowProperties(QPlatformWindow *window) const override; QVariant windowProperty(QPlatformWindow *window, const QString &name) const override; diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index 20461357256..840a3a11c48 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -62,19 +62,70 @@ QT_BEGIN_NAMESPACE static const DWORD VENDOR_ID_AMD = 0x1002; +static GpuDescription adapterIdentifierToGpuDescription(const D3DADAPTER_IDENTIFIER9 &adapterIdentifier) +{ + GpuDescription result; + result.vendorId = adapterIdentifier.VendorId; + result.deviceId = adapterIdentifier.DeviceId; + result.revision = adapterIdentifier.Revision; + result.subSysId = adapterIdentifier.SubSysId; + QVector version(4, 0); + version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product + version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version + version[2] = HIWORD(adapterIdentifier.DriverVersion.LowPart); // Sub version + version[3] = LOWORD(adapterIdentifier.DriverVersion.LowPart); // build + result.driverVersion = QVersionNumber(version); + result.driverName = adapterIdentifier.Driver; + result.description = adapterIdentifier.Description; + return result; +} + +class QDirect3D9Handle +{ +public: + Q_DISABLE_COPY(QDirect3D9Handle) + + QDirect3D9Handle(); + ~QDirect3D9Handle(); + + bool isValid() const { return m_direct3D9 != nullptr; } + + UINT adapterCount() const { return m_direct3D9 ? m_direct3D9->GetAdapterCount() : 0u; } + bool retrieveAdapterIdentifier(UINT n, D3DADAPTER_IDENTIFIER9 *adapterIdentifier) const; + +private: + QSystemLibrary m_d3d9lib; + IDirect3D9 *m_direct3D9 = nullptr; +}; + +QDirect3D9Handle::QDirect3D9Handle() : + m_d3d9lib(QStringLiteral("d3d9")) +{ + using PtrDirect3DCreate9 = IDirect3D9 *(WINAPI *)(UINT); + + if (m_d3d9lib.load()) { + if (auto direct3DCreate9 = (PtrDirect3DCreate9)m_d3d9lib.resolve("Direct3DCreate9")) + m_direct3D9 = direct3DCreate9(D3D_SDK_VERSION); + } +} + +QDirect3D9Handle::~QDirect3D9Handle() +{ + if (m_direct3D9) + m_direct3D9->Release(); +} + +bool QDirect3D9Handle::retrieveAdapterIdentifier(UINT n, D3DADAPTER_IDENTIFIER9 *adapterIdentifier) const +{ + return m_direct3D9 + && SUCCEEDED(m_direct3D9->GetAdapterIdentifier(n, 0, adapterIdentifier)); +} + GpuDescription GpuDescription::detect() { - typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT); - GpuDescription result; - QSystemLibrary d3d9lib(QStringLiteral("d3d9")); - if (!d3d9lib.load()) - return result; - PtrDirect3DCreate9 direct3DCreate9 = (PtrDirect3DCreate9)d3d9lib.resolve("Direct3DCreate9"); - if (!direct3DCreate9) - return result; - IDirect3D9 *direct3D9 = direct3DCreate9(D3D_SDK_VERSION); - if (!direct3D9) + QDirect3D9Handle direct3D9; + if (!direct3D9.isValid()) return result; D3DADAPTER_IDENTIFIER9 adapterIdentifier; @@ -85,20 +136,8 @@ GpuDescription GpuDescription::detect() // and D3D uses by default. Therefore querying any additional adapters is // futile and not useful for our purposes in general, except for // identifying a few special cases later on. - HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier); - if (SUCCEEDED(hr)) { - result.vendorId = adapterIdentifier.VendorId; - result.deviceId = adapterIdentifier.DeviceId; - result.revision = adapterIdentifier.Revision; - result.subSysId = adapterIdentifier.SubSysId; - QVector version(4, 0); - version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product - version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version - version[2] = HIWORD(adapterIdentifier.DriverVersion.LowPart); // Sub version - version[3] = LOWORD(adapterIdentifier.DriverVersion.LowPart); // build - result.driverVersion = QVersionNumber(version); - result.driverName = adapterIdentifier.Driver; - result.description = adapterIdentifier.Description; + if (direct3D9.retrieveAdapterIdentifier(0, &adapterIdentifier)) { + result = adapterIdentifierToGpuDescription(adapterIdentifier); isAMD = result.vendorId == VENDOR_ID_AMD; } @@ -106,30 +145,41 @@ GpuDescription GpuDescription::detect() // when starting apps on a screen connected to the Intel card) by looking // for a default AMD adapter and an additional non-AMD one. if (isAMD) { - const UINT adapterCount = direct3D9->GetAdapterCount(); + const UINT adapterCount = direct3D9.adapterCount(); for (UINT adp = 1; adp < adapterCount; ++adp) { - hr = direct3D9->GetAdapterIdentifier(adp, 0, &adapterIdentifier); - if (SUCCEEDED(hr)) { - if (adapterIdentifier.VendorId != VENDOR_ID_AMD) { - // Bingo. Now figure out the display for the AMD card. - DISPLAY_DEVICE dd; - memset(&dd, 0, sizeof(dd)); - dd.cb = sizeof(dd); - for (int dev = 0; EnumDisplayDevices(nullptr, dev, &dd, 0); ++dev) { - if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { - // DeviceName is something like \\.\DISPLAY1 which can be used to - // match with the MONITORINFOEX::szDevice queried by QWindowsScreen. - result.gpuSuitableScreen = QString::fromWCharArray(dd.DeviceName); - break; - } + if (direct3D9.retrieveAdapterIdentifier(adp, &adapterIdentifier) + && adapterIdentifier.VendorId != VENDOR_ID_AMD) { + // Bingo. Now figure out the display for the AMD card. + DISPLAY_DEVICE dd; + memset(&dd, 0, sizeof(dd)); + dd.cb = sizeof(dd); + for (int dev = 0; EnumDisplayDevices(nullptr, dev, &dd, 0); ++dev) { + if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { + // DeviceName is something like \\.\DISPLAY1 which can be used to + // match with the MONITORINFOEX::szDevice queried by QWindowsScreen. + result.gpuSuitableScreen = QString::fromWCharArray(dd.DeviceName); + break; } - break; } + break; } } } - direct3D9->Release(); + return result; +} + +QVector GpuDescription::detectAll() +{ + QVector result; + QDirect3D9Handle direct3D9; + if (const UINT adapterCount = direct3D9.adapterCount()) { + for (UINT adp = 0; adp < adapterCount; ++adp) { + D3DADAPTER_IDENTIFIER9 adapterIdentifier; + if (direct3D9.retrieveAdapterIdentifier(adp, &adapterIdentifier)) + result.append(adapterIdentifierToGpuDescription(adapterIdentifier)); + } + } return result; } diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h index 08628c2586c..9576dfbae05 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.h +++ b/src/plugins/platforms/windows/qwindowsopengltester.h @@ -42,6 +42,7 @@ #include #include +#include #include QT_BEGIN_NAMESPACE @@ -52,6 +53,7 @@ class QVariant; struct GpuDescription { static GpuDescription detect(); + static QVector detectAll(); QString toString() const; QVariant toVariant() const; From 74aeacace4124b7452a3b1e951e1a3b25f84d47f Mon Sep 17 00:00:00 2001 From: Christian Andersen Date: Sun, 10 Mar 2019 22:42:44 +0100 Subject: [PATCH 12/16] Windows QPA: only calculate invisible margins when window has a frame In commit ec97be5585 an invisible frame calculation was added for Windows 10 that fixes QWidget::move(0,0) for main windows and dialogs. But because e.g. Qt::ToolTip windows do not have a window frame, the invisible margin calculation causes them to pop-up in the wrong position (off by a few pixels). [ChangeLog][Windows] Fixed QToolTip pop-ups and QComboBox animation pop-ups being off by a few pixels on Windows 10. Fixes: QTBUG-74062 Change-Id: I218e8409a250a8b81ecd1d409b597ebd01fb255f Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 6 ++++-- src/plugins/platforms/windows/qwindowswindow.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index c5d57be2ad3..2c0ffc9b264 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -746,7 +746,8 @@ QWindowsWindowData const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle)); QWindowsContext::instance()->setWindowCreationContext(context); - QMargins invMargins = topLevel && !(result.flags & Qt::FramelessWindowHint) && QWindowsGeometryHint::positionIncludesFrame(w) + const bool hasFrame = (style & (WS_DLGFRAME | WS_THICKFRAME)); + QMargins invMargins = topLevel && hasFrame && QWindowsGeometryHint::positionIncludesFrame(w) ? invisibleMargins(QPoint(context->frameX, context->frameY)) : QMargins(); qCDebug(lcQpaWindows).nospace() @@ -777,6 +778,7 @@ QWindowsWindowData result.geometry = context->obtainedGeometry; result.fullFrameMargins = context->margins; result.embedded = embedded; + result.hasFrame = hasFrame; result.customMargins = context->customMargins; return result; @@ -2232,7 +2234,7 @@ void QWindowsWindow::setFullFrameMargins(const QMargins &newMargins) QMargins QWindowsWindow::frameMargins() const { QMargins result = fullFrameMargins(); - if (isTopLevel() && !(m_data.flags & Qt::FramelessWindowHint)) + if (isTopLevel() && m_data.hasFrame) result -= invisibleMargins(geometry().topLeft()); return result; } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index b9b398b67bb..2675990cf18 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -112,6 +112,7 @@ struct QWindowsWindowData QMargins customMargins; // User-defined, additional frame for NCCALCSIZE HWND hwnd = 0; bool embedded = false; + bool hasFrame = false; static QWindowsWindowData create(const QWindow *w, const QWindowsWindowData ¶meters, From a6154ca6486f8f181ffff375bb2ffb6bb5d3d019 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 14 Mar 2019 14:16:54 +0100 Subject: [PATCH 13/16] androiddeployqt: Also shellquote rootPath as part of importPaths Fixes: QTBUG-74212 Change-Id: Ie0c9b5b230e93e50d6e636a6105c3bd717715374 Reviewed-by: Andy Shaw --- 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 f57c6122445..45808c4311f 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -1722,7 +1722,7 @@ bool scanImports(Options *options, QSet *usedDependencies) QStringList importPaths; importPaths += shellQuote(options->qtInstallDirectory + QLatin1String("/qml")); - importPaths += rootPath; + importPaths += shellQuote(rootPath); for (const QString &qmlImportPath : qAsConst(options->qmlImportPaths)) importPaths += shellQuote(qmlImportPath); From 02c25f334da817fe206aa28ba0e045c57d8c0359 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 12 Mar 2019 20:43:35 +0100 Subject: [PATCH 14/16] uic: write out min/maximumSectionSize property before current size Since faff43348bfae5cfc709fabe9d2698fc3063c050 the min/maxSectionSize is respected when setting the current/default section size programatically. This is not honored when writing out the properties and therefore the default section size is not correctly set when it's smaller then the default minimum section size. Therefore make sure to set min/maxSectionSize property before all other properties. Fixes: QTBUG-74352 Change-Id: I8f9ede3e90b7c9c65f8440953b00e1d9d6006d38 Reviewed-by: Jarek Kobus --- src/tools/uic/cpp/cppwriteinitialization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 7ab6c31cb20..0adc91ddb96 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -767,9 +767,9 @@ void WriteInitialization::acceptWidget(DomWidget *node) static const QLatin1String realPropertyNames[] = { QLatin1String("visible"), QLatin1String("cascadingSectionResizes"), + QLatin1String("minimumSectionSize"), // before defaultSectionSize QLatin1String("defaultSectionSize"), QLatin1String("highlightSections"), - QLatin1String("minimumSectionSize"), QLatin1String("showSortIndicator"), QLatin1String("stretchLastSection"), }; From b8d5e0b4ce2f1daef35dad38f5048040ae915412 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 11 Mar 2019 21:27:51 +0100 Subject: [PATCH 15/16] QAbstractItemView: Don't let editor width exceed item width if not needed The editor geometry was adjusted in RTL but not in LTR mode before Qt5.11. 3ed91da4997cf793742e5bba2adb3dbec9ecd458 fixed this but now all editors are shown with their default size instead adjusting to the item width. This works in most cases but fails for small column widths and e.g. a QDoubleSpinBox. Therefore adjust the size policy for the editors so their default size is ignored and therefore the column width is used. Don't do this for a QDateTimeEdit since this makes no sense to only show a cut of part of the editor. Fixes: QTBUG-74327 Change-Id: Ie526155571bf24a2d8f38e988d8b2af4bfcc92ba Reviewed-by: Samuel Gaist Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qitemeditorfactory.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index 0986da97074..1465ee71a7c 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -244,6 +244,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) case QVariant::Bool: { QBooleanComboBox *cb = new QBooleanComboBox(parent); cb->setFrame(false); + cb->setSizePolicy(QSizePolicy::Ignored, cb->sizePolicy().verticalPolicy()); return cb; } #endif #if QT_CONFIG(spinbox) @@ -252,12 +253,14 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) sb->setFrame(false); sb->setMinimum(0); sb->setMaximum(INT_MAX); + sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy()); return sb; } case QVariant::Int: { QSpinBox *sb = new QSpinBox(parent); sb->setFrame(false); sb->setMinimum(INT_MIN); sb->setMaximum(INT_MAX); + sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy()); return sb; } #endif #if QT_CONFIG(datetimeedit) @@ -284,6 +287,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) sb->setFrame(false); sb->setMinimum(-DBL_MAX); sb->setMaximum(DBL_MAX); + sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy()); return sb; } #endif #if QT_CONFIG(lineedit) From 097bf6fdd234ca7e5707610edfd3c804b3ba2a52 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 13 Mar 2019 21:47:27 +0100 Subject: [PATCH 16/16] Fix compilation of qCDebug("", ...) with QT_NO_DEBUG_OUTPUT ... and fix QT_NO_INFO_OUTPUT, QT_NO_WARNING_OUTPUT alongside. Fixes: QTBUG-74359 Change-Id: I2167dc943ae8c52602e08e24ca815d95f82a5db8 Reviewed-by: Thiago Macieira --- src/corelib/io/qloggingcategory.h | 55 ++++++++++++------- .../auto/corelib/io/qnodebug/tst_qnodebug.cpp | 1 + 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h index 489e250087f..91e3144300e 100644 --- a/src/corelib/io/qloggingcategory.h +++ b/src/corelib/io/qloggingcategory.h @@ -120,15 +120,30 @@ private: return category; \ } -#define qCDebug(category, ...) \ +#if !defined(QT_NO_DEBUG_OUTPUT) +# define qCDebug(category, ...) \ for (bool qt_category_enabled = category().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) \ QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).debug(__VA_ARGS__) -#define qCInfo(category, ...) \ +#else +# define qCDebug(category, ...) QT_NO_QDEBUG_MACRO() +#endif + +#if !defined(QT_NO_INFO_OUTPUT) +# define qCInfo(category, ...) \ for (bool qt_category_enabled = category().isInfoEnabled(); qt_category_enabled; qt_category_enabled = false) \ QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).info(__VA_ARGS__) -#define qCWarning(category, ...) \ +#else +# define qCInfo(category, ...) QT_NO_QDEBUG_MACRO() +#endif + +#if !defined(QT_NO_WARNING_OUTPUT) +# define qCWarning(category, ...) \ for (bool qt_category_enabled = category().isWarningEnabled(); qt_category_enabled; qt_category_enabled = false) \ QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).warning(__VA_ARGS__) +#else +# define qCWarning(category, ...) QT_NO_QDEBUG_MACRO() +#endif + #define qCCritical(category, ...) \ for (bool qt_category_enabled = category().isCriticalEnabled(); qt_category_enabled; qt_category_enabled = false) \ QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).critical(__VA_ARGS__) @@ -144,26 +159,28 @@ private: } // check for enabled category inside QMessageLogger. -#define qCDebug qDebug -#define qCInfo qInfo -#define qCWarning qWarning +#if !defined(QT_NO_DEBUG_OUTPUT) +# define qCDebug qDebug +#else +# define qCDebug(category) QT_NO_QDEBUG_MACRO() +#endif + +#if !defined(QT_NO_INFO_OUTPUT) +# define qCInfo qInfo +#else +# define qCInfo(category) QT_NO_QDEBUG_MACRO() +#endif + +#if !defined(QT_NO_WARNING_OUTPUT) +# define qCWarning qWarning +#else +# define qCWarning(category) QT_NO_QDEBUG_MACRO() +#endif + #define qCCritical qCritical #endif // Q_COMPILER_VARIADIC_MACROS || defined(Q_MOC_RUN) -#if defined(QT_NO_DEBUG_OUTPUT) -# undef qCDebug -# define qCDebug(category) QT_NO_QDEBUG_MACRO() -#endif -#if defined(QT_NO_INFO_OUTPUT) -# undef qCInfo -# define qCInfo(category) QT_NO_QDEBUG_MACRO() -#endif -#if defined(QT_NO_WARNING_OUTPUT) -# undef qCWarning -# define qCWarning(category) QT_NO_QDEBUG_MACRO() -#endif - QT_END_NAMESPACE #endif // QLOGGINGCATEGORY_H diff --git a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp index 17c51eaaf42..569c610e24e 100644 --- a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp +++ b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp @@ -53,6 +53,7 @@ void tst_QNoDebug::noDebugOutput() const // should do nothing qDebug() << "foo"; qCDebug(cat) << "foo"; + qCDebug(cat, "foo"); // qWarning still works, though QTest::ignoreMessage(QtWarningMsg, "bar");