[PySide6] XDG D-Bus: qt.dbus.integration: Could not connect "org.freedesktop.portal.Request" to nRequestResponse
-
Hi,
I'm trying to implement the XDG Portal D-Bus APIs for screencasting using the QtDBus module in PySide6.
I'm getting this error:
qt.dbus.integration: Could not connect "org.freedesktop.portal.Request" to nRequestResponse : Failed to connect to Response signal for /org/freedesktop/portal/desktop/request/_1_359/colorpycker_bedcade8
Here's the code I have so far, can anyone help me where the error is?
I have used Bustle and also dbus-monitor to see all the D-Bus Requests and I can see a couple successfull calls with the response that I do require, so why is it failing here? I've also noticed the logs show
nRequestResponse
instead ofonRequestResponse
. Not sure what's happening here.Here's the relevant code and I've linked to a pastebin of the entire code below if you want to test it:
def _connect_request_signal(self, request_path: str, method_name: str): """Connect to the Response signal for a request""" self.current_requests[request_path] = method_name success = self.bus.connect( "org.freedesktop.portal.Desktop", request_path, "org.freedesktop.portal.Request", "Response", self, "onRequestResponse", ) if not success: print(f"Failed to connect to Response signal for {request_path}") @Slot(int, dict) def onRequestResponse(self, response_code: int, results: dict): """Handle Response signal from portal requests""" sender_obj = self.sender() if not sender_obj: print("No sender object available") return method_name = "unknown" request_path_to_remove = None for path, stored_method in list(self.current_requests.items()): if not path.endswith("_handler"): method_name = stored_method request_path_to_remove = path break print(f"Response for {method_name}: code={response_code}, results={results}") if response_code != 0: error_msg = f"{method_name} failed with code {response_code}" self.screencast_failed.emit(error_msg) return if method_name == "CreateSession": self.session_handle = results.get("session_handle") if self.session_handle: self.session_created.emit(self.session_handle) else: self.screencast_failed.emit("No session handle received") elif method_name == "SelectSources": self.sources_selected.emit() elif method_name == "Start": streams = results.get("streams", []) restore_token = results.get("restore_token") if restore_token: print(f"Restore token: {restore_token}") if streams: self.screencast_started.emit(streams) else: self.screencast_failed.emit("No streams received") if request_path_to_remove and request_path_to_remove in self.current_requests: del self.current_requests[request_path_to_remove]
Pastebin to entire file: https://paste.centos.org/view/49a14c2d
-
A truncation like "nRequestResponse" instead of "onRequestResponse" typically means the SLOT function is missing. Probably SLOT("onRequestResponse") needs to be specified in the connect statement ( see https://doc.qt.io/qtforpython-6/tutorials/basictutorial/signals_and_slots.html#tutorial-signals-and-slots ).
-
I've tried a variety of options but none of them work.
@Slot() def on_session_created(self): self.bus.connect( "org.freedesktop.portal.Desktop", self.object_path, "org.freedesktop.portal.Request", "Response", self, SLOT("select_sources(uint, QVariantMap)"), ) @Slot(int, dict) def select_sources(response: int, results: dict): print(f"Received response: {response}, with results: {results}")
I have tried:
SLOT("select_sources(uint, QVariantMap)"), SLOT("select_sources"), just passing a method and many other things. -
Try decorating with string types:
@Slot("uint", "QVariantMap") def select_sources()
-
Try decorating with string types:
@Slot("uint", "QVariantMap") def select_sources()
@friedemannkleint This did not work either, although I wasn't getting any errors as such