mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Use gsl::finally to pop thread context where appropriate
This commit is contained in:
parent
1261c775d4
commit
b335741f99
3 changed files with 10 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -108,6 +108,9 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
|
|||
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(
|
||||
[&](
|
||||
|
@ -163,7 +166,6 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
|
|||
QWindow window;
|
||||
QGuiApplicationPrivate::showModalWindow(&window);
|
||||
loop->run();
|
||||
g_main_context_pop_thread_default(context->gobj());
|
||||
QGuiApplicationPrivate::hideModalWindow(&window);
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue