mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
display: Verify GtkWidget is a GimpCanvas object...
...before trying to get its GimpColorConfig. Resolves #13691 After the color space invasion, various GimpCanvas functions are now aware of color management settings. However, these public GimpCanvas functions do not require the user to pass in a GimpCanvas, just a GtkWidget. This can lead to crashes if we pass in a different kind of GtkWidget, since it may not have a GimpColorConfig property. One example is the Navigation Dockable, which crashes when it tries to draw boundaries around the image when "Show All" is turned on, because it passes a GimpView widget instead of a GimpCanvas. This patch adds a check if the "canvas" parameter is actually a GimpCanvas, and sets the config to NULL otherwise.
This commit is contained in:
parent
ea89353fd7
commit
c3814125e3
1 changed files with 18 additions and 12 deletions
|
@ -232,7 +232,7 @@ gimp_canvas_set_guide_style (GtkWidget *canvas,
|
|||
gdouble offset_y)
|
||||
{
|
||||
const Babl *render_space;
|
||||
GimpColorConfig *config;
|
||||
GimpColorConfig *config = NULL;
|
||||
cairo_pattern_t *pattern;
|
||||
GeglColor *normal_fg;
|
||||
GeglColor *normal_bg;
|
||||
|
@ -284,6 +284,7 @@ gimp_canvas_set_guide_style (GtkWidget *canvas,
|
|||
|
||||
cairo_set_line_width (cr, line_width);
|
||||
|
||||
if (GIMP_IS_CANVAS (canvas))
|
||||
config = GIMP_CORE_CONFIG (GIMP_CANVAS (canvas)->config)->color_management;
|
||||
render_space = gimp_widget_get_render_space (canvas, config);
|
||||
if (active)
|
||||
|
@ -324,7 +325,7 @@ gimp_canvas_set_grid_style (GtkWidget *canvas,
|
|||
gdouble offset_y)
|
||||
{
|
||||
const Babl *render_space;
|
||||
GimpColorConfig *config;
|
||||
GimpColorConfig *config = NULL;
|
||||
GeglColor *fg;
|
||||
GeglColor *bg;
|
||||
|
||||
|
@ -336,6 +337,7 @@ gimp_canvas_set_grid_style (GtkWidget *canvas,
|
|||
|
||||
fg = gimp_grid_get_fgcolor (grid);
|
||||
|
||||
if (GIMP_IS_CANVAS (canvas))
|
||||
config = GIMP_CORE_CONFIG (GIMP_CANVAS (canvas)->config)->color_management;
|
||||
render_space = gimp_widget_get_render_space (canvas, config);
|
||||
switch (gimp_grid_get_style (grid))
|
||||
|
@ -403,7 +405,7 @@ gimp_canvas_set_layer_style (GtkWidget *canvas,
|
|||
gdouble offset_y)
|
||||
{
|
||||
const Babl *render_space;
|
||||
GimpColorConfig *config;
|
||||
GimpColorConfig *config = NULL;
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (canvas));
|
||||
|
@ -413,6 +415,7 @@ gimp_canvas_set_layer_style (GtkWidget *canvas,
|
|||
cairo_set_line_width (cr, 1.0);
|
||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
||||
|
||||
if (GIMP_IS_CANVAS (canvas))
|
||||
config = GIMP_CORE_CONFIG (GIMP_CANVAS (canvas)->config)->color_management;
|
||||
render_space = gimp_widget_get_render_space (canvas, config);
|
||||
if (gimp_layer_get_mask (layer) &&
|
||||
|
@ -445,7 +448,7 @@ gimp_canvas_set_canvas_style (GtkWidget *canvas,
|
|||
gdouble offset_y)
|
||||
{
|
||||
const Babl *render_space;
|
||||
GimpColorConfig *config;
|
||||
GimpColorConfig *config = NULL;
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (canvas));
|
||||
|
@ -454,6 +457,7 @@ gimp_canvas_set_canvas_style (GtkWidget *canvas,
|
|||
cairo_set_line_width (cr, 1.0);
|
||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
||||
|
||||
if (GIMP_IS_CANVAS (canvas))
|
||||
config = GIMP_CORE_CONFIG (GIMP_CANVAS (canvas)->config)->color_management;
|
||||
render_space = gimp_widget_get_render_space (canvas, config);
|
||||
pattern = gimp_cairo_pattern_create_stipple (canvas_fg, canvas_bg, 0,
|
||||
|
@ -470,7 +474,7 @@ gimp_canvas_set_selection_out_style (GtkWidget *canvas,
|
|||
gdouble offset_y)
|
||||
{
|
||||
const Babl *render_space;
|
||||
GimpColorConfig *config;
|
||||
GimpColorConfig *config = NULL;
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (canvas));
|
||||
|
@ -479,6 +483,7 @@ gimp_canvas_set_selection_out_style (GtkWidget *canvas,
|
|||
cairo_set_line_width (cr, 1.0);
|
||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
||||
|
||||
if (GIMP_IS_CANVAS (canvas))
|
||||
config = GIMP_CORE_CONFIG (GIMP_CANVAS (canvas)->config)->color_management;
|
||||
render_space = gimp_widget_get_render_space (canvas, config);
|
||||
pattern = gimp_cairo_pattern_create_stipple (selection_out_fg, selection_out_bg, 0,
|
||||
|
@ -495,7 +500,7 @@ gimp_canvas_set_selection_in_style (GtkWidget *canvas,
|
|||
gdouble offset_y)
|
||||
{
|
||||
const Babl *render_space;
|
||||
GimpColorConfig *config;
|
||||
GimpColorConfig *config = NULL;
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (canvas));
|
||||
|
@ -504,6 +509,7 @@ gimp_canvas_set_selection_in_style (GtkWidget *canvas,
|
|||
cairo_set_line_width (cr, 1.0);
|
||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
||||
|
||||
if (GIMP_IS_CANVAS (canvas))
|
||||
config = GIMP_CORE_CONFIG (GIMP_CANVAS (canvas)->config)->color_management;
|
||||
render_space = gimp_widget_get_render_space (canvas, config);
|
||||
pattern = gimp_cairo_pattern_create_stipple (selection_in_fg, selection_in_bg, index,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue