Skip to content

Commit

Permalink
gpm-statistics: fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuj committed Oct 22, 2021
1 parent 1308a5b commit 14ae269
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions src/gpm-statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ gpm_stats_add_device (UpDevice *device, GPtrArray *devices)
{
const gchar *id;
GtkTreeIter iter;
const gchar *icon;
char *icon;
UpDeviceKind kind;
gchar *label, *vendor, *model;

Expand Down Expand Up @@ -905,6 +905,7 @@ gpm_stats_add_device (UpDevice *device, GPtrArray *devices)
GPM_DEVICES_COLUMN_ID, id,
GPM_DEVICES_COLUMN_TEXT, label,
GPM_DEVICES_COLUMN_ICON, icon, -1);
g_free (icon);
g_free (label);
g_free (vendor);
g_free (model);
Expand Down Expand Up @@ -1334,16 +1335,36 @@ main (int argc, char *argv[])
gpm_stats_add_devices_columns (GTK_TREE_VIEW (widget));
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget)); /* show */

history_type = g_settings_get_string (settings, GPM_SETTINGS_INFO_HISTORY_TYPE);
history_time = g_settings_get_int (settings, GPM_SETTINGS_INFO_HISTORY_TIME);
if (history_type == NULL)
char *history_type_temp = g_settings_get_string (settings, GPM_SETTINGS_INFO_HISTORY_TYPE);
if ((history_type_temp == NULL) || (strcmp (history_type_temp, GPM_HISTORY_CHARGE_VALUE) == 0)) {
history_type = GPM_HISTORY_CHARGE_VALUE;
} else if (strcmp (history_type_temp, GPM_HISTORY_RATE_VALUE) == 0) {
history_type = GPM_HISTORY_RATE_VALUE;
} else if (strcmp (history_type_temp, GPM_HISTORY_TIME_FULL_VALUE) == 0) {
history_type = GPM_HISTORY_TIME_FULL_VALUE;
} else if (strcmp (history_type_temp, GPM_HISTORY_TIME_EMPTY_VALUE) == 0) {
history_type = GPM_HISTORY_TIME_EMPTY_VALUE;
} else {
g_assert_not_reached ();
}
g_free (history_type_temp);
history_time = g_settings_get_int (settings, GPM_SETTINGS_INFO_HISTORY_TIME);
if (history_time == 0)
history_time = GPM_HISTORY_HOUR_VALUE;

stats_type = g_settings_get_string (settings, GPM_SETTINGS_INFO_STATS_TYPE);
if (stats_type == NULL)
char *stats_type_temp = g_settings_get_string (settings, GPM_SETTINGS_INFO_STATS_TYPE);
if ((stats_type_temp == NULL) || (strcmp (stats_type_temp, GPM_STATS_CHARGE_DATA_VALUE) == 0)) {
stats_type = GPM_STATS_CHARGE_DATA_VALUE;
} else if (strcmp (stats_type_temp, GPM_STATS_DISCHARGE_DATA_VALUE) == 0) {
stats_type = GPM_STATS_DISCHARGE_DATA_VALUE;
} else if (strcmp (stats_type_temp, GPM_STATS_CHARGE_ACCURACY_VALUE) == 0) {
stats_type = GPM_STATS_CHARGE_ACCURACY_VALUE;
} else if (strcmp (stats_type_temp, GPM_STATS_DISCHARGE_ACCURACY_VALUE) == 0) {
stats_type = GPM_STATS_DISCHARGE_ACCURACY_VALUE;
} else {
g_assert_not_reached ();
}
g_free (stats_type_temp);

widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_history_type"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_RATE_TEXT);
Expand Down

0 comments on commit 14ae269

Please sign in to comment.