Resubscribe to signal when running with old xdg-desktop-portal
This commit is contained in:
parent
f1a9884011
commit
95b4435396
|
@ -408,35 +408,37 @@ void XDPFileDialog::openPortal() {
|
||||||
+ uniqueName
|
+ uniqueName
|
||||||
+ '/'
|
+ '/'
|
||||||
+ handleToken;
|
+ handleToken;
|
||||||
|
|
||||||
|
const auto responseCallback = crl::guard(this, [=](
|
||||||
|
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||||
|
const Glib::ustring &sender_name,
|
||||||
|
const Glib::ustring &object_path,
|
||||||
|
const Glib::ustring &interface_name,
|
||||||
|
const Glib::ustring &signal_name,
|
||||||
|
const Glib::VariantContainerBase ¶meters) {
|
||||||
|
try {
|
||||||
|
auto parametersCopy = parameters;
|
||||||
|
|
||||||
|
const auto response = base::Platform::GlibVariantCast<uint>(
|
||||||
|
parametersCopy.get_child(0));
|
||||||
|
|
||||||
|
const auto results = base::Platform::GlibVariantCast<
|
||||||
|
std::map<
|
||||||
|
Glib::ustring,
|
||||||
|
Glib::VariantBase
|
||||||
|
>>(parametersCopy.get_child(1));
|
||||||
|
|
||||||
|
gotResponse(response, results);
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
LOG(("XDP File Dialog Error: %1").arg(
|
||||||
|
QString::fromStdString(e.what())));
|
||||||
|
|
||||||
|
_reject.fire({});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
_requestSignalId = _dbusConnection->signal_subscribe(
|
_requestSignalId = _dbusConnection->signal_subscribe(
|
||||||
crl::guard(this, [=](
|
responseCallback,
|
||||||
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
|
||||||
const Glib::ustring &sender_name,
|
|
||||||
const Glib::ustring &object_path,
|
|
||||||
const Glib::ustring &interface_name,
|
|
||||||
const Glib::ustring &signal_name,
|
|
||||||
const Glib::VariantContainerBase ¶meters) {
|
|
||||||
try {
|
|
||||||
auto parametersCopy = parameters;
|
|
||||||
|
|
||||||
const auto response = base::Platform::GlibVariantCast<uint>(
|
|
||||||
parametersCopy.get_child(0));
|
|
||||||
|
|
||||||
const auto results = base::Platform::GlibVariantCast<
|
|
||||||
std::map<
|
|
||||||
Glib::ustring,
|
|
||||||
Glib::VariantBase
|
|
||||||
>>(parametersCopy.get_child(1));
|
|
||||||
|
|
||||||
gotResponse(response, results);
|
|
||||||
} catch (const std::exception &e) {
|
|
||||||
LOG(("XDP File Dialog Error: %1").arg(
|
|
||||||
QString::fromStdString(e.what())));
|
|
||||||
|
|
||||||
_reject.fire({});
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
{},
|
{},
|
||||||
"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 = {
|
||||||
|
|
Loading…
Reference in New Issue