Resubscribe to signal when running with old xdg-desktop-portal

This commit is contained in:
Ilya Fedin 2021-05-06 22:12:03 +04:00 committed by John Preston
parent f1a9884011
commit 95b4435396
1 changed files with 38 additions and 31 deletions

View File

@ -409,8 +409,7 @@ void XDPFileDialog::openPortal() {
+ '/' + '/'
+ handleToken; + handleToken;
_requestSignalId = _dbusConnection->signal_subscribe( const auto responseCallback = crl::guard(this, [=](
crl::guard(this, [=](
const Glib::RefPtr<Gio::DBus::Connection> &connection, const Glib::RefPtr<Gio::DBus::Connection> &connection,
const Glib::ustring &sender_name, const Glib::ustring &sender_name,
const Glib::ustring &object_path, const Glib::ustring &object_path,
@ -436,7 +435,10 @@ void XDPFileDialog::openPortal() {
_reject.fire({}); _reject.fire({});
} }
}), });
_requestSignalId = _dbusConnection->signal_subscribe(
responseCallback,
{}, {},
"org.freedesktop.portal.Request", "org.freedesktop.portal.Request",
"Response", "Response",
@ -461,10 +463,15 @@ void XDPFileDialog::openPortal() {
Glib::ustring>(reply.get_child(0)); Glib::ustring>(reply.get_child(0));
if (handle != requestPath) { if (handle != requestPath) {
crl::on_main([=] { _dbusConnection->signal_unsubscribe(
_failedToOpen = true; _requestSignalId);
_reject.fire({});
}); _requestSignalId = _dbusConnection->signal_subscribe(
responseCallback,
{},
"org.freedesktop.portal.Request",
"Response",
handle);
} }
} catch (const Glib::Error &e) { } catch (const Glib::Error &e) {
static const auto NotSupportedErrors = { static const auto NotSupportedErrors = {