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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
This commit is contained in:
Jonas Ådahl 2022-09-13 18:11:15 +02:00 committed by Marge Bot
parent fa1bb402d3
commit 3aecb1c262
3 changed files with 7 additions and 6 deletions

View File

@ -790,6 +790,7 @@ save_icc_profile (const char *file_path,
static CdIcc * static CdIcc *
create_icc_profile_from_edid (MetaColorDevice *color_device, create_icc_profile_from_edid (MetaColorDevice *color_device,
const MetaEdidInfo *edid_info, const MetaEdidInfo *edid_info,
const char *file_path,
GError **error) GError **error)
{ {
MetaColorManager *color_manager = color_device->color_manager; MetaColorManager *color_manager = color_device->color_manager;
@ -839,6 +840,7 @@ create_icc_profile_from_edid (MetaColorDevice *color_device,
return NULL; return NULL;
} }
cd_icc_add_metadata (cd_icc, CD_PROFILE_PROPERTY_FILENAME, file_path);
cd_icc_add_metadata (cd_icc, cd_icc_add_metadata (cd_icc,
CD_PROFILE_METADATA_DATA_SOURCE, CD_PROFILE_METADATA_DATA_SOURCE,
CD_PROFILE_METADATA_DATA_SOURCE_EDID); 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", "Generating ICC profile for '%s' from EDID",
meta_color_device_get_id (color_device)); 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) if (!cd_icc)
{ {
g_task_return_error (task, g_steal_pointer (&error)); g_task_return_error (task, g_steal_pointer (&error));
@ -939,9 +943,6 @@ create_device_profile_from_edid (MetaColorDevice *color_device,
return; 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); file_md5_checksum = g_compute_checksum_for_bytes (G_CHECKSUM_MD5, bytes);
cd_icc_add_metadata (cd_icc, CD_PROFILE_METADATA_FILE_CHECKSUM, cd_icc_add_metadata (cd_icc, CD_PROFILE_METADATA_FILE_CHECKSUM,
file_md5_checksum); file_md5_checksum);

View File

@ -377,7 +377,8 @@ meta_color_profile_get_id (MetaColorProfile *color_profile)
const char * const char *
meta_color_profile_get_file_path (MetaColorProfile *color_profile) 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 * const char *

View File

@ -132,7 +132,6 @@ create_profile_from_contents (MetaColorStore *color_store,
bytes = g_bytes_new (contents, size); bytes = g_bytes_new (contents, size);
/* Set metadata needed by colord */
cd_icc_add_metadata (cd_icc, CD_PROFILE_PROPERTY_FILENAME, cd_icc_add_metadata (cd_icc, CD_PROFILE_PROPERTY_FILENAME,
file_path); file_path);