summaryrefslogtreecommitdiffstats
path: root/src/dbus/doc
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-02-03 19:01:21 -0800
committerThiago Macieira <thiago.macieira@intel.com>2024-02-05 19:36:17 -0800
commit9e73917537368d1904cc227da3332e970ad23752 (patch)
tree683cbdfc043080c223e5a9e8cda4e29fd58aa7c1 /src/dbus/doc
parent366657b95113a06ac5432839ec73121cc8631a42 (diff)
QDBusAbstractInterface/Doc: fix example to match the description
The docs say "This example illustrates function calling with 0, 1 and 2 parameters" because it was copied from the synchronous call() documentation. But the snippet didn't do that, because back in Qt 4 when this was created, it was too difficult to exemplify that for asynchronous use. It now no longer is, with lambdas. Drive-by update the docs for both functions to refer to each other. Fixes: QTBUG-121873 Pick-to: 6.6 6.7 Change-Id: I664b9f014ffc48cbb49bfffd17b089b7f77c1cde Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Diffstat (limited to 'src/dbus/doc')
-rw-r--r--src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp
index 85945ac2c7..92b9dea909 100644
--- a/src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp
+++ b/src/dbus/doc/snippets/code/src_qdbus_qdbusabstractinterface.cpp
@@ -47,12 +47,22 @@ else
void Abstract_DBus_Interface::asyncCall()
{
//! [1]
-QString value = retrieveValue();
-QDBusPendingCall pcall = interface->asyncCall("Process"_L1, value);
-
-QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall);
+QDBusPendingCall pcall = interface->asyncCall("GetAPIVersion"_L1);
+auto watcher = new QDBusPendingCallWatcher(pcall, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this,
- &Abstract_DBus_Interface::callFinishedSlot);
+ [&](QDBusPendingCallWatcher *w) {
+ QString value = retrieveValue();
+ QDBusPendingReply<int> reply(*w);
+ QDBusPendingCall pcall;
+ if (reply.argumentAt<0>() >= 14)
+ pcall = interface->asyncCall("ProcessWorkUnicode"_L1, value);
+ else
+ pcall = interface->asyncCall("ProcessWork"_L1, "UTF-8"_L1, value.toUtf8());
+
+ w = new QDBusPendingCallWatcher(pcall);
+ QObject::connect(w, &QDBusPendingCallWatcher::finished, this,
+ &Abstract_DBus_Interface::callFinishedSlot);
+});
//! [1]
}