[gimp/gtk3-port: 289/444] Revert "app: remove all deprecated threads_enter/leave code"



commit d0c16cad916ae793fdc2844dd6b11ef4c3be2c06
Author: Michael Natterer <mitch gimp org>
Date:   Wed May 2 16:14:54 2018 +0200

    Revert "app: remove all deprecated threads_enter/leave code"
    
    This reverts commit 94b028bc39c7250997ee9883793e6649bf2490c7.
    
    Dunno what breaks here, it just crashes, leave the commits there
    instead of rebasing them away, as reminder...

 app/app.c                            |    8 +++++---
 app/core/gimp-gui.c                  |   20 ++++++++++++++++++++
 app/core/gimp-gui.h                  |    6 ++++++
 app/gui/gui-vtable.c                 |   17 +++++++++++++++++
 app/plug-in/gimpplugin.c             |    2 ++
 app/plug-in/gimppluginmanager-call.c |    4 ++++
 6 files changed, 54 insertions(+), 3 deletions(-)
---
diff --git a/app/app.c b/app/app.c
index 964f599..85c178b 100644
--- a/app/app.c
+++ b/app/app.c
@@ -392,7 +392,6 @@ app_run (const gchar         *full_prog_name,
               g_object_unref (file);
             }
         }
-
       /* Delete backup XCF images. */
       for (iter = recovered_files; iter; iter = iter->next)
         {
@@ -420,7 +419,6 @@ app_run (const gchar         *full_prog_name,
             }
         }
     }
-
   if (font_error)
     {
       gimp_message_literal (gimp, NULL,
@@ -433,7 +431,11 @@ app_run (const gchar         *full_prog_name,
     gimp_batch_run (gimp, batch_interpreter, batch_commands);
 
   if (run_loop)
-    g_main_loop_run (loop);
+    {
+      gimp_threads_leave (gimp);
+      g_main_loop_run (loop);
+      gimp_threads_enter (gimp);
+    }
 
   if (gimp->be_verbose)
     g_print ("EXIT: %s\n", G_STRFUNC);
diff --git a/app/core/gimp-gui.c b/app/core/gimp-gui.c
index 77ac497..7c77b3d 100644
--- a/app/core/gimp-gui.c
+++ b/app/core/gimp-gui.c
@@ -42,6 +42,8 @@ gimp_gui_init (Gimp *gimp)
   g_return_if_fail (GIMP_IS_GIMP (gimp));
 
   gimp->gui.ungrab                 = NULL;
+  gimp->gui.threads_enter          = NULL;
+  gimp->gui.threads_leave          = NULL;
   gimp->gui.set_busy               = NULL;
   gimp->gui.unset_busy             = NULL;
   gimp->gui.show_message           = NULL;
@@ -77,6 +79,24 @@ gimp_gui_ungrab (Gimp *gimp)
 }
 
 void
+gimp_threads_enter (Gimp *gimp)
+{
+  g_return_if_fail (GIMP_IS_GIMP (gimp));
+
+  if (gimp->gui.threads_enter)
+    gimp->gui.threads_enter (gimp);
+}
+
+void
+gimp_threads_leave (Gimp *gimp)
+{
+  g_return_if_fail (GIMP_IS_GIMP (gimp));
+
+  if (gimp->gui.threads_leave)
+    gimp->gui.threads_leave (gimp);
+}
+
+void
 gimp_set_busy (Gimp *gimp)
 {
   g_return_if_fail (GIMP_IS_GIMP (gimp));
diff --git a/app/core/gimp-gui.h b/app/core/gimp-gui.h
index f7c4f5c..aa374df 100644
--- a/app/core/gimp-gui.h
+++ b/app/core/gimp-gui.h
@@ -25,6 +25,9 @@ struct _GimpGui
 {
   void           (* ungrab)                 (Gimp                *gimp);
 
+  void           (* threads_enter)          (Gimp                *gimp);
+  void           (* threads_leave)          (Gimp                *gimp);
+
   void           (* set_busy)               (Gimp                *gimp);
   void           (* unset_busy)             (Gimp                *gimp);
 
@@ -109,6 +112,9 @@ void           gimp_gui_init               (Gimp                *gimp);
 
 void           gimp_gui_ungrab             (Gimp                *gimp);
 
+void           gimp_threads_enter          (Gimp                *gimp);
+void           gimp_threads_leave          (Gimp                *gimp);
+
 GimpObject   * gimp_get_window_strategy    (Gimp                *gimp);
 GimpObject   * gimp_get_empty_display      (Gimp                *gimp);
 GimpObject   * gimp_get_display_by_ID      (Gimp                *gimp,
diff --git a/app/gui/gui-vtable.c b/app/gui/gui-vtable.c
index a2f7eaa..3dfeec7 100644
--- a/app/gui/gui-vtable.c
+++ b/app/gui/gui-vtable.c
@@ -87,6 +87,9 @@
 
 static void           gui_ungrab                 (Gimp                *gimp);
 
+static void           gui_threads_enter          (Gimp                *gimp);
+static void           gui_threads_leave          (Gimp                *gimp);
+
 static void           gui_set_busy               (Gimp                *gimp);
 static void           gui_unset_busy             (Gimp                *gimp);
 
@@ -164,6 +167,8 @@ gui_vtable_init (Gimp *gimp)
   g_return_if_fail (GIMP_IS_GIMP (gimp));
 
   gimp->gui.ungrab                 = gui_ungrab;
+  gimp->gui.threads_enter          = gui_threads_enter;
+  gimp->gui.threads_leave          = gui_threads_leave;
   gimp->gui.set_busy               = gui_set_busy;
   gimp->gui.unset_busy             = gui_unset_busy;
   gimp->gui.show_message           = gui_message;
@@ -208,6 +213,18 @@ gui_ungrab (Gimp *gimp)
 }
 
 static void
+gui_threads_enter (Gimp *gimp)
+{
+  GDK_THREADS_ENTER ();
+}
+
+static void
+gui_threads_leave (Gimp *gimp)
+{
+  GDK_THREADS_LEAVE ();
+}
+
+static void
 gui_set_busy (Gimp *gimp)
 {
   gimp_displays_set_busy (gimp);
diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c
index f0f852d..8869bc4 100644
--- a/app/plug-in/gimpplugin.c
+++ b/app/plug-in/gimpplugin.c
@@ -784,7 +784,9 @@ gimp_plug_in_main_loop (GimpPlugIn *plug_in)
 
   proc_frame->main_loop = g_main_loop_new (NULL, FALSE);
 
+  gimp_threads_leave (plug_in->manager->gimp);
   g_main_loop_run (proc_frame->main_loop);
+  gimp_threads_enter (plug_in->manager->gimp);
 
   g_clear_pointer (&proc_frame->main_loop, g_main_loop_unref);
 }
diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c
index f2defc3..a5a419f 100644
--- a/app/plug-in/gimppluginmanager-call.c
+++ b/app/plug-in/gimppluginmanager-call.c
@@ -256,7 +256,9 @@ gimp_plug_in_manager_call_run (GimpPlugInManager   *manager,
         {
           plug_in->ext_main_loop = g_main_loop_new (NULL, FALSE);
 
+          gimp_threads_leave (manager->gimp);
           g_main_loop_run (plug_in->ext_main_loop);
+          gimp_threads_enter (manager->gimp);
 
           /*  main_loop is quit in gimp_plug_in_handle_extension_ack()  */
 
@@ -272,7 +274,9 @@ gimp_plug_in_manager_call_run (GimpPlugInManager   *manager,
 
           proc_frame->main_loop = g_main_loop_new (NULL, FALSE);
 
+          gimp_threads_leave (manager->gimp);
           g_main_loop_run (proc_frame->main_loop);
+          gimp_threads_enter (manager->gimp);
 
           /*  main_loop is quit in gimp_plug_in_handle_proc_return()  */
 


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