Use gsl::finally in PortalAutostart

This commit is contained in:
Ilya Fedin 2021-03-07 02:29:38 +04:00 committed by John Preston
parent b918170464
commit 67eba93e29
1 changed files with 6 additions and 1 deletions

View File

@ -172,6 +172,12 @@ PortalAutostart::PortalAutostart(bool start, bool silent) {
"Response",
requestPath);
const auto signalGuard = gsl::finally([&] {
if (signalId != 0) {
connection->signal_unsubscribe(signalId);
}
});
connection->call_sync(
std::string(kXDGDesktopPortalObjectPath),
"org.freedesktop.portal.Background",
@ -186,7 +192,6 @@ PortalAutostart::PortalAutostart(bool start, bool silent) {
QGuiApplicationPrivate::showModalWindow(this);
loop.exec();
QGuiApplicationPrivate::hideModalWindow(this);
connection->signal_unsubscribe(signalId);
}
} catch (const Glib::Error &e) {
if (!silent) {