forked from AuroraMiddleware/gtk
colorscale: Don't free surface data before surface
When drawing onto a recording surface, source surfaces get cached. But if we g_free() the surface data after we're done, that cache is gonna point at invalid data...
This commit is contained in:
parent
98a9f2b3c1
commit
6bad307180
@ -90,9 +90,10 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
|
|||||||
gdouble f;
|
gdouble f;
|
||||||
int hue_x, hue_y;
|
int hue_x, hue_y;
|
||||||
|
|
||||||
stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width);
|
tmp = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
|
||||||
|
width, height);
|
||||||
data = g_malloc (height * stride);
|
stride = cairo_image_surface_get_stride (tmp);
|
||||||
|
data = (guint32* )cairo_image_surface_get_data (tmp);
|
||||||
|
|
||||||
f = 1.0 / (height - 1);
|
f = 1.0 / (height - 1);
|
||||||
for (hue_y = 0; hue_y < height; hue_y++)
|
for (hue_y = 0; hue_y < height; hue_y++)
|
||||||
@ -105,18 +106,16 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
|
|||||||
red = CLAMP (r * 255, 0, 255);
|
red = CLAMP (r * 255, 0, 255);
|
||||||
green = CLAMP (g * 255, 0, 255);
|
green = CLAMP (g * 255, 0, 255);
|
||||||
blue = CLAMP (b * 255, 0, 255);
|
blue = CLAMP (b * 255, 0, 255);
|
||||||
p[hue_x] = (red << 16) | (green << 8) | blue;
|
p[hue_x] = 0xFF000000 | (red << 16) | (green << 8) | blue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = cairo_image_surface_create_for_data ((guchar *)data, CAIRO_FORMAT_RGB24,
|
cairo_surface_mark_dirty (tmp);
|
||||||
width, height, stride);
|
|
||||||
|
|
||||||
cairo_set_source_surface (cr, tmp, 0, 0);
|
cairo_set_source_surface (cr, tmp, 0, 0);
|
||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
|
|
||||||
cairo_surface_destroy (tmp);
|
cairo_surface_destroy (tmp);
|
||||||
g_free (data);
|
|
||||||
}
|
}
|
||||||
else if (scale->priv->type == GTK_COLOR_SCALE_ALPHA)
|
else if (scale->priv->type == GTK_COLOR_SCALE_ALPHA)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user