2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 00:46:08 +00:00

Use gsl::finally to pop thread context where appropriate

This commit is contained in:
Ilya Fedin
2021-07-02 20:29:46 +04:00
committed by John Preston
parent 1261c775d4
commit b335741f99
3 changed files with 10 additions and 3 deletions

View File

@@ -148,6 +148,9 @@ void PortalAutostart(bool start, bool silent) {
const auto context = Glib::MainContext::create();
const auto loop = Glib::MainLoop::create(context);
g_main_context_push_thread_default(context->gobj());
const auto contextGuard = gsl::finally([&] {
g_main_context_pop_thread_default(context->gobj());
});
const auto signalId = connection->signal_subscribe(
[&](
@@ -200,7 +203,6 @@ void PortalAutostart(bool start, bool silent) {
QWindow window;
QGuiApplicationPrivate::showModalWindow(&window);
loop->run();
g_main_context_pop_thread_default(context->gobj());
QGuiApplicationPrivate::hideModalWindow(&window);
}
} catch (const Glib::Error &e) {