From efff8ff57a70f6de9a70e2bfda625bef86a9d6b6 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 15 Dec 2019 13:17:39 +0100 Subject: QFileSystemWatcher/win: watch also for attribute changes of directories The windows filesystemwatcher did not watch for attribute changes for directories (e.g. hidden flag) so it was not in sync with other backends. Fix it by adding FILE_NOTIFY_CHANGE_ATTRIBUTES to the watch flags when watching a directory. [ChangeLog][QtCore][QFileSystemWatcher] Fixed a bug that caused QFSW not to watch for attribute changes on Windows. Now it will correctly report when files and directories become hidden or unhidden, for example. Fixes: QTBUG-80545 Change-Id: I31767a0da899963e3940b4f5b36d1d581e6aa57c Reviewed-by: Thiago Macieira Reviewed-by: Friedemann Kleint --- src/corelib/io/qfilesystemwatcher_win.cpp | 1 + .../qfilesystemwatcher/tst_qfilesystemwatcher.cpp | 28 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 5f91ce5e3d..3b67dd61c7 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -403,6 +403,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, const QString absolutePath = isDir ? fileInfo.absoluteFilePath() : fileInfo.absolutePath(); const uint flags = isDir ? (FILE_NOTIFY_CHANGE_DIR_NAME + | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_FILE_NAME) : (FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_FILE_NAME diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index cdd1f6361e..7d88601e54 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -34,6 +34,9 @@ #include #include #include +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#include +#endif /* All tests need to run in temporary directories not used * by the application to avoid non-deterministic failures on Windows @@ -79,6 +82,9 @@ private slots: void signalsEmittedAfterFileMoved(); void watchUnicodeCharacters(); +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) + void watchDirectoryAttributeChanges(); +#endif private: QString m_tempDirPattern; @@ -813,5 +819,27 @@ void tst_QFileSystemWatcher::watchUnicodeCharacters() QTRY_COMPARE(changedSpy.count(), 1); } +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +void tst_QFileSystemWatcher::watchDirectoryAttributeChanges() +{ + QTemporaryDir temporaryDirectory(m_tempDirPattern); + QVERIFY2(temporaryDirectory.isValid(), qPrintable(temporaryDirectory.errorString())); + + QDir testDir(temporaryDirectory.path()); + const QString subDir(QString::fromLatin1("attrib_test")); + QVERIFY(testDir.mkdir(subDir)); + testDir = QDir(temporaryDirectory.path() + QDir::separator() + subDir); + + QFileSystemWatcher watcher; + QVERIFY(watcher.addPath(temporaryDirectory.path())); + FileSystemWatcherSpy changedSpy(&watcher, FileSystemWatcherSpy::SpyOnDirectoryChanged); + QCOMPARE(changedSpy.count(), 0); + QVERIFY(SetFileAttributes(reinterpret_cast(testDir.absolutePath().utf16()), FILE_ATTRIBUTE_HIDDEN) != 0); + QTRY_COMPARE(changedSpy.count(), 1); + QVERIFY(SetFileAttributes(reinterpret_cast(testDir.absolutePath().utf16()), FILE_ATTRIBUTE_NORMAL) != 0); + QTRY_COMPARE(changedSpy.count(), 2); +} +#endif + QTEST_MAIN(tst_QFileSystemWatcher) #include "tst_qfilesystemwatcher.moc" -- cgit v1.2.3 From c4a9429be7e0e927289abbe7a34c061df0c07628 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 19 Dec 2019 10:36:15 +0100 Subject: Fix developer build with clang-cl failing due exception spec Clang does seem to understand __declspec(nothrow) as used by the COM macros like STDMETHOD. Suppress the warning, fixing errors like: qwindowsfontenginedirectwrite.cpp(105,24): error: 'AddBeziers' is missing exception specification '__attribute__((nothrow))' [-Werror,-Wmicrosoft-exception-spec] Task-number: QTBUG-63512 Change-Id: If582cb0c12c62a7d12c4ae702747aac1f735db3c Reviewed-by: Oliver Wolff --- .../fontdatabases/windows/qwindowsfontenginedirectwrite.cpp | 3 +++ src/plugins/platforms/windows/qwindowscombase.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index e796c18e79..bc34a77e08 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -62,6 +62,9 @@ QT_BEGIN_NAMESPACE +// Clang does not consider __declspec(nothrow) as nothrow +QT_WARNING_DISABLE_CLANG("-Wmicrosoft-exception-spec") + // Convert from design units to logical pixels #define DESIGN_TO_LOGICAL(DESIGN_UNIT_VALUE) \ QFixed::fromReal((qreal(DESIGN_UNIT_VALUE) / qreal(m_unitsPerEm)) * fontDef.pixelSize) diff --git a/src/plugins/platforms/windows/qwindowscombase.h b/src/plugins/platforms/windows/qwindowscombase.h index 45cba9c68b..bb4b295395 100644 --- a/src/plugins/platforms/windows/qwindowscombase.h +++ b/src/plugins/platforms/windows/qwindowscombase.h @@ -107,6 +107,9 @@ private: ULONG m_ref; }; +// Clang does not consider __declspec(nothrow) as nothrow +QT_WARNING_DISABLE_CLANG("-Wmicrosoft-exception-spec") + QT_END_NAMESPACE #endif // QWINDOWSCOMBASE_H -- cgit v1.2.3 From c584380c6901b1bcd9f8100fa1087b09d3cb023d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 10 Jan 2020 13:20:42 +0100 Subject: Windows QPA: Update documentation on command line options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sort alphabetically and add recent relevant options with version information. Change-Id: I10c8cc82ce357775ed68cb811a0c906cd38633a5 Reviewed-by: Tor Arne Vestbรธ --- src/gui/kernel/qguiapplication.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bdcea275c3..2b3299f745 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -605,8 +605,13 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME The following parameters are available for \c {-platform windows}: \list + \li \c {altgr}, detect the key \c {AltGr} found on some keyboards as + Qt::GroupSwitchModifier (since Qt 5.12). \li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and \c none disables them. + + \li \c {dpiawareness=[0|1|2} Sets the DPI awareness of the process + (see \l{High DPI Displays}, since Qt 5.4). \li \c {fontengine=freetype}, uses the FreeType font engine. \li \c {menus=[native|none]}, controls the use of native menus. @@ -616,10 +621,23 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME provide hover signals. They are mainly intended for Qt Quick. By default, they will be used if the application is not an instance of QApplication or for Qt Quick Controls 2 - applications. + applications (since Qt 5.10). - \li \c {altgr}, detect the key \c {AltGr} found on some keyboards as - Qt::GroupSwitchModifier. + \li \c {nocolorfonts} Turn off DirectWrite Color fonts + (since Qt 5.8). + + \li \c {nodirectwrite} Turn off DirectWrite fonts (since Qt 5.8). + + \li \c {nomousefromtouch} Ignores mouse events synthesized + from touch events by the operating system. + + \li \c {nowmpointer} Switches from Pointer Input Messages handling + to legacy mouse handling (since Qt 5.12). + \li \c {reverse} Activates Right-to-left mode (experimental). + Windows title bars will be shown accordingly in Right-to-left locales + (since Qt 5.13). + \li \c {tabletabsoluterange=} Sets a value for mouse mode detection + of WinTab tablets (Legacy, since Qt 5.3). \endlist The following parameter is available for \c {-platform cocoa} (on macOS): -- cgit v1.2.3 From 577d698b8e72bc0969ae7545a1a56d3a3d08bdda Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 16 Dec 2019 20:09:25 +0100 Subject: QString::isLower/isUpper: redo the implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QStringIterator rather than indexed loops. This fixes handling of non-BMP code points (which may be lower or uppercase, see the test). Change also the semantics of the functions, adopting Unicode ยง3.13 definitions: a string is lowercase/uppercase if it's equal to its own toLower/toUpper folding. As a side effect, empty strings are now correctly reported to be lowercase AND uppercase. [ChangeLog][Important Behavior Changes] The semantics of QString::isLower() and QString::isUpper() have been changed to match the Unicode specification. Now lowercase (resp. uppercase) strings are allowed to contain any character; a string is considered lowercase (resp. uppercase) if it's equal to its own toLower() (resp. toUpper()) folding. Previously, a non-letter character would make the string not lowercase nor uppercase, and the mere presence of an uppercase (resp. lowercase) letter would make isLower() (resp. isUpper()) return false, even if the letter wouldn't change under case folding. As a consequence, now empty strings are lowercase and uppercase. [ChangeLog][QtCore][QString] Fixed a number of bugs of QString::isLower() and QString::isUpper(). Empty strings are now correctly reported to be lowercase (resp. uppercase), and strings containing code points outside the BMP are now correctly handled. Note that the behavior of these functions has also been changed. Change-Id: Iba1398279a072399a9f21295fe75f6e414f3f813 Reviewed-by: Thiago Macieira --- src/corelib/text/qstring.cpp | 44 +++++---- tests/auto/corelib/text/qstring/tst_qstring.cpp | 119 ++++++++++++++++-------- 2 files changed, 105 insertions(+), 58 deletions(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index b929786255..fa8b5cf3f8 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -5109,21 +5109,25 @@ bool QString::endsWith(QChar c, Qt::CaseSensitivity cs) const } /*! - Returns \c true if the string only contains uppercase letters, - otherwise returns \c false. + Returns \c true if the string is uppercase, that is, it's identical + to its toUpper() folding. + + Note that this does \e not mean that the string does not contain + lowercase letters (some lowercase letters do not have a uppercase + folding; they are left unchanged by toUpper()). + For more information, refer to the Unicode standard, section 3.13. + \since 5.12 - \sa QChar::isUpper(), isLower() + \sa QChar::toUpper(), isLower() */ bool QString::isUpper() const { - if (isEmpty()) - return false; + QStringIterator it(*this); - const QChar *d = data(); - - for (int i = 0, max = size(); i < max; ++i) { - if (!d[i].isUpper()) + while (it.hasNext()) { + uint uc = it.nextUnchecked(); + if (qGetProp(uc)->cases[QUnicodeTables::UpperCase].diff) return false; } @@ -5131,21 +5135,25 @@ bool QString::isUpper() const } /*! - Returns \c true if the string only contains lowercase letters, - otherwise returns \c false. + Returns \c true if the string is lowercase, that is, it's identical + to its toLower() folding. + + Note that this does \e not mean that the string does not contain + uppercase letters (some uppercase letters do not have a lowercase + folding; they are left unchanged by toLower()). + For more information, refer to the Unicode standard, section 3.13. + \since 5.12 - \sa QChar::isLower(), isUpper() + \sa QChar::toLower(), isUpper() */ bool QString::isLower() const { - if (isEmpty()) - return false; + QStringIterator it(*this); - const QChar *d = data(); - - for (int i = 0, max = size(); i < max; ++i) { - if (!d[i].isLower()) + while (it.hasNext()) { + uint uc = it.nextUnchecked(); + if (qGetProp(uc)->cases[QUnicodeTables::LowerCase].diff) return false; } diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 2108e99f20..7ea93a87d6 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -459,8 +459,8 @@ private slots: void trimmed(); void toUpper(); void toLower(); - void isUpper(); - void isLower(); + void isLower_isUpper_data(); + void isLower_isUpper(); void toCaseFolded(); void rightJustified(); void leftJustified(); @@ -2311,44 +2311,83 @@ void tst_QString::toLower() #endif // icu } -void tst_QString::isUpper() -{ - QVERIFY(!QString().isUpper()); - QVERIFY(!QString("").isUpper()); - QVERIFY(QString("TEXT").isUpper()); - QVERIFY(!QString("text").isUpper()); - QVERIFY(!QString("Text").isUpper()); - QVERIFY(!QString("tExt").isUpper()); - QVERIFY(!QString("teXt").isUpper()); - QVERIFY(!QString("texT").isUpper()); - QVERIFY(!QString("TExt").isUpper()); - QVERIFY(!QString("teXT").isUpper()); - QVERIFY(!QString("tEXt").isUpper()); - QVERIFY(!QString("tExT").isUpper()); - QVERIFY(!QString("@ABYZ[").isUpper()); - QVERIFY(!QString("@abyz[").isUpper()); - QVERIFY(!QString("`ABYZ{").isUpper()); - QVERIFY(!QString("`abyz{").isUpper()); -} - -void tst_QString::isLower() -{ - QVERIFY(!QString().isLower()); - QVERIFY(!QString("").isLower()); - QVERIFY(QString("text").isLower()); - QVERIFY(!QString("Text").isLower()); - QVERIFY(!QString("tExt").isLower()); - QVERIFY(!QString("teXt").isLower()); - QVERIFY(!QString("texT").isLower()); - QVERIFY(!QString("TExt").isLower()); - QVERIFY(!QString("teXT").isLower()); - QVERIFY(!QString("tEXt").isLower()); - QVERIFY(!QString("tExT").isLower()); - QVERIFY(!QString("TEXT").isLower()); - QVERIFY(!QString("@ABYZ[").isLower()); - QVERIFY(!QString("@abyz[").isLower()); - QVERIFY(!QString("`ABYZ{").isLower()); - QVERIFY(!QString("`abyz{").isLower()); +void tst_QString::isLower_isUpper_data() +{ + QTest::addColumn("string"); + QTest::addColumn("isLower"); + QTest::addColumn("isUpper"); + + int row = 0; + QTest::addRow("lower-and-upper-%02d", row++) << QString() << true << true; + QTest::addRow("lower-and-upper-%02d", row++) << QString("") << true << true; + QTest::addRow("lower-and-upper-%02d", row++) << QString(" ") << true << true; + QTest::addRow("lower-and-upper-%02d", row++) << QString("123") << true << true; + QTest::addRow("lower-and-upper-%02d", row++) << QString("@123$#") << true << true; + QTest::addRow("lower-and-upper-%02d", row++) << QString("๐„ž๐„ด๐†โ™ซ") << true << true; // Unicode Block 'Musical Symbols' + // not foldable + QTest::addRow("lower-and-upper-%02d", row++) << QString("๐šŠ๐š‹๐šŒ๐š๐šŽ") << true << true; // MATHEMATICAL MONOSPACE SMALL A, ... E + QTest::addRow("lower-and-upper-%02d", row++) << QString("๐™–,๐™—,๐™˜,๐™™,๐™š") << true << true; // MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL A, ... E + QTest::addRow("lower-and-upper-%02d", row++) << QString("๐—”๐—•๐—–๐——๐—˜") << true << true; // MATHEMATICAL SANS-SERIF BOLD CAPITAL A, ... E + QTest::addRow("lower-and-upper-%02d", row++) << QString("๐€,๐,๐‚,๐ƒ,๐„") << true << true; // MATHEMATICAL BOLD CAPITAL A, ... E + + row = 0; + QTest::addRow("only-lower-%02d", row++) << QString("text") << true << false; + QTest::addRow("only-lower-%02d", row++) << QString("ร aa") << true << false; + QTest::addRow("only-lower-%02d", row++) << QString("รธรฆรŸ") << true << false; + QTest::addRow("only-lower-%02d", row++) << QString("text ") << true << false; + QTest::addRow("only-lower-%02d", row++) << QString(" text") << true << false; + QTest::addRow("only-lower-%02d", row++) << QString("hello, world!") << true << false; + QTest::addRow("only-lower-%02d", row++) << QString("123@abyz[") << true << false; + QTest::addRow("only-lower-%02d", row++) << QString("`abyz{") << true << false; + QTest::addRow("only-lower-%02d", row++) << QString("a๐™–a|b๐™—b|c๐™˜c|d๐™™d|e๐™še") << true << false; // MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL A, ... E + QTest::addRow("only-lower-%02d", row++) << QString("๐จ") << true << false; // DESERET SMALL LETTER LONG I + // uppercase letters, not foldable + QTest::addRow("only-lower-%02d", row++) << QString("text๐—”text") << true << false; // MATHEMATICAL SANS-SERIF BOLD CAPITAL A + + row = 0; + QTest::addRow("only-upper-%02d", row++) << QString("TEXT") << false << true; + QTest::addRow("only-upper-%02d", row++) << QString("ร€AA") << false << true; + QTest::addRow("only-upper-%02d", row++) << QString("ร˜ร†แบž") << false << true; + QTest::addRow("only-upper-%02d", row++) << QString("TEXT ") << false << true; + QTest::addRow("only-upper-%02d", row++) << QString(" TEXT") << false << true; + QTest::addRow("only-upper-%02d", row++) << QString("HELLO, WORLD!") << false << true; + QTest::addRow("only-upper-%02d", row++) << QString("123@ABYZ[") << false << true; + QTest::addRow("only-upper-%02d", row++) << QString("`ABYZ{") << false << true; + QTest::addRow("only-upper-%02d", row++) << QString("A๐€A|B๐B|C๐‚C|D๐ƒD|E๐„E") << false << true; // MATHEMATICAL BOLD CAPITAL A, ... E + QTest::addRow("only-upper-%02d", row++) << QString("๐€") << false << true; // DESERET CAPITAL LETTER LONG I + // lowercase letters, not foldable + QTest::addRow("only-upper-%02d", row++) << QString("TEXT๐šŠTEXT") << false << true; // MATHEMATICAL MONOSPACE SMALL A + + row = 0; + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("Text") << false << false; + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("tExt") << false << false; + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("teXt") << false << false; + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("texT") << false << false; + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("TExt") << false << false; + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("teXT") << false << false; + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("tEXt") << false << false; + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("tExT") << false << false; + // not foldable + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("TEXT๐šŠtext") << false << false; // MATHEMATICAL MONOSPACE SMALL A + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("text๐—”TEXT") << false << false; // MATHEMATICAL SANS-SERIF BOLD CAPITAL A + // titlecase, foldable + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("abcวˆdef") << false << false; // LATIN CAPITAL LETTER L WITH SMALL LETTER J + QTest::addRow("not-lower-nor-upper-%02d", row++) << QString("ABCวˆDEF") << false << false; // LATIN CAPITAL LETTER L WITH SMALL LETTER J +} + +void tst_QString::isLower_isUpper() +{ + QFETCH(QString, string); + QFETCH(bool, isLower); + QFETCH(bool, isUpper); + + QCOMPARE(string.isLower(), isLower); + QCOMPARE(string.toLower() == string, isLower); + QVERIFY(string.toLower().isLower()); + + QCOMPARE(string.isUpper(), isUpper); + QCOMPARE(string.toUpper() == string, isUpper); + QVERIFY(string.toUpper().isUpper()); } void tst_QString::toCaseFolded() -- cgit v1.2.3 From 2f536411d8d6918a8fed53198190d60fe188b0a4 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 6 Jan 2020 11:51:07 +0100 Subject: QRegularExpression: minor doc fixes Amends d24a1d4323e73400ef4ecca99e03ff0f41c60389 Change-Id: I108f85b174e21ef71bf269fb9f6725972e76f107 Reviewed-by: David Faure --- src/corelib/text/qregularexpression.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index 8627cbba4f..67be67c243 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -463,10 +463,10 @@ QT_BEGIN_NAMESPACE \c{\xHHHH} with more than 2 digits. A pattern like \c{\x2022} neeeds to be ported to \c{\x{2022}}, or it will match a space (\c{0x20}) followed by the string \c{"22"}. In general, it is highly recommended to always use - curly braces with the \c{\\x} escape, no matter the amount of digits + curly braces with the \c{\x} escape, no matter the amount of digits specified. - \li A 0-to-n quantification like \c{{,n}} needs to be ported to c{{0,n}} to + \li A 0-to-n quantification like \c{{,n}} needs to be ported to \c{{0,n}} to preserve semantics. Otherwise, a pattern such as \c{\d{,3}} would actually match a digit followed by the exact string \c{"{,3}"}. -- cgit v1.2.3 From 3d1e257770e8c79c7cd9a08f9caf1bd8395cb10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 31 Oct 2019 09:33:40 +0100 Subject: Wasm: Support event loop wakeup from secondary threads Minimal fix for the missing wakeup issue, in leu of a new event loop implementation. So far, emscripten_async_run_in_main_runtime_thread_ looks to be our option for scheduling calls on the main thread. This function is available on emsdk 1.38.22 and higher. Requires making from QEventDispatcherUNIX::wakeUp() non-final. The future event dispatcher implementation will not inherit QEventDispatcherUNIX, so this is a temporary change. Fixes: QTBUG-75793 Task-number: QTBUG-76007 Change-Id: Ie6f6ee6f7674206fc0673a4fe866ac614432ab65 Reviewed-by: Lorn Potter --- src/corelib/kernel/qeventdispatcher_unix_p.h | 2 +- .../platforms/wasm/qwasmeventdispatcher.cpp | 23 ++++++++++++++++++++++ src/plugins/platforms/wasm/qwasmeventdispatcher.h | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index f37edfc967..581df9242c 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -118,7 +118,7 @@ public: int remainingTime(int timerId) final; - void wakeUp() final; + void wakeUp() override; void interrupt() final; void flush() override; diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp index 41355d72ae..d89cd78b28 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp @@ -33,6 +33,14 @@ #include +#if (__EMSCRIPTEN_major__ > 1 || __EMSCRIPTEN_minor__ > 38 || __EMSCRIPTEN_minor__ == 38 && __EMSCRIPTEN_tiny__ >= 22) +# define EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD +#endif + +#ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD +#include +#endif + class QWasmEventDispatcherPrivate : public QEventDispatcherUNIXPrivate { @@ -179,3 +187,18 @@ void QWasmEventDispatcher::doMaintainTimers() emscripten_async_call(callback, this, toWaitDuration); m_currentTargetTime = newTargetTime; } + +void QWasmEventDispatcher::wakeUp() +{ +#ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD + if (!emscripten_is_main_runtime_thread()) + emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, (void*)(&QWasmEventDispatcher::mainThreadWakeUp), this); +#endif + QEventDispatcherUNIX::wakeUp(); +} + +void QWasmEventDispatcher::mainThreadWakeUp(void *eventDispatcher) +{ + emscripten_resume_main_loop(); // Service possible requestUpdate Calls + static_cast(eventDispatcher)->processEvents(QEventLoop::AllEvents); +} diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.h b/src/plugins/platforms/wasm/qwasmeventdispatcher.h index 5300b3de73..f72d92ce07 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.h +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.h @@ -51,6 +51,8 @@ public: protected: bool processEvents(QEventLoop::ProcessEventsFlags flags) override; void doMaintainTimers(); + void wakeUp() override; + static void mainThreadWakeUp(void *eventDispatcher); private: bool m_hasMainLoop = false; -- cgit v1.2.3