app: fix autotools build.

My previous commit broke the autotools build. Apparently when using
g_object_unref(), some C++ symbol leaked into libapppaint.a archive
library, hence the main binaries (e.g. gimp-2.99) could not be linked
without adding -lstdc++ flag:

> /usr/bin/ld: paint/libapppaint.a(gimppaintcore-loops.o): undefined reference to symbol '__gxx_personality_v0@@CXXABI_1.3'
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line

Not exactly sure why using this GLib function in particular caused this,
but let's just try another approach in order not to link the main binary
with C++ standard lib.
Instead let's manage all GeglOperation allocation in gimp-layer-modes.c
by adding a gimp_layer_modes_exit() function and some static array for
storing operation object of each layer mode.
This commit is contained in:
Jehan 2020-11-10 12:36:36 +01:00
parent 8069659e60
commit f40dc40cbc
6 changed files with 49 additions and 42 deletions

View file

@ -104,6 +104,7 @@ gimp_gegl_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp_operations_exit (gimp);
gimp_parallel_exit (gimp);
}

View file

@ -223,3 +223,11 @@ gimp_operations_init (Gimp *gimp)
set_settings_folder (GIMP_TYPE_LEVELS_CONFIG,
"levels");
}
void
gimp_operations_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp_layer_modes_exit ();
}

View file

@ -22,6 +22,7 @@
void gimp_operations_init (Gimp *gimp);
void gimp_operations_exit (Gimp *gimp);
#endif /* __GIMP_OPERATIONS_H__ */

View file

@ -1110,6 +1110,7 @@ static const GimpLayerMode layer_mode_groups[][2] =
}
};
static GeglOperation *ops[G_N_ELEMENTS (layer_mode_infos)] = { 0 };
/* public functions */
@ -1124,6 +1125,15 @@ gimp_layer_modes_init (void)
}
}
void
gimp_layer_modes_exit (void)
{
gint i;
for (i = 0; i < G_N_ELEMENTS (layer_mode_infos); i++)
g_clear_object (&ops[i]);
}
static const GimpLayerModeInfo *
gimp_layer_mode_info (GimpLayerMode mode)
{
@ -1265,55 +1275,54 @@ gimp_layer_mode_get_operation_name (GimpLayerMode mode)
return info->op_name;
}
/**
* gimp_layer_mode_get_operation:
* @mode:
*
* Returns: a #GeglOperation for @mode which may be reused and must not
* be freed.
*/
GeglOperation *
gimp_layer_mode_get_operation (GimpLayerMode mode)
{
const GimpLayerModeInfo *info = gimp_layer_mode_info (mode);
GeglNode *node;
GeglOperation *operation;
const gchar *op_name;
if (! info)
info = layer_mode_infos;
node = gegl_node_new_child (NULL,
"operation", info->op_name,
NULL);
operation = gegl_node_get_gegl_operation (node);
g_object_ref (operation);
g_object_unref (node);
return operation;
}
GimpLayerModeFunc
gimp_layer_mode_get_function (GimpLayerMode mode)
{
const GimpLayerModeInfo *info = gimp_layer_mode_info (mode);
static GimpLayerModeFunc funcs[G_N_ELEMENTS (layer_mode_infos)];
op_name = gimp_layer_mode_get_operation_name (mode);
if (! info)
info = layer_mode_infos;
mode = info - layer_mode_infos;
if (! funcs[mode])
if (! ops[mode])
{
GeglNode *node;
GeglOperation *operation;
node = gegl_node_new_child (NULL,
"operation", info->op_name,
"operation", op_name,
NULL);
operation = gegl_node_get_gegl_operation (node);
funcs[mode] = GIMP_OPERATION_LAYER_MODE_GET_CLASS (operation)->process;
g_object_ref (operation);
g_object_unref (node);
ops[mode] = operation;
}
return funcs[mode];
return ops[mode];
}
GimpLayerModeFunc
gimp_layer_mode_get_function (GimpLayerMode mode)
{
GeglOperation *operation;
operation = gimp_layer_mode_get_operation (mode);
return GIMP_OPERATION_LAYER_MODE_GET_CLASS (operation)->process;
}
GimpLayerModeBlendFunc

View file

@ -24,6 +24,7 @@
void gimp_layer_modes_init (void);
void gimp_layer_modes_exit (void);
gboolean gimp_layer_mode_is_legacy (GimpLayerMode mode);

View file

@ -1876,13 +1876,12 @@ struct DoLayerBlend : Base
static constexpr gint max_n_iterators = Base::max_n_iterators + 2;
const Babl *iterator_format;
GimpOperationLayerMode *layer_mode = NULL;
const GimpPaintCoreLoopsParams *params;
const Babl *iterator_format;
GimpOperationLayerMode *layer_mode = NULL;
explicit
DoLayerBlend (const GimpPaintCoreLoopsParams *params) :
Base (params), params(params)
Base (params)
{
layer_mode = GIMP_OPERATION_LAYER_MODE (gimp_layer_mode_get_operation (params->paint_mode));
layer_mode->layer_mode = params->paint_mode;
@ -1902,18 +1901,6 @@ struct DoLayerBlend : Base
g_return_if_fail (gimp_temp_buf_get_format (params->paint_buf) == iterator_format);
}
DoLayerBlend (const DoLayerBlend &algorithm) :
Base (algorithm.params), params(algorithm.params)
{
layer_mode = GIMP_OPERATION_LAYER_MODE (g_object_ref (algorithm.layer_mode));
iterator_format = algorithm.iterator_format;
}
~DoLayerBlend ()
{
g_clear_object (&layer_mode);
}
template <class Derived>
struct State : Base::template State<Derived>
{