mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix check for disconnected error
This commit is contained in:
parent
41078869a9
commit
0d96657c33
2 changed files with 25 additions and 10 deletions
|
@ -71,8 +71,18 @@ auto MakeFilterList(const QString &filter) {
|
||||||
|
|
||||||
std::optional<uint> FileChooserPortalVersion() {
|
std::optional<uint> FileChooserPortalVersion() {
|
||||||
try {
|
try {
|
||||||
const auto connection = Gio::DBus::Connection::get_sync(
|
const auto connection = [] {
|
||||||
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
try {
|
||||||
|
return Gio::DBus::Connection::get_sync(
|
||||||
|
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
||||||
|
} catch (...) {
|
||||||
|
return Glib::RefPtr<Gio::DBus::Connection>();
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
if (!connection) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
auto reply = connection->call_sync(
|
auto reply = connection->call_sync(
|
||||||
std::string(kXDGDesktopPortalObjectPath),
|
std::string(kXDGDesktopPortalObjectPath),
|
||||||
|
@ -90,7 +100,6 @@ std::optional<uint> FileChooserPortalVersion() {
|
||||||
reply.get_child(0)));
|
reply.get_child(0)));
|
||||||
} catch (const Glib::Error &e) {
|
} catch (const Glib::Error &e) {
|
||||||
static const auto NotSupportedErrors = {
|
static const auto NotSupportedErrors = {
|
||||||
"org.freedesktop.DBus.Error.Disconnected",
|
|
||||||
"org.freedesktop.DBus.Error.ServiceUnknown",
|
"org.freedesktop.DBus.Error.ServiceUnknown",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -435,10 +444,7 @@ void XDPFileDialog::openPortal() {
|
||||||
},
|
},
|
||||||
_cancellable,
|
_cancellable,
|
||||||
std::string(kXDGDesktopPortalService));
|
std::string(kXDGDesktopPortalService));
|
||||||
} catch (const Glib::Error &e) {
|
} catch (...) {
|
||||||
LOG(("XDP File Dialog Error: %1").arg(
|
|
||||||
QString::fromStdString(e.what())));
|
|
||||||
|
|
||||||
_reject.fire({});
|
_reject.fire({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -430,8 +430,18 @@ bool UseUnityCounter() {
|
||||||
|
|
||||||
bool IsSNIAvailable() {
|
bool IsSNIAvailable() {
|
||||||
try {
|
try {
|
||||||
const auto connection = Gio::DBus::Connection::get_sync(
|
const auto connection = [] {
|
||||||
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
try {
|
||||||
|
return Gio::DBus::Connection::get_sync(
|
||||||
|
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
||||||
|
} catch (...) {
|
||||||
|
return Glib::RefPtr<Gio::DBus::Connection>();
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
if (!connection) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto reply = connection->call_sync(
|
auto reply = connection->call_sync(
|
||||||
std::string(kSNIWatcherObjectPath),
|
std::string(kSNIWatcherObjectPath),
|
||||||
|
@ -448,7 +458,6 @@ bool IsSNIAvailable() {
|
||||||
reply.get_child(0)));
|
reply.get_child(0)));
|
||||||
} catch (const Glib::Error &e) {
|
} catch (const Glib::Error &e) {
|
||||||
static const auto NotSupportedErrors = {
|
static const auto NotSupportedErrors = {
|
||||||
"org.freedesktop.DBus.Error.Disconnected",
|
|
||||||
"org.freedesktop.DBus.Error.ServiceUnknown",
|
"org.freedesktop.DBus.Error.ServiceUnknown",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue