The message processing may finish before watcherHelper is
setup. Use locking and an additional check for message
processing completion to avoid the race condition.
Move the code to new function inside QDBusPendingCallPrivate,
close to where the waiting without GUI is done.
Add assertions that check that watcherHelper is not overwritten.
Change-Id: I24e54598135edf293c41b3a80369b0a3b46f775c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This list is accessed by ~QDBusServerConnection in a user thead.
Task-number: QTBUG-116621
Change-Id: Ic115612b2a0f12fd9f69f38f4662dc36fffbf178
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Also lock before accessing serverObject member, it is cleared
by ~QDBusServer().
Task-number: QTBUG-116621
Change-Id: I14c96e34316a46fe43ecd929e44cd1800ba8b803
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
When the operation fails we print a warning, but that warning does not
include the error message that prepareHook internally collects but
ignores.
Printing the error is useful for debugging.
Pick-to: 6.6
Change-Id: I946c4781942115a17ffd43a79bff7676b6674be1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Disable copy and move for the class because it is polymorphic.
Make the constructor protected because instances of this
class are not supposed to be created directly.
Mark drived classes final.
Change-Id: Ia6f2d640f3642ad4a6ecb3830fba152155e237b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use atomic pointers.
While at it, declare the function type with `using` instead
of a typedef for better readability, do the declaration
locally so that less preprocessor concatenation is needed,
use reinterpret_cast instead of C-style cast.
Change-Id: I5ed0d35b7ddfdd62ef6c12403fe7052019453f34
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This avoids having direction member uninitialized by mistake. Make the
member variable const as it is never modified.
While at it, make Direction and enum class.
Change-Id: I53814ae9e1d6bcf786433674619145a1ee61e063
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Declare flags as QDBusConnection::ConnectionCapabilities
instead of bare int. Do the same for derived classes
QDBusMarshaller and QDBusDemarshaller. Make the constructors
explicit, replacing useless `inline` where it was used.
Make flags argument default to empty flags.
Change-Id: I6caedde06b2ef41d725f15348ee780d1cc20b355
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
For better readability and ease of modification.
Do the same for derived classes.
Change-Id: I9601f0b280feb5e3d0e71ed4a3405fdd9cca8dd2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This makes function declarations much easier to read.
Change-Id: Ib05433cda97a39f4a3b8c2759c32309a60716bfb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This gives more information than an int, also simplifies the code
slightly.
Change-Id: I76c00230386d74c70d294e638b4927de883f03ff
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Slots like (un)registerServiceNoLock() modify shared state and
should be run with write lock taken. Having only read lock results
in hard to reproduce crashes.
Task-number: QTBUG-116621
Change-Id: I4456b64f9f2200378012822143e1a05345859d62
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Do the same for the derived classes.
Change-Id: Ieec1d222a96775d57af91f9c6757648561b75e53
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This class is reference counted, having a parent would
interfere with this reference counting code.
Change-Id: I5ab4fdfa74af94d8b760bd3600bd1f828e3d2b91
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The \generate list names are added for each categorized section with
some explanation. Here, calling the overviews as
explanations-(name of the section). The idea is to give general terms
instead of specific phrases like 'core' etc, for better understanding.
Task-number: QTBUG-115347
Pick-to: 6.5 6.6
Change-Id: I673e38c0e9193b7f7d54008bfcf82c2d3a10be3f
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
The function is declared but never defined.
Change-Id: Ic9c4369ecaee3103b74d2dc9b84cbece99379603
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This also includes variables only used in Q_ASSERT, those
don't generate warnings anymore even when asserts are disabled.
Change-Id: Ia557120d442c100c9437b106a01a4079d48640af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This removes the need for doing two separate iteration to find
entries in the hash. Also QMultyHash can now be replaced by
plain QHash.
Change-Id: Ie704e74c1dbb0c8e40d22a7cd572fcc8a3bfcd5d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Nothing in those files uses QPair; and a local build finished fine without them.
Task-number: QTBUG-115841
Change-Id: I669cfecaa9129bce6b31e464826287f138b159db
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Seeing a public keyword may make the reader mistakenly
believe that the section above is not public.
Change-Id: I074d54ed5f6a5b5911d4c6038d33e14d2c58abe0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This class has two bindable properties - watchedServices and watchMode.
What makes this class non-trivial is the fact that these properties
depend on each other - setWatchedServices() need an up-to-date
watchMode to set up the services, and setWatchMode() needs an
up-to-date list of services in order to update the mode on them.
Update the setters in such way that they remove the bindings from
the updated property, and at the same time trigger the re-evaluation
of the property they depend on.
This includes refactoring of the helper setConnection() method in such
way that it does not cause property re-evaluation, and also update
of the {add,remove}Service() helper functions to take the watchMode as
an input parameter.
The public {add,remove}WatchedService() methods were updated similarly.
The logic of the removeWatchedService() method was additionally
updated to do some changes to the properties only if the
service-to-be-removed actually existed in the list.
Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: If46cf926c7ace9dc4893d8daaef088f61e41c21a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Remove indirection via _q_newConnection() because the server object
may not exist anymore when this method is invoked.
This amends commit d865e3ef1d.
Task-number: QTBUG-116621
Change-Id: I5f9a667bc0e2e3cd36492c24767505031fe0e1d7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Use QMetaObject::invokeMethod() to schedule call to
QDBusConnectionPrivate::_q_newConnectioni() instead.
This also gets rid of a by name signal/slot connection.
Change-Id: I8725c4e3815c5580c5561bdddda0ab722b06346e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use connection to a lambda instead. This makes
QDBusPendingCallWatcherPrivate obsolete and it is also removed.
Change-Id: I3d80ff2da25609c694322e5fef4231600ba346b4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This makes the code slightly more readable.
Rename one overload of QDBusConnectionManager::doConnectToBus to
avoid using qOverload.
Change-Id: Id878e5baade539c3f748b5bf66a5aff726604b89
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Make `mutex` member private and make all former users call
new public member functions that perform locking. Make
old non-locking member functions private.
Change-Id: I29092d1bd785aa6b830183c1c1fe125b16e0d633
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use QMetaObject::invokeMethod() with a lambda instead of setting
up a permanent signal/slot connections with BlockingQueuedConnection
type. This makes the code flow easier to follow.
Change-Id: I0e77433e3fb96f99ed39f2d14dad737d444d3269
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use QMetaObject::invokeMethod() with a lambda instead of setting
up a permanent signal/slot connections with BlockingQueuedConnection
type. This makes the code flow easier to follow.
Change-Id: Ib6566e7a4694ecbd69900b645d020b3331fb3462
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Split the source code into a separate file for easier code
navigation and to better match the rest of Qt.
Update the link to the blog post explaining the
preventDllUnload() function, mention the blog post title
to make it easier to find it again when the link breaks.
Change-Id: I061d72bc795110f03352abf10fc639ddd6243527
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Move the definition of cachedRelaySlotMethodIndex inside
relaySlotMethodIndex() to get thread-safe initialization.
Change-Id: I48683078f4dc610e9c7d1591287cf2d1dcfe8778
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
That's weird and I have no idea how that worked.
Change-Id: I6ecb967e108256ebf1609e08ef02fc2ec83ef2ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
By actually registering them.
Commit 850d850c5a changed from
qMetaTypeId<QDBusArgument>() to QMetaType::fromType<QDBusArgument>() and
in Qt 6, fromType() does not register the type with the database. That
means the lines became runtime no-ops at that time or during the
QMetaType updates since 6.0. All they did was instantiate the C++ inline
variable.
The testing also detected we didn't register QList<QDBusVariant> as an
alias for the "av" signature. I'm not entirely sure you're allowed to
use this because QtDBus does not like re-registration of the built-in
types, and "av" is already assigned to QVariantList. This is no trouble
for the parser, anyway.
Minor change to qdbuscpp2xml to allow reading from stdin, so we don't
have to create temporary files.
Pick-to: 6.5 6.6
Fixes: QTBUG-115964
Change-Id: I80612a7d275c41f1baf0fffd177a14925e7d23ac
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Call QDBusMetaTypeId::init() in the cosntructor. This ensures that
the custom metatype registry is not destroyed before the instance
of the connection manager.
Task-number: QTBUG-58732
Pick-to: 6.6
Change-Id: I8c7c4c23deab2c7e11c6389a8976666ccf6baf48
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This reverts commit 4c1df115ec.
We cannot guarantee that there are no more QMetaType
instances that reference the interfaces being destroyed.
All such instances will become invalid after the interface
destruction with no way to verify that.
Pick-to: 6.6 6.5
Change-Id: Iad17fe88753143734b8b817dda184e3c3818575c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Combine the lock and the custom types list into one struct
so that the check code does not have to be duplicated.
Pick-to: 6.6
Task-number: QTBUG-58732
Change-Id: Ib61d5be3a3cb6465acc5834e5dcbc735fb8b4d8e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
The assertion is triggered when a timer cannot be started. This
is normal occurrence when an application exits before all pending
D-Bus calls are processed. And there is a code handling such failure
in the same function. Qt also prints a warning message in this
case:
QEventDispatcherGlib::registerTimer: invalid arguments
Task-number: QTBUG-58732
Pick-to: 6.6
Change-Id: I37859443fa90ae1bf7da1572ac9b02a54c8e1b99
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This makes the rest of the code slightly cleaner.
Change-Id: I67606b369f00d54fc24f7d6f41c004a728d37b5f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Introduce a mutex that protects access to the spy hooks list.
Also don't pass around raw pointers to the spy hook list,
those can change when new hooks are added and storage is
reallocated. Change the type of the hooks list to QList
to take advantage of copy-on-write in common case.
Check whether the global static is destroyed in qDBusAddSpyHook().
Change-Id: I440a88ce088d6fb5817660c8e1e02901281b842f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Only const members of the object are used inside the function body.
This addresses a review comment for 0f37c47713
Change-Id: I873d87104eb2483c4388929487d750d4a7d44bf3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QMetaType does not own the interface from which it is constructed.
Consequently, we end up with a memory leak.
This is not a huge issue, given that the map of meta-types is static,
and the application is about to be close when can discard it anyway, but
it causes avoidable sanitizer warnings, which are annoying when
debugging more severe memory leaks.
Pick-to: 6.6 6.5
Change-Id: Ifee3f4e19835536f4a6cfa4f6866ab621581ad4f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This has happened before: there's a disagreement on whether property
names need to be identifiers or not. In Qt, we insist they are, and if
this code had been around before, other specifications from other teams
in freedesktop.org and gnome.org would have adhered to this rule. But it
wasn't, so such properties exist (see [1]).
Commit bcc93850fc converted the check that
had bene here all along as a proper error for qdbusxml2cpp. So downgrade
it a warning and move on.
An alternative implementation would keep on going and install this
property with the invalid name, but qdbusxml2cpp and other generators
may want to ignore such property names later on. I'm not implementing
this in a bug fix (or at all).
[1] https://fprint.freedesktop.org/fprintd-dev/Device.html
Fixes: QTBUG-115596
Task-number: QTBUG-2597
Pick-to: 6.6
Change-Id: Ifbf974a4d10745b099b1fffd1776fb8cc9239125
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
The member function is never implemented.
Change-Id: Iee93c7d24df40b48b897d937889bb9556b8feb1a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The autogenerated list of overviews was adding the \group command which
included all the groups instead of overviews.
The idea here is to categorize the overviews later on once we have
the list of all overviews.
Task-number: QTBUG-114762
Pick-to: 6.5 6.6
Change-Id: I3cf53886be277abc86b5ec54d399cd6933fbe882
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>