[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 08/11: - don't assert too many pointers to still make the stand-alone app work - free the font strings appropriately

noreply at xfce.org noreply at xfce.org
Tue Mar 7 23:38:32 CET 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 998b08b244d0ca1ca5ff288eadd9a19fa22da919
Author: Fabian <timystery at arcor.de>
Date:   Tue Mar 7 00:11:14 2017 +0100

    - don't assert too many pointers to still make the stand-alone app work
    - free the font strings appropriately
---
 lib/configuration.c            | 11 ++++++-----
 lib/sensors-interface-common.c |  6 +-----
 panel-plugin/sensors-plugin.c  |  9 +++++----
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/lib/configuration.c b/lib/configuration.c
index 2a48981..0bb658f 100644
--- a/lib/configuration.c
+++ b/lib/configuration.c
@@ -235,9 +235,12 @@ sensors_read_general_config (XfceRc *ptr_xfceresources, t_sensors *ptr_sensors)
         }
 
         if ((str_value = xfce_rc_read_entry (ptr_xfceresources, "Font", NULL)) && *str_value) {
-            //g_free(ptr_sensors->font); // font is initialized to NULL
+            if (font)
+                g_free(font); // font is initialized to NULL
             font = g_strdup(str_value); // in tacho.h for the tachometers
         }
+        else if (font==NULL)
+            font = g_strdup("Sans 12");
 
         ptr_sensors->val_fontsize = xfce_rc_read_int_entry (ptr_xfceresources,
                                                  "val_fontsize", 2);
@@ -286,12 +289,10 @@ sensors_read_preliminary_config (XfcePanelPlugin *ptr_panelplugin, t_sensors *pt
 
     TRACE ("enters sensors_read_preliminary_config");
 
-    g_return_if_fail(ptr_panelplugin!=NULL);
-
-    g_return_if_fail(ptr_sensors!=NULL);
-
     if (ptr_panelplugin)
     {
+        g_return_if_fail(ptr_sensors!=NULL);
+
         if ((str_file = ptr_sensors->plugin_config_file))
         {
             ptr_xfceresource = xfce_rc_simple_open (str_file, TRUE);
diff --git a/lib/sensors-interface-common.c b/lib/sensors-interface-common.c
index fe7bf68..cee1e5a 100644
--- a/lib/sensors-interface-common.c
+++ b/lib/sensors-interface-common.c
@@ -45,9 +45,6 @@ sensors_new (XfcePanelPlugin *plugin, gchar *plugin_config_file)
 
     TRACE ("enters sensors_new");
 
-    g_return_val_if_fail(plugin!=NULL, NULL);
-    g_return_val_if_fail(plugin_config_file!=NULL, NULL);
-
     sensors = g_new0 (t_sensors, 1);
     sensors->plugin_config_file = plugin_config_file; /* important as we check against NULL frequently */
 
@@ -103,7 +100,6 @@ sensors_init_default_values  (t_sensors *sensors, XfcePanelPlugin *plugin)
     TRACE ("enters sensors_init_default_values");
 
     g_return_if_fail(sensors!=NULL);
-    g_return_if_fail(plugin!=NULL);
 
     sensors->show_title = TRUE;
     sensors->show_labels = TRUE;
@@ -145,7 +141,7 @@ format_sensor_value (t_tempscale scale, t_chipfeature *chipfeature,
 {
     /* TRACE ("enters format_sensor_value"); */
     g_return_if_fail(chipfeature!=NULL);
-    g_return_if_fail(*help!=NULL);
+    g_return_if_fail(help!=NULL);
 
     switch (chipfeature->class) {
         case TEMPERATURE:
diff --git a/panel-plugin/sensors-plugin.c b/panel-plugin/sensors-plugin.c
index cb60a26..654186f 100644
--- a/panel-plugin/sensors-plugin.c
+++ b/panel-plugin/sensors-plugin.c
@@ -1245,9 +1245,10 @@ sensors_free (XfcePanelPlugin *plugin, t_sensors *sensors)
     g_free (sensors->plugin_config_file);
     g_free (sensors->command_name);
     sensors->command_name = NULL;
-/*
-    g_free (sensors->font);
-*/
+
+    if (font)
+        g_free (font);
+
     g_free (sensors->str_fontsize);
     g_free (sensors);
 
@@ -1915,7 +1916,7 @@ on_font_set (GtkWidget *widget, gpointer data)
         g_assert (sensors!=NULL);
 
         if (font)
-                g_free (font);
+            g_free (font);
 
         font = g_strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON(widget)));
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list