summaryrefslogtreecommitdiffstats
path: root/src/dbus
Commit message (Collapse)AuthorAgeFilesLines
* Replace one-shot uses of QSemaphore with QLatchThiago Macieira21 hours3-29/+10
| | | | | | | | | | | | | | | This commit replaces one-shot synchronization of threads that were using QSemaphore with QLatch. QSemaphore is efficient on Linux and Windows, but allocates memory elsewhere. Even on those platforms where we have futex-like OS support, QSemaphore is heavier than what we really need here. All but one uses of QSemaphore in qtbase libraries (I didn't change examples or tests) were replaced. The remaining use of QSemaphore in qnetworkproxy_libproxy.cpp is a proper producer-consumer. Change-Id: Ib5ce7a497e034ebabb2cfffd1761a4fcb2be9a6c Reviewed-by: Volker Hilsheimer <[email protected]>
* QDBusMessage: add move-constructorIvan Solovev13 days2-2/+13
| | | | | | | | | | | | | | | | | | Since the class was not desigend to support a nullptr d_ptr, this change requires modifications in the destructor and copy-ctor. The change in destructor is straightforward - simply add a check that d_ptr is not null. The copy-constructor was using a qAtomicAssign() helper, which was relying on the fact that the passed pointers are not null, so we cannot use it anymore. Use copy-and-swap instead. The other methods do not require any changes, because the moved-from object can only be destroyed or assigned-to. [ChangeLog][QtDBus][QDBusMessage] Added move constructor. Change-Id: Ic8a0d913b9cf2f881369f7ad4f3a88c1f3fb345f Reviewed-by: Marc Mutz <[email protected]>
* QDBusPendingCall: add move-constructorIvan Solovev13 days2-0/+14
| | | | | | | | | | | | | | The class uses QESDP for the d_ptr, so the default implementation is fine. This requires to add the QT_{DECLARE,DEFINE}_QESDP_SPECIALIZATION_DTOR pair of macros, so that the compiler sees the declaration of the d_ptr destructor. [ChangeLog][QtDBus][QDBusPendingCall] Added move constructor. Change-Id: I687459397ab7fb1dbd31cea5a42b7580ffe6c749 Reviewed-by: Marc Mutz <[email protected]>
* Document QDBusPendingCall move-assignment operatorIvan Solovev13 days1-0/+12
| | | | | | | | | | It was added in Qt 5 times, so pick to all active Qt 6 branches. Amends bc1804fa7247502b27a0501ec030e398a95bf367. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I429b808c439bdc1013e4f53c60e1f55366602320 Reviewed-by: Marc Mutz <[email protected]>
* Document QDBusMessage move-assignment operatorIvan Solovev13 days1-0/+12
| | | | | | | | | It was added in 15a50356713079804d0a7c97fa0ae4c27dd44d41, back in Qt 5 times, so pick into all active branches. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I46b17e50cc0b68d0b29a8a0660052599d0926c7d Reviewed-by: Marc Mutz <[email protected]>
* qdbusintegrator_p.h: do not use qSwap()Ivan Solovev2025-06-161-3/+3
| | | | | | | | | Use std::swap() or member-swap() instead, because qSwap() is an overkill when we know the types. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Iec598dbc16cf594a00f3cb03f4621b76869f3a1c Reviewed-by: Thiago Macieira <[email protected]>
* Mark qdbusargument.cpp and qdbus(de)marshaller.cpp as security-criticalIvan Solovev2025-06-163-0/+3
| | | | | | | | | | | | | | | | | | | | | The qdbusdemarshaller.cpp file implements deserialization of data that is received over D-Bus. An error in deserialization (e.g. reading a string instead of an int) may lead to a crash, so the code is security-critical. The qdbusmarshaller.cpp file is also marked security-critical, because it serializes the data, and so: * can crash libdbus upon incorrect serialization, or * can cause crashes in another (potentially Qt-based) application that later tries to deserialize the data The patch also marks qdbusargument.cpp as security-critical, becuase it implements marshalling and demarshalling for Qt-specific types. Task-number: QTBUG-135199 Pick-to: 6.10 6.9 6.8 Change-Id: Ifc8d78cf4534ad398e9eb9fc869e8064d56db603 Reviewed-by: Thiago Macieira <[email protected]>
* QDBusAdaptorConnector::AdaptorData: use QBAV in comparisonIvan Solovev2025-06-162-3/+4
| | | | | | | | | | | | | Update the comparison operators to use QByteArrayView instead of QByteArray. This allows to save unnecessary memory allocations when sorting the adaptors or searching for an adaptor. Amends the beginning of the public history, so pick to all active Qt 6 branches. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Ib2e330e20249123b4aaaed8a843c341943b484ef Reviewed-by: Thiago Macieira <[email protected]>
* Mark qdbus_symbols.cpp as security-significantIvan Solovev2025-06-161-0/+1
| | | | | | | | | | | | | The code in the file loads the dbus library and resolve symbols from it, so technically provides access to the external code. However, it uses the QLibrary API to do that. It's the QLibrary that should be marked security-critical, so keep this file as security-significant (the default). Task-number: QTBUG-135199 Pick-to: 6.10 6.9 6.8 Change-Id: I933108ccaa188ff4eeffbe9e11976cdf4b44f975 Reviewed-by: Thiago Macieira <[email protected]>
* qdbus: add call GetConnectionCredentials interfaceLi Changze2025-06-042-0/+17
| | | | | | | | | | | [ChangeLog][QtDBus][QDBusConnectionInterface] Added method serviceCredentials(). See <https://dbus.freedesktop.org/doc/dbus-specification.html> section: 'Method: org.freedesktop.DBus.GetConnectionCredentials' for more information. Pick-to: 6.10 Change-Id: If37687a35278fde8b0afc33eb19f9fa6b8dbe200 Reviewed-by: Christian Ehrlicher <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* Doc: Enable automatic linking to sources on code.qt.ioTopi Reinio2025-05-271-0/+3
| | | | | | | | | | | | Since 6.10, QDoc is capable of generating links to the declaration in the source code for each documented C++ API entity in their `Detailed description`. Add the required configuration to enable this feature in online documentation builds. Change-Id: Iaafabc5aea50a6cd72549bb1c04007bb4de498ca Reviewed-by: Paul Wicking <[email protected]>
* Doc: Qt D-Bus: Add image alt textsTopi Reinio2025-04-091-1/+1
| | | | | | | | | | | To increase accessibility for the documentation, provide altenative descriptions for the images. Pick-to: 6.9 6.8 Fixes: QTBUG-135116 Change-Id: Id2d97251af9af0d4222f0dc15aa5b8e266ca36f4 Reviewed-by: Safiyyah Moosa <[email protected]> Reviewed-by: Andreas Eliasson <[email protected]>
* Use QThread::isMainThread() in a few placesThiago Macieira2025-02-262-2/+2
| | | | | | | | | | | | | | | It's thread-safe, whereas trying to load qApp isn't in Qt 6.x (will be in 7.0) and dereferencing it to call QObject::thread() will probably never be. It's also faster, being a single function call instead of two or three. This is not an exhaustive search, it's just a few places I found while searching for QThread::instance(). Pick-to: 6.9 6.8 Change-Id: I3b4e1c75bb3966e2cd2dfffd79bfc8a40f6cf40b Reviewed-by: Ivan Solovev <[email protected]> Reviewed-by: Mårten Nordheim <[email protected]>
* Short live QCoreApplication::instanceExists()Thiago Macieira2025-02-261-1/+1
| | | | | | | | | | | | | | | | | | This is a thread-safe version of QCoreApplication::instance() != nullptr for Qt 6.x, because QCoreApplication::self is not atomic and thus reading it from outside the main thread could be a data race. That's not to say it always is: if by construction the code can only run in the main thread or while QCoreApplication definitely exists, that's safe. Therefore, this commit focuses on places that are meant to be used in multi-threaded environment (ruling out most of QtGui and QtWidgets) or where the code was going to dereference the returned pointer anyway. Change-Id: I6fc556c5fe5cbe0b5902fffdfb6b3bb345b0ee50 Reviewed-by: Marc Mutz <[email protected]>
* Use `_qt_internal_set_source_file_generated`Cristian Le2025-02-171-7/+7
| | | | | | | | | Migrate implementations that set `GENERATED` source property Task-number: QTBUG-125077 Pick-to: 6.9 Change-Id: Ia77ecf8422bf3983f7746c26e5a9994d1f6415f2 Reviewed-by: Alexey Edelev <[email protected]>
* Qt D-Bus Viewer: Update documentationJerome Pasion2025-02-122-3/+13
| | | | | | | | | | | | -Added information about the location of qdbusviewer -Fix name to "Qt D-Bus Viewer" Fixes: QTBUG-118997 Pick-to: 6.8 6.9 Change-Id: I90f1e75a04a959d9c739e33779d978b607a8181c Reviewed-by: Topi Reiniö <[email protected]> Reviewed-by: Ralf Habacker <[email protected]> Reviewed-by: Kai Köhne <[email protected]>
* Docs: fix minor issues with topic namingAlexei Cazacov2025-02-042-2/+2
| | | | | | Pick-to: 6.9 Change-Id: Iaf8d12743a5f43c355f6960f1da0c6764e622bf8 Reviewed-by: Andreas Eliasson <[email protected]>
* Make module ready for source SBOM checkingLucie Gérard2025-01-272-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This includes: - turning VERIFY_SOURCE_SBOM ON - adding exception to the licenseRule.json files - correcting the licensing given via REUSE.toml files - renaming license files not located in LICENSES folder. They need to be named LICENSE. to be ignored by reuse and excluded from the source SBOM. The name are updated in the corresponding qt_attribution.json A lot of files are skipped during the license test, but all are present in the source SBOM. This is why correction are needed before turning the source SBOM check on. [ChangeLog][Third-Party Code] Renaming the license files with prefix LICENSE. to have them ignored by reuse tool. Task-number: QTBUG-131434 Pick-to: 6.9 Change-Id: Iab517215bb10a17357d2d2436bba8d3af76e5cd1 Reviewed-by: Joerg Bornemann <[email protected]>
* CMake: Use the $<VERSION> placeholder in qt_attribution.jsonAlexandru Croitor2025-01-091-1/+1
| | | | | | | | | | For all CPE and PURL fields where it makes sense, to avoid duplication. Pick-to: 6.8 6.9 Task-number: QTBUG-132181 Change-Id: Icd1c5267e4e9b582eea28150ebd1b2cca3852229 Reviewed-by: Joerg Bornemann <[email protected]>
* QDBusPendingReplyBase: add missing copy operationsGiuseppe D'Angelo2025-01-082-0/+7
| | | | | | | | | | | | | | QDBusPendingReplyBase declares its destructor (and defines it, as defaulted, out-of-line). I'm not sure why that's the case, since QDBusPendingReplyBase isn't polymorphic. This generates warnings when QDBusPendingReplyBase objects are copied in the subclasses, since the copy operations are deprecated due to the presence of the destructor. Add the missing copy operations, and mark destructor and copies to be removed in Qt 7. Change-Id: Iec2c98f5e512c3f19e5d28ab2ce2dba365c66175 Reviewed-by: Thiago Macieira <[email protected]>
* Provide D-Bus de-/marshalling operators for std::tupleDavid Redondo2024-12-132-2/+23
| | | | | | | | | | | | | | | Currently Qt provides only generic operators for pairs which can be used generically for structs with two elements. A tuple is the natural fit for dealing generically with structs that have more elements. This can be helpful when wanting to make a one-of calls to APIs that take or return such types or deferring to tuple marshalling without having to write custom operators. [ChangeLog][QtDBus][QDBusArgument] Added generic support for marshalling and demarshalling D-Bus STRUCTs from/to std::tuple. Change-Id: Id5cf49063c9b43ed68ad7821111376f6fa887a73 Reviewed-by: Thiago Macieira <[email protected]>
* CMake: Add PURL and CPE info to 3rd party attribution filesAlexandru Croitor2024-11-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change adds CPE and PURL keys to all qt_attribution.json files in the repo. In case if no sensible CPE or PURL exists, a "Comment" field is added with the text "no relevant CPE or PURL found". If only one of them does not exist, it is written as such in the Comment field. This allows filtering for files that haven't had the information added yet vs those that were looked up but no relevant information was found. For sources that are not hosted on github, a generic PURL is used with a download_url fragment pointing either to the exact location where the sources can be downloaded, or to the homepage of the project. The generic package name was chosen based on the 'Id' key of the attribution entry where it was present, and is not authoritative. For PURL github packages, the 'git tag' name was specified into the 'version' part of the PURL, rather than the 'version number', because SBOM processing tooling handle that better than the version number. For example for the freetype package, we specify the string 'VER-2-13-3' rather than the tag name '2.13.3'. We might revisit this in the future. [ChangeLog][Third-Party Code] Added PURL and CPE information to the attribution files of 3rd party sources. Pick-to: 6.5 6.8 Task-number: QTBUG-122899 Task-number: QTBUG-129602 Change-Id: Iad126242cafc3ea0b678c5c36b26f857039b1dbd Reviewed-by: Alexey Edelev <[email protected]>
* Create qdoc macros for C++ class docs 1.3: member-swap(), non-standard phrasingMarc Mutz2024-11-085-14/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | We have some patterns for how to document certain functions, but we also vary the sentences a lot, and you have to look up one documentation piece and copy it, essentially. If we ever want to change them, we end up with shotgun surgery. So apply DRY to the documentation and start a collection of macros to help with repetitive C++ class documentation tasks. The first macro is for member-swap(), and this third patch is for documentation that used a non-standard phrasing for documenting member-swap(). By using the macro, the documentation automatically conforms to what the documentation team picks as the \memberswap expansion going forward. As a drive-by, fix doc block indentation to the Qt standard of 4 spaces (only in changed lines), and add a few blank lines where they were missing before. Fixes: QTBUG-129573 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: If007602d7690572fcbb848a8d0235416c908cfd2 Reviewed-by: Topi Reiniö <[email protected]> Reviewed-by: Ivan Solovev <[email protected]>
* Create qdoc macros for C++ class docs 1.2: member-swap(), simplified phrasingMarc Mutz2024-11-082-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have some patterns for how to document certain functions, but we also vary the sentences a lot, and you have to look up one documentation piece and copy it, essentially. If we ever want to change them, we end up with shotgun surgery. So apply DRY to the documentation and start a collection of macros to help with repetitive C++ class documentation tasks. The first macro is for member-swap(), and this second patch is for documentation that used the simplified phrasing ("Swaps this X with \a other."), which this patch adopts as the text for \memberswap, too, because it doesn't repeat the macro argument, making it easier to find a grammatically-fitting argument than in the traditional phrasing. This doesn't change the documentation, except as follows: * standardizes on simpified instead of traditional phrasing for docs that already use the \memberswap macro * adds the "very fast and never fails" blurb, if it was missing * changes the function's argument name to `other`, as required by the macro. Task-number: QTBUG-129573 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: I1123e783ce0da76c5997ff74007d77504ac5b334 Reviewed-by: Topi Reiniö <[email protected]> Reviewed-by: Ivan Solovev <[email protected]>
* Document QVariantMap with invalid QVariant is disallowed in D-Bus argumentsFushan Wen2024-10-251-0/+3
| | | | | | | | | | | Invalid QVariant is not allowed in arguments and Qt has a check for that. However, if an argument is QVariantMap with invalid QVariant, the application will crash when sending the message, which is an expected behavior and needs to be documented. Task-number: QTBUG-130038 Change-Id: I120785b8557afa089b6d12f82680c85505d110b9 Reviewed-by: Thiago Macieira <[email protected]>
* QtDBus: disallow sending method calls without destinations on a busThiago Macieira2024-10-213-4/+16
| | | | | | | | | | | | | | | | QtDBus has allowed this because the bus would stop the message and return it to us as an UnknownMethod. But it makes no sense to send it, so let's block it early. For practical purposes, this allows the tst_qdbusmarshall test to continue working regardless of which daemon is running the bus. The message it was checking against only came from dbus-daemon; for users of systems now running dbus-broker (like my openSUSE Tumbleweed) the message was different and the test was failing. Pick-to: 6.8 Change-Id: Ia134ca414080cf243974fffd913fdad09d80cc60 Reviewed-by: Ahmad Samir <[email protected]>
* QDBusUtil::isValidBusName: implement "contains at least two such elements"Thiago Macieira2024-10-211-0/+2
| | | | | | | | | | | It was in our docs but we didn't implement it. This failure allowed QDBusMessagePrivate::toDBusMessage() to proceed in calling libdbus-1 methods, which had the validation and might crash the application. Pick-to: 6.8 6.5 6.2 Fixes: QTBUG-130304 Change-Id: Ibb5d210c03672a363016fffd7b1a2b55c02119bd Reviewed-by: Ahmad Samir <[email protected]>
* QMetaMethod: make some QByteArray-returning methods slightly fasterThiago Macieira2024-10-031-1/+1
| | | | | | | | | | | | | | | | | | | QByteArray::fromRawData() allocates no memory. Since we know that the data range is valid, there's no precondition violation either. But we can only use it for static-lifetime meta objects: those constructed by QMetaObjectBuilder or QtDBus may get deallocated, causing the strings obtained from them to crash on use if they do outlive (unlikely, but not impossible). To differentiate, this commit introduces a new flag to the QMetaObject header and makes use of it in those two places. Come Qt 7, we should change these functions to return QByteArrayView, making the retention of the data in a QByteArray the responsibility of the user. Making the change right now with #if or QTx_ONLY() is ugly, so this commit just leaves a comment. Change-Id: I5aaddbc7ce3fc7a70e15fffd29e276c79d5ef6e4 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Ahmad Samir <[email protected]>
* moc & QMetaObject: move the QMetaMethod revision informationThiago Macieira2024-09-211-1/+1
| | | | | | | | | | | | | | | | | | | | | Instead of storing them as an array for every single method (some of which may not have revisions) at a different location in the uint array, store the revision after the parameter type and name lists, in the usual place. This is not implemented for the old integer table in moc, because it's going away. [ChangeLog][Important Behavior Changes] With Qt 6.9, the layout of the meta object data table changed incompatibly for classes containing meta methods (signals, slots) marked with Q_REVISION. This is marked by the presence of revision 13 or later. Code that reads or writes the meta object's raw data directly instead of using QMetaMethod must detect the new layout. Change-Id: I8a96935cf6c742259c9dfffd17e97a2530b52b3e Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* Docs: Organize topics in the qtbase repoAlexei Cazacov2024-08-132-1/+37
| | | | | | | | | | This commit organizes the articles, so they: - have a reasonable tree structure - can be navigated through the topic tree in the Qt Creator help viewer Task-number: QTBUG-127046 Change-Id: I66f2b131b8aacc887b35a770e51c1425431dffb5 Reviewed-by: Topi Reiniö <[email protected]>
* QExplicitlySharedDataPointer: Use new comparison helper macrosRym Bouabid2024-07-041-3/+1
| | | | | | | | | | | | | | | | | Provide the new comparesEqual() helper function as an implementation of the (in)equality operators and compareThreeWay() helper function for the rest of the relational operators. Use Q_DECLARE_STRONGLY_ORDERED to provide all relational operators. Use the new Qt::totally_ordered_wrapper to wrap the "d" pointer to avoid UB when performing comparisons of QExplicitlySharedDataPointer. Add some comparisons related tests for QExplicitlySharedDataPointer. Use QT_TEST_ALL_COMPARISON_OPS macros in unit-tests. Task-number: QTBUG-120306 Change-Id: I275484a96a57da2df92712ac97e237a88a889da5 Reviewed-by: Ivan Solovev <[email protected]>
* QtDBus: don't detach in registerComplexDBusType()::Hash static destructionMarc Mutz2024-07-031-2/+2
| | | | | | | | | | | | | | | The old code's use of ranged-for loop over a QHash would trigger said QHash to detach. We don't require a detach here, so avoid this unnecessary program shutdown slowdown using std::as_const(). Possibly-related: remove the pointless std::move() around QMetaType passing - QMetaType is trivially copyable. Amends 1697fbdf05ff643d617a9ba1614454926e86a3d9. Pick-to: 6.8 6.7 6.5 Change-Id: I7b8d404e93ae4dde71a30e22e9e2f56a4b5354fb Reviewed-by: Thiago Macieira <[email protected]>
* QDBusSignature: de-inline the default ctorMarc Mutz2024-07-032-3/+5
| | | | | | | | | | | | | | | It used to merely default-construct the QString member (which is just zero-initialization), but since we discovered that we need to set m_signature to empty instead of null, it's doing too much for inline code (temporary QString (atomics), compile-time), so de-inline. Amends ed6d1fa71a79a70b7e6a20fbbc737ed9f6c287b1, but since this is adding a new symbol on non-Windows platforms, only pick to unreleased branches. Pick-to: 6.8 Change-Id: I610dad86ac4a080f5a45495ebc9536aa1d0bcbea Reviewed-by: Thiago Macieira <[email protected]>
* QDBusSignature: fix default ctor to not allocate memoryMarc Mutz2024-07-031-3/+2
| | | | | | | | | | | | | | | | | | The QDBusSignature default ctor is noexcept since 49f7281d36028055e61175c23bc455b4147480b9 (Qt 5.5-ish), so detach() (which must needs allocate memory) cannot be used without breaking the contract. Fix by assigning ""_L1 instead, the canonical way to access the shared empty state. While fromLatin1() isn't noexcept, fromLatin1(""_L1) never throws. Amends ed6d1fa71a79a70b7e6a20fbbc737ed9f6c287b1. Pick-to: 6.8 6.7 6.5 Task-number: QTBUG-124919 Change-Id: I5f0c3bdc199998deaa22971a60388f8f3ed0eaa8 Reviewed-by: Thiago Macieira <[email protected]>
* Straighten out various logging categoriesUlf Hermann2024-06-191-1/+1
| | | | | | | | | | | | Either make them static or declare them in a header. We want them to be static wherever possible, in order to reduce the number of visible symbols. If they can't be static, however, they should at least be declared in only one place. Task-number: QTBUG-67692 Change-Id: I6f3b596ed4f0adc9873dd0a5f54f055a991a6207 Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* Remove GENERATE_CPP_EXPORTS argumentAlexey Edelev2024-06-121-1/+0
| | | | | | | | | The behavior that argument was enabling is the default one now. Pick-to: 6.8 Task-number: QTBUG-90492 Change-Id: I11711d4c794f0b22169abb595b8ffad2eeb1300d Reviewed-by: Alexandru Croitor <[email protected]>
* Remove redundant qtimer.h includesAhmad Samir2024-06-112-2/+0
| | | | | | | | | | | | | | If QTimer isn't used in the file where it's included, remove the include. Fix files that depended on transitive includes. QMacPanGestureRecognizer: drive by change: classes inheriting from QObject should have Q_OBJECT macro in the definition. Change-Id: Ia8d71f4195a1ca643c9fcb14db41877413348d98 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
* [docs] Document QDBusObjectPath QDebug stream operatorMarc Mutz2024-06-061-0/+5
| | | | | | | | | | | Amends c89b1bbddc73b044762cabc67c1e5063a6ffee86. [ChangeLog][QtDBus][QDBusObjectPath] Added QDebug stream operator. Pick-to: 6.8 Change-Id: I677bef4be07e8138448d1c4bad6d590d607a0161 Reviewed-by: Volker Hilsheimer <[email protected]> Reviewed-by: Ahmad Samir <[email protected]>
* Make QDBusObjectPath QDebug stream operator a hidden friendMarc Mutz2024-06-061-3/+3
| | | | | | | | | | | | | | Because that's how we declare them these days. Found in API-review. Amends c89b1bbddc73b044762cabc67c1e5063a6ffee86. Pick-to: 6.8 Change-Id: I5163952e43abc1185b8f8f5c5fde2b4839e78e0d Reviewed-by: Volker Hilsheimer <[email protected]> Reviewed-by: Kai Uwe Broulik <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* QDBusSignature: accept empty strings as validThiago Macieira2024-05-104-6/+11
| | | | | | | | | | | | | | | | QDBusSignature holds a D-Bus value of type SIGNATURE, which is zero or more signatures, not one or more. This changes the default constructor to create a valid signature, which we denote by not being a null QString. That means we need to use something other than the default constructor in our tests for attempting to pass invalid signatures. [ChangeLog][QtDBus][QDBusSignature] Fixed a bug that caused the class not to accept an empty string as a valid D-Bus SIGNATURE value. Fixes: QTBUG-124919 Pick-to: 6.5 6.7 Change-Id: I262c3499666e4f4fbcfbfffd17cb3793dcf2eae3 Reviewed-by: Mårten Nordheim <[email protected]>
* QTimer/QObject::startTimer: improve the detection of overflowThiago Macieira2024-04-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | Converting from int milliseconds to int64_t nanoseconds can't overflow (it won't even for picoseconds, so we'll be fine for a couple more decades), so we only need to address the cases where the millisecond value was passed in int64_t: that is, in the std::chrono::milliseconds overloads. For the other cases, I added a comment. Amends bfc7535a10f7a6e3723f354b41f08a0fe1d18719 to not allow the detected overflow to happen at all, which could cause the timer to become very small. Instead, we saturate to the maximum, which is about 292 years (just under 106752 days). That's longer than computers have existed, so the chance that some Qt application is still running on a computer without any reboots from today to 24th century is remote at best. This parallels QDeadlineTimer, which already has code to saturate when using milliseconds. Change-Id: I6818d78a57394e37857bfffd17b9b1465b6a5d19 Reviewed-by: Ahmad Samir <[email protected]>
* Long live [[nodiscard]] QFile::openGiuseppe D'Angelo2024-04-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having already caught some bugs in real code because of unchecked calls to QFile::open, this commit marks QFile::open (and open() in other file-I/O classes) as [[nodiscard]]. Since it's going to raise warnings, the plan is to keep the existing behavior up to and including the next LTS. Then the warnings will switch on by default. All of this is protected by system of macros to opt-in or opt-out the behavioral change at any time. A possible counter-argument for doing this is that QFile::open is also used for opening files in the the resource system, and that opening "cannot fail". It clearly can, if the resource is moved away or renamed; code should at a minimum use a Q_ASSERT in debug builds. Another counter-argument is the opening of file handles or descriptors; but again, that opening may fail in case the handle has been closed or if the flags are incompatible. --- Why not marking *every* open() override? Because some are not meant to be called directly -- for instance sockets are supposed to be open via calls to `connectToHost` or similar. One notable exception is QIODevice::open() itself. Although rarely called directly by user code (which just calls open() on a specific subclass, which likely has an override), it may be called: 1) By code that just takes a `QIODevice *` and does something with it. That code is arguably more rare than code using QFile directly. Still, being "generic" code, they have an extra responsibility when making sure to handle a possible opening failure. 2) By QIODevice subclasses, which are even more rare. However, they usually ignore the return from QIODevice::open() as it's unconditionally true. (QIODevice::open() doesn't use the protected virtual pattern.) I'll try and tackle QIODevice in a future commit. [ChangeLog][QtCore][QFileDevice] The open() functions of file-related I/O classes (such as QFile, QSaveFile, QTemporaryFile) can now be marked with the "nodiscard" attribute, in order to prevent a category of bugs where the return value of open() is not checked and the file is then used. In order to avoid warnings in existing code, the marking can be opted in or out, by defining QT_USE_NODISCARD_FILE_OPEN or the QT_NO_USE_NODISCARD_FILE_OPEN macros. By default, Qt will automatically enable nodiscard on these functions starting from Qt 6.10. Change-Id: Ied940e1c0a37344f5200b2c51b05cd1afcb2557d Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
* QDBusObjectPath: Add QDebug stream operatorKai Uwe Broulik2024-03-012-0/+12
| | | | | | | Prints its path. Change-Id: I9467f9d33b927cf6b6d4692b2e2824001366625c Reviewed-by: Thiago Macieira <[email protected]>
* Correct doc snippet licenseLucie Gérard2024-02-282-2/+2
| | | | | | | | | | | | | | All file under doc/snippet should be license as Documentation snippets and according to QUIP-18 [1] this is LicenseRef-Qt-Commercial OR BSD-3-Clause [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I76eedfb6b15c4091f726a5652e3530001d7cdaf7 Reviewed-by: Volker Hilsheimer <[email protected]>
* QDBusUtil: document the D-Bus signature grammarMarc Mutz2024-02-271-0/+15
| | | | | | | | | | | | | | The specification doesn't provide an explicit grammar, so I turned the prose into ABNF for easier reference. The goal is both to aid review of the validateSingleType() function and to eventually use this to write a parser that doesn't use, or at least limits, recursion. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I21f81aa83cde356ab48105ea98f066024e0b7b5e Reviewed-by: Juha Vuolle <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* [docs] QDBusUtil::isValidObjectPath(): simplify descriptionMarc Mutz2024-02-271-3/+2
| | | | | | | | | | | The "does not contain two slashes in sequence" condition reads a bit unmotivated. It's easier written as "each part is not empty", so do that. Pick-to: 6.7 6.6 6.5 Change-Id: Ibb204429521910582bd8ee03ff54f72d7e15ce84 Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Leena Miettinen <[email protected]>
* QDBusIntrospection: make DiagnosticsReporter safe to useMarc Mutz2024-02-222-1/+7
| | | | | | | | | | | | | Add a virtual destructor to this polymorphic class and disable copying (requires to bring the default ctor back manually, and to export the class nested in an exported class). Amends 248d2103b5ef8f9cf8c1189cb67d78e1b6e741b7. Pick-to: 6.7 Change-Id: I9008e4ecebca34feac6ae92fa026f2673b652ba9 Reviewed-by: Ivan Solovev <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* QDBusIntrospection: fix position of Annotation definitionMarc Mutz2024-02-221-12/+12
| | | | | | | | | | | | | | | | | | | | | When 2e8a48c1cdc8547ec47f097a41dd53c641715b77 made Annotations::mapped_type a struct Annotation instead of just QString, it inserted the Annotation definition after the first inline user of Annotations (struct Method). I don't know why this compiled in the first place, but it did, probably because of the re-parse-everything-at-closing-of-class rule, but there's no reason to not move it to before the first users, so do that. Found while trying to make QDBusIntrospection a namespace instead of a struct. Amends 2e8a48c1cdc8547ec47f097a41dd53c641715b77. Pick-to: 6.7 Change-Id: I316cb5e49f3476adc5ff5abb023b9d74303ab640 Reviewed-by: Ivan Solovev <[email protected]>
* QDBusUtil::isValidBusName(): remove an impossible condition guardMarc Mutz2024-02-221-3/+0
| | | | | | | | | | | | | | | | | | QStringView::split() only returns an empty container if a) the haystack is empty and b) SkipEmptyParts is in effect. Neither is the case here: We use the implicit default of KeepEmptyParts, and we've already checked that the haystack isn't empty in the first line of the function. So the result of split() can never be empty here. Remove the check to avoid confusing more readers than just yours truly. Amends the start of the public history. Pick-to: 6.7 6.6 6.5 Change-Id: I423e747ae4de0708d063a6bb2befd625dbd5c591 Reviewed-by: Ivan Solovev <[email protected]>
* [docs] QDBusUtil: remove documentation of bygone functionsMarc Mutz2024-02-211-19/+0
| | | | | | | | | | | | | | The referenced QString overloads were removed when 6bbfae9457248f1f65cf18f87ecc6ff66a6fdd70 ported from QString/QStringRef overload sets to single QStringView functions. Remove the docs. Amends 6bbfae9457248f1f65cf18f87ecc6ff66a6fdd70. Pick-to: 6.7 6.6 6.5 6.2 Change-Id: I766ad104f83aa19d90eeefe5b67524184869640a Reviewed-by: Ivan Solovev <[email protected]>