[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 02/03: Fix memory leaks with the tacho views by adding a callback for the destroy event and by properly nulling the already freed stuff
noreply at xfce.org
noreply at xfce.org
Sun Mar 26 23:02:39 CEST 2017
This is an automated email from the git hooks/post-receive script.
timystery pushed a commit to branch master
in repository panel-plugins/xfce4-sensors-plugin.
commit 5a8bd7644f3c65a267ddb94238c2e77df1814b57
Author: Fabian <timystery at arcor.de>
Date: Sun Mar 26 22:05:54 2017 +0200
Fix memory leaks with the tacho views by adding a callback for the destroy event and by properly nulling the already freed stuff
---
lib/tacho.c | 22 ++++++++++++++++++++++
panel-plugin/sensors-plugin.c | 1 +
src/actions.c | 8 ++++++--
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/lib/tacho.c b/lib/tacho.c
index ee1fce3..078d16c 100644
--- a/lib/tacho.c
+++ b/lib/tacho.c
@@ -60,6 +60,7 @@ static void gtk_sensorstacho_size_allocate(GtkWidget *widget,
GtkAllocation *allocation);
static GtkSizeRequestMode gtk_sensorstacho_get_request_mode(GtkWidget *widget);
+void gtk_sensorstacho_destroy(GtkWidget *widget);
gchar *font = NULL; // declared as extern in tacho.h
@@ -136,6 +137,7 @@ gtk_sensorstacho_class_init (GtkSensorsTachoClass *ptr_gtksensorstachoclass)
ptr_widgetclass->get_preferred_height_for_width = gtk_sensorstacho_get_preferred_height_for_width;
ptr_widgetclass->size_allocate = gtk_sensorstacho_size_allocate;
ptr_widgetclass->draw = gtk_sensorstacho_paint;
+ ptr_widgetclass->destroy = gtk_sensorstacho_destroy;
if (font==NULL)
font = g_strdup("Sans 12");
@@ -387,6 +389,26 @@ gtk_sensorstacho_paint (GtkWidget *widget,
return TRUE;
}
+
+/* -------------------------------------------------------------------------- */
+void
+gtk_sensorstacho_destroy(GtkWidget *widget)
+{
+ GtkSensorsTacho *ptr_sensorstacho = GTK_SENSORSTACHO(widget);
+ TRACE("enter gtk_sensorstacho_destroy\n");
+ g_return_if_fail(ptr_sensorstacho!=NULL);
+
+ if (ptr_sensorstacho->color != NULL)
+ {
+ g_free(ptr_sensorstacho->color);
+ ptr_sensorstacho->color = NULL;
+ }
+
+ gtk_sensorstacho_unset_text(ptr_sensorstacho);
+ TRACE("leave gtk_sensorstacho_destroy\n");
+}
+
+
/* -------------------------------------------------------------------------- */
void
gtk_sensorstacho_set_value (GtkSensorsTacho *ptr_sensorstacho, gdouble value)
diff --git a/panel-plugin/sensors-plugin.c b/panel-plugin/sensors-plugin.c
index 217ef97..9b09ceb 100644
--- a/panel-plugin/sensors-plugin.c
+++ b/panel-plugin/sensors-plugin.c
@@ -569,6 +569,7 @@ sensors_show_graphical_display (t_sensors *sensors)
sensors->css_provider = gtk_css_provider_new ();
ptr_gdkdisplay = gdk_display_get_default ();
ptr_gdkscreen = gdk_display_get_default_screen (ptr_gdkdisplay);
+ g_return_val_if_fail(ptr_gdkscreen!=NULL, FALSE);
gtk_style_context_add_provider_for_screen (ptr_gdkscreen,
GTK_STYLE_PROVIDER (sensors->css_provider),
diff --git a/src/actions.c b/src/actions.c
index 9308cf1..d27f7dd 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -210,11 +210,15 @@ refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure)
{
DBG("Removing deselected widget from container.");
gtk_container_remove(GTK_CONTAINER(ptr_wdgt_table), ptr_sensorstachowidget);
- if (ptr_sensorstacho->text)
+ if (ptr_sensorstacho->text) {
g_free(ptr_sensorstacho->text);
+ ptr_sensorstacho->text = NULL;
+ }
- if (ptr_sensorstacho->color)
+ if (ptr_sensorstacho->color) {
g_free(ptr_sensorstacho->color);
+ ptr_sensorstacho->color = NULL;
+ }
ptr_sensors_structure->tachos[idx_chip][idx_feature] = NULL;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list