Files
gimp/app/operations/layer-modes/gimp-layer-modes.h
Jehan b3fc24268a Issue #5888: GIMP 2.99.2 crash when using brush in multiply mode.
The GimpOperationLayerMode variable member in DoLayerBlend was not
properly constructed. C++ class constructor can be called by creating
object variables, but with GObject, we have to do it with pointers.
Otherwise here we were only allocating the memory for the struct, but
not actually calling any initialization functions.

Also it would seem that the struct was not initialized at zero, as the
space_fish variable was not NULL when it should (i.e. even with same
composite and blend space), hence composite_to_blend_fish was not NULL
and since the operation was not a valid GeglOperation when entering
gimp_operation_layer_mode_real_process(), we crashed.
Not sure how it went unseen for so long!

So instead let's make the layer_mode class member into a pointer. As
such, I have to properly allocate and free it. This is also why I am
adding a copy constructor which will ref the pointer (otherwise we unref
more than we ref as the default copy constructor would just copy the
pointer).
2020-11-10 01:11:01 +01:00

75 lines
4.3 KiB
C

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimp-layer-modes.h
* Copyright (C) 2017 Michael Natterer <mitch@gimp.org>
* Øyvind Kolås <pippin@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_LAYER_MODES_H__
#define __GIMP_LAYER_MODES_H__
void gimp_layer_modes_init (void);
gboolean gimp_layer_mode_is_legacy (GimpLayerMode mode);
gboolean gimp_layer_mode_is_blend_space_mutable (GimpLayerMode mode);
gboolean gimp_layer_mode_is_composite_space_mutable (GimpLayerMode mode);
gboolean gimp_layer_mode_is_composite_mode_mutable (GimpLayerMode mode);
gboolean gimp_layer_mode_is_subtractive (GimpLayerMode mode);
gboolean gimp_layer_mode_is_alpha_only (GimpLayerMode mode);
gboolean gimp_layer_mode_is_trivial (GimpLayerMode mode);
GimpLayerColorSpace gimp_layer_mode_get_blend_space (GimpLayerMode mode);
GimpLayerColorSpace gimp_layer_mode_get_composite_space (GimpLayerMode mode);
GimpLayerCompositeMode gimp_layer_mode_get_composite_mode (GimpLayerMode mode);
GimpLayerCompositeMode gimp_layer_mode_get_paint_composite_mode (GimpLayerMode mode);
const gchar * gimp_layer_mode_get_operation_name (GimpLayerMode mode);
GeglOperation * gimp_layer_mode_get_operation (GimpLayerMode mode);
GimpLayerModeFunc gimp_layer_mode_get_function (GimpLayerMode mode);
GimpLayerModeBlendFunc gimp_layer_mode_get_blend_function (GimpLayerMode mode);
GimpLayerModeContext gimp_layer_mode_get_context (GimpLayerMode mode);
GimpLayerMode * gimp_layer_mode_get_context_array (GimpLayerMode mode,
GimpLayerModeContext context,
gint *n_modes);
GimpLayerModeGroup gimp_layer_mode_get_group (GimpLayerMode mode);
const GimpLayerMode * gimp_layer_mode_get_group_array (GimpLayerModeGroup group,
gint *n_modes);
gboolean gimp_layer_mode_get_for_group (GimpLayerMode old_mode,
GimpLayerModeGroup new_group,
GimpLayerMode *new_mode);
const Babl * gimp_layer_mode_get_format (GimpLayerMode mode,
GimpLayerColorSpace blend_space,
GimpLayerColorSpace composite_space,
GimpLayerCompositeMode composite_mode,
const Babl *preferred_format);
GimpLayerCompositeRegion gimp_layer_mode_get_included_region (GimpLayerMode mode,
GimpLayerCompositeMode composite_mode);
#endif /* __GIMP_LAYER_MODES_H__ */