Fix: D-Bus CreateSession "Missing token" error\n\nAdded a handle_token to the QVariantMap passed to the CreateSession call in wayland_poc.cpp to resolve the "Missing token" error. Updated lessons_learned.md.

This commit is contained in:
Tobias J. Endres 2025-08-14 07:16:48 +02:00
parent 0ccac075a4
commit 536e264590
2 changed files with 8 additions and 1 deletions

View File

@ -108,6 +108,11 @@ This document summarizes the key challenges, debugging steps, and solutions enco
* **Diagnosis:** The `xdg-desktop-portal` API for `CreateSession` had changed, and the `handlePath`, `sessionPath`, and `applicationName` arguments were no longer expected.
* **Fix:** Modified the `CreateSession` call in `wayland_poc.cpp` to only send an empty `QVariantMap` as its argument.
* **D-Bus `CreateSession` "Missing token" Error:**
* **Problem:** After fixing the `CreateSession` signature, the call failed with a "Missing token" error.
* **Diagnosis:** The `CreateSession` method, while expecting a single dictionary of options, also requires a `handle_token` within that dictionary.
* **Fix:** Added a `handle_token` to the `QVariantMap` passed to the `CreateSession` call in `wayland_poc.cpp`.
* **New Runtime Error: "Remote peer disconnected"**
* **Problem:** After successfully building and copying `wayland_poc` to the host, running it resulted in "D-Bus call to SelectSources failed: "Remote peer disconnected"".
* **Diagnosis:** This indicates a problem with the D-Bus connection itself, rather than a rejection from the portal. Possible causes include incorrect D-Bus environment variables on the host, `xdg-desktop-portal` not running, or permission issues.

View File

@ -145,7 +145,9 @@ int main(int argc, char *argv[]) {
QDBusObjectPath sessionPath("/org/freedesktop/portal/session/12345/screencast_sess_1");
// Add arguments: handle, session_handle, app_id, options
message << QVariantMap(); // Empty options map
QVariantMap options;
options.insert("handle_token", QUuid::createUuid().toString(QUuid::WithoutBraces)); // Add handle_token
message << options; // Empty options map
QDBusPendingCall pendingCall = sessionBus.asyncCall(message);
QDBusPendingCallWatcher *mainWatcher = new QDBusPendingCallWatcher(pendingCall);