added GIMP_MODULE_ABI_VERSION define and a "guint32 abi_version" field to

2003-01-02  Michael Natterer  <mitch@gimp.org>

	* libgimpmodule/gimpmodule.[ch]: added GIMP_MODULE_ABI_VERSION
	define and a "guint32 abi_version" field to GimpModuleInfo.  When
	querying a module, check if it was compiled against the same ABI
	version as the code loading it. Fixes bug #5744.

	* modules/cdisplay_colorblind.c
	* modules/cdisplay_gamma.c
	* modules/cdisplay_highcontrast.c
	* modules/colorsel_triangle.c
	* modules/colorsel_water.c: changed accordingly.
This commit is contained in:
Michael Natterer 2003-01-02 17:44:28 +00:00 committed by Michael Natterer
parent f6d7f59766
commit 7eefdb5404
8 changed files with 54 additions and 19 deletions

View file

@ -1,3 +1,16 @@
2003-01-02 Michael Natterer <mitch@gimp.org>
* libgimpmodule/gimpmodule.[ch]: added GIMP_MODULE_ABI_VERSION
define and a "guint32 abi_version" field to GimpModuleInfo. When
querying a module, check if it was compiled against the same ABI
version as the code loading it. Fixes bug #5744.
* modules/cdisplay_colorblind.c
* modules/cdisplay_gamma.c
* modules/cdisplay_highcontrast.c
* modules/colorsel_triangle.c
* modules/colorsel_water.c: changed accordingly.
2003-01-02 Sven Neumann <sven@gimp.org>
* app/widgets/gimpviewabledialog.c (gimp_viewable_dialog_close):

View file

@ -308,9 +308,12 @@ gimp_module_query_module (GimpModule *module)
info = module->query_module (G_TYPE_MODULE (module));
if (! info)
if (! info || info->abi_version != GIMP_MODULE_ABI_VERSION)
{
gimp_module_set_last_error (module, "gimp_module_query() returned NULL");
gimp_module_set_last_error (module,
info ?
"module ABI version does not match" :
"gimp_module_query() returned NULL");
if (module->verbose)
g_message (_("Module '%s' load error:\n%s"),
@ -418,21 +421,23 @@ gimp_module_set_last_error (GimpModule *module,
/* GimpModuleInfo functions */
GimpModuleInfo *
gimp_module_info_new (const gchar *purpose,
const gchar *author,
const gchar *version,
const gchar *copyright,
const gchar *date)
gimp_module_info_new (guint32 abi_version,
const gchar *purpose,
const gchar *author,
const gchar *version,
const gchar *copyright,
const gchar *date)
{
GimpModuleInfo *info;
info = g_new0 (GimpModuleInfo, 1);
info->purpose = g_strdup (purpose);
info->author = g_strdup (author);
info->version = g_strdup (version);
info->copyright = g_strdup (copyright);
info->date = g_strdup (date);
info->abi_version = abi_version;
info->purpose = g_strdup (purpose);
info->author = g_strdup (author);
info->version = g_strdup (version);
info->copyright = g_strdup (copyright);
info->date = g_strdup (date);
return info;
}
@ -442,7 +447,8 @@ gimp_module_info_copy (const GimpModuleInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return gimp_module_info_new (info->purpose,
return gimp_module_info_new (info->abi_version,
info->purpose,
info->author,
info->version,
info->copyright,

View file

@ -31,6 +31,15 @@
G_BEGIN_DECLS
/* increment the ABI version each time one of the following changes:
*
* - the libgimpmodule implementation (if the change affects modules).
* - one of the classes implemented by modules (currently GimpColorDisplay
* and GimpColorSelector).
*/
#define GIMP_MODULE_ABI_VERSION 0x0001
typedef enum
{
GIMP_MODULE_STATE_ERROR, /* missing gimp_module_register function
@ -49,11 +58,12 @@ typedef enum
struct _GimpModuleInfo
{
gchar *purpose;
gchar *author;
gchar *version;
gchar *copyright;
gchar *date;
guint32 abi_version;
gchar *purpose;
gchar *author;
gchar *version;
gchar *copyright;
gchar *date;
};
@ -115,7 +125,8 @@ const gchar * gimp_module_state_name (GimpModuleState state);
/* GimpModuleInfo functions */
GimpModuleInfo * gimp_module_info_new (const gchar *purpose,
GimpModuleInfo * gimp_module_info_new (guint32 abi_version,
const gchar *purpose,
const gchar *author,
const gchar *version,
const gchar *copyright,

View file

@ -97,6 +97,7 @@ static void colorblind_deficiency_callback (GtkWidget *widget
static const GimpModuleInfo cdisplay_colorblind_info =
{
GIMP_MODULE_ABI_VERSION,
N_("Colorblind display filter"),
"Michael Natterer <mitch@gimp.org>",
"v0.1",

View file

@ -86,6 +86,7 @@ static void gamma_configure_adj_callback (GtkAdjustment *adj,
static const GimpModuleInfo cdisplay_gamma_info =
{
GIMP_MODULE_ABI_VERSION,
N_("Gamma color display filter"),
"Manish Singh <yosh@gimp.org>",
"v0.2",

View file

@ -86,6 +86,7 @@ static void contrast_configure_adj_callback (GtkAdjustment *adj,
static const GimpModuleInfo cdisplay_contrast_info =
{
GIMP_MODULE_ABI_VERSION,
N_("High Contrast color display filter"),
"Jay Cox <jaycox@earthlink.net>",
"v0.2",

View file

@ -104,6 +104,7 @@ static gboolean colorsel_triangle_event (GtkWidget *widget,
static const GimpModuleInfo colorsel_triangle_info =
{
GIMP_MODULE_ABI_VERSION,
N_("Painter-style triangle color selector"),
"Simon Budig <Simon.Budig@unix-ag.org>",
"v0.03",

View file

@ -100,6 +100,7 @@ static void pressure_adjust_update (GtkAdjustment *adj,
static const GimpModuleInfo colorsel_water_info =
{
GIMP_MODULE_ABI_VERSION,
N_("Watercolor style color selector"),
"Raph Levien <raph@acm.org>, Sven Neumann <sven@gimp.org>",
"v0.3",