File trivial-Do-not-assume-cd_device_get_default_profile-.patch of Package colord-gtk
From: Richard Hughes <richard@hughsie.com>
Date: Sat, 24 Jun 2023 20:32:01 +0100
Subject: trivial: Do not assume cd_device_get_default_profile() always returns a profile
Patch-mainline: 0.4.0?
Git-commit: 46643db6d136b30c33cdcc8ac67a3f0823d96818
References: https://github.com/hughsie/colord-gtk/issues/22
---
libcolord-gtk/cd-window.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/libcolord-gtk/cd-window.c
+++ b/libcolord-gtk/cd-window.c
@@ -309,13 +309,13 @@ cd_window_device_changed_cb (CdClient *client, CdDevice *device, CdWindow *windo
/* get new default profile */
profile = cd_device_get_default_profile (window->priv->device);
- if (cd_profile_equal (profile, window->priv->profile))
+ if (profile == NULL && window->priv->profile == NULL)
+ return;
+ if (profile != NULL && cd_profile_equal (profile, window->priv->profile))
return;
/* replace profile instance and emit if changed */
- if (window->priv->profile != NULL)
- g_object_unref (window->priv->profile);
- window->priv->profile = g_object_ref (profile);
+ g_set_object(&window->priv->profile, profile);
g_signal_emit (window, signals[SIGNAL_CHANGED], 0,
window->priv->profile);
}