[gimp] libgimp: fix legacy plug-ins, which I broke with the big ID removal
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: fix legacy plug-ins, which I broke with the big ID removal
- Date: Thu, 29 Aug 2019 16:39:35 +0000 (UTC)
commit 37897b13fea42fa713f1b2b0bcf59ccc30abd7f4
Author: Michael Natterer <mitch gimp org>
Date: Thu Aug 29 18:36:59 2019 +0200
libgimp: fix legacy plug-ins, which I broke with the big ID removal
- hand out and leak proxy object objects to legacy API like candy,
bypassing the factory in GimpPlugIn, because there is no plug-in
singleton.
- gimpgpcompat.c: image, item etc. are now objects, simply forgot this
file.
libgimp/gimpdisplay.c | 14 +++++++++++---
libgimp/gimpgpcompat.c | 52 +++++++++++++++++++++++++++++++++++---------------
libgimp/gimpimage.c | 14 +++++++++++---
libgimp/gimpitem.c | 43 +++++++++++++++++++++++++++++++++++++----
4 files changed, 98 insertions(+), 25 deletions(-)
---
diff --git a/libgimp/gimpdisplay.c b/libgimp/gimpdisplay.c
index f796231b40..b66067c783 100644
--- a/libgimp/gimpdisplay.c
+++ b/libgimp/gimpdisplay.c
@@ -160,10 +160,18 @@ gimp_display_get_by_id (gint32 display_id)
{
if (display_id > 0)
{
- GimpPlugIn *plug_in = gimp_get_plug_in ();
- GimpProcedure *procedure = _gimp_plug_in_get_procedure (plug_in);
+ GimpPlugIn *plug_in = gimp_get_plug_in ();
- return _gimp_procedure_get_display (procedure, display_id);
+ if (plug_in)
+ {
+ GimpProcedure *procedure = _gimp_plug_in_get_procedure (plug_in);
+
+ return _gimp_procedure_get_display (procedure, display_id);
+ }
+
+ return g_object_new (GIMP_TYPE_DISPLAY,
+ "id", display_id,
+ NULL);
}
return NULL;
diff --git a/libgimp/gimpgpcompat.c b/libgimp/gimpgpcompat.c
index 895849abd3..cf2c9dc36a 100644
--- a/libgimp/gimpgpcompat.c
+++ b/libgimp/gimpgpcompat.c
@@ -457,31 +457,38 @@ _gimp_params_to_value_array (const GimpParam *params,
break;
case GIMP_PDB_ITEM:
- g_value_set_int (&value, params[i].data.d_item);
+ g_value_set_object (&value,
+ gimp_item_get_by_id (params[i].data.d_item));
break;
case GIMP_PDB_DISPLAY:
- g_value_set_int (&value, params[i].data.d_display);
+ g_value_set_object (&value,
+ gimp_display_get_by_id (params[i].data.d_display));
break;
case GIMP_PDB_IMAGE:
- g_value_set_int (&value, params[i].data.d_image);
+ g_value_set_object (&value,
+ gimp_image_get_by_id (params[i].data.d_image));
break;
case GIMP_PDB_LAYER:
- g_value_set_int (&value, params[i].data.d_layer);
+ g_value_set_object (&value,
+ gimp_item_get_by_id (params[i].data.d_layer));
break;
case GIMP_PDB_CHANNEL:
- g_value_set_int (&value, params[i].data.d_channel);
+ g_value_set_object (&value,
+ gimp_item_get_by_id (params[i].data.d_channel));
break;
case GIMP_PDB_DRAWABLE:
- g_value_set_int (&value, params[i].data.d_drawable);
+ g_value_set_object (&value,
+ gimp_item_get_by_id (params[i].data.d_drawable));
break;
case GIMP_PDB_SELECTION:
- g_value_set_int (&value, params[i].data.d_selection);
+ g_value_set_object (&value,
+ gimp_item_get_by_id (params[i].data.d_selection));
break;
case GIMP_PDB_COLORARRAY:
@@ -538,7 +545,8 @@ _gimp_value_array_to_params (GimpValueArray *args,
for (i = 0; i < length; i++)
{
- GValue *value = gimp_value_array_index (args, i);
+ GValue *value = gimp_value_array_index (args, i);
+ GObject *object;
params[i].type = _gimp_pdb_gtype_to_arg_type (G_VALUE_TYPE (value));
@@ -620,31 +628,45 @@ _gimp_value_array_to_params (GimpValueArray *args,
break;
case GIMP_PDB_ITEM:
- params[i].data.d_item = g_value_get_int (value);
+ object = g_value_get_object (value);
+ params[i].data.d_item =
+ object ? gimp_item_get_id (GIMP_ITEM (object)) : -1;
break;
case GIMP_PDB_DISPLAY:
- params[i].data.d_display = g_value_get_int (value);
+ object = g_value_get_object (value);
+ params[i].data.d_display =
+ object ? gimp_display_get_id (GIMP_DISPLAY (object)) : -1;
break;
case GIMP_PDB_IMAGE:
- params[i].data.d_image = g_value_get_int (value);
+ object = g_value_get_object (value);
+ params[i].data.d_image =
+ object ? gimp_image_get_id (GIMP_IMAGE (object)) : -1;
break;
case GIMP_PDB_LAYER:
- params[i].data.d_layer = g_value_get_int (value);
+ object = g_value_get_object (value);
+ params[i].data.d_layer =
+ object ? gimp_item_get_id (GIMP_ITEM (object)) : -1;
break;
case GIMP_PDB_CHANNEL:
- params[i].data.d_channel = g_value_get_int (value);
+ object = g_value_get_object (value);
+ params[i].data.d_channel =
+ object ? gimp_item_get_id (GIMP_ITEM (object)) : -1;
break;
case GIMP_PDB_DRAWABLE:
- params[i].data.d_drawable = g_value_get_int (value);
+ object = g_value_get_object (value);
+ params[i].data.d_drawable =
+ object ? gimp_item_get_id (GIMP_ITEM (object)) : -1;
break;
case GIMP_PDB_SELECTION:
- params[i].data.d_selection = g_value_get_int (value);
+ object = g_value_get_object (value);
+ params[i].data.d_selection =
+ object ? gimp_item_get_id (GIMP_ITEM (object)) : -1;
break;
case GIMP_PDB_COLORARRAY:
diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c
index c5020d5aea..5d26e57f0d 100644
--- a/libgimp/gimpimage.c
+++ b/libgimp/gimpimage.c
@@ -158,10 +158,18 @@ gimp_image_get_by_id (gint32 image_id)
{
if (image_id > 0)
{
- GimpPlugIn *plug_in = gimp_get_plug_in ();
- GimpProcedure *procedure = _gimp_plug_in_get_procedure (plug_in);
+ GimpPlugIn *plug_in = gimp_get_plug_in ();
- return _gimp_procedure_get_image (procedure, image_id);
+ if (plug_in)
+ {
+ GimpProcedure *procedure = _gimp_plug_in_get_procedure (plug_in);
+
+ return _gimp_procedure_get_image (procedure, image_id);
+ }
+
+ return g_object_new (GIMP_TYPE_IMAGE,
+ "id", image_id,
+ NULL);
}
return NULL;
diff --git a/libgimp/gimpitem.c b/libgimp/gimpitem.c
index 5500bab53a..acdc8cb2ca 100644
--- a/libgimp/gimpitem.c
+++ b/libgimp/gimpitem.c
@@ -163,10 +163,45 @@ gimp_item_get_by_id (gint32 item_id)
{
if (item_id > 0)
{
- GimpPlugIn *plug_in = gimp_get_plug_in ();
- GimpProcedure *procedure = _gimp_plug_in_get_procedure (plug_in);
-
- return _gimp_procedure_get_item (procedure, item_id);
+ GimpPlugIn *plug_in = gimp_get_plug_in ();
+
+ if (plug_in)
+ {
+ GimpProcedure *procedure = _gimp_plug_in_get_procedure (plug_in);
+
+ return _gimp_procedure_get_item (procedure, item_id);
+ }
+
+ if (gimp_item_id_is_layer (item_id))
+ {
+ return g_object_new (GIMP_TYPE_LAYER,
+ "id", item_id,
+ NULL);
+ }
+ else if (gimp_item_id_is_layer_mask (item_id))
+ {
+ return g_object_new (GIMP_TYPE_LAYER_MASK,
+ "id", item_id,
+ NULL);
+ }
+ else if (gimp_item_id_is_selection (item_id))
+ {
+ return g_object_new (GIMP_TYPE_SELECTION,
+ "id", item_id,
+ NULL);
+ }
+ else if (gimp_item_id_is_channel (item_id))
+ {
+ return g_object_new (GIMP_TYPE_CHANNEL,
+ "id", item_id,
+ NULL);
+ }
+ else if (gimp_item_id_is_vectors (item_id))
+ {
+ return g_object_new (GIMP_TYPE_VECTORS,
+ "id", item_id,
+ NULL);
+ }
}
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]