mirror of https://github.com/GNOME/gimp.git
added GIMP_CONFIG_ERROR_VERSION to GimpConfigError enum.
2003-11-08 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-error.h: added GIMP_CONFIG_ERROR_VERSION to GimpConfigError enum. * libgimpbase/gimpprotocol.h: renamed GP_VERSION to GIMP_PROTOCOL_VERSION. * libgimp/gimp.c * app/plug-in/plug-in-run.c: changed accordingly. * app/plug-in/plug-in-rc.[ch]: write the protocol version to the pluginrc and stop parsing when a wrong protocol version is found. * app/plug-in/plug-ins.c: pass a GError to plug_in_rc_parse().
This commit is contained in:
parent
a868b35310
commit
74c8218a3f
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2003-11-08 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/config/gimpconfig-error.h: added GIMP_CONFIG_ERROR_VERSION
|
||||
to GimpConfigError enum.
|
||||
|
||||
* libgimpbase/gimpprotocol.h: renamed GP_VERSION to
|
||||
GIMP_PROTOCOL_VERSION.
|
||||
|
||||
* libgimp/gimp.c
|
||||
* app/plug-in/plug-in-run.c: changed accordingly.
|
||||
|
||||
* app/plug-in/plug-in-rc.[ch]: write the protocol version to the
|
||||
pluginrc and stop parsing when a wrong protocol version is found.
|
||||
|
||||
* app/plug-in/plug-ins.c: pass a GError to plug_in_rc_parse().
|
||||
|
||||
2003-11-07 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpbase/gimpprotocol.[ch]: added "wm_name", "wm_class",
|
||||
|
|
|
@ -24,10 +24,11 @@
|
|||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_CONFIG_ERROR_OPEN, /* open failed */
|
||||
GIMP_CONFIG_ERROR_OPEN_ENOENT, /* file does not exist */
|
||||
GIMP_CONFIG_ERROR_WRITE, /* write failed */
|
||||
GIMP_CONFIG_ERROR_PARSE /* parser error */
|
||||
GIMP_CONFIG_ERROR_OPEN, /* open failed */
|
||||
GIMP_CONFIG_ERROR_OPEN_ENOENT, /* file does not exist */
|
||||
GIMP_CONFIG_ERROR_WRITE, /* write failed */
|
||||
GIMP_CONFIG_ERROR_PARSE, /* parser error */
|
||||
GIMP_CONFIG_ERROR_VERSION /* parser failed due to version mismatch */
|
||||
} GimpConfigError;
|
||||
|
||||
#define GIMP_CONFIG_ERROR (gimp_config_error_quark ())
|
||||
|
|
|
@ -94,7 +94,7 @@ plug_in_run (Gimp *gimp,
|
|||
goto done;
|
||||
}
|
||||
|
||||
config.version = GP_VERSION;
|
||||
config.version = GIMP_PROTOCOL_VERSION;
|
||||
config.tile_width = TILE_WIDTH;
|
||||
config.tile_height = TILE_HEIGHT;
|
||||
config.shm_ID = plug_in_shm_get_ID (gimp);
|
||||
|
|
|
@ -94,7 +94,7 @@ plug_in_run (Gimp *gimp,
|
|||
goto done;
|
||||
}
|
||||
|
||||
config.version = GP_VERSION;
|
||||
config.version = GIMP_PROTOCOL_VERSION;
|
||||
config.tile_width = TILE_WIDTH;
|
||||
config.tile_height = TILE_HEIGHT;
|
||||
config.shm_ID = plug_in_shm_get_ID (gimp);
|
||||
|
|
|
@ -94,6 +94,7 @@ plug_ins_init (Gimp *gimp,
|
|||
gdouble n_plugins;
|
||||
gdouble n_extensions;
|
||||
gdouble nth;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (status_callback != NULL);
|
||||
|
@ -120,7 +121,7 @@ plug_ins_init (Gimp *gimp,
|
|||
if (!g_path_is_absolute (filename))
|
||||
{
|
||||
gchar *tmp = g_build_filename (gimp_directory (), filename, NULL);
|
||||
|
||||
|
||||
g_free (filename);
|
||||
filename = tmp;
|
||||
}
|
||||
|
@ -131,7 +132,12 @@ plug_ins_init (Gimp *gimp,
|
|||
}
|
||||
|
||||
(* status_callback) (_("Resource configuration"), filename, -1);
|
||||
plug_in_rc_parse (gimp, filename);
|
||||
|
||||
if (! plug_in_rc_parse (gimp, filename, &error))
|
||||
{
|
||||
g_message (error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
/* Query any plug-ins that have changed since we last wrote out
|
||||
* the pluginrc file.
|
||||
|
@ -184,7 +190,7 @@ plug_ins_init (Gimp *gimp,
|
|||
g_warning ("removing duplicate PDB procedure \"%s\"",
|
||||
overridden_proc_def->db_info.name);
|
||||
|
||||
/* search the plugin list to see if any plugins had references to
|
||||
/* search the plugin list to see if any plugins had references to
|
||||
* the overridden_proc_def.
|
||||
*/
|
||||
for (tmp2 = gimp->plug_in_defs; tmp2; tmp2 = g_slist_next (tmp2))
|
||||
|
@ -746,9 +752,9 @@ plug_ins_image_types_parse (gchar *image_types)
|
|||
gchar *type_spec = image_types;
|
||||
PlugInImageType types = 0;
|
||||
|
||||
/*
|
||||
/*
|
||||
* If the plug_in registers with image_type == NULL or "", return 0
|
||||
* By doing so it won't be touched by plug_in_set_menu_sensitivity()
|
||||
* By doing so it won't be touched by plug_in_set_menu_sensitivity()
|
||||
*/
|
||||
if (!image_types)
|
||||
return types;
|
||||
|
@ -914,7 +920,7 @@ plug_ins_add_to_db (Gimp *gimp)
|
|||
{
|
||||
return_vals =
|
||||
procedural_db_execute (gimp,
|
||||
"gimp_register_save_handler",
|
||||
"gimp_register_save_handler",
|
||||
args);
|
||||
g_free (return_vals);
|
||||
}
|
||||
|
@ -922,7 +928,7 @@ plug_ins_add_to_db (Gimp *gimp)
|
|||
{
|
||||
return_vals =
|
||||
procedural_db_execute (gimp,
|
||||
"gimp_register_magic_load_handler",
|
||||
"gimp_register_magic_load_handler",
|
||||
args);
|
||||
g_free (return_vals);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,12 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpbase/gimpprotocol.h"
|
||||
|
||||
#include "plug-in-types.h"
|
||||
|
||||
#include "config/gimpconfig-error.h"
|
||||
#include "config/gimpconfigwriter.h"
|
||||
#include "config/gimpscanner.h"
|
||||
|
||||
|
@ -59,7 +63,8 @@ static GTokenType plug_in_has_init_deserialize (GScanner *scanner,
|
|||
|
||||
enum
|
||||
{
|
||||
PLUG_IN_DEF = 1,
|
||||
PROTOCOL_VERSION = 1,
|
||||
PLUG_IN_DEF,
|
||||
PROC_DEF,
|
||||
LOCALE_DEF,
|
||||
HELP_DEF,
|
||||
|
@ -69,21 +74,27 @@ enum
|
|||
|
||||
|
||||
gboolean
|
||||
plug_in_rc_parse (Gimp *gimp,
|
||||
const gchar *filename)
|
||||
plug_in_rc_parse (Gimp *gimp,
|
||||
const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
GScanner *scanner;
|
||||
GTokenType token;
|
||||
GError *error = NULL;
|
||||
gboolean retval = FALSE;
|
||||
gint version = GIMP_PROTOCOL_VERSION;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
scanner = gimp_scanner_new_file (filename, &error);
|
||||
scanner = gimp_scanner_new_file (filename, error);
|
||||
|
||||
if (! scanner)
|
||||
return TRUE;
|
||||
|
||||
g_scanner_scope_add_symbol (scanner, 0,
|
||||
"protocol-version",
|
||||
GINT_TO_POINTER (PROTOCOL_VERSION));
|
||||
g_scanner_scope_add_symbol (scanner, 0,
|
||||
"plug-in-def", GINT_TO_POINTER (PLUG_IN_DEF));
|
||||
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
||||
|
@ -99,7 +110,8 @@ plug_in_rc_parse (Gimp *gimp,
|
|||
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
|
||||
while (g_scanner_peek_next_token (scanner) == token)
|
||||
while (version == GIMP_PROTOCOL_VERSION &&
|
||||
g_scanner_peek_next_token (scanner) == token)
|
||||
{
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
|
||||
|
@ -110,13 +122,22 @@ plug_in_rc_parse (Gimp *gimp,
|
|||
break;
|
||||
|
||||
case G_TOKEN_SYMBOL:
|
||||
if (scanner->value.v_symbol == GINT_TO_POINTER (PLUG_IN_DEF))
|
||||
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
||||
{
|
||||
case PROTOCOL_VERSION:
|
||||
token = G_TOKEN_INT;
|
||||
if (gimp_scanner_parse_int (scanner, &version))
|
||||
token = G_TOKEN_RIGHT_PAREN;
|
||||
break;
|
||||
case PLUG_IN_DEF:
|
||||
g_scanner_set_scope (scanner, PLUG_IN_DEF);
|
||||
token = plug_in_def_deserialize (gimp, scanner);
|
||||
g_scanner_set_scope (scanner, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case G_TOKEN_RIGHT_PAREN:
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
|
@ -127,19 +148,26 @@ plug_in_rc_parse (Gimp *gimp,
|
|||
}
|
||||
}
|
||||
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
if (version != GIMP_PROTOCOL_VERSION)
|
||||
{
|
||||
g_set_error (error,
|
||||
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_VERSION,
|
||||
_("Skipping '%s': wrong GIMP protocol version."), filename);
|
||||
}
|
||||
else if (token != G_TOKEN_LEFT_PAREN)
|
||||
{
|
||||
g_scanner_get_next_token (scanner);
|
||||
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
||||
_("fatal parse error"), TRUE);
|
||||
|
||||
g_message (error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = TRUE;
|
||||
}
|
||||
|
||||
gimp_scanner_destroy (scanner);
|
||||
|
||||
return (token != G_TOKEN_EOF);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
|
@ -407,6 +435,11 @@ plug_in_rc_write (GSList *plug_in_defs,
|
|||
if (!writer)
|
||||
return FALSE;
|
||||
|
||||
gimp_config_writer_open (writer, "protocol-version");
|
||||
gimp_config_writer_printf (writer, "%d", GIMP_PROTOCOL_VERSION);
|
||||
gimp_config_writer_close (writer);
|
||||
gimp_config_writer_linefeed (writer);
|
||||
|
||||
for (list = plug_in_defs; list; list = list->next)
|
||||
{
|
||||
plug_in_def = list->data;
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
|
||||
|
||||
gboolean plug_in_rc_parse (Gimp *gimp,
|
||||
const gchar *filename);
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
gboolean plug_in_rc_write (GSList *proc_defs,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
|
|
|
@ -94,7 +94,7 @@ plug_in_run (Gimp *gimp,
|
|||
goto done;
|
||||
}
|
||||
|
||||
config.version = GP_VERSION;
|
||||
config.version = GIMP_PROTOCOL_VERSION;
|
||||
config.tile_width = TILE_WIDTH;
|
||||
config.tile_height = TILE_HEIGHT;
|
||||
config.shm_ID = plug_in_shm_get_ID (gimp);
|
||||
|
|
|
@ -94,6 +94,7 @@ plug_ins_init (Gimp *gimp,
|
|||
gdouble n_plugins;
|
||||
gdouble n_extensions;
|
||||
gdouble nth;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (status_callback != NULL);
|
||||
|
@ -120,7 +121,7 @@ plug_ins_init (Gimp *gimp,
|
|||
if (!g_path_is_absolute (filename))
|
||||
{
|
||||
gchar *tmp = g_build_filename (gimp_directory (), filename, NULL);
|
||||
|
||||
|
||||
g_free (filename);
|
||||
filename = tmp;
|
||||
}
|
||||
|
@ -131,7 +132,12 @@ plug_ins_init (Gimp *gimp,
|
|||
}
|
||||
|
||||
(* status_callback) (_("Resource configuration"), filename, -1);
|
||||
plug_in_rc_parse (gimp, filename);
|
||||
|
||||
if (! plug_in_rc_parse (gimp, filename, &error))
|
||||
{
|
||||
g_message (error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
/* Query any plug-ins that have changed since we last wrote out
|
||||
* the pluginrc file.
|
||||
|
@ -184,7 +190,7 @@ plug_ins_init (Gimp *gimp,
|
|||
g_warning ("removing duplicate PDB procedure \"%s\"",
|
||||
overridden_proc_def->db_info.name);
|
||||
|
||||
/* search the plugin list to see if any plugins had references to
|
||||
/* search the plugin list to see if any plugins had references to
|
||||
* the overridden_proc_def.
|
||||
*/
|
||||
for (tmp2 = gimp->plug_in_defs; tmp2; tmp2 = g_slist_next (tmp2))
|
||||
|
@ -746,9 +752,9 @@ plug_ins_image_types_parse (gchar *image_types)
|
|||
gchar *type_spec = image_types;
|
||||
PlugInImageType types = 0;
|
||||
|
||||
/*
|
||||
/*
|
||||
* If the plug_in registers with image_type == NULL or "", return 0
|
||||
* By doing so it won't be touched by plug_in_set_menu_sensitivity()
|
||||
* By doing so it won't be touched by plug_in_set_menu_sensitivity()
|
||||
*/
|
||||
if (!image_types)
|
||||
return types;
|
||||
|
@ -914,7 +920,7 @@ plug_ins_add_to_db (Gimp *gimp)
|
|||
{
|
||||
return_vals =
|
||||
procedural_db_execute (gimp,
|
||||
"gimp_register_save_handler",
|
||||
"gimp_register_save_handler",
|
||||
args);
|
||||
g_free (return_vals);
|
||||
}
|
||||
|
@ -922,7 +928,7 @@ plug_ins_add_to_db (Gimp *gimp)
|
|||
{
|
||||
return_vals =
|
||||
procedural_db_execute (gimp,
|
||||
"gimp_register_magic_load_handler",
|
||||
"gimp_register_magic_load_handler",
|
||||
args);
|
||||
g_free (return_vals);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-11-08 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpbase/libgimpbase-sections.txt
|
||||
* libgimpbase/tmpl/gimpprotocol.sgml: GIMP_PROTOCOL_VERSION.
|
||||
|
||||
2003-11-07 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/app-docs.sgml
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
<bookinfo>
|
||||
<title>GIMP Application Reference Manual</title>
|
||||
<releaseinfo>for GIMP &version;</releaseinfo>
|
||||
<releaseinfo>
|
||||
for GIMP <xi:include href="version" parse="text"/>
|
||||
</releaseinfo>
|
||||
</bookinfo>
|
||||
|
||||
<part id="app-hierarchy-part">
|
||||
|
|
|
@ -70,7 +70,7 @@ gimp_pixpipe_params_build
|
|||
|
||||
<SECTION>
|
||||
<FILE>gimpprotocol</FILE>
|
||||
GP_VERSION
|
||||
GIMP_PROTOCOL_VERSION
|
||||
GPConfig
|
||||
GPTileReq
|
||||
GPTileAck
|
||||
|
|
|
@ -15,7 +15,7 @@ The communication protocol between GIMP and it's plug-ins.
|
|||
#libgimp-gimpwire
|
||||
</para>
|
||||
|
||||
<!-- ##### MACRO GP_VERSION ##### -->
|
||||
<!-- ##### MACRO GIMP_PROTOCOL_VERSION ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
|
|
@ -1551,7 +1551,7 @@ gimp_loop (void)
|
|||
static void
|
||||
gimp_config (GPConfig *config)
|
||||
{
|
||||
if (config->version < GP_VERSION)
|
||||
if (config->version < GIMP_PROTOCOL_VERSION)
|
||||
{
|
||||
g_message ("Could not execute plug-in \"%s\"\n(%s)\n"
|
||||
"because the GIMP is using an older version of the "
|
||||
|
@ -1559,7 +1559,7 @@ gimp_config (GPConfig *config)
|
|||
g_get_prgname (), progname);
|
||||
gimp_quit ();
|
||||
}
|
||||
else if (config->version > GP_VERSION)
|
||||
else if (config->version > GIMP_PROTOCOL_VERSION)
|
||||
{
|
||||
g_message ("Could not execute plug-in \"%s\"\n(%s)\n"
|
||||
"because it uses an obsolete version of the "
|
||||
|
|
|
@ -27,7 +27,7 @@ G_BEGIN_DECLS
|
|||
|
||||
/* Increment every time the protocol changes
|
||||
*/
|
||||
#define GP_VERSION 0x000F
|
||||
#define GIMP_PROTOCOL_VERSION 0x000F
|
||||
|
||||
|
||||
enum
|
||||
|
|
|
@ -24,10 +24,11 @@
|
|||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_CONFIG_ERROR_OPEN, /* open failed */
|
||||
GIMP_CONFIG_ERROR_OPEN_ENOENT, /* file does not exist */
|
||||
GIMP_CONFIG_ERROR_WRITE, /* write failed */
|
||||
GIMP_CONFIG_ERROR_PARSE /* parser error */
|
||||
GIMP_CONFIG_ERROR_OPEN, /* open failed */
|
||||
GIMP_CONFIG_ERROR_OPEN_ENOENT, /* file does not exist */
|
||||
GIMP_CONFIG_ERROR_WRITE, /* write failed */
|
||||
GIMP_CONFIG_ERROR_PARSE, /* parser error */
|
||||
GIMP_CONFIG_ERROR_VERSION /* parser failed due to version mismatch */
|
||||
} GimpConfigError;
|
||||
|
||||
#define GIMP_CONFIG_ERROR (gimp_config_error_quark ())
|
||||
|
|
Loading…
Reference in New Issue