From a86ed68870b8a3a11f0b28c688b725c696dfdaf0 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 10 Nov 2020 21:40:47 +0100 Subject: [PATCH] =?UTF-8?q?app:=20wait=20for=20the=20software=20to=20be=20?= =?UTF-8?q?fully=20initialized=20before=20processing=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … DBus calls. In particular, Aryeom would start GIMP and directly double click some image to be loaded in GIMP in the very short while when splash is visible. Previous code would wait for the `restored` flag to be TRUE. This was nearly it as we can actually start loading images as soon as the 'restore' signal has passed. Yet the flag is set in the main handler, but we actually also need the UI manager to exist, which is created in gui_restore_after_callback() (so also a 'restore' handler, yet after the main signal handler, i.e. after `restored` is set to TRUE). Without this, gui_display_create() would fail with a CRITICAL, hence file_open_with_proc_and_display() as well. I could have tried to set the `restored` flag later, maybe with some clever signal handling trick (and handle both the GUI and non-GUI cases, i.e. I cannot set the flag inside gui_restore_after_callback() as it would break the non-GUI cases). Instead I go for a simpler logics with a new `initialized` flag which is only meant to be set once, once everything has been loaded, i.e. once you can consider GIMP to be fully running hence ready to process any common runtime command. --- app/app.c | 3 +++ app/core/gimp.h | 1 + app/gui/gimpdbusservice.c | 3 +-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/app.c b/app/app.c index a93b3b1fe0..c2f7ee3311 100644 --- a/app/app.c +++ b/app/app.c @@ -351,6 +351,9 @@ app_run (const gchar *full_prog_name, G_CALLBACK (app_exit_after_callback), &run_loop); + /* The software is now fully loaded and ready to be used. */ + gimp->initialized = TRUE; + #ifndef GIMP_CONSOLE_COMPILATION if (run_loop && ! no_interface) { diff --git a/app/core/gimp.h b/app/core/gimp.h index 81c27ed74a..a543520d32 100644 --- a/app/core/gimp.h +++ b/app/core/gimp.h @@ -60,6 +60,7 @@ struct _Gimp GimpGui gui; /* gui vtable */ gboolean restored; /* becomes TRUE in gimp_restore() */ + gboolean initialized; /* Fully initialized (only set once at start). */ gint busy; guint busy_idle_id; diff --git a/app/gui/gimpdbusservice.c b/app/gui/gimpdbusservice.c index e90c229171..04dec1a37f 100644 --- a/app/gui/gimpdbusservice.c +++ b/app/gui/gimpdbusservice.c @@ -328,14 +328,13 @@ gimp_dbus_service_process_idle (GimpDBusService *service) { IdleData *data; - if (! service->gimp->restored) + if (! service->gimp->initialized || ! service->gimp->restored) return TRUE; data = g_queue_pop_tail (service->queue); if (data) { - if (data->file) file_open_from_command_line (service->gimp, data->file, data->as_new, NULL /* FIXME monitor */);