diff options
| author | mbkma <[email protected]> | 2026-03-11 23:14:37 +0100 |
|---|---|---|
| committer | mbkma <[email protected]> | 2026-03-11 23:17:26 +0100 |
| commit | 87d70966e151f2400cd7122aa63997f1c6bc6f38 (patch) | |
| tree | 47525e104aaed5ce9bfcfe95a0725ea6012c6fc9 | |
| parent | 4b3c8d07b445a9410c8697a85cf50f7f42d116cc (diff) | |
| download | mate-notification-daemon-memleak.tar.bz2 mate-notification-daemon-memleak.tar.xz | |
fix memory leak in update_applet_displaymemleak
| -rw-r--r-- | src/capplet/mate-notification-applet.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/capplet/mate-notification-applet.c b/src/capplet/mate-notification-applet.c index dd2f4e1..d6620b7 100644 --- a/src/capplet/mate-notification-applet.c +++ b/src/capplet/mate-notification-applet.c @@ -276,32 +276,37 @@ update_unread_count (MateNotificationApplet *applet) static void update_applet_display (MateNotificationApplet *applet) { - gchar *tooltip_text; gboolean dnd_active; gboolean history_enabled; dnd_active = g_settings_get_boolean (applet->settings, GSETTINGS_KEY_DO_NOT_DISTURB); history_enabled = g_settings_get_boolean (applet->settings, GSETTINGS_KEY_HISTORY_ENABLED); - /* Update tooltip based on number of unread notifications and user state */ - if (!history_enabled) - tooltip_text = g_strdup (_("(privacy mode)")); - else if (applet->unread_count > 99) - tooltip_text = g_strdup (_("(99+ unread)")); - else if (applet->unread_count > 0) - tooltip_text = g_strdup_printf ("(%d unread)", applet->unread_count); - else - tooltip_text = g_strdup (""); + g_autoptr(GString) tooltip = g_string_new (NULL); + /* Prefix */ if (dnd_active) - tooltip_text = g_strdup_printf ("Do Not Disturb %s", tooltip_text); + g_string_append (tooltip, "Do Not Disturb"); else if (!dbus_context_is_available (applet->dbus_context)) - tooltip_text = g_strdup (_("Notifications (daemon unavailable)")); + { + gtk_widget_set_tooltip_text (GTK_WIDGET (applet->applet), + _("Notifications (daemon unavailable)")); + set_status_image (applet, dnd_active, history_enabled); + update_count_badge (applet); + return; + } else - tooltip_text = g_strdup_printf ("Notifications %s", tooltip_text); + g_string_append (tooltip, "Notifications"); + + /* Suffix */ + if (!history_enabled) + g_string_append_printf (tooltip, " %s", _("(privacy mode)")); + else if (applet->unread_count > 99) + g_string_append_printf (tooltip, " %s", _("(99+ unread)")); + else if (applet->unread_count > 0) + g_string_append_printf (tooltip, " (%d unread)", applet->unread_count); - gtk_widget_set_tooltip_text (GTK_WIDGET (applet->applet), tooltip_text); - g_free (tooltip_text); + gtk_widget_set_tooltip_text (GTK_WIDGET (applet->applet), tooltip->str); set_status_image (applet, dnd_active, history_enabled); update_count_badge (applet); |
