Fix: QDBusMessage::clearArguments() method not found\n\nRemoved the call to clearArguments() as it was causing a compilation error due to its removal in Qt 5.15. Updated lessons_learned.md.

This commit is contained in:
Tobias J. Endres 2025-08-14 07:15:06 +02:00
parent c0626e7232
commit 46a5aa63a1
2 changed files with 6 additions and 1 deletions

View File

@ -98,6 +98,11 @@ This document summarizes the key challenges, debugging steps, and solutions enco
1. Created a new handler function, `handleCreateSessionFinished`, to specifically process the `CreateSession` reply. This function extracts the session handle and then correctly initiates the `SelectSources` D-Bus call with its own `QDBusPendingCallWatcher` connected to `handleSelectSourcesResponse`.
2. Modified the `main` function to connect the `CreateSession`'s `QDBusPendingCallWatcher` to `handleCreateSessionFinished`.
* **`QDBusMessage::clearArguments()` Method Not Found:**
* **Problem:** Compilation failed with an error indicating `QDBusMessage` had no member named `clearArguments()`.
* **Diagnosis:** The `clearArguments()` method was removed in Qt 5.15, which is the version likely used in the Docker build environment. The call was also redundant as arguments were being cleared and then immediately re-added.
* **Fix:** Removed the line `message.clearArguments();` from `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

@ -105,7 +105,7 @@ void handleCreateSessionFinished(QDBusPendingCallWatcher *watcher) {
options.insert("handle_token", QUuid::createUuid().toString(QUuid::WithoutBraces)); // Use QUuid without braces
options.insert("restore_token", QUuid::createUuid().toString(QUuid::WithoutBraces)); // Add restore_token (OBS value)
message.clearArguments(); // Clear any existing arguments
message << options;
QDBusPendingCall pendingCall = sessionBus.asyncCall(message);