summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* tst_qmetatype: remove traces of compiler workarounds againMarc Mutz2021-12-163-13/+0
| | | | | | | | | Now that all platforms can deal with the full tst_QMetaType again, remove the last traces of the workaround. Pick-to: 6.3 Change-Id: I530cab8413f8b68903991b30a1f29b5871877a88 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qmetatype: remove the previous MingW workaroundMarc Mutz2021-12-161-8/+0
| | | | | | | | | | Let's see whether splitting the TUs has made the test amenable to be compiled with MinGW again. Pick-to: 6.3 Change-Id: Icde1bad20943c7648dbb119ca879bce62325bd6c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qmetatype: remove the previous clang-arm workaroundMarc Mutz2021-12-151-5/+0
| | | | | | | | | Let's see whether splitting the TUs has made the test amenable to be compiled on Clang for ARM again. Pick-to: 6.3 Change-Id: I6bf1e31189f5058dc393adefabaf3014dce4bcf2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "tst_qmetatype: Temporarily disable expensive tests on QNX"Marc Mutz2021-12-151-2/+2
| | | | | | | | | | | | | | This reverts commit 925ad7802470ab9b4fd1cce51548ccc5182eb4cc. Reason for revert: Meanwhile, the QNX VM has been assigned more resources, and the offending test function been split. Re-enable the test on QNX, to get back to previous test coverage. Fixes: QTQAINFRA-4669 Pick-to: 6.3 Change-Id: Ib085fbfa7e0d8445f007d1a9346cee3113620720 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qmetatype: factor the most expensive test into its own TUMarc Mutz2021-12-074-81/+127
| | | | | | | | | | | | | | | | The PRINT_2ARD_TEMPLATE macro expansion alone is responsible for about 50% of the compile time and RAM requirements of tst_qmetatype.cpp. By factoring it into its own TU, we reduce the maximum memory load on my machine from 4.0GiB to 2.5GiB, provided we don't parallelize the build, then we take 0.5GiB more. This is a quick-fix for the QNX build problems currently plaguing the CI. Going forward, we should probably have a better solution, whatever that may be. Task-number: QTQAINFRA-4669 Change-Id: I2732b4c25b369b15cce1c7afe222d041ecb6795a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qmetatype: move an #ifdef to the headerMarc Mutz2021-12-072-8/+8
| | | | | | | | | ... so it can be used by multiple .cpp files. Task-number: QTQAINFRA-4669 Change-Id: I7212b9b08cd3bfa44ee741ee4789d1d0024e4708 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QObject: Q_ASSERT the object type before calling a PMFThiago Macieira2021-11-271-2/+69
| | | | | | | | | | | | | | | | | | | | | | | | The old-syle signal-slot syntax had the advantage of not delivering signals to slots in derived classes after that derived class's destructor had finished running (because we called via the virtual qt_metacall). The new syntax made no checks, so a conversion from the old to the new syntax may introduce crashes or other data corruptions at runtime if the destructor had completed. This commit introduces a Q_ASSERT to print the class name that the object is not any more. Since this is in inline code, this should get enabled for users' debug modes and does not therefore depend on Qt being built in debug mode. It required some Private classes to be adapted to the new form, by exposing the public q_func() in the public: part. Pick-to: 6.2 Fixes: QTBUG-33908 Change-Id: Iccb47e5527544b6fbd75fffd16b874cdc08c1f3e Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* tst_qmetatype: Temporarily disable expensive tests on QNXFabian Kosmale2021-11-251-2/+5
| | | | | | | | | | The compiler runs out of memory and fails to compile tst_qmetatype.cpp. Set TST_QMETATYPE_BROKEN_COMPILER from a previous compiler workaround for QNX to disable the most expensive part of the test. Task-number: QTQAINFRA-4669 Change-Id: I3a99b6b790dc074e9d1db262e758555fb45e4331 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Introduce Q_APPLICATION_STATICMike Achtelik2021-11-183-0/+74
| | | | | | | | | | | | | | QObjects must be deleted if the QCoreApplication is being destroyed. This was previously done by implementing custom code in qtbase and other modules. So unify it and introduce a Q_APPLICATION_STATIC, based on the Q_GLOBAL_STATIC, which centralises the logic. Since we still have a few remaining living QObjects, this comes in handy to fix those as well. Task-number: QTBUG-84234 Change-Id: I3040a2280ff56291f2b1c39948c06a23597865c4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qvariant: fix -Wclass-memaccessMarc Mutz2021-11-161-1/+1
| | | | | | | | The source was already protected, but the destination wasn't. Pick-to: 6.2 Change-Id: I300f19c3e65abd8bc1eef4309aefa11852d1c049 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Android: check if objectClass() is not null in registerNativeMethods()Assam Boudjelthia2021-11-152-12/+48
| | | | | | | | | | | | In case the class doens't have a default constructor, checking for object.isValid() will give false because the object won't be created, however, the class could still be loaded and we could have a valid jclass. Pick-to: 6.2 Fixes: QTBUG-96069 Change-Id: I8d59e26d9d7c0e8e363ce443937091a374a24473 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Include qproperty.h where neededMarc Mutz2021-11-042-0/+2
| | | | | | | Don't rely on transitive include from qobject.h, which will go away. Change-Id: I99dd97ff4fb1d0632d040daab0bffa2d7b85d3ae Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QVariant: suppress warning about memcpying over QVariantThiago Macieira2021-10-211-1/+1
| | | | | | | tst_qvariant.cpp:3624:15: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘class QVariant’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess] Change-Id: Ic17a33f599b844d8ab5dfffd16aafcbd74823696 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QObjectCompatProperty: Add support for custom gettersIevgenii Meshcheriakov2021-10-201-1/+56
| | | | | | | | | | Add additional template argument to QObjectCompatProperty to specify a custom getter. This may be useful for classes like QAbstractProxyModelPrivate the need to customize property getters. Task-number: QTBUG-89655 Change-Id: I34fe4bdebbbf1446aff60bd20a946454607f52d5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compile Private API autotests for INTEGRITYTatiana Borisova2021-10-201-3/+1
| | | | | | | | | | | | | | | | | | | | | - GHS's __PRETTY_FUNCTION__ (used by QT as Q_FUNC_INFO) doesn't have spaces round the = operator when indicating the type of the template parameter. The compilation error: qt5/qtbase/src/corelib/kernel/qmetatype.h", line 2104: note #3316-D: cannot access position 53 in array of 49 elements constexpr const char *begin = func + prefix; ^ detected during: instantiation of "auto QtPrivate::typenameHelper<T>() [with T=void]" at line 2186 Task-number: QTBUG-97087 Pick-to: 6.2 Change-Id: I33e61f5d54a61944a5aecf07d149a8dee0ef1e5d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Re-enable QT_NO_NARROWING_CONVERSIONS_IN_CONNECT for QtGiuseppe D'Angelo2021-10-131-0/+5
| | | | | | | | | | This define used to be set for the entirety of the Qt build but was lost during the qmake->CMake transition. Re-enable it. Change-Id: Idc4cb6ada485158559485b60f62f76439550b255 Pick-to: 6.2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Compile private Qt APIs autotests for INTEGRITYTatiana Borisova2021-10-051-0/+1
| | | | | | | | | | - getgrgid/getpwuid are not supported - the default constructor of "ObserverOrUninit" must be referenced for GHS compiler Task-number: QTBUG-96176 Pick-to: 6.2 Change-Id: I24093da76e116aba4b87a8f5c5763b03d082a2cd Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove checks for features available in C++17Ievgenii Meshcheriakov2021-10-021-4/+0
| | | | | | | | | | This patch removes most of the checks that are made using C++20 __cpp_* macros for features available in C++17 and earlier. Library feature check macros (__cpp_lib_*) are unaffected. Change-Id: I557b2bd0d4ff09b13837555e9880eb28e0355f64 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Assume that <variant> header is always presentIevgenii Meshcheriakov2021-10-011-4/+0
| | | | | | | | | This header is a C++17 feature that is already used unconditionally in qtypeinfo.h. Change-Id: I26330d298e95102f3e94c0c69fc95c1025666eb4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove checks for C++ standard versions C++17 and belowIevgenii Meshcheriakov2021-10-012-3/+3
| | | | | | | | | | | Qt requires a compiler that support C++17 thus __cplusplus is always 201703L or higher. This patch removes checks for __cplusplus value that always succeed. Change-Id: I4b830683ecefab8f913d8b09604086d53209d2e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qmetatype: Fix operator< detection for std::optionalFabian Kosmale2021-09-211-0/+2
| | | | | | | | | | Amends ca54b741d6edda24773137aacee229db31dd3585. operator< is not constrained in MSVC's standard library, either. Pick-to: 6.2 Fixes: QTBUG-96690 Change-Id: Ibcbb9e53a1f9e8b13786f6d8c01489c61d8d2d7f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Compile autotests for IntegrityTatiana Borisova2021-09-204-6/+20
| | | | | | | | | - process environment/DNS are OFF for INTEGRITY Task-number: QTBUG-96176 Pick-to: 6.2 Change-Id: I189a97f88c96a428586c31a66b8d250e04482900 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove conditioning on Android embeddedEdward Welbourne2021-09-173-4/+4
| | | | | | | | It is no longer handled separately from Android. This effectively reverts commit 6d50f746fe05a7008b63818e77784dd0c99270a1 Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Add missing dependencies of tests on their helper programsEdward Welbourne2021-09-172-10/+9
| | | | | | | | | | | | | | | | | This ensures that a command such as $ ninja tst_qlocale && ninja tst_qlocale_check will automagically build the syslocaleapp program that the test runs from a subtest. Similar for testlib's selftests and tst_QProcess. As a drive-by, pruned some legacy comments from when CMakeLists.txt files were generated from .pro files. Change-Id: I67691a8175aaef124d4104cf1898193993408bdf Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Q_DECLARE_INTERFACE: delete unspecialized qobject_interface_iid()Thiago Macieira2021-09-071-2/+0
| | | | | | | | Instead of making it return a non-useful nullptr. Change-Id: Ie72b0dd0fbe84d2caae0fffd16a245cce5ea65f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QObject::connect(): fail to connect to a functor if UniqueConnection is passedGiuseppe D'Angelo2021-08-271-2/+3
| | | | | | | | | | | | | | | | | | | | | The connect() documentation makes it clear that UniqueConnection does not work with free functions / function objects and the like; only with actual PMFs. Rather than silently *ignoring* the flag, be vocal about its presence by warning, and make the connection fail (as the user has passed an illegal argument). [ChangeLog][QtCore][QObject] QObject::connect() now will refuse to connect a signal to a free function / function object if UniqueConnection is passed. Note that UniqueConnection has never worked for such connections -- the flag was simply ignored, and they were established multiple times. Now, the flag is not ignored and results in a connection failure (as well as a runtime warning by Qt). Change-Id: I6509667018c74f9bd24910cde0a1b16c5f84f064 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Re-add QPropertyAlias functionalityFabian Kosmale2021-08-231-0/+17
| | | | | | | | | | | | | | | | | As QPropertyAlias was public by accident in 6.0, we have to ensure that it still works in 6.2. This re-adds some tests for it, and reimplements the unlinking functionality. To avoid performance regressions in hot-paths, a new unlink_fast function is added, which behaves like the old unlink: It ignores the special handling for QPropertyAlias, so that we can skip the tag check. It is only used in QPropertyObserverNodeProtector and clearDependencyObservers, where we already know the type of the observer. Fixes: QTBUG-95846 Pick-to: 6.2 Change-Id: Ifb405b8327c4d61c673b1a912ed6e169d27c2d8f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QVariant: Tolerate QObject* metatypes without QMetaObjectUlf Hermann2021-08-101-0/+48
| | | | | | | | | | QMetaType does. QVariant should do the same. Pick-to: 6.2 Change-Id: I3419276b78b3b5ce8bd144dee92685195797d568 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Daniel Nicoletti <daniel.nicoletti@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPrivateSlotBase: add empty base class optimizationMarc Mutz2021-07-291-1/+1
| | | | | | | | | | | | | | | There are few slots whose lambdas are empty; most will at least capture [this]. But there are a few in Qt examples that do, e.g. []{ qApp->quit(); }. Logging is also an example. So go the extra mile and optimize for empty functors by inheriting from them as opposed to storing them in a member variable. Change-Id: I3904f10db5ebe904ba889d29c08569edd804df3b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTranslator: Fix loading of meta catalogs from absolute .qm pathKai Köhne2021-07-151-0/+14
| | | | | | | | | | | | | | | In case of QTranslator translator; translator.load("somedir/file.qm"); and file.qm being a meta catalog file, the sub-catalogs in somedir couldn't be located, unless "somedir" was set as second argument. Pick-to: 5.15 6.1 6.2 Fixes: QTBUG-95013 Change-Id: I06103244ce2ff9800c2c64cb0c17f9bc7ef0e8de Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* tst_qtranslator: Simplify extraction of test dataKai Köhne2021-07-154-45/+5
| | | | | | | | | This makes it easier to further extend the test. The overhead this causes is negligible. Pick-to: 5.15 6.1 6.2 Change-Id: I42941879f55337268bb2914e122a5f573ab7e6f9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QObject: optimize the common case of findChildren(QString())Marc Mutz2021-07-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Outside tests, all in-tree callers of QObject::findChildren() pass no name to match, and in my experience that is also true for the vast majority of out-of-tree users. Avoid the temporary QString creation in the caller and the repeated QString::isNull() checks in the implementation by overloading findChildren() without a name argument and checking for name.isNull() only once, forking off into separate helper functions. Adjust in-tree callers that used an explicit `QString()` argument in order to pass options, which goes to show that `name` should never have been the first argument of findChilden() in the first place, even though I appreciate the symmetry with findChild() (the use-cases of which, however, are radically different). Change a `findChildren().size() == 0` call found while scanning for findChildren() calls to `!findChild()` as a drive-by. Modernize loops in the various qt_qFindChild{,ren}_helper() overloads to match how the new code looks. [ChangeLog][QtCore][QObject] Added findChildren() overload taking no name (thus optimizing this common case). Change-Id: Ifc56e5438023d079b40c67f11ae274a3e128ad5e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* CMake: Remove the usage of QT_SOURCE_TREE from testsJoerg Bornemann2021-07-121-2/+0
| | | | | | | | | | | | | | The ${QT_SOURCE_TREE}/src/network include paths of several tests are apparently not needed anymore. Remove those. tst_qfilesystementry and tst_qfreelist are the only tests that actually need to reference files in qtbase's source tree. Simply use the paths relative to the project file. Task-number: QTBUG-88090 Change-Id: Ic6f341e001338c1b07dce6e58316245bc9560c5e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QProperty: Downgrade assert in noSelfDependencies to warningFabian Kosmale2021-07-071-0/+9
| | | | | | | | | | | | | | | We call evaluateRecursive_inline in setBinding, which in turns runs the noSelfDependecies check. However, creating a binding resuting in a binding loop must not crash, but instead result in the binding entering an error state. To prevent a crash caused by the assert in debug builds of Qt, we replace the assert with a warning for now. A better approach in the future would be to ensure that we only run the check in cases where we are sure that a self-dependency is really a fatal error. Pick-to: 6.2 Change-Id: I58158864ed81fa907132a4e7d6667c9b529e7e64 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Expand a test that QVariant isn't null even when what it wraps isEdward Welbourne2021-06-241-4/+6
| | | | | | | Match the checks in the constructor test that are similar. Change-Id: Ifb62af09e31aac339f001f44bc30789330c85be6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QBindable: Use setter in setValue for QObjectCompatPropertyFabian Kosmale2021-06-171-0/+11
| | | | | | | | | | | | Directly writing to the underlying property storage has the potential of breaking all kinds of internal invariants. As we return QBindable in the public interface, we should not grant callers access to the internals of the object. Pick-to: 6.2 6.1 Change-Id: I737ff293b9d921b7de861da5ae23356c17690b78 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* Universally pass QMetaType by valueUlf Hermann2021-06-171-3/+3
| | | | | | | ... and add Qt7 TODOs where we can't because of BC. Change-Id: Idce8b677ae95231e1690ac4265dc6f06818052e7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Apple: Use POSIX IPC instead of System V in sandboxed applicationsTor Arne Vestbø2021-06-161-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | System V semaphores are not supported in sandboxed applications, so when Qt is configured with App Store compliance, or the user requests POSIX IPC explicitly, we use that instead. https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW24 As the shared memory name limit on Apple platforms is very low, we have to skip the existing logic for naming, and instead use a truncated hash of the key. This should still be fine for avoiding any collisions in practice. An explicit check for the ENAMETOOLONG error has been added to catch any cases where they key goes beyond the allowed length. Sandboxed applications also have an extra requirement that the key must include an application group identifier. This requirement has been pushed up to the user and documented, as we don't have enough information in Qt to know which identifier to use. Both tst_QSystemSemaphore and tst_QSharedMemory work as before with both sandboxed and non-sandboxed applications, after removing some assumptions in tst_QSharedMemory about System V behavior. Fixes: QTBUG-91130 Change-Id: Iaf1edb36a5d84d69e42ec31471a48d112faa8c6a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* normalizeTypeFromSignature: Beware of anonymous struct/unionFabian Kosmale2021-06-081-0/+15
| | | | | | | | | | | | | | | | | | Do a quick check whether the type name contains an anonymous type. If so, do not try to use optimized version. The simple check should still be faster than calling normalizeType unconditionally. Also only apply the faster version for clang and gcc, instead of all non-MSVC compilers. Applying it to other compilers would require further testing to handle anonymous structs. Moreover, remove space before '(', which is necessary for function pointers. Fixes: QTBUG-94213 Change-Id: I795d1964f7a68daa6f9a5f262816d51ee7728788 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QProperty: Do not involve semi-destroyed QObjects in bindingsFabian Kosmale2021-06-071-0/+30
| | | | | | | | | | | | | Once we're in ~QObject, only methods of QObject are still valid. Notably, no setter of any derived class is still valid. Thus, to be safe we must no longer react to binding changes of those properties. To ensure that this happens for QObjectCompatProperty properties, we explicitly clear the binding storage. Fixes a particles3d example crash. Change-Id: I10d2bfa5e96621ce039d751cffaf3ac41893623e Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* JNI: Add calls to get field IDsAssam Boudjelthia2021-06-042-0/+53
| | | | | | | Task-number: QTBUG-92952 Change-Id: Ie68ede4b00a411064a29925b28b1f60a84d2d678 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Add a const JNINativeMethod[] overload for registerNativeMethods()Assam Boudjelthia2021-06-021-2/+2
| | | | | | | | | | | The JNI interface expects a const JNINativeMethod[] and our wrapper takes a non-const. Also, this was causing refactoring of exisisting code with a const JNINativeMethod[] to fail because the call expects a non-const. Change-Id: If790c401650cb33fe31f93bafe41aab7714488e9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify storing of notification objectsLars Knoll2021-06-011-0/+32
| | | | | | | | | | | | | | | | | | | | QPropertyChangeHandler is a templated class and it's argument is a functor. That makes it inherently cumbersome to use the class in any context where the change handler needs to be stored. Introduce a QPropertyNotifier class that stores the functor in a std::function<void()>, and add a QProperty::addNotifier() method that can be used instead of onValueChanged(). Also make QPropertyNotifier default constructible. This significantly simplifies the code that needs to be written and makes it possible to store notifications as class members without major hassle. Fixes: QTBUG-92980 Change-Id: Id5b7baec093b9ac0467946cded943d92ad21030b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QPropertyBinding: Do not reevaluate if not installed on propertyFabian Kosmale2021-05-121-0/+27
| | | | | | | | | | | | | | | | | | | | | | Since we changed binding evaluation to be always eager, we notify and evaluate all bindings as soon as any dependency changes. This includes bindings which have been initially installed on a property, but which were later removed. With lazy evaluation, we would only notify those bindings and mark them as dirty, which is unproblematic. With eager evalution, we attempt to evaluate the binding, though. While that part is still fine, afterwards we would attempt to write the new value into the property. However, there is no property at that point, as the binding is not installed. Instead of adding a check whether the propertydataptr is null, we skip the reevaluation completely by removing the bindings observers - and thus the cause for the binding function's reevaluation. As soon as the binding is set, we reevaluate the function anyway, at which point we also capture the observers again. Task-number: QTBUG-89505 Change-Id: Ie1885ccd8be519fb96f6fde658275810b54f445a Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QProperty: Cleanup QPropertyAlias leftoversFabian Kosmale2021-05-111-84/+0
| | | | | | | | | | | | | | | This removes traces of QPropertyAlias which is internal API which is a) not really working even before this change (no compatibility with QBindableInterface due to QPropertyAlias not being derived from QUntypedPropertyData) b) not used anywhere For BIC reasons, we need to keep some methods still around until Qt 7, though. Change-Id: I5bb4735a4c88cba275dc2cc6e29a46ca09622059 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QMetaMethod: Store method constness in metaobject systemFabian Kosmale2021-05-071-2/+23
| | | | | | | | | [ChangeLog][QtCore][QMetaMethod] It is now possible to query the constness of a method with QMetaMethod::isConst. Change-Id: I8a94480b8074ef5b30555aeccd64937c4c6d97d4 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix set*Field JNI template callsAssam Boudjelthia2021-05-052-0/+164
| | | | | | | | | | | The calls were trying to pass a JNIEnv* from a QJniEnvironment using conversion operator which was removed, and weren't detected since they are templates and were missing tests. This fix that and add test cases for setField() and setStaticField() calls. Pick-to: 6.1 Change-Id: I6e1e6b7f557bbc664248ad364c48d63f58b70756 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>