[gimp/gimp-2-10] app: wait for the software to be fully initialized before processing…



commit f2f0b6aae8d950fe4795c436157edee27f7e3a50
Author: Jehan <jehan girinstud io>
Date:   Tue Nov 10 21:40:47 2020 +0100

    app: wait for the software to be fully initialized before processing…
    
    … 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 <Image> 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.
    
    (cherry picked from commit a86ed68870b8a3a11f0b28c688b725c696dfdaf0)

 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 19148d0168..b179abd5aa 100644
--- a/app/app.c
+++ b/app/app.c
@@ -346,6 +346,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 f221351387..d4b1e39d8c 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 16628616f0..1e2f59f1ba 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 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]