2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-08 10:35:15 +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

@@ -574,6 +574,10 @@ int XDPFileDialog::exec() {
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());
});
rpl::lifetime lifetime;
accepted(
@@ -594,7 +598,6 @@ int XDPFileDialog::exec() {
QPointer<QDialog> guard = this;
loop->run();
g_main_context_pop_thread_default(context->gobj());
if (guard.isNull()) {
return QDialog::Rejected;