From 0f5ed788f295ccd1ecc8708ef846e957906d5b97 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 8 Mar 2019 10:36:12 +0100 Subject: 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 21b0bab9cf..5a9b7fd210 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 -- cgit v1.2.3 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: 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 7cadd783ea..c341f9c972 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 -- cgit v1.2.3 From 6620f93a74af056743262193e92ced2037bc0979 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 5 Mar 2019 19:28:54 +0100 Subject: 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 be04513de6..9a6f879431 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 -- cgit v1.2.3 From d5bb757987f5f759e37ebac402dbb07c2af01f69 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 12 Mar 2019 16:04:10 +0100 Subject: 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 fbd31b08cf..b311586e8f 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 fcf091458a..85fe4df2ce 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(). -- cgit v1.2.3 From 0181e0e527cfdceb6fcae5c3c1c3db5b9c340562 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Mar 2019 22:16:21 -0800 Subject: 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 264856b4bf..7ccc0ff3a7 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) -- cgit v1.2.3 From c21e2d5706ca50fb4fccf1eae70b76f0e278db99 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 9 Mar 2019 09:30:46 -0800 Subject: 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 7ccc0ff3a7..d062cff067 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 -- cgit v1.2.3 From 68a2b3d46a31167ae738f559b3b48d1db7f20dd0 Mon Sep 17 00:00:00 2001 From: Karim Pinter Date: Tue, 29 Jan 2019 16:05:06 +0200 Subject: 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 | 23 ++++++++++++++++------- src/plugins/platforms/qnx/qqnxintegration.h | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index db79780407..a996e765c4 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(); + m_qpaInputContext = QPlatformInputContextFactory::create(); + #if QT_CONFIG(qqnx_pps) - // Create/start the keyboard class. - m_virtualKeyboard = new QQnxVirtualKeyboardPps(); + 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); + // 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 4a6f15fc08..366556dc4b 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; -- cgit v1.2.3 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: 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 c341f9c972..79dcfe352d 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 -- cgit v1.2.3 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: 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 79dcfe352d..b34e146f5f 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 -- cgit v1.2.3 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: 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 47036ca257..15537fede4 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); -- cgit v1.2.3 From 15f88a7c01007ae1962b83aefc5a536e16fcb446 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Mar 2019 13:32:34 +0100 Subject: 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 --- .../platforms/windows/qwindowsnativeinterface.cpp | 9 ++ .../platforms/windows/qwindowsnativeinterface.h | 2 + .../platforms/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 32eec322e8..ed945ec4b1 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 d085a4afb3..e6f8aae8fb 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 2046135725..840a3a11c4 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; -GpuDescription GpuDescription::detect() +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")) { - typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT); + 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() +{ 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 08628c2586..9576dfbae0 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; -- cgit v1.2.3 From 74aeacace4124b7452a3b1e951e1a3b25f84d47f Mon Sep 17 00:00:00 2001 From: Christian Andersen Date: Sun, 10 Mar 2019 22:42:44 +0100 Subject: 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 c5d57be2ad..2c0ffc9b26 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 b9b398b67b..2675990cf1 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, -- cgit v1.2.3 From 9649c41ed950eaa7dd9d3cb6d37a05d3a9ed8a3e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 13 Mar 2019 20:22:52 -0700 Subject: qfloat16: suppress the tables if FP16 is supported by the CPU If QtCore is being compiled to a system with FP16 support, then all applications are too and, therefore, we don't need the tables. Saves 12k of read-only data. Change-Id: I46363e5b8944459e8c48fffd158bb53d906df297 Reviewed-by: Allan Sandfeld Jensen --- src/tools/qfloat16-tables/gen_qfloat16_tables.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp index a9bf7e86e4..17fc978039 100644 --- a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp +++ b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp @@ -79,6 +79,7 @@ qint32 main(qint32 argc, char **argv) fid.write("#include \n\n"); fid.write("QT_BEGIN_NAMESPACE\n\n"); + fid.write("#if !defined(__F16C__) && !defined(__ARM_FP16_FORMAT_IEEE)\n\n"); fid.write("const quint32 qfloat16::mantissatable[2048] = {\n"); fid.write("0,\n"); @@ -155,6 +156,7 @@ qint32 main(qint32 argc, char **argv) fid.write("};\n\n"); + fid.write("#endif // !__F16C__ && !__ARM_FP16_FORMAT_IEEE\n\n"); fid.write("QT_END_NAMESPACE\n"); fid.close(); return 0; -- cgit v1.2.3 From a6154ca6486f8f181ffff375bb2ffb6bb5d3d019 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 14 Mar 2019 14:16:54 +0100 Subject: 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 f57c612244..45808c4311 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); -- cgit v1.2.3 From 02c25f334da817fe206aa28ba0e045c57d8c0359 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 12 Mar 2019 20:43:35 +0100 Subject: 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 7ab6c31cb2..0adc91ddb9 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"), }; -- cgit v1.2.3 From b8d5e0b4ce2f1daef35dad38f5048040ae915412 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 11 Mar 2019 21:27:51 +0100 Subject: 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 0986da9707..1465ee71a7 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) -- cgit v1.2.3 From 097bf6fdd234ca7e5707610edfd3c804b3ba2a52 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 13 Mar 2019 21:47:27 +0100 Subject: 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 | 49 +++++++++++++++++-------- tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp | 1 + 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h index 489e250087..91e3144300 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 -#define qCCritical qCritical - -#endif // Q_COMPILER_VARIADIC_MACROS || defined(Q_MOC_RUN) - -#if defined(QT_NO_DEBUG_OUTPUT) -# undef qCDebug +#if !defined(QT_NO_DEBUG_OUTPUT) +# define qCDebug qDebug +#else # define qCDebug(category) QT_NO_QDEBUG_MACRO() #endif -#if defined(QT_NO_INFO_OUTPUT) -# undef qCInfo + +#if !defined(QT_NO_INFO_OUTPUT) +# define qCInfo qInfo +#else # define qCInfo(category) QT_NO_QDEBUG_MACRO() #endif -#if defined(QT_NO_WARNING_OUTPUT) -# undef qCWarning + +#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) + 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 17c51eaaf4..569c610e24 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"); -- cgit v1.2.3 From 11228e54b6f0799a1ed432db98de19de0c6f792a Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 7 Dec 2018 14:11:57 +1000 Subject: wasm: fix touchpoint handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit emscripten sends a touchstart event for every touch point when a new touch point happens, so this makes them moved or stationary if already known. This allows QtQuick PinchArea to work. Task-number: QTBUG-72214 Change-Id: I8e7c0cd2d78b07cfeae21491846cc31092359050 Reviewed-by: Morten Johan Sørvig --- .../platforms/wasm/qwasmeventtranslator.cpp | 69 ++++++++++++++-------- src/plugins/platforms/wasm/qwasmeventtranslator.h | 3 + 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index 14222da807..63a764e741 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -695,7 +695,12 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh int QWasmEventTranslator::touchCallback(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData) { - QWasmEventTranslator *eventTranslator = static_cast(userData); + auto translator = reinterpret_cast(userData); + return translator->handleTouch(eventType, touchEvent); +} + +int QWasmEventTranslator::handleTouch(int eventType, const EmscriptenTouchEvent *touchEvent) +{ QList touchPointList; touchPointList.reserve(touchEvent->numTouches); QWindow *window2; @@ -704,50 +709,68 @@ int QWasmEventTranslator::touchCallback(int eventType, const EmscriptenTouchEven const EmscriptenTouchPoint *touches = &touchEvent->touches[i]; - QPoint point(touches->canvasX, touches->canvasY); - window2 = eventTranslator->screen()->compositor()->windowAt(point, 5); - + QPoint point(touches->targetX, touches->targetY); + window2 = this->screen()->compositor()->windowAt(point, 5); QWindowSystemInterface::TouchPoint touchPoint; - auto cX = point.x(); - auto cY = point.y(); touchPoint.area = QRect(0, 0, 8, 8); - touchPoint.area.moveCenter(QPointF(cX,cY)); // simulate area - touchPoint.id = touches->identifier; - touchPoint.normalPosition = QPointF(cX / window2->width(), cY / window2->height()); + touchPoint.pressure = 1.0; + + const QPointF screenPos(point); + + touchPoint.area.moveCenter(screenPos); + + const auto tp = pressedTouchIds.constFind(touchPoint.id); + if (tp != pressedTouchIds.constEnd()) + touchPoint.normalPosition = tp.value(); + + QPointF normalPosition(screenPos.x() / window2->width(), + screenPos.y() / window2->height()); + + const bool stationaryTouchPoint = (normalPosition == touchPoint.normalPosition); + touchPoint.normalPosition = normalPosition; switch (eventType) { case EMSCRIPTEN_EVENT_TOUCHSTART: - touchPoint.state = Qt::TouchPointPressed; + if (tp != pressedTouchIds.constEnd()) { + touchPoint.state = (stationaryTouchPoint + ? Qt::TouchPointStationary + : Qt::TouchPointMoved); + } else { + touchPoint.state = Qt::TouchPointPressed; + } + pressedTouchIds.insert(touchPoint.id, touchPoint.normalPosition); + break; case EMSCRIPTEN_EVENT_TOUCHEND: touchPoint.state = Qt::TouchPointReleased; + pressedTouchIds.remove(touchPoint.id); break; case EMSCRIPTEN_EVENT_TOUCHMOVE: - touchPoint.state = Qt::TouchPointMoved; + touchPoint.state = (stationaryTouchPoint + ? Qt::TouchPointStationary + : Qt::TouchPointMoved); + + pressedTouchIds.insert(touchPoint.id, touchPoint.normalPosition); break; default: - Q_UNREACHABLE(); + break; } touchPointList.append(touchPoint); } - QWasmEventTranslator *wasmEventTranslator = (QWasmEventTranslator*)userData; - QFlags keyModifier = wasmEventTranslator->translatKeyModifier(touchEvent); + QFlags keyModifier = translatKeyModifier(touchEvent); + + QWindowSystemInterface::handleTouchEvent( + window2, getTimestamp(), touchDevice, touchPointList, keyModifier); - if (eventType != EMSCRIPTEN_EVENT_TOUCHCANCEL) - QWindowSystemInterface::handleTouchEvent - (window2, wasmEventTranslator->getTimestamp(), - wasmEventTranslator->touchDevice, - touchPointList, keyModifier); - else - QWindowSystemInterface::handleTouchCancelEvent(window2, wasmEventTranslator->getTimestamp(), - wasmEventTranslator->touchDevice, keyModifier); + if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL) + QWindowSystemInterface::handleTouchCancelEvent(window2, getTimestamp(), touchDevice, keyModifier); QWasmEventDispatcher::maintainTimers(); - return 1; + return 0; } quint64 QWasmEventTranslator::getTimestamp() diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.h b/src/plugins/platforms/wasm/qwasmeventtranslator.h index ba08dce946..d6043072ba 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.h +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.h @@ -61,6 +61,7 @@ public: void processEvents(); void initEventHandlers(); + int handleTouch(int eventType, const EmscriptenTouchEvent *touchEvent); Q_SIGNALS: void getWindowAt(const QPoint &point, QWindow **window); @@ -114,6 +115,8 @@ private: { Qt::Key_U, Qt::Key_Ucircumflex} }; + QMap pressedTouchIds; + private: QWindow *draggedWindow; QWindow *pressedWindow; -- cgit v1.2.3 From edf2e699856e0385746ea03fea23ec20c08c0b2c Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 13 Apr 2018 09:19:48 +0200 Subject: Don't increase the size of the layout unnecessarily when moving toolbars When the toolbar was moved from one position to another it could end up increasing the size of the saveState data due to extra lines. This removes any needless ones that should not be included. Change-Id: I1c5d094ae1405d6a82db5fcdc3cd081904706837 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qtoolbararealayout.cpp | 6 +- .../widgets/qmainwindow/saveStateSize/main.cpp | 111 +++++++++++++++++++++ .../qmainwindow/saveStateSize/saveStateSize.pro | 4 + 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 tests/manual/widgets/widgets/qmainwindow/saveStateSize/main.cpp create mode 100644 tests/manual/widgets/widgets/qmainwindow/saveStateSize/saveStateSize.pro diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 884eface3c..adc329131c 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -1078,7 +1078,11 @@ bool QToolBarAreaLayout::insertGap(const QList &path, QLayoutItem *item) void QToolBarAreaLayout::remove(const QList &path) { Q_ASSERT(path.count() == 3); - docks[path.at(0)].lines[path.at(1)].toolBarItems.removeAt(path.at(2)); + QToolBarAreaLayoutInfo &dock = docks[path.at(0)]; + QToolBarAreaLayoutLine &line = dock.lines[path.at(1)]; + line.toolBarItems.removeAt(path.at(2)); + if (line.toolBarItems.isEmpty()) + dock.lines.removeAt(path.at(1)); } void QToolBarAreaLayout::remove(QLayoutItem *item) diff --git a/tests/manual/widgets/widgets/qmainwindow/saveStateSize/main.cpp b/tests/manual/widgets/widgets/qmainwindow/saveStateSize/main.cpp new file mode 100644 index 0000000000..dbca6df454 --- /dev/null +++ b/tests/manual/widgets/widgets/qmainwindow/saveStateSize/main.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** + ** + ** 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$ + ** + ****************************************************************************/ + +// Test that the size of the saved state bytearray does not change due to moving a +// toolbar from one area to another. It should stay the same size as the first time +// it had that toolbar in it + +#include +#include +#include +#include +#include +#include +#include + +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + MainWindow() : QMainWindow() + { + auto *tb = new QToolBar(this); + tb->setObjectName("Toolbar"); + tb->addAction("Test action"); + tb->addAction("Test action"); + addToolBar(Qt::TopToolBarArea, tb); + auto *movableTb = new QToolBar(this); + movableTb->setObjectName("Movable Toolbar"); + movableTb->addAction("Test action"); + movableTb->addAction("Test action"); + addToolBar(Qt::TopToolBarArea, movableTb); + auto *widget = new QWidget; + auto *vbox = new QVBoxLayout; + auto *label = new QLabel; + label->setText("1. Click on check state size to save initial state\n" + "2. Drag the movable toolbar in the top dock area to the left area." + " Click on check state size to save moved state\n" + "3. Drag the movable toolbar from the left dock area to the top area." + " Click on check state size to compare the state sizes.\n" + "4. Drag the movable toolbar in the top dock area to the left area." + " Click on check state size to compare the state sizes.\n" + "5. Drag the movable toolbar from the left dock area to the top area." + " Click on check state size to compare the state sizes.\n"); + vbox->addWidget(label); + auto *pushButton = new QPushButton("Check state size"); + connect(pushButton, &QPushButton::clicked, this, &MainWindow::checkState); + vbox->addWidget(pushButton); + widget->setLayout(vbox); + setCentralWidget(widget); + } +public slots: + void checkState() + { + stepCounter++; + QString messageText; + if (stepCounter == 1) { + beforeMoveStateData = saveState(); + messageText = QLatin1String("Initial state saved"); + } else if (stepCounter == 2) { + afterMoveStateData = saveState(); + messageText = QLatin1String("Moved state saved"); + } else { + const int currentSaveSize = saveState().size(); + const int compareValue = (stepCounter == 4) ? afterMoveStateData.size() : beforeMoveStateData.size(); + messageText = QString::fromLatin1("%1 step %2") + .arg((currentSaveSize == compareValue) ? QLatin1String("SUCCESS") : QLatin1String("FAIL")) + .arg(stepCounter); + } + QMessageBox::information(this, "Step done", messageText); + } +private: + int stepCounter = 0; + QByteArray beforeMoveStateData; + QByteArray afterMoveStateData; +}; + +#include "main.moc" + +int main(int argc, char **argv) +{ + QApplication a(argc, argv); + MainWindow mw; + mw.show(); + return a.exec(); +} + diff --git a/tests/manual/widgets/widgets/qmainwindow/saveStateSize/saveStateSize.pro b/tests/manual/widgets/widgets/qmainwindow/saveStateSize/saveStateSize.pro new file mode 100644 index 0000000000..6ee128ed3b --- /dev/null +++ b/tests/manual/widgets/widgets/qmainwindow/saveStateSize/saveStateSize.pro @@ -0,0 +1,4 @@ +QT += widgets +TEMPLATE = app +TARGET = saveStateSize +SOURCES += main.cpp -- cgit v1.2.3 From 041296a88cdf1c57aab10b45cf675b34a2feb8fb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 15 Mar 2019 13:25:46 +0100 Subject: Fix qdoc errors in QIcon header Add missing forward declaration, fixing: src/gui/image/qicon.h:93:16: error: unknown type name 'QPainter' This apparently only happens for qdoc. Change-Id: I39e78258f16628d477b629778241c4f5031820c4 Reviewed-by: Paul Wicking --- src/gui/image/qicon.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index 6a4fc8927a..8870950982 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QIconPrivate; class QIconEngine; +class QPainter; class Q_GUI_EXPORT QIcon { -- cgit v1.2.3 From c306663990ba86814717b1edc770ddd221fce722 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 15 Mar 2019 09:38:03 +0100 Subject: Fix qdoc errors in QProcess header Split apart the #ifdef so that qdoc on non-Windows systems sees Q_SECURITY_ATTRIBUTES and Q_STARTUPINFO, fixing: LOG Build & visit PCH for QtCore src/corelib/io/qprocess.h:204:9: error: unknown type name 'Q_SECURITY_ATTRIBUTES' src/corelib/io/qprocess.h:205:9: error: unknown type name 'Q_SECURITY_ATTRIBUTES' src/corelib/io/qprocess.h:210:9: error: unknown type name 'Q_STARTUPINFO' Change-Id: I50b4ee6113da4cd49b6b08b84e6e6590438c5573 Reviewed-by: Paul Wicking --- src/corelib/io/qprocess.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index 42cf769698..a2e3c01f7c 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -48,22 +48,24 @@ QT_REQUIRE_CONFIG(processenvironment); -QT_BEGIN_NAMESPACE - -class QProcessPrivate; - -#if !defined(Q_OS_WIN) -typedef qint64 Q_PID; -#else -QT_END_NAMESPACE +#ifdef Q_OS_WIN typedef struct _PROCESS_INFORMATION *Q_PID; +#endif + +#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) typedef struct _SECURITY_ATTRIBUTES Q_SECURITY_ATTRIBUTES; typedef struct _STARTUPINFOW Q_STARTUPINFO; -QT_BEGIN_NAMESPACE #endif +QT_BEGIN_NAMESPACE + +class QProcessPrivate; class QProcessEnvironmentPrivate; +#ifndef Q_OS_WIN +typedef qint64 Q_PID; +#endif + class Q_CORE_EXPORT QProcessEnvironment { public: -- cgit v1.2.3 From 4554fa7b191566df0a6c07e686c642c78eb88095 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 15 Mar 2019 13:27:44 +0100 Subject: Fix some qdoc warnings src/network/ssl/qsslsocket.cpp:1501: (qdoc) warning: Can't link to 'QSslConfiguration::defaultCaCertificates()' src/network/ssl/qsslsocket.cpp:1482: (qdoc) warning: Can't link to 'QSslConfiguration::defaultCaCertificates()' src/network/ssl/qsslsocket.cpp:1513: (qdoc) warning: Can't link to 'QSslConfiguration::defaultCaCertificates()' src/network/ssl/qsslsocket.cpp:1119: (qdoc) warning: Can't link to 'QSslConfiguration::setDefaultCiphers()' src/network/ssl/qsslsocket.cpp:1119: (qdoc) warning: Can't link to 'QSslConfiguration::defaultCiphers()' src/gui/opengl/qopengltexture.cpp:4137: (qdoc) warning: Can't link to 'setComparisonFunction()' src/widgets/dialogs/qfilesystemmodel.cpp:1215: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/widgets/graphicsview/qgraphicswidget.cpp:1229: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/widgets/graphicsview/qgraphicsscene.cpp:3313: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/gui/painting/qpaintengine_raster.cpp:3438: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/widgets/widgets/qtextedit.cpp:2544: (qdoc) warning: Overrides a previous doc src/widgets/widgets/qplaintextedit.cpp:2932: (qdoc) warning: (The previous doc is here) Change-Id: I0c68c59a87eb6a5d9e974f857af6aca0c6e0672d Reviewed-by: Paul Wicking --- src/gui/opengl/qopengltexture.cpp | 2 +- src/gui/painting/qpaintengine_raster.cpp | 2 +- src/network/ssl/qsslsocket.cpp | 8 ++++---- src/widgets/graphicsview/qgraphicsscene.cpp | 3 +++ src/widgets/graphicsview/qgraphicswidget.cpp | 3 +++ src/widgets/itemviews/qabstractitemview.cpp | 3 +++ src/widgets/widgets/qplaintextedit.cpp | 2 +- 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 5b7956d31e..e04a00e592 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -4114,7 +4114,7 @@ QOpenGLTexture::DepthStencilMode QOpenGLTexture::depthStencilMode() const */ -/* +/*! \since 5.5 Sets the texture comparison function on this texture to \a function. The texture diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 0f5c7756ad..d3404c6575 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3436,7 +3436,7 @@ bool QRasterPaintEngine::requiresPretransformedGlyphPositions(QFontEngine *fontE } /*! - Indicates whether glyph caching is supported by the font engine + Returns whether glyph caching is supported by the font engine \a fontEngine with the given transform \a m applied. */ bool QRasterPaintEngine::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index cf8a472606..e164217e4e 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1128,8 +1128,8 @@ QList QSslSocket::peerCertificateChain() const handshake phase begins. \sa QSslConfiguration::ciphers(), QSslConfiguration::setCiphers(), - QSslConfiguration::setDefaultCiphers(), - QSslConfiguration::defaultCiphers(), + QSslConfiguration::setCiphers(), + QSslConfiguration::ciphers(), QSslConfiguration::supportedCiphers() */ QSslCipher QSslSocket::sessionCipher() const @@ -1489,7 +1489,7 @@ QList QSslSocket::caCertificates() const Each SSL socket's CA certificate database is initialized to the default CA certificate database. - \sa QSslConfiguration::defaultCaCertificates(), addCaCertificates(), + \sa QSslConfiguration::caCertificates(), addCaCertificates(), addDefaultCaCertificate() */ bool QSslSocket::addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat encoding, @@ -1515,7 +1515,7 @@ void QSslSocket::addDefaultCaCertificate(const QSslCertificate &certificate) SSL socket's CA certificate database is initialized to the default CA certificate database. - \sa QSslConfiguration::defaultCaCertificates(), addCaCertificates() + \sa QSslConfiguration::caCertificates(), addCaCertificates() */ void QSslSocket::addDefaultCaCertificates(const QList &certificates) { diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 8bdce4af8b..19d9f25307 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -3324,6 +3324,9 @@ void QGraphicsScene::advance() \l{QWidget::}{enterEvent()} and \l{QWidget::}{leaveEvent()}. Use this function to obtain those events instead. + Returns \c true if \a event has been recognized and processed; otherwise, + returns \c false. + \sa contextMenuEvent(), keyPressEvent(), keyReleaseEvent(), mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), focusInEvent(), focusOutEvent() diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index f69faa7572..ad3be5766d 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -1232,6 +1232,9 @@ QVariant QGraphicsWidget::propertyChange(const QString &propertyName, const QVar event() or in any of the convenience functions; you should not have to reimplement this function in a subclass of QGraphicsWidget. + Returns \c true if \a event has been recognized and processed; otherwise, + returns \c false. + \sa QGraphicsItem::sceneEvent() */ bool QGraphicsWidget::sceneEvent(QEvent *event) diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 59d3ed1d15..95631ffa5f 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1689,6 +1689,9 @@ bool QAbstractItemView::event(QEvent *event) This? mode, if the given \a event is a QEvent::ToolTip,or a QEvent::WhatsThis. It passes all other events on to its base class viewportEvent() handler. + + Returns \c true if \a event has been recognized and processed; otherwise, + returns \c false. */ bool QAbstractItemView::viewportEvent(QEvent *event) { diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 363422ac74..dc8765ad88 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -2930,7 +2930,7 @@ bool QPlainTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options) #endif /*! - \fn bool QTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options) + \fn bool QPlainTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options) \since 5.13 \overload -- cgit v1.2.3