Skip to content
Snippets Groups Projects
Commit b37872c5 authored by Stepan Salenikovich's avatar Stepan Salenikovich Committed by Guillaume Roguez
Browse files

gnome: fix crash in video settings

The crash occurs when changing video settings on
systems with cogl < 1.18.

Refs #72531

(cherry picked from commit 6e7b092f)
Change-Id: I82e4468f9130831e1e372094c646561a09e0e703
parent 9e419095
Branches
Tags
No related merge requests found
......@@ -415,9 +415,42 @@ clutter_render_image(VideoWidgetRenderer* wg_renderer)
/* render a black frame set the bool back to false, this is likely done
* when the renderer is stopped so we ignore whether or not it is running
*/
if (auto image_old = clutter_actor_get_content(actor)) {
gfloat width;
gfloat height;
if (clutter_content_get_preferred_size(image_old, &width, &height)) {
/* NOTE: this is a workaround for #72531, a crash which occurs
* in cogl < 1.18. We allocate a black frame of the same size
* as the previous image, instead of simply setting an empty or
* a NULL ClutterImage.
*/
auto image_empty = clutter_image_new();
if (auto empty_data = (guint8 *)g_try_malloc0((gsize)width * height * 4)) {
GError* error = NULL;
clutter_image_set_data(
CLUTTER_IMAGE(image_empty),
empty_data,
COGL_PIXEL_FORMAT_BGRA_8888,
(guint)width,
(guint)height,
(guint)width*4,
&error);
if (error) {
g_warning("error rendering empty image to clutter: %s", error->message);
g_clear_error(&error);
g_object_unref(image_empty);
return;
}
clutter_actor_set_content(actor, image_empty);
g_object_unref(image_empty);
g_free(empty_data);
} else {
clutter_actor_set_content(actor, NULL);
}
} else {
clutter_actor_set_content(actor, NULL);
}
}
wg_renderer->show_black_frame = false;
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment