summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Q(Untyped)Bindable: Print warnings when operations failFabian Kosmale2021-05-031-0/+22
| | | | | | | | | Instead of silently failing, we now print an explanatory warning to aid with debugging. Task-number: QTBUG-89512 Change-Id: I36dd2ce452af12d0523c19286919095e366bd390 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QJniObject: add callStatic[Object]Method overloads for jmethodIDIvan Solovev2021-05-031-0/+167
| | | | | | | | | | | | This patch extends the QJniObject::callStatic[Object]Method functions with the overload which accepts a jmethodID parameter. This can be convenient when the method id is already cached and you do not want to query the method by its name and signature. Task-number: QTBUG-92952 Change-Id: Ib0852a5a27da2a244ac63112784751ef9e32cfa5 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QJniEnvironment: extend APIIvan Solovev2021-05-032-0/+74
| | | | | | | | | | | | | | This patch adds some convenience methods to QJniEnvironment API: * an overload of registerNativeMethods() that accepts jclass instead of const char *className. * a findMethod() function is added to query a methodID of a static or nonstatic method by its name and signature. Task-number: QTBUG-92952 Change-Id: Ib1bc892decea97e625c4822888b6183af6edd6dc Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Fix namespace error of std::source_location under C++20Zhang Xiang2021-04-291-1/+11
| | | | | | | | | | | | | | | | | | | | With C++20 standard, src/corelib/kernel/qproperty.h of Qt Base cannot be compiled at line 100: QPropertyBindingSourceLocation( const std::experimental::source_location &cppLocation ) The reason is that source_location has been merged into namespace std since C++20, and the header file has also been change from <experimental/source_location> to <source_location>. The problem can be avoided by define a constant. Fixes: QTBUG-93270 Change-Id: I46b4daac6ea20f9623b43746880500d41396afb2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix QJniObject templates implementationsAssam Boudjelthia2021-04-231-12/+14
| | | | | | | | | | | | | Define the template calls in the header to allow for better type handling and checking with constexpr and avoid overuse of macros. Depending on the type provided in the QJniObject's call, the signatures and the correct JNI function variant is used. If a type is not supported a static_assert throws a compiler error. Pick-to: 6.1 6.1.0 Change-Id: I8a4d3ce85e1ff76ef385633f2a68511fffd12e55 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QObjectBindableProperty: Allow signals taking a valueFabian Kosmale2021-04-221-1/+24
| | | | | | | | | | | | | If the signal takes a value, we pass the current value of the property to it. As we now use eager evaluation, accessing the current value is now possible. Change-Id: I5e6947a6575bfa8ca5143f56620c645d4750a686 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add QObjectBindableProperyt::notifyFabian Kosmale2021-04-221-0/+45
| | | | | | | | | | | This mirrors the functionality of QObjectCompatProperty::notify, and can be useful to delay notifications until a class invariant has been restored. Change-Id: I1c16a0b1537a1b53d144c8abe48e546553edf877 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QObject: port to new property systemIvan Solovev2021-04-212-2/+12
| | | | | | | | | | | | | | | Extended QObjectPrivate::ExtraData to store a pointer to its parent, and reimplemented qGetBindingStorage() function for QObjectPrivate::ExtraData. This allows to use Q_OBJECT_COMPAT_PROPERTY macro for a property, stored in QObjectPrivate::ExtraData and solves all the problems with calling a custom setter. Task-number: QTBUG-85520 Change-Id: I40e01c29430846359ef9160fa1ae97c702be9a18 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QPropertyBinding: Add sticky modeFabian Kosmale2021-04-161-0/+25
| | | | | | | | | | | A sticky QPropertyBinding is a binding that does not get removed when a write occurs. This is used in the QML engine to implement support for the QQmlPropertyData::DontRemoveBinding flag. Task-number: QTBUG-91689 Change-Id: Ib575b49abe634215318ccc7ba46212cc21eb4dad Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>