From 3aecb1c262bedc22be1367613c0673b16399974f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 13 Sep 2022 18:11:15 +0200 Subject: [PATCH] color-profile: Rely on property on ICC for filename This is instead of getting anything from the CdDevice. This avoids a crash when CdDevice isn't successfully setup but something still tries to look up the filename of the ICC profile. This isn't a real bug fix for anything, but there is no reason having to rely on CdDevice for this anyway, and as we don't really have control of it, it's less reliable of containing something valid. Part-of: --- src/backends/meta-color-device.c | 9 +++++---- src/backends/meta-color-profile.c | 3 ++- src/backends/meta-color-store.c | 1 - 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backends/meta-color-device.c b/src/backends/meta-color-device.c index e6854fc3a..0c58cd8ed 100644 --- a/src/backends/meta-color-device.c +++ b/src/backends/meta-color-device.c @@ -790,6 +790,7 @@ save_icc_profile (const char *file_path, static CdIcc * create_icc_profile_from_edid (MetaColorDevice *color_device, const MetaEdidInfo *edid_info, + const char *file_path, GError **error) { MetaColorManager *color_manager = color_device->color_manager; @@ -839,6 +840,7 @@ create_icc_profile_from_edid (MetaColorDevice *color_device, return NULL; } + cd_icc_add_metadata (cd_icc, CD_PROFILE_PROPERTY_FILENAME, file_path); cd_icc_add_metadata (cd_icc, CD_PROFILE_METADATA_DATA_SOURCE, CD_PROFILE_METADATA_DATA_SOURCE_EDID); @@ -923,7 +925,9 @@ create_device_profile_from_edid (MetaColorDevice *color_device, "Generating ICC profile for '%s' from EDID", meta_color_device_get_id (color_device)); - cd_icc = create_icc_profile_from_edid (color_device, edid_info, &error); + cd_icc = create_icc_profile_from_edid (color_device, + edid_info, file_path, + &error); if (!cd_icc) { g_task_return_error (task, g_steal_pointer (&error)); @@ -939,9 +943,6 @@ create_device_profile_from_edid (MetaColorDevice *color_device, return; } - /* Set metadata needed by colord */ - cd_icc_add_metadata (cd_icc, CD_PROFILE_PROPERTY_FILENAME, file_path); - file_md5_checksum = g_compute_checksum_for_bytes (G_CHECKSUM_MD5, bytes); cd_icc_add_metadata (cd_icc, CD_PROFILE_METADATA_FILE_CHECKSUM, file_md5_checksum); diff --git a/src/backends/meta-color-profile.c b/src/backends/meta-color-profile.c index 82c235b0f..be131bb02 100644 --- a/src/backends/meta-color-profile.c +++ b/src/backends/meta-color-profile.c @@ -377,7 +377,8 @@ meta_color_profile_get_id (MetaColorProfile *color_profile) const char * meta_color_profile_get_file_path (MetaColorProfile *color_profile) { - return cd_profile_get_filename (color_profile->cd_profile); + return cd_icc_get_metadata_item (color_profile->cd_icc, + CD_PROFILE_PROPERTY_FILENAME); } const char * diff --git a/src/backends/meta-color-store.c b/src/backends/meta-color-store.c index 1e6038374..60608b6f6 100644 --- a/src/backends/meta-color-store.c +++ b/src/backends/meta-color-store.c @@ -132,7 +132,6 @@ create_profile_from_contents (MetaColorStore *color_store, bytes = g_bytes_new (contents, size); - /* Set metadata needed by colord */ cd_icc_add_metadata (cd_icc, CD_PROFILE_PROPERTY_FILENAME, file_path);