summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
* Add compile-time generation of JNI class namesVolker Hilsheimer2022-05-273-4/+32
| | | | | | | | | | | | | | | | | | | | | As with method signatures, register class names using template function specialization in the QtJniTypes namespace, and then declare C++ types as JNI classes with a class name string. Such classes implicitly get registered as JNI types as well. Add a QJniObject construct method (since C++ constructors that are templates cannot be explicitly instantiated with a type), and a QJniEnvironment::findClass overload. Add test coverage, also for the recently added macros for native methods. As a drive-by, change the name of the Q_JNI_DECLARE_NATIVE_METHOD macro to Q_DECLARE_JNI_NATIVE_METHOD for consistency. Change-Id: Ic19562d78da726f202b3bdf4e9354e8ad24d8bd9 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Compile-time generate a JNINativeMethod from a C functionVolker Hilsheimer2022-05-231-14/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a template function that allows us to get the method signature string from a free function, which are used as native callbacks methods from Java. Provide a macro that defines a signature object, and a JNINativeMethod object based on it, in an internal namespace so that we don't pollute the namespace with generated names. Add another macro to get the generated JNINativeMethod object based on the free function name. Lastly, add overloads to QJniEnvironment::registerNativeMethods that take a std::initializer_list of JNINativeMethods. We can now declare a free function to be a JNI native method: static bool callbackFromJava(JNIEnv *e, jobject /*thiz*/, jstring p1) { // ... } Q_JNI_DECLARE_NATIVE_METHOD(callbackFromJava); and register it with the JNI environment like this: QJniEnvironment jni; jni.registerNativeMethods(clazz, { Q_JNI_NATIVE_METHOD(callbackFromJava) }); removing a significant amount of boiler plate code. Change-Id: Ie4007b24125879fed3dae1f4d232b4aa95999b44 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QMetaType: disable conversion from smart pointer<const QObject>Giuseppe D'Angelo2022-05-211-0/+17
| | | | | | | | | | | | | | | | | | | | | QMetaType can register a converter from a smart pointer class to QObject *. The code tries to do so even if the smart pointer is actually holding a pointer to a _const_ QObject (e.g. shared_ptr<const QObject>), causing a compile error: ../src/qt5/qtbase/build/include/QtCore/../../../src/corelib/kernel/qmetatype.h:1208:32: error: invalid conversion from ‘const QObject*’ to ‘QObject*’ [-fpermissive] 1208 | return p.operator->(); | ~~~~~~~~~~~~^~ | | | const QObject* Disable the conversion if indeed the source is const qualified. Change-Id: I9e9bc5992f74131e5cfd6ece9b83d4f26d370e92 Fixes: QTBUG-103741 Pick-to: 6.2 6.3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix return value of qGlobalPostedEventsCount()Marc Mutz2022-05-181-11/+6
| | | | | | | | | | | | The unsigned return value was very un-Qt-ish, and, indeed, tst_QCoreApplication just stored the result in ints. Port to qsizetype, being the type of the expression that the function calculates. Task-number: QTBUG-103532 Change-Id: I95a81a686439b0686faad7a430adeaab66dc9e8d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make qGlobalPostedEventsCount() auto-test-exported-onlyMarc Mutz2022-05-182-0/+4
| | | | | | | | The only in-tree user outside QtCore is tst_QCoreApplication, guard the (single) test function there with QT_BUILD_INTERNAL. Change-Id: Ibc87ba76f2135cd8283acd75318f80a95e4b5c45 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove manual declarations of qGlobalPostedEventsCount()Marc Mutz2022-05-181-4/+1
| | | | | | | | | ... in favor of including qabstracteventdispatcher_p.h, where needed. Keeps the code DRY. Change-Id: I5bee2e653cb29ffac2601ff03c952a4b3adbdb9c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Return specific types for frequently used Java objectsVolker Hilsheimer2022-05-171-0/+9
| | | | | | | | | | | | | | | | | | This allows us to specialize JNI type signature templates for e.g. the context object, which in Java signatures is "android/content/Context". Introduce a Q_DECLARE_JNI_TYPE macro that takes care of the plumbing. The types declared this way live in the QtJniTypes namespace, and transparently convert from and to jobject. Since jobject is a typedef to _jobject* we cannot create a subclass. Use a "Object" superclass that we can provide a QJniObject constructor for so that we don't require the QJniObject declaration to be able to use the macro. The APIs in the QNativeInterface namespace doesn't provide source or binary compatibility guarantees, so we can change the return types. Change-Id: I4cf9fa734ec9a5550b6fddeb14ef0ffd72663f29 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Fold methods for object return type into generic methodsVolker Hilsheimer2022-05-171-0/+31
| | | | | | | | | | | | | Since we know at compile time whether the return type is an object type, we can use 'if constexpr' and auto return type in the call(Static)Method and get(Static)Field functions to call the object-type methods. This makes the object-methods conceptually obsolete, but don't declare them as deprecated as long as they are still used in submodules to avoid warning floods and build failures in -Werror configurations. Change-Id: Ic3019ed990a9252eefcb02cdb355f8a6ed6bc2ff Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1641-1117/+92
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add variadic template overloads for QJniObject/Environment methodsVolker Hilsheimer2022-05-132-17/+150
| | | | | | | | | | | | | | | | | | | | | | | | | This allows the compiler to deduce the template arguments based on the provided method parameters, which we can then pass to the methodSignature and fieldSignature helpers to generate the signature string completely at compile time. Since we can't partially specialize template member functions, replace the specializations for void methods with compile-time-if branches in the general templates. This variadic template now prevents implicit conversion from the LiteralStorage types to const char* signatures, so catch the case where such a type ends up in the parameter list. Due to overload resolution rules for constructors, we need to explicitly disable the constructor if any of the arguments is a string literal type, as we have to keep the old C-style variadic function working for such calls. Add variations that use the variadic templates to the unit tests. Change-Id: I8734664b38bae932369462330a9a03302254c33c Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QMetaType: Fix normalization on MSVC if name contains enumFabian Kosmale2022-05-121-0/+6
| | | | | | | | | | | | | | | During type normalization, we remove the struct, class and enum keywords (see the skipStructClassOrEnum function). However, we only want to do that for actual keywords, not for a name that happens to start with e.g. "enum", as in "enumerationNameSpacce". Adjust the MSVC check to still require no identifier character after the keyword, while still allowing for some remaining characters. Fixes: QTBUG-97813 Pick-to: 6.3 6.2 Change-Id: I82b873d02ff454cce4b75f2814a52a66f2268208 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove remnants of the old Intel C++ compilerThiago Macieira2022-05-111-1/+1
| | | | | | | | | | | | | We don't support it any more. I don't think it has ever properly compiled Qt 6 (and it's no longer working for me against GCC 12's libstdc++ headers). If you report a bug against it, Intel support's first question is if you can try instead the new Clang/LLVM-based oneAPI C++ compiler. So we support only that one, which identifies itself as Q_CC_CLANG. Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb57a092c8439e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Generate JNI signature strings at compile timeVolker Hilsheimer2022-05-053-0/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce an internal QtJniTypes namespace with types that allow us to concatenate string literals at compile time. This makes it possible to generate arbitrary strings based on types, which we can then use as signatures to JNI method calls. Move some of the private members of QJniObject into the QtJniTypes namespace for consistency, and to allow further template specialization by user code to make other types and their JNI signature string known. Remove the "Jni" prefix from names. Use the compile-time generated string in QJniObject methods that created the signature string at runtime, which involved a temporary memory allocation. Treat 'void' as a primitive type (with signature string 'V'), and remove redundant template specializations. Add a test case to verify the the strings are constructed correctly at compile time. Change-Id: I5e3895a97f7dc1b86961f7a7855b899d9203037d Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up includes involving tst_qmetatype_common.hEdward Welbourne2022-04-262-4/+4
| | | | | | | | | | | The functions it defines depend on many many types in QtCore for which it did not have a #include; both files that included it thus had to pull in QtCore to compile. Put that #include where it belongs and clean out many specific QtCore includes that it makes redundant. Change-Id: Ie9d9ec325d4879d771cb14baecb06fecbdaf62c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace uses of _qs with _s in testsSona Kurazyan2022-04-071-3/+3
| | | | | | Task-number: QTBUG-101408 Change-Id: If092a68828a1e8056259cf90d035d9a87989244b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Revert "Blacklist: test cases blacklisted in tst_QSystemSemaphore:"Pasi Petäjäjärvi2022-04-011-4/+0
| | | | | | | | | | This reverts commit 797a6ca7e6408dff12db033f2e12ae5379602f5a. Reason for revert: Fixed 98de89cc1569be25e9845fe99ada76342aa27ad9 Task-number: QTBUG-101618 Change-Id: I49c59715b8880bd89cc5cd0c8b3443a834689bab Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
* Make QUnixEventDispatcherQPA XFAIL the testVolker Hilsheimer2022-03-251-1/+1
| | | | | | | | Needed for QNX, don't be overly specific with XcbUnix. Pick-to: 6.3 6.2 Change-Id: I240313bc48d9d81d1f18f27ee11f7c9352e3e452 Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
* QProperty: Allow manual scheduling of binding notificationUlf Hermann2022-03-211-0/+16
| | | | | | | | | In some situation we want to notify even if the value didn't change. Task-number: QTBUG-101771 Pick-to: 6.2 6.3 Change-Id: I7d82a9f6e0f7d5eb48065e3f428b814939181ea8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Tests: Do not depend on transitive includesFabian Kosmale2022-03-173-0/+6
| | | | | Change-Id: Ibc6a948480a904913a5427e6408d4d296784fb4f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QObject: add another couple of tests for broken connect()Giuseppe D'Angelo2022-03-171-0/+11
| | | | | | | | | Connecting to a non-signal should fail, but apparently it doesn't on Windows+MSVC under certain conditions. Task-number: QTBUG-101761 Change-Id: I3e014660e4e5b287242e32307f677bb22ab10a39 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QObject: give some TLC to dumpRecursive()Marc Mutz2022-03-161-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In no particular order: - use the variable field width feature of QString::asprintf() to generate the indentation implicitly, instead of fill()ing a QByteArray with the desired number of spaces - just default-construct 'flags', don't assign an empty string - use qUtf16Printable() to avoid funneling UTF-16 data through 8-bit encodings - use a C++11 ranged for instead of a counted loop - remove a pointless isEmpty() guard (the loop won't execute when the children().isEmpty()) - avoid copying object->children() (returns by cref, so it's also ok to stuff it directly into the ranged for loop). Add a test. Pick-to: 6.3 Change-Id: Ie7314713cb48de7e890cdee0760c0361dd24fd18 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Blacklist: test cases blacklisted in tst_QSystemSemaphore:CI Insignificant Platforms Monitor Bot2022-03-101-0/+4
| | | | | | | | | | - initialValue on qnx Pick-to: 6.2 Pick-to: 6.3 Task-number: QTBUG-101618 Change-Id: Iea5a45690aa2e1225297c3b652d88864cf5f3ddb Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
* QProperty: fix threading issuesFabian Kosmale2022-03-101-0/+86
| | | | | | | | | | | | | | | | | | | | QObject's cache the binding status pointer to avoid TLS lookups. However, when an object is moved to a different thread, we need to update the cached pointer (as the original thread might stop and thus no longer exist, and to correctly allow setting up bindings in the object's thread). Fix this by also storing the binding status in QThreadPrivate and updating the object's binding status when moved. This does only work when the thread is already running, though. If it is not running, we instead treat the QThreadPrivate's status pointer as a pointer to a vector of pending objects. Once the QThread has been started, we check if there are pending objects, and update them at this point. Pick-to: 6.2 6.3 Fixes: QTBUG-101177 Change-Id: I0490bbbdc1a17cb5f85044ad6eb2e1a8c759d4b7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QMetaObjectBuilder: Always set Data::metatypesFabian Kosmale2022-03-021-0/+12
| | | | | | | | | | | The array of metatypes should always contain at least one entry (for the metatype of the current metaobject itself). This prevents crashes in the case of a metaobject without meta-methods and properties (as observed in Qt for Python). Pick-to: 6.2 6.3 Change-Id: I7a6fb316eea48c4852b6f1c26e0a930aeba4c799 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Core: Fix tests that did break because QProcess security fixPasi Petäjäjärvi2022-02-241-1/+1
| | | | | | | | Amends 29fceed2ffb41954a63001414bd042611f2d4980 Pick-to: 5.15 6.2 6.3 Change-Id: Ief3317a89f7be1dd1dc249297bd16e958b9e1ef2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify failure detection logic in QEventDispatcher testVolker Hilsheimer2022-02-181-17/+10
| | | | | | | | | | | | The test always fails when either the Xcb or UNIX, one of the Windows event dispatchers is used. So only test for the event dispatcher name, which then covers all platforms, including QNX and INTEGRITY (which use the UNIX event dispatcher). Pick-to: 6.3 6.2 Change-Id: I2e315831b53f823c5496ad0319319df78f064cc1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
* Make large inputs to qNextPowerOfTwo give undefined outputAllan Sandfeld Jensen2022-02-171-11/+0
| | | | | | | | | | Fixing documentation and removing tests. [ChangeLog][Important Behavior Changes] The qNextPowerOfTwo() functions now have preconditions. Change-Id: If6d5e8bee66826910e89be7cac388a1f0422ebfd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Set version for tst_qguiapplication and tst_qcoreapplicationAndreas Buhr2022-02-171-0/+5
| | | | | | | | | | | In tst_qguiapplication and tst_qcoreapplication, the application version should be set. On Android, this is done using QT_ANDROID_VERSION_CODE. Pick-to: 6.2 6.3 Change-Id: I6b473ad25092fb24df9400e0ab8fbb8ea4edbb6a Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QMetaObjectBuilder: fix addProperty() recording of the property typeThiago Macieira2022-02-161-2/+4
| | | | | | | | | | | | Issue introduced by commit 465701bb98f3c3454d15c22b8e38ab4ad8821dfc. [ChangeLog][QtCore][QMetaObjectBuilder] Fixed a bug that would cause addProperty() to use the incorrect type for the property if the property's name matched a valid type registered with QMetaType. Pick-to: 6.2 6.3 Change-Id: Ic15405335d804bdea761fffd16d402f2c9611f30 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix failures for tst_eventdispatcher on INTEGRITYTatiana Borisova2022-02-151-1/+1
| | | | | | | | | | | - New testcase tst_eventdispatcher added under commit d292f0143f0. It shows that only glib implementation works correctly. Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: I7b861a6207fcb319de362645fc8f00a8ab6cd4b9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Repair tst_qcoreapplication to not segfault on AndroidAndreas Buhr2022-02-151-2/+2
| | | | | | | | | | | | | | tst_qcoreapplication.cpp is used both in tst_qcoreapplication and tst_qguiapplication. To distinguish these two compilations, the define QT_GUI_LIB was used. This led to an error on Android, where Qt::Gui is always linked, because the Qt Android Platform Plugin needs it. This patch introduces the preprocessor define QT_QGUIAPPLICATIONTEST which is to be used only in the compilation of tst_qguiapplication. This is then used instead of QT_GUI_LIB. Change-Id: Ifa5bfacb197d68365288c1da85573106515fc6c2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Core: Remove 'properties' featureKai Köhne2022-02-141-4/+1
| | | | | | | | | | | | | Even QtCore alone cannot be built without the properties feature since Qt 5.5. While fixing this is easy, other modules like dbus, networking are also using QObject::property() and friends liberally. All in all I doubt that anybody will miss the feature (otherwise it would have been fixed in the last decade). Change-Id: Iaf3cc20bda54ee2ff3b809fac8fa82b94ecc88c0 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_QSystemSemaphore: give proper path to test-helperMårten Nordheim2022-02-121-1/+1
| | | | | | | | Amends 29fceed2ffb41954a63001414bd042611f2d4980 Pick-to: 5.15 6.2 6.3 Change-Id: Ie386d3af68e4dff84ae893cd24cb96caf2d8e08e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Cleanup tests that add test data to resources explicitlyAlexey Edelev2022-02-111-17/+0
| | | | | | | | | | | | Remove Integrity and Android specific code that explicitly adds test data to the resource files. qt_internal_add_test functions implicitly adds test data to resources for Android and Integrity platforms by default. Change-Id: Ia1d58755b47442e1953462e38606f70fec262368 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Add BUILTIN_TESTDATA option to qt_internal_add_testAlexey Edelev2022-02-111-14/+8
| | | | | | | | | | | Multiple tests use qt_internal_add_resource that copies the functionality that is already implemented inside the qt_internal_add_test function. Simplify these test by replacing the qt_internal_add_resource call with the new BUILTIN_TESTDATA option. Change-Id: I18475b817d6f87264f0de53817d6c26c5ccab4e2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix clang-cl build of tst_qobjectAllan Sandfeld Jensen2022-02-021-1/+1
| | | | | | | | Not MSVC, but pretends to be. Pick-to: 6.3 6.2 Change-Id: I5c201dd917e79a22d6ef15715bf1d3a7010d123e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QMetaType: remove call to pthread_yield()Thiago Macieira2022-01-191-3/+0
| | | | | | | | | It was Linux-only and now even Linux is complaining: tst_qmetatype.cpp:421:26: warning: ‘int pthread_yield()’ is deprecated: pthread_yield is deprecated, use sched_yield instead [-Wdeprecated-declarations] Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1eadfa301f16 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaType: remove the IsInitialized checkThiago Macieira2022-01-192-28/+11
| | | | | | | | | All primitive types are initialized and have been since at least commit 33cd680ddbaccf6139e215d851a39e657ae36394 ("New QMetaType representation"). Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1fe22dc5c8f5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qmetatype: add a few more row for QMetaType::UknknownTypeThiago Macieira2022-01-191-0/+23
| | | | | Change-Id: I0e5f6bec596a4a78bd3bfffd16cb215d7f6c6ddb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qeventdispatcher: avoid influence between test functionsAlex Trotsenko2022-01-191-0/+8
| | | | | | | | | | | | | | | | | When some test function fails (even as expected), it can leave the event dispatcher in an inconsistent state where the posted events queue might not be empty. As a result, this may break the internal logic of the next test function that is run. So, calling eventDispatcher->processEvents() after each completed function resets the event dispatcher to its initial state, which fixes the problem. Pick-to: 6.2 6.3 Change-Id: I5a54f892d09a6eca73c8fc82875ce3b9ce4a3242 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Win32: always allow the event loop to be woken up by posted eventsVolker Hilsheimer2022-01-191-3/+0
| | | | | | | | | | | | | | | | | | | We set the wakeUps atomic to prevent multiple WM_QT_SENDPOSTEDEVENTS from being posted. However, this might happen right after the event processing thread cleared the atomic, but before it processed the previous WM_QT_SENDPOSTEDEVENTS message. In that case, we end up with a set atomic and an empty event queue, resulting in the event loop to block even though there are posted QEvents. To prevent that, always reset the atomic when we handle the WM_QT_SENDPOSTEDEVENTS message. In that case, we either call sendPostedEvents, or startPostedEventsTimer. The former already resets wakeUps; reset it in the latter as well. Fixes: QTBUG-99323 Pick-to: 6.2 6.3 5.15 Change-Id: I931c02be9c42b02e8ca20daba5059cd8185f0a37 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* Add more tests for event dispatcher waking upVolker Hilsheimer2022-01-191-1/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add two tests for some problematic scenarios where the behavior is not consistent across platforms and depending on which event dispatcher is used: 1) reliably waking up the dispatcher when posting events from a worker thread. That test fails 100% of the time on Windows no matter what type of application is created. It passes reliably on Linux and macOS for both core and gui applications. 2) waking up the dispatcher when we post an event from within an event handler. That test fails 100% of the time on Windows, both with core and GUI event dispatchers. On macOS, the test fails 100% of the time with the core dispatcher, and passes 100% of the time with the GUI dispatcher. On Linux, it passes only if a Glib based event dispatcher is used; the default Unix event dispatcher (which is also the one used on macOS for core applications) fails. Task-number: QTBUG-99323 Pick-to: 6.2 6.3 5.15 Change-Id: I2489533b9f0032488707777be0512bb933669a7d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* QMetaType: add a missing check for null d_ptrThiago Macieira2022-01-182-0/+55
| | | | | | | | | | | | | Bug introduced in 6.0. This is the only unprotected d_ptr I could find. [ChangeLog][QtCore][QMetaType] Fixed a bug that would cause QMetaType::compare() and QVariant::compare() to crash on invalid meta types and variants. Pick-to: 6.2 6.3 Fixes: QTBUG-99960 Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1f7b2d146688 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove unused .qrc filesJoerg Bornemann2022-01-172-11/+0
| | | | | | | | Task-number: QTBUG-94446 Change-Id: I136d8b4ab070a832866aa50b5701fc6bd863df8a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QMetaType: Allow conversion of derived gadget types to their base typesUlf Hermann2022-01-132-2/+30
| | | | | | | | A derived gadget has an is-a relationship with its base type. It should be convertible. In fact, canConvert() already tells us it is. Change-Id: I71a5ac9afd78e88adb23b4d0e757f34077f63207 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_qeventdispatcher: fix UB in single-shot timers activationAlex Trotsenko2022-01-131-6/+6
| | | | | | | | | | | | | | | Any of these timers must be stopped before the corresponding test function completes. Otherwise, functors will operate on dangling pointers, which can lead to failures or unreliability of other tests. Fix this by setting a correct context in the QTimer::singleShot() call. Pick-to: 6.2 6.3 Change-Id: Icd23f6d9a2c6e7f33495d6badc4080a1b10c19f8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* tst_qtranslator: fix memleakMarc Mutz2022-01-031-3/+3
| | | | | | | | | | QCoreApplication::installTranslator() does not take ownership of the QTranslator. The QTranslator dtor removes itself from QCoreApplication again. Pick-to: 6.3 6.2 5.15 Change-Id: I17eb7ab350631eb32fe76af29d9a576a0efa05d8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_qsharedmemory: skip readOnly() test under asanMarc Mutz2021-12-231-0/+2
| | | | | | | | | | | The test helper is expected to crash, but when built with asan, it just fails. Skip the test in that case. Pick-to: 6.3 6.2 5.15 Change-Id: I583142f5ec623895df62498100c1a30539b149ab Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_qmetatype: fix memleaksMarc Mutz2021-12-221-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | We didn't delete the new'ed up QMetaTypeInterfaces, causing asan to complain. Fix by storing them in strong references alongside their users in a statically-allocated container. We use shared_ptr to hold them, because QMetaTypeInterface doesn't have a virtual destructor, so deleting objects of the TypeInfo types (plural!) derived from QMetaTypeInterface though a pointer to the base class is UB. The shared_ptr constructor, however, is templated, so it stores the correct call (~TypeInfo()) in its type-erased deleter. We can't use std::make_shared(), because that doesn't support aggregate initialization until C++20, so we manually new up the TypeInfos. 5.15 is not affected. Pick-to: 6.3 6.2 Change-Id: Ic7ec88c34e02a9e0dd3421848c0c0885f4756702 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Fix autotest runtime failures on INTEGRITYTatiana Borisova2021-12-163-0/+21
| | | | | | | | | | | - add test resources to binaries - link Qt::Gui to tst_qpointer for static build case Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: I311827b9c641eaf9537091b051c15f9fcbcb9f0c Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>