summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
* Allow destruction of QWinEventNotifier in its signalAlex Trotsenko2021-09-111-1/+3
| | | | | | | | | | | | Avoid use-after-free issue in QProcess. Fixes: QTBUG-96285 Fixes: QTBUG-96359 Change-Id: I953d7a8ecaf301ec3a27db37e13748f905c3d097 Reviewed-by: Christoph Cullmann <cullmann@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> (cherry picked from commit 4e0082a9cacfdfd0c43e6105274bc0d41dd18801)
* QObject: cleanup the orphaned connection lists on destructionGiuseppe D'Angelo2021-09-061-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a signal/slot connection is broken, it gets added to the sender's list of "orphaned connections", to clean up later. This cleanup happens when the sender gets destroyed or as soon as it emits any signal. This may cause soft memory leaks in case receivers get destroyed, and the sender is a long living object and doesn't emit signals for a while (e.g. QThread). For some reason, an explicit disconnection cleans up the list (either by using the QMetaObject::Connection object, or in case of string-based connect, using a string-based disconnect). This raises lots of doubts about why having this list in the first place. Fix the soft-leak by cleaning up the orphaned connection list when destroying a receiver. Note: I still believe that we shouldn't have any "orphaned" connection list, and rather cleanup on disconnect/deletion (otherwise, emitting a signal may cause a CPU spike because it triggers a cleanup). If we allow for any "impredictability" during signal activation we're just admitting that signals/slots aren't suitable for e.g. low-latency codepaths. That's why I'm not marking the problem as fixed. Original-patch-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Task-number: QTBUG-88248 Task-number: QTBUG-87774 Change-Id: Id25f67a45dff49f740132a44d36e88740eb12070 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit c2839843f23fb5c289175cb9577981d48dd273fc) Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QTranslator: Fix loading of meta catalogs from absolute .qm pathKai Köhne2021-07-151-3/+8
| | | | | | | | | | | | | | | | 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. Fixes: QTBUG-95013 Change-Id: I06103244ce2ff9800c2c64cb0c17f9bc7ef0e8de Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> (cherry picked from commit 85eaae36f6951f03c4aeac50ca826fea5cc088bd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix binding functor addressing in QPropertyAndrei Golubev2021-07-081-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | We create the callable object at sizeof(QPBP) offset from the beginning of the memory block. However, evaluateRecursive() uses sizeof() + alignment when fetching that same callable from the memory While on 64-bit platforms this is fine due to sizeof(QPBP) == QPBP::getSizeEnsuringAlignment(), this is broken for 32-bit systems where there's actually alignment bits that follow the QPBP struct in memory (and thus we cast a random memory location to an object) (Note: QPBP is short for QPropertyBindingPrivate) To fix this, change the offset for creation and destruction of the callable to the one that uses alignment. This way, evaluateRecursive() code becomes correct Fixes: QTBUG-93890 Change-Id: Ief57051846632fa61df4b79b3f054c25062a9498 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 565864090d4ca38768c2268ffd265d2f4b49d1b0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QEventDispatcherWin32: suppress old {FD_CLOSE|FD_CONNECT} notificationsAlex Trotsenko2021-06-191-3/+10
| | | | | | | | | | | As with other network events, we must also ignore these notifications until WM_QT_ACTIVATENOTIFIERS message is received. Fixes: QTBUG-82835 Change-Id: I0740bf22e8d1cb0e8b4eba7fc1a27ffe669973ff Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit fe6d84d96e67113846801803c3ba1f20b26e123f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix crash in concurrent disconnectLars Knoll2021-06-172-21/+42
| | | | | | | | | | | | | | | This does not fix all data races that we have in the system yet. One major issue is the virtual disconnectNotify(), that can be called from any thread and thus is inherently problematic, as it can collide with the object getting destroyed at the same time in another thread. Task-number: QTBUG-88248 Change-Id: I9d841eb363b7e4f0de1657aeb8f5340d0fd55190 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 71b4d4f150bc3c904a5aceec37513ddc3cd1c150) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* cleanOrphanedConnectionsImpl: Allow to skip lockingFabian Kosmale2021-06-172-6/+26
| | | | | | | | | | | | This function is/will be used in a few places where we already have a lock. Temporarily unlocking and relocking invites all kinds of troubles. By adding a flag we can instead tell the function that we already hold the lock. Change-Id: Ibca089de61133661d5cd75290f2a55c22c5d013c Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 556fc646cfac4dca43a34f5c4a4f7e6e3ef9104d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Fix QVariant documentationKai Köhne2021-06-101-52/+51
| | | | | | | | | | | Update documentation to not reference API that is obsolete in Qt 6. Also fix documentation for changed behavior (isNull()), and fix snippets. Change-Id: I526efeff63d907bbadd5e8a539ccf237cb992125 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 704f0354998937363162fdb9ed6984a7339bc370) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty: Fix source_location feature testingFabian Kosmale2021-06-071-2/+10
| | | | | | | | | | | | | | | | | | The presence of the source_location header does not guarantee the availablility of std::source_location. For instance, if using clang 11 with a modern libstdc++, the source_location header is available, but std::source_location is not available as it would require __builtin_source_location, which clang does not implement. Consequently, we need to explicitly check the feature test macro instead, and only use std::(experimental::)source_location when it is defined. Task-number: QTBUG-94194 Change-Id: If6fda9a1b98244b1f2944fff6fe1991def30fc0f Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 1924f78df68d69fa7c69c394c547307e25dfffe1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix set*Field JNI template callsAssam Boudjelthia2021-05-281-6/+6
| | | | | | | | | | | | 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. Change-Id: I6e1e6b7f557bbc664248ad364c48d63f58b70756 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 45daea19c393259297973ce99ce8717965e62224) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add documentation links for some JNI entitiesAssam Boudjelthia2021-05-282-3/+5
| | | | | | | | | | | Add doc page link for: * AttachCurrentThread call. * Interface Function Table which describes JNIEnv. Change-Id: I12b41429c40838e5133e58132930aede287e2e71 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit d72067c93833e9787a45aeddee800faab0d2d40a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix namespace error of std::source_location under C++20Zhang Xiang2021-05-221-2/+6
| | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 675a4b0cc77a81d92cea6e044200349676f3b117)
* Silence MSVC warning about int/size_t mismatchVolker Hilsheimer2021-05-061-2/+2
| | | | | | | | | | | | | | | | Warning was qmetaobjectbuilder.cpp(1439): warning C4267: '+=': conversion from 'size_t' to 'int', possible loss of data Instead of adding another cast in that line, fix the warning by making the size variable a qsizetype, and remove the now unnecessary static_cast to int. Change-Id: Ieff9330501f5a07c4bbe1e851a3ef211f8bf2d24 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 718d1f88d7089d6792eea4dcb56875734a09a742) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Fix warnings on qproperty.cppTopi Reinio2021-05-061-18/+22
| | | | | | | | Task-number: QTBUG-90662 Change-Id: I91f8b83c68c3692dc620063c93be9ddea64685a6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 4916255445f3b64a57683c0ef6bd5d80ad3b6359)
* fix: The QtStartUpFunction function may be called repeatedlyJiDe Zhang2021-04-271-1/+9
| | | | | | | | | | Don't call pre routine function in qAddPreRoutine if the qt_call_pre_routines is not called Task-number: QTBUG-90341 Change-Id: I0ee70561dc57b857f8b3b1cf42c9dfe0cf45bd49 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 22e967c3049608f82abd32a0beb0b4b36ee134bf)
* Fix build error on iOS with the configure option -qtnamespaceLars Schmertmann2021-04-272-3/+9
| | | | | | | | | | | | | qtbase/src/corelib/kernel/qsharedmemory_p.h:62:33: error: unknown type name 'QString'; did you mean 'XXXX::QString'? int createUnixKeyFile(const QString &fileName); ^~~~~~~ XXXX::QString Change-Id: I455526503f059efc2f496b159b4cb098385dda00 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit d81a9206ac528ad7b5093305d7fe0037053468b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QJniObject templates implementationsAssam Boudjelthia2021-04-233-681/+708
| | | | | | | | | | | | | | 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. Change-Id: I8a4d3ce85e1ff76ef385633f2a68511fffd12e55 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit f4e23bf3deb69131f78eb78a1cb06da0fe72d9d4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Replace conversion operator by operator* in QJniEnvironmentAssam Boudjelthia2021-04-153-62/+72
| | | | | | | | | | | | Since conversion operators do implicit conversion that might bring some potential issues while using the API, let's stick to having an operator* instead. Change-Id: Ie7ad5537958944b8d1c11d69fbd30284b4b0344d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 13592385723a9b81b3715b5344bdd04e6a393a12) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCoreApplication: improve docs on exit() and quit() thread-safetyThiago Macieira2021-04-091-1/+14
| | | | | | | | | Reporter of QTBUG-91771 was confused. Change-Id: I26b8286f61534f88b649fffd166c4368167a5638 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 183df80b9c1439202ae6b967774123cb313e9097) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCoreApplication::exit: make it a slotThiago Macieira2021-04-091-1/+1
| | | | | | | | | | | | The documentation even refers to it as such. Instead of refactoring the documentation to explain that it isn't, just make it a slot. [ChangeLog][QtCore][QCoreApplication] exit() is now a slot, like quit(). Change-Id: I26b8286f61534f88b649fffd166c43afbb80927f Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 2e6c37fe51b5f6073db0c7335c4a4272269d482f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix return type of QMetaType::sizeOf in documentationVolker Hilsheimer2021-04-071-1/+1
| | | | | | | Change-Id: I6f5a866fa83f0e2720d62c5170c9283997b31a7f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 1e8b085f8c8bce5d69852df4c4b72d30fcffe793) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Rename QJniEnvironment exceptionCheckAndClear to checkAndClearExceptionsAssam Boudjelthia2021-03-304-50/+50
| | | | | | | | | | Address feedback from header view. Task-number: QTBUG-90211 Change-Id: Iad2b609598b16f66fd6ab09484fe6e6899981263 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit b9f27335e7462a15ac642841bb6d86ebebb349f9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Get rid of the Core_qobject static libraryAlexandru Croitor2021-03-261-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Core_qobject target was problematic for a few reasons. In the very beginning, Core_qobject was an OBJECT library, explaining its existence with the following comment "requires to spill internals into users". The object library contained qobject.cpp and qproperty.cpp and their manually generated moc files. It was was a dependency of Core. Afterwards it got converted into a static library instead, presumably to circumvent some issues with metatype generation. Unfortunately making it a static library was wrong, because it leads to linker failures (undefined symbols) in a static Qt build when trying to link a project that uses only QtCore. Both Core and Core_qobject refer to each other's symbols, and whichever library came first on the link line, many of its symbols were discarded by the linker. Transforming Core_qobject back into an object library could be an option, but that leads to trouble with creating proper prl files (our infrastructure doesn't quite support that for object libraries yet). Furthermore, there was some internal discussion and concern about how to merge the two metatype json file lists (Core and Core_qobject) into a single file. Instead of using an object library, move qobject.cpp and qproperty.cpp to be directly a part of Core again and remove the Core_qobject target. In order to do that, we have to circumvent some issues with AUTOMOC. First, we have to disable AUTOMOC for qobject.cpp and its headers. qobject.cpp contains Q_GADGET, Q_NAMESPACE, etc keywords in its doc comments. That confuses AUTOMOC, because it expects a qobject.moc file which is not included by qobject.cpp. See e2ff9e3b9957f844d6530cc92096bed3c16fa46a for some details on the Q_GADGET + AUTOMOC issue. We still need to run moc on on qobject.h and compile moc_qobject.cpp, so we manually run moc on the header file. Because qobject.cpp directly includes moc_qobject.cpp, we need to adjust the header include path to the generated file. Second, we remove the direct inclusion of moc_qnamespace.cpp in qobject.cpp to prevent duplicate symbol compilation, because the symbols were compiled both as part of qobject.cpp and mocs_compilation.cpp. Finally, because manual moc is used on qobject.h, the generated json file needs to be explicitly passed to Core's metatype generation step. Amends e57a94cbd8f28ccab8b3368afc4365237c533a4f Amends 3c4c02b3f1cec8ebc0134fd05b0e51f1f771937d Task-number: QTBUG-87580 Change-Id: I859a7d2f95508eda211a0a0b4ec132540b78bda4 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 04df85bbecdc034876d509b9c96a4f17fc990293) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix warning from syncqt.pl about header inclusion pathEdward Welbourne2021-03-251-1/+1
| | | | | | | | | | | | After a "QtCore: WARNING:" intro (separated to avoid being mistaken for a footer) syncqt.pl said: .../qtbase/src/corelib/kernel/qjnienvironment.h includes QScopedPointer when it should include QtCore/QScopedPointer Change-Id: Iaa1f025367b7321af9c5de27196ebf271f9179df Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 968f4001a86d4a3321ac41f6b2808ccb3b1271fe) Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QProperty: markDirty should be internalFabian Kosmale2021-03-221-0/+3
| | | | | | Change-Id: If69a6f37c32ce0d7f824794a2a1c52bad82d84cc Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QEventDispatcher(Win): Always honor interrupted status to avoid racesMårten Nordheim2021-03-111-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | There may be a race where e.g. thread 'B' is woken up by a queued invoke. At the same time thread 'A' asks 'B' to quit, which will set various atomics (some important ones are 'interrupt' in the dispatcher and 'exit' in the event loop), but it does _not_ try to send another wake since there is already an unhandled wake triggered by 'B' itself. Sadly 'B' reads the 'exit' atomic before 'A' updates it. Then, slightly before, 'B' sets 'interrupt' back to 0, 'A' write 1 to it, meaning 'A's interrupt is ignored. Then, since there is no interrupt, 'B' goes back to waiting for events, leaving the thread alive and running instead of quitting. Maybe this has unforeseen consequences (one consequence is that it will return and re-enter the event dispatcher once more, possible unnecessarily) Fixes: QTBUG-91539 Change-Id: Ie6f861f42ffddf4817d5c8af2d764abe9d9103c2 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit f274f91cebb0a4fd2ebe37bb3a605c47d6acd404) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add documentation for Q_OBJECT_BINDABLE_PROPERTYAndreas Buhr2021-03-071-0/+23
| | | | | | | | | | | | | | | | The duo Q_OBJECT_BINDABLE_PROPERTY and QObjectBindableProperty can only be documented together. The documentation is now with QObjectBindableProperty. This patch adds a documentation entry for Q_OBJECT_BINDABLE_PROPERTY which links the user to QObjectBindableProperty. Task-number: QTBUG-90511 Change-Id: I9af4a99d49f4b02ee9645a2cc9a9a024a6a1a552 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 89cc39a894dddaa0347ecf08438ea31b4880961c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Simplify code, remove redundant conditionWang Yicun2021-03-052-6/+2
| | | | | | | | | | | 'clazz || (!clazz && isCached)' is equivalent to 'clazz || isCached' Done-with: Tang Peng <tangpeng@uniontech.com> Change-Id: Ie9eab4a94a61be2b360f64980c4666a622f3a209 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit a913002f13d8a2faad512ffda6c70f413b8e7ee5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMetaType::create: don't leak memory if copy can't be madeVolker Hilsheimer2021-03-041-1/+1
| | | | | | | | | | | | | | | | | | | | | QMetaType::construct will return nullptr if a copy is requested but if there is no copy constructor. In that case, the memory allocated in QMetaType::create will be leaked. This case is covered in the unit tests in template<> void testCreateHelper<QMetaType::Void>() so we can't assert in construct that a copy constructor is present if a copy is requested. Fixes static analyzer warning 618b1e6877f737df57c39fd35ad91cd4. Change-Id: Ic439b36b1f120b9d0f888efaeab2801d8acc13de Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 90b51219ddc75c4dd2d171f2dba644e67d1e4a62) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QEventDispatcherWin32: get rid of the hook procedureAlex Trotsenko2021-02-262-30/+9
| | | | | | | | | | | | | | | | | | | Instead of intercepting the WM_QT_SENDPOSTEDEVENTS message in the hook procedure, we can handle it at receive points, making qt_GetMessageHook() unnecessary. Including general performance improvements, this patch fixes the issue where some applications (e.g. Ableton Live) do not call a chain of nested hooks for plugins. Fixes: QTBUG-90949 Change-Id: If8e96848392c6f10d45af2aac0567707d16af673 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Nuno Santos <nunosantos@imaginando.net> (cherry picked from commit b7e08599cc784777d06d34e49e90c2d408ab629d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QSystemSemaphore: Fix broken translated messagesFriedemann Kleint2021-02-245-28/+15
| | | | | | | | | Add Q_DECLARE_TR_FUNCTIONS() and use tr(). Change-Id: I31a27afa06ee2a592a7e588283e5ff08b5d14f3b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> (cherry picked from commit 1128e0bea1dbe8578cd71385ef3c7231aee80e1e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Assert that either both or neither pointer are nullptrVolker Hilsheimer2021-02-241-0/+10
| | | | | | | | | | | | | | | If called by QMetaType::canConvert with two nullptr values, the QMETATYPE_CONVERTER_ASSIGN macro will expand to code dereferencing both 'to' and 'from' pointers. Assert that others callers provide two valid pointers. Fixes static analyzer warning 02dc34cc2ad1d4c3c6e55b44e08983f2 Change-Id: I24de914faa25dc7cb1da5eae09a125506caac389 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 52b5e9b76663fa7b43da1466fb2678d6b18d86b2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Re-order includes in qjniobject.cppAssam Boudjelthia2021-02-221-1/+2
| | | | | | | Change-Id: I80acd829bfd0940d17170f2277e92bc9620ce929 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit f265736e9fdce7e9d049774f2e9f648f52aef31f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Mark QSocketNotifier::activated(int) QT_MOC_COMPATMårten Nordheim2021-02-181-1/+1
| | | | | | | | Fixes: QTBUG-83888 Change-Id: I0833812376a5bf1a024a4b036c09b23760437862 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 9d19a8ca2fc4fbd99427d2be10ad1d1e98b34506) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix some qdoc-warnings for 6.1Friedemann Kleint2021-02-182-1/+7
| | | | | | | | | | | | | | | | | | Fix: qtbase/src/testlib/qtestelementattribute.cpp:89: (qdoc) warning: Undocumented enum item 'LET_Message' in QTest::LogElementType qtbase/src/testlib/qtestelementattribute.cpp:89: (qdoc) warning: No such enum item 'LET_Error' in QTest::LogElementType qtbase/src/testlib/qtestelementattribute.cpp:89: (qdoc) warning: Undocumented enum item 'LET_SystemOutput' in QTest::LogElementType qtbase/src/network/ssl/qsslsocket.cpp:1666: (qdoc) warning: Unknown command '\cl' qtbase/src/corelib/kernel/qproperty.cpp:883: (qdoc) warning: Unknown command '\T' qtbase/src/corelib/kernel/qproperty.cpp:799: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text qtbase/src/corelib/kernel/qjnienvironment.cpp:250: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text Change-Id: I116f5d8ace2c29ba7b6b93256d5761591e01296a Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Nico Vertriest <nico.vertriest@qt.io> (cherry picked from commit 868242b6e1840fcea491ad86d8b2a7a101c4eeaa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Do not make QTimer::interval bindableFabian Kosmale2021-02-162-15/+4
| | | | | | | | | | Issues were found and fixed only in 6.2. Let's play it safe and do not make interval bindable in 6.1. Change-Id: I4465d3991d0c303037de7421d5a670f009ac2bf9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Mark QPropertyAlias as internalFabian Kosmale2021-02-161-0/+2
| | | | | | | | | | That class was only really meant for the QML compiler, and it is dubious if event that one needs it. The current implementation is also broken. Change-Id: Ie40d282707f3fabc8079bee9e98f082aeb9d30b3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 5481601debd6ce06bb8f0135e3ea4baf8a21cb3d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix docs misuse of escape character \Assam Boudjelthia2021-02-121-2/+2
| | | | | | | | | | Use {} instead of \, this fix a badly generated block of text. Task-number: QTBUG-89632 Change-Id: Ia4aad4c06285eb016a092f4340669fcbef1a6780 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 448ea34637af3a8a92c2a4c5780815ca44e0ecf9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Refactor duplicate code for clearing JNI exceptions before returningAssam Boudjelthia2021-02-111-80/+43
| | | | | | | | | | | Add a private function to handle checking/clearing and deleting the local reference to jobject before returning a QJniObject. Task-number: QTBUG-89633 Change-Id: I0ea28c8ba4da0bfc1e341c6b4c1f61fecfec87a6 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit c7bcc51e2c196e5cc3def89137ca31b4a9d29157) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix registerNativeMethods for goodAssam Boudjelthia2021-02-111-3/+4
| | | | | | | | | | | | | | | | | | The initial implementation and the commit c00ab6f8eaa3cdc9a29dd103c91b2eaf212cac9f was wrong: * env->findClass() in fact returns a global reference, and in any case we shouldn't be calling that, instead QJniObject would be enough. * The size param provided to env->RegisterNatives was wrong. * A test for registerNativeMethods() is added to ensure such break is not repeated again. Task-number: QTBUG-89633 Change-Id: I4d3a6a9270755f465c40add25521fb750dd4de0a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit deca7cd730a44988d3e15c551d9a82a5c75618e2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Documentation improvements to JNI APIAssam Boudjelthia2021-02-093-249/+329
| | | | | | | | | | | | Amends 4e60681c879a54cf5b34862a30e27c492ed36363. Fixes: QTBUG-89632 Change-Id: I7856e9b63eea5ba68a5472575016540ae656ec5f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 817f8ac03cd4e85b7813b45f8cabf5b679f28702) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QJniObject::registerNativeMethods use of global referenceAssam Boudjelthia2021-02-021-4/+3
| | | | | | | | | registerNativeMethods() should be using the local jclass from findClass() instead of the global reference. Task-number: QTBUG-89633 Change-Id: I469a9a1ecff95ab9948421baa5c88735ba7ad776 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Do delete on QMetaType::destroy() even without dtorUlf Hermann2021-02-011-2/+3
| | | | | | | | | As we call operator new on create(), we also need to delete on destroy(). Otherwise we leak memory. Change-Id: Ib80fe96c4173cba6fa474d3c81d88fe603d1ded2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove QObjectCompatProperty::operator= for safer usageAndreas Buhr2021-01-291-6/+0
| | | | | | | | | | | | | Introduction of QObjectCompatProperty requires every write to the property to be examined whether it is OK or should be replaced by a setValueBypassingBindings/markDirty combination. The existence of operator= make this difficult as it is easy to miss places where it is written. By not having operator=, we can help developers make sure they had a conscious decision about each write to the property. Change-Id: Ia61ea4722eb0bab26ce7684b85dd03d710cd1751 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QEventDispatcherGlib: do not omit active notifiers on source dispatchingAlex Trotsenko2021-01-291-2/+8
| | | | | | | | | | | | | | | | It is quite common for a socket notifier to be disabled in a slot connected to its activated() signal. But the event dispatcher did not update the position in the list of registered notifiers, which caused the next notifier to be omitted. Of course, on the next iteration of the event loop, the omitted notifier would fire again, but this reduced the scalability of applications that use a large number of sockets. To solve the problem, we update the current position in the list when a notifier becomes unregistered. Change-Id: I6565bf23500d9e38ce84b34784d89d227fa166e1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVariant: Use QMetaTypeInferface directlyFabian Kosmale2021-01-283-24/+63
| | | | | | | | | | | | There is no reason for QVariant to go through QMetaType when it can use the QMetaTypeInterface directly. Without LTO, the QMetaType method calls are opaque, and we therefore risk to lose optimizations. Additionally, avoid constructing a QMetaType from a type id if we already have the QMetaType. Fixes: QTBUG-90673 Change-Id: I7069ff6aff70d5baecdf5cf5760014c3dda81784 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProperty: Treat change listener modifying its source property as a loopFabian Kosmale2021-01-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is in line with QML where import QtQuick 2.15 Rectangle { width: 100 height: 100 color: "red" Rectangle { id: inner x: 10 y: x width: 50 height: 50 onYChanged: { console.log("hey"); inner.x = 10} TapHandler { onTapped: inner.x = 20 } } } results in a binding loop warning when the tap handler triggers. While the change handler would only run once, we cannot statically determine if we need to loop once, twice, or if there actually is a diverging loop. Thus we unconditionally warn about the binding loop and stop executing the binding. As a drive-by, verify in the related test that a change handler which overwrites its properties binding itself removes the binding. Change-Id: I5372019c2389ab724c49cd7489ecbd3ebced1c69 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Create bindable property overview documentationAndreas Buhr2021-01-281-54/+5
| | | | | | | | | | | So far, all documentation about bindable properties was in the corresponding classes QProperty and QObjectBindableProperty. This patch creates one documentation page for a general introduction to bindable properties and information concerning all of those classes. Change-Id: Ib718dbeb385c3899fb34cc2ce03bec7a8d43a034 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Safer setting of interval in QTimerAndreas Buhr2021-01-281-2/+4
| | | | | | | | | | | There are two methods which set the interval and do things afterwards. Setting the interval might trigger other code. This patch uses setValueBypassingBindings and marks the interval dirty later, just to be safe. Change-Id: I2cae3e4a9f040007dfd246c424250034e8df10a0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS: Silence warnings properlyFabian Kosmale2021-01-271-5/+5
| | | | | | | | Same reason as for the version without args. Amends 1461df2ce4ea0283759e653612208c8729a03d7a. Change-Id: Ib9f0d8f27d858ff35134001c3cd7945b17668ae4 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>