color-lcms: unref stock sRGB cprof instead of directly destroying it

Directly destroying the cprof is not ideal, because it may hide issues
that we have in the code. If we are destroying a cprof with ref_count
bigger than 1, there's something wrong that we need to fix.

Instead, assert that the stock sRGB cprof has ref_count == 1 when we are
destroying the color manager. And use unref() instead of destroy().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2023-10-27 12:09:59 -03:00 committed by Pekka Paalanen
parent d18fd64a15
commit 39de0bd988

View File

@ -381,8 +381,11 @@ cmlcms_destroy(struct weston_color_manager *cm_base)
{
struct weston_color_manager_lcms *cm = get_cmlcms(cm_base);
if (cm->sRGB_profile)
cmlcms_color_profile_destroy(cm->sRGB_profile);
if (cm->sRGB_profile) {
assert(cm->sRGB_profile->base.ref_count == 1);
unref_cprof(cm->sRGB_profile);
}
assert(wl_list_empty(&cm->color_transform_list));
assert(wl_list_empty(&cm->color_profile_list));