Commit cc5e9240 authored by Michael Natterer's avatar Michael Natterer 😴

libgmp: move the remaining legacy code to gimplegacy, even PLUG_IN_INFO

Add gimplegacy-private.h to keep it separate from gimp-private.h.

The legacy code could now be removed and GimpPlugIn-ported plug-ins
would not notice.
parent 3c001a61
Pipeline #102446 failed with stages
in 13 minutes and 18 seconds
......@@ -113,6 +113,7 @@ libgimp_private_sources = \
gimpgpparams.h \
gimplegacy.c \
gimplegacy.h \
gimplegacy-private.h \
gimpdb-private.h \
gimppdbprocedure.c \
gimppdbprocedure.h \
......
......@@ -24,14 +24,12 @@
G_BEGIN_DECLS
void _gimp_config (GPConfig *config);
void _gimp_legacy_init (GIOChannel *read_channel,
GIOChannel *write_channel);
void _gimp_legacy_quit (void);
void _gimp_loop (GimpRunProc run_proc);
void _gimp_read_expect_msg (GimpWireMessage *msg,
gint type);
void _gimp_set_pdb_error (GimpValueArray *return_vals);
gint _gimp_main_internal (GType plug_in_type,
const GimpPlugInInfo *info,
gint argc,
gchar *argv[]);
void _gimp_config (GPConfig *config);
void _gimp_set_pdb_error (GimpValueArray *return_vals);
G_END_DECLS
......
......@@ -101,6 +101,7 @@
#include "gimp-shm.h"
#include "gimpgpcompat.h"
#include "gimpgpparams.h"
#include "gimplegacy-private.h"
#include "gimppdb-private.h"
#include "gimpplugin-private.h"
#include "gimpunitcache.h"
......@@ -108,59 +109,58 @@
#include "libgimp-intl.h"
static gint gimp_main_internal (GType plug_in_type,
const GimpPlugInInfo *info,
gint argc,
gchar *argv[]);
static void gimp_close (void);
static void gimp_message_func (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer data);
static void gimp_fatal_func (const gchar *log_domain,
GLogLevelFlags flags,
const gchar *message,
gpointer data);
static void gimp_close (void);
static void gimp_message_func (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer data);
static void gimp_fatal_func (const gchar *log_domain,
GLogLevelFlags flags,
const gchar *message,
gpointer data);
#ifdef G_OS_WIN32
#ifdef HAVE_EXCHNDL
static LONG WINAPI gimp_plugin_sigfatal_handler (PEXCEPTION_POINTERS pExceptionInfo);
#endif
#else
static void gimp_plugin_sigfatal_handler (gint sig_num);
#endif
#if defined G_OS_WIN32 && defined HAVE_EXCHNDL
static LPTOP_LEVEL_EXCEPTION_FILTER _prevExceptionFilter = NULL;
static gchar *plug_in_backtrace_path = NULL;
#endif
static gint _tile_width = -1;
static gint _tile_height = -1;
static gboolean _show_help_button = TRUE;
static gboolean _export_profile = FALSE;
static gboolean _export_exif = FALSE;
static gboolean _export_xmp = FALSE;
static gboolean _export_iptc = FALSE;
static GimpCheckSize _check_size = GIMP_CHECK_SIZE_MEDIUM_CHECKS;
static GimpCheckType _check_type = GIMP_CHECK_TYPE_GRAY_CHECKS;
static gint _gdisp_ID = -1;
static gchar *_wm_class = NULL;
static gchar *_display_name = NULL;
static gint _monitor_number = 0;
static guint32 _timestamp = 0;
static gchar *_icon_theme_dir = NULL;
static const gchar *progname = NULL;
static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_NEVER;
static GimpPlugIn *PLUG_IN = NULL;
static GimpPDB *PDB = NULL;
static GimpPlugInInfo PLUG_IN_INFO = { 0, };
static GimpPDBStatusType pdb_error_status = GIMP_PDB_SUCCESS;
static gchar *pdb_error_message = NULL;
#else /* ! G_OS_WIN32 */
static void gimp_plugin_sigfatal_handler (gint sig_num);
#endif /* G_OS_WIN32 */
static GimpPlugIn *PLUG_IN = NULL;
static GimpPDB *PDB = NULL;
static gint _tile_width = -1;
static gint _tile_height = -1;
static gboolean _show_help_button = TRUE;
static gboolean _export_profile = FALSE;
static gboolean _export_exif = FALSE;
static gboolean _export_xmp = FALSE;
static gboolean _export_iptc = FALSE;
static GimpCheckSize _check_size = GIMP_CHECK_SIZE_MEDIUM_CHECKS;
static GimpCheckType _check_type = GIMP_CHECK_TYPE_GRAY_CHECKS;
static gint _gdisp_ID = -1;
static gchar *_wm_class = NULL;
static gchar *_display_name = NULL;
static gint _monitor_number = 0;
static guint32 _timestamp = 0;
static gchar *_icon_theme_dir = NULL;
static const gchar *progname = NULL;
static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_NEVER;
static GimpPDBStatusType pdb_error_status = GIMP_PDB_SUCCESS;
static gchar *pdb_error_message = NULL;
/**
......@@ -181,34 +181,14 @@ gimp_main (GType plug_in_type,
gint argc,
gchar *argv[])
{
return gimp_main_internal (plug_in_type, NULL, argc, argv);
return _gimp_main_internal (plug_in_type, NULL, argc, argv);
}
/**
* gimp_main_legacy:
* @info: the #GimpPlugInInfo structure
* @argc: the number of arguments
* @argv: (array length=argc): the arguments
*
* The main procedure that must be called with the #GimpPlugInInfo
* structure and the 'argc' and 'argv' that are passed to "main".
*
* Returns: an exit status as defined by the C library,
* on success EXIT_SUCCESS.
**/
gint
gimp_main_legacy (const GimpPlugInInfo *info,
gint argc,
gchar *argv[])
{
return gimp_main_internal (G_TYPE_NONE, info, argc, argv);
}
static gint
gimp_main_internal (GType plug_in_type,
const GimpPlugInInfo *info,
gint argc,
gchar *argv[])
_gimp_main_internal (GType plug_in_type,
const GimpPlugInInfo *info,
gint argc,
gchar *argv[])
{
enum
{
......@@ -229,6 +209,7 @@ gimp_main_internal (GType plug_in_type,
gint protocol_version;
#ifdef G_OS_WIN32
gint i, j, k;
/* Reduce risks */
......@@ -307,7 +288,7 @@ gimp_main_internal (GType plug_in_type,
ExcHndlInit ();
ExcHndlSetLogFileNameA (plug_in_backtrace_path);
}
#endif
#endif /* HAVE_EXCHNDL */
#ifndef _WIN64
{
......@@ -319,7 +300,7 @@ gimp_main_internal (GType plug_in_type,
if (p_SetProcessDEPPolicy)
(*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
}
#endif
#endif /* _WIN64 */
/* Group all our windows together on the taskbar */
{
......@@ -371,7 +352,8 @@ gimp_main_internal (GType plug_in_type,
}
}
}
#endif
#endif /* G_OS_WIN32 */
g_assert ((plug_in_type != G_TYPE_NONE && info == NULL) ||
(plug_in_type == G_TYPE_NONE && info != NULL));
......@@ -421,6 +403,7 @@ gimp_main_internal (GType plug_in_type,
GIMP_STACK_TRACE_ALWAYS);
#ifndef G_OS_WIN32
/* No use catching these on Win32, the user won't get any meaningful
* stack trace from glib anyhow. It's better to let Windows inform
* about the program error, and offer debugging if the plug-in
......@@ -441,7 +424,8 @@ gimp_main_internal (GType plug_in_type,
/* Restart syscalls interrupted by SIGCHLD */
gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
#endif
#endif /* ! G_OS_WIN32 */
#ifdef G_OS_WIN32
readc_hannel = g_io_channel_win32_new_fd (atoi (argv[ARG_READ_FD]));
......@@ -591,10 +575,9 @@ gimp_main_internal (GType plug_in_type,
}
else
{
PLUG_IN_INFO = *info;
_gimp_legacy_init (read_channel,
write_channel);
_gimp_legacy_initialize (info,
read_channel,
write_channel);
}
if (strcmp (argv[ARG_MODE], "-query") == 0)
......@@ -603,17 +586,9 @@ gimp_main_internal (GType plug_in_type,
_gimp_debug_stop ();
if (PLUG_IN)
{
_gimp_plug_in_query (PLUG_IN);
}
_gimp_plug_in_query (PLUG_IN);
else
{
if (PLUG_IN_INFO.init_proc)
gp_has_init_write (write_channel, NULL);
if (PLUG_IN_INFO.query_proc)
PLUG_IN_INFO.query_proc ();
}
_gimp_legacy_query ();
gimp_close ();
......@@ -626,14 +601,9 @@ gimp_main_internal (GType plug_in_type,
_gimp_debug_stop ();
if (PLUG_IN)
{
_gimp_plug_in_init (PLUG_IN);
}
_gimp_plug_in_init (PLUG_IN);
else
{
if (PLUG_IN_INFO.init_proc)
PLUG_IN_INFO.init_proc ();
}
_gimp_legacy_init ();
gimp_close ();
......@@ -646,13 +616,9 @@ gimp_main_internal (GType plug_in_type,
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Here I am!");
if (PLUG_IN)
{
_gimp_plug_in_run (PLUG_IN);
}
_gimp_plug_in_run (PLUG_IN);
else
{
_gimp_loop (PLUG_IN_INFO.run_proc);
}
_gimp_legacy_run ();
gimp_close ();
......@@ -1049,16 +1015,9 @@ gimp_close (void)
_gimp_debug_stop ();
if (PLUG_IN)
{
_gimp_plug_in_quit (PLUG_IN);
}
_gimp_plug_in_quit (PLUG_IN);
else
{
if (PLUG_IN_INFO.quit_proc)
PLUG_IN_INFO.quit_proc ();
_gimp_legacy_quit ();
}
_gimp_legacy_quit ();
}
static void
......@@ -1123,7 +1082,7 @@ gimp_fatal_func (const gchar *log_domain,
}
break;
}
#endif
#endif /* ! G_OS_WIN32 */
/* Do not end with gimp_quit().
* We want the plug-in to continue its normal crash course, otherwise
......@@ -1169,9 +1128,10 @@ gimp_plugin_sigfatal_handler (PEXCEPTION_POINTERS pExceptionInfo)
else
return EXCEPTION_CONTINUE_SEARCH;
}
#endif
#endif /* HAVE_EXCHNDL */
#else /* ! G_OS_WIN32 */
#else
static void
gimp_plugin_sigfatal_handler (gint sig_num)
{
......@@ -1225,7 +1185,8 @@ gimp_plugin_sigfatal_handler (gint sig_num)
*/
exit (EXIT_FAILURE);
}
#endif
#endif /* G_OS_WIN32 */
void
_gimp_config (GPConfig *config)
......
......@@ -31,6 +31,7 @@
#include "gimp-private.h"
#include "gimpgpcompat.h"
#include "gimpgpparams.h"
#include "gimplegacy-private.h"
/**
......@@ -57,6 +58,7 @@
}
static void gimp_loop (GimpRunProc run_proc);
static void gimp_process_message (GimpWireMessage *msg);
static void gimp_single_message (void);
static gboolean gimp_extension_read (GIOChannel *channel,
......@@ -79,15 +81,37 @@ static gboolean gimp_flush (GIOChannel *channel,
gpointer user_data);
GIOChannel *_gimp_readchannel = NULL;
GIOChannel *_gimp_writechannel = NULL;
GIOChannel *_gimp_readchannel = NULL;
GIOChannel *_gimp_writechannel = NULL;
static gchar write_buffer[WRITE_BUFFER_SIZE];
static gulong write_buffer_index = 0;
static gchar write_buffer[WRITE_BUFFER_SIZE];
static gulong write_buffer_index = 0;
static GHashTable *gimp_temp_proc_ht = NULL;
static GimpPlugInInfo PLUG_IN_INFO = { 0, };
static GHashTable *gimp_temp_proc_ht = NULL;
/**
* gimp_main_legacy:
* @info: the #GimpPlugInInfo structure
* @argc: the number of arguments
* @argv: (array length=argc): the arguments
*
* The main procedure that must be called with the #GimpPlugInInfo
* structure and the 'argc' and 'argv' that are passed to "main".
*
* Returns: an exit status as defined by the C library,
* on success EXIT_SUCCESS.
**/
gint
gimp_main_legacy (const GimpPlugInInfo *info,
gint argc,
gchar *argv[])
{
return _gimp_main_internal (G_TYPE_NONE, info, argc, argv);
}
/**
* gimp_install_procedure:
* @name: the procedure's name.
......@@ -482,8 +506,8 @@ gimp_extension_process (guint timeout)
}
void
_gimp_read_expect_msg (GimpWireMessage *msg,
gint type)
_gimp_legacy_read_expect_msg (GimpWireMessage *msg,
gint type)
{
ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
......@@ -783,7 +807,7 @@ gimp_run_procedure_array (const gchar *name,
if (! gp_proc_run_write (_gimp_writechannel, &proc_run, NULL))
gimp_quit ();
_gimp_read_expect_msg (&msg, GP_PROC_RETURN);
_gimp_legacy_read_expect_msg (&msg, GP_PROC_RETURN);
proc_return = msg.data;
......@@ -912,9 +936,14 @@ gimp_destroy_paramdefs (GimpParamDef *paramdefs,
}
void
_gimp_legacy_init (GIOChannel *read_channel,
GIOChannel *write_channel)
_gimp_legacy_initialize (const GimpPlugInInfo *info,
GIOChannel *read_channel,
GIOChannel *write_channel)
{
ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
PLUG_IN_INFO = *info;
_gimp_readchannel = read_channel;
_gimp_writechannel = write_channel;
......@@ -925,18 +954,29 @@ _gimp_legacy_init (GIOChannel *read_channel,
}
void
_gimp_legacy_quit (void)
_gimp_legacy_query (void)
{
_gimp_shm_close ();
ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
gp_quit_write (_gimp_writechannel, NULL);
if (PLUG_IN_INFO.init_proc)
gp_has_init_write (_gimp_writechannel, NULL);
if (PLUG_IN_INFO.query_proc)
PLUG_IN_INFO.query_proc ();
}
void
_gimp_loop (GimpRunProc run_proc)
_gimp_legacy_init (void)
{
GimpWireMessage msg;
ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
if (PLUG_IN_INFO.init_proc)
PLUG_IN_INFO.init_proc ();
}
void
_gimp_legacy_run (void)
{
ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
gimp_temp_proc_ht = g_hash_table_new (g_str_hash, g_str_equal);
......@@ -946,55 +986,20 @@ _gimp_loop (GimpRunProc run_proc)
gimp_plugin_io_error_handler,
NULL);
while (TRUE)
{
if (! gimp_wire_read_msg (_gimp_readchannel, &msg, NULL))
return;
switch (msg.type)
{
case GP_QUIT:
gimp_wire_destroy (&msg);
return;
case GP_CONFIG:
_gimp_config (msg.data);
break;
case GP_TILE_REQ:
case GP_TILE_ACK:
case GP_TILE_DATA:
g_warning ("unexpected tile message received (should not happen)");
break;
case GP_PROC_RUN:
gimp_proc_run (msg.data, run_proc);
gimp_wire_destroy (&msg);
return;
case GP_PROC_RETURN:
g_warning ("unexpected proc return message received (should not happen)");
break;
case GP_TEMP_PROC_RUN:
g_warning ("unexpected temp proc run message received (should not happen");
break;
gimp_loop (PLUG_IN_INFO.run_proc);
}
case GP_TEMP_PROC_RETURN:
g_warning ("unexpected temp proc return message received (should not happen");
break;
void
_gimp_legacy_quit (void)
{
ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
case GP_PROC_INSTALL:
g_warning ("unexpected proc install message received (should not happen)");
break;
if (PLUG_IN_INFO.quit_proc)
PLUG_IN_INFO.quit_proc ();
case GP_HAS_INIT:
g_warning ("unexpected has init message received (should not happen)");
break;
}
_gimp_shm_close ();
gimp_wire_destroy (&msg);
}
gp_quit_write (_gimp_writechannel, NULL);
}
/* old gimp_plugin cruft */
......@@ -1149,6 +1154,62 @@ gimp_plugin_icon_register (const gchar *procedure_name,
/* private functions */
static void
gimp_loop (GimpRunProc run_proc)
{
GimpWireMessage msg;
while (TRUE)
{
if (! gimp_wire_read_msg (_gimp_readchannel, &msg, NULL))
return;
switch (msg.type)
{
case GP_QUIT:
gimp_wire_destroy (&msg);
return;
case GP_CONFIG:
_gimp_config (msg.data);
break;
case GP_TILE_REQ:
case GP_TILE_ACK:
case GP_TILE_DATA:
g_warning ("unexpected tile message received (should not happen)");
break;
case GP_PROC_RUN:
gimp_proc_run (msg.data, run_proc);
gimp_wire_destroy (&msg);
return;
case GP_PROC_RETURN:
g_warning ("unexpected proc return message received (should not happen)");
break;
case GP_TEMP_PROC_RUN:
g_warning ("unexpected temp proc run message received (should not happen");
break;
case GP_TEMP_PROC_RETURN:
g_warning ("unexpected temp proc return message received (should not happen");
break;
case GP_PROC_INSTALL:
g_warning ("unexpected proc install message received (should not happen)");
break;
case GP_HAS_INIT:
g_warning ("unexpected has init message received (should not happen)");
break;
}
gimp_wire_destroy (&msg);
}
}
static void
gimp_process_message (GimpWireMessage *msg)
{
......@@ -1207,7 +1268,7 @@ gimp_extension_read (GIOChannel *channel,
{
gimp_single_message ();
return TRUE;
return G_SOURCE_CONTINUE;
}
static void
......
......@@ -43,7 +43,7 @@ GQuark _gimp_pdb_error_quark (void) G_GNUC_CONST;
GimpPDB * _gimp_pdb_new (GimpPlugIn *plug_in);
GimpPlugIn * _gimp_pdb_get_plug_in (GimpPDB *pdb);
GimpPlugIn * _gimp_pdb_get_plug_in (GimpPDB *pdb);
G_END_DECLS
......
......@@ -29,7 +29,6 @@
#include "libgimpbase/gimpprotocol.h"
#include "libgimpbase/gimpwire.h"
#include "gimp-private.h"
#include "gimpplugin-private.h"
#include "gimpprocedure-private.h"
......
......@@ -26,7 +26,6 @@
#include "libgimpbase/gimpprotocol.h"
#include "libgimpbase/gimpwire.h"
#include "gimp-private.h"
#include "gimpgpparams.h"
#include "gimpplugin-private.h"
#include "gimpprocedure-private.h"
......
......@@ -24,6 +24,7 @@
#include <sys/types.h>
#include "gimp.h"
#include "gimppdb-private.h"
#include "gimpprocedure-private.h"
......
......@@ -29,8 +29,8 @@
#include "libgimpbase/gimpprotocol.h"
#include "libgimpbase/gimpwire.h"
#include "gimp-private.h"
#include "gimp-shm.h"
#include "gimplegacy-private.h"
#include "gimpplugin-private.h"
#include "gimptilebackendplugin.h"
......@@ -351,7 +351,7 @@ gimp_tile_get (GimpTileBackendPlugin *backend_plugin,
if (! gp_tile_req_write (_gimp_writechannel, &tile_req, NULL))
gimp_quit ();
_gimp_read_expect_msg (&msg, GP_TILE_DATA);
_gimp_legacy_read_expect_msg (&msg, GP_TILE_DATA);
}
tile_data = msg.data;
......@@ -436,7 +436,7 @@ gimp_tile_put (GimpTileBackendPlugin *backend_plugin,
if (! gp_tile_req_write (_gimp_writechannel, &tile_req, NULL))
gimp_quit ();
_gimp_read_expect_msg (&msg, GP_TILE_DATA);
_gimp_legacy_read_expect_msg (&msg, GP_TILE_DATA);
}
tile_info = msg.data;
......@@ -481,7 +481,7 @@ gimp_tile_put (GimpTileBackendPlugin *backend_plugin,
if (plug_in)
_gimp_plug_in_read_expect_msg (plug_in, &msg, GP_TILE_ACK);
else
_gimp_read_expect_msg (&msg, GP_TILE_ACK);
_gimp_legacy_read_expect_msg (&msg, GP_TILE_ACK);
gimp_wire_destroy (&msg);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment