[gimp] libgimp: separate more new from old code by duplicating more logic in GimpPlugIn
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: separate more new from old code by duplicating more logic in GimpPlugIn
- Date: Mon, 5 Aug 2019 20:38:50 +0000 (UTC)
commit 6cf1ec820001db62e6d921bb8fb3442a816e8b45
Author: Michael Natterer <mitch gimp org>
Date: Mon Aug 5 22:37:26 2019 +0200
libgimp: separate more new from old code by duplicating more logic in GimpPlugIn
libgimp/gimp.c | 34 ++++++++++-------------------
libgimp/gimpplugin-private.c | 52 ++++++++++++++++++++++++++++++++++----------
2 files changed, 52 insertions(+), 34 deletions(-)
---
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index e208763f98..b073b8e943 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -614,17 +614,6 @@ gimp_main_internal (GType plug_in_type,
if (strcmp (argv[ARG_MODE], "-query") == 0)
{
- if (PLUG_IN)
- {
- if (GIMP_PLUG_IN_GET_CLASS (PLUG_IN)->init_procedures)
- gp_has_init_write (_gimp_writechannel, NULL);
- }
- else
- {
- if (PLUG_IN_INFO.init_proc)
- gp_has_init_write (_gimp_writechannel, NULL);
- }
-
if (_gimp_debug_flags () & GIMP_DEBUG_QUERY)
_gimp_debug_stop ();
@@ -634,6 +623,9 @@ gimp_main_internal (GType plug_in_type,
}
else
{
+ if (PLUG_IN_INFO.init_proc)
+ gp_has_init_write (_gimp_writechannel, NULL);
+
if (PLUG_IN_INFO.query_proc)
PLUG_IN_INFO.query_proc ();
}
@@ -668,17 +660,17 @@ gimp_main_internal (GType plug_in_type,
else if (_gimp_debug_flags () & GIMP_DEBUG_PID)
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Here I am!");
- g_io_add_watch (_gimp_readchannel,
- G_IO_ERR | G_IO_HUP,
- gimp_plugin_io_error_handler,
- NULL);
-
if (PLUG_IN)
{
_gimp_plug_in_run (PLUG_IN);
}
else
{
+ g_io_add_watch (_gimp_readchannel,
+ G_IO_ERR | G_IO_HUP,
+ gimp_plugin_io_error_handler,
+ NULL);
+
_gimp_loop (PLUG_IN_INFO.run_proc);
}
@@ -1101,11 +1093,11 @@ gimp_close (void)
{
if (PLUG_IN_INFO.quit_proc)
PLUG_IN_INFO.quit_proc ();
- }
- _gimp_shm_close ();
+ _gimp_shm_close ();
- gp_quit_write (_gimp_writechannel, NULL);
+ gp_quit_write (_gimp_writechannel, NULL);
+ }
}
static void
@@ -1373,11 +1365,9 @@ _gimp_config (GPConfig *config)
{
GFile *file;
gchar *path;
- gint shm_ID;
_tile_width = config->tile_width;
_tile_height = config->tile_height;
- shm_ID = config->shm_ID;
_check_size = config->check_size;
_check_type = config->check_type;
_show_help_button = config->show_help_button ? TRUE : FALSE;
@@ -1411,7 +1401,7 @@ _gimp_config (GPConfig *config)
g_free (path);
g_object_unref (file);
- _gimp_shm_open (shm_ID);
+ _gimp_shm_open (config->shm_ID);
}
static void
diff --git a/libgimp/gimpplugin-private.c b/libgimp/gimpplugin-private.c
index 08fb6d635d..86ab46a096 100644
--- a/libgimp/gimpplugin-private.c
+++ b/libgimp/gimpplugin-private.c
@@ -27,6 +27,7 @@
#include "libgimpbase/gimpwire.h"
#include "gimp-private.h"
+#include "gimp-shm.h"
#include "gimpgpparams.h"
#include "gimpplugin-private.h"
#include "gimpprocedure-private.h"
@@ -34,18 +35,21 @@
/* local function prototpes */
-static void gimp_plug_in_register (GimpPlugIn *plug_in,
- GList *procedures);
-static void gimp_plug_in_loop (GimpPlugIn *plug_in);
-static void gimp_plug_in_process_message (GimpPlugIn *plug_in,
- GimpWireMessage *msg);
-static void gimp_plug_in_proc_run (GimpPlugIn *plug_in,
- GPProcRun *proc_run);
-static void gimp_plug_in_temp_proc_run (GimpPlugIn *plug_in,
- GPProcRun *proc_run);
-static void gimp_plug_in_proc_run_internal (GPProcRun *proc_run,
- GimpProcedure *procedure,
- GPProcReturn *proc_return);
+static void gimp_plug_in_register (GimpPlugIn *plug_in,
+ GList *procedures);
+static void gimp_plug_in_loop (GimpPlugIn *plug_in);
+static void gimp_plug_in_process_message (GimpPlugIn *plug_in,
+ GimpWireMessage *msg);
+static void gimp_plug_in_proc_run (GimpPlugIn *plug_in,
+ GPProcRun *proc_run);
+static void gimp_plug_in_temp_proc_run (GimpPlugIn *plug_in,
+ GPProcRun *proc_run);
+static void gimp_plug_in_proc_run_internal (GPProcRun *proc_run,
+ GimpProcedure *procedure,
+ GPProcReturn *proc_return);
+static gboolean gimp_plug_in_io_error_handler (GIOChannel *channel,
+ GIOCondition cond,
+ gpointer data);
/* public functions */
@@ -55,6 +59,9 @@ _gimp_plug_in_query (GimpPlugIn *plug_in)
{
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
+ if (GIMP_PLUG_IN_GET_CLASS (plug_in)->init_procedures)
+ gp_has_init_write (_gimp_writechannel, NULL);
+
if (GIMP_PLUG_IN_GET_CLASS (plug_in)->query_procedures)
{
GList *procedures =
@@ -83,6 +90,11 @@ _gimp_plug_in_run (GimpPlugIn *plug_in)
{
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
+ g_io_add_watch (_gimp_readchannel,
+ G_IO_ERR | G_IO_HUP,
+ gimp_plug_in_io_error_handler,
+ NULL);
+
gimp_plug_in_loop (plug_in);
}
@@ -93,6 +105,10 @@ _gimp_plug_in_quit (GimpPlugIn *plug_in)
if (GIMP_PLUG_IN_GET_CLASS (plug_in)->quit)
GIMP_PLUG_IN_GET_CLASS (plug_in)->quit (plug_in);
+
+ _gimp_shm_close ();
+
+ gp_quit_write (_gimp_writechannel, NULL);
}
void
@@ -362,3 +378,15 @@ gimp_plug_in_proc_run_internal (GPProcRun *proc_run,
gimp_value_array_unref (return_values);
}
+
+static gboolean
+gimp_plug_in_io_error_handler (GIOChannel *channel,
+ GIOCondition cond,
+ gpointer data)
+{
+ g_printerr ("%s: fatal error: GIMP crashed\n", gimp_get_progname ());
+ gimp_quit ();
+
+ /* never reached */
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]