Commit a6e9d084 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

charpick: fix -Wdiscarded-qualifiers warning

parent 170fa858
......@@ -258,8 +258,10 @@ menuitem_activated (GtkMenuItem *menuitem, charpick_data *curr_data)
string = g_object_get_data (G_OBJECT (menuitem), "string");
if (g_ascii_strcasecmp (curr_data->charlist, string) == 0)
return;
curr_data->charlist = string;
g_free (curr_data->charlist);
curr_data->charlist = g_strdup (string);
build_table (curr_data);
if (g_settings_is_writable (curr_data->settings, KEY_CURRENT_LIST))
g_settings_set_string (curr_data->settings, KEY_CURRENT_LIST, curr_data->charlist);
......@@ -660,23 +662,30 @@ charpicker_applet_fill (charpick_data *curr_data)
get_chartable (curr_data);
string = g_settings_get_string (curr_data->settings, KEY_CURRENT_LIST);
if (string[0] != '\0') {
list = curr_data->chartable;
while (list) {
if (g_ascii_strcasecmp (list->data, string) == 0)
curr_data->charlist = list->data;
list = g_list_next (list);
}
/* FIXME: yeah leak, but this code is full of leaks and evil
point shuffling. This should really be rewritten
-George */
if (curr_data->charlist == NULL)
curr_data->charlist = string;
else
g_free (string);
} else {
curr_data->charlist = curr_data->chartable->data;
}
if (string[0] != '\0')
{
list = curr_data->chartable;
while (list)
{
if (g_ascii_strcasecmp (list->data, string) == 0)
{
g_free (curr_data->charlist);
curr_data->charlist = g_strdup (list->data);
}
list = g_list_next (list);
}
if (curr_data->charlist == NULL)
curr_data->charlist = g_strdup (string);
}
else
{
curr_data->charlist = g_strdup (curr_data->chartable->data);
}
g_free (string);
orientation = gp_applet_get_orientation (GP_APPLET (curr_data));
curr_data->panel_vertical = (orientation == GTK_ORIENTATION_VERTICAL);
......@@ -763,6 +772,18 @@ charpick_applet_dispose (GObject *object)
G_OBJECT_CLASS (charpick_applet_parent_class)->dispose (object);
}
static void
charpick_applet_finalize (GObject *object)
{
CharpickApplet *self;
self = CHARPICK_APPLET (object);
g_clear_pointer (&self->charlist, g_free);
G_OBJECT_CLASS (charpick_applet_parent_class)->finalize (object);
}
static void
charpick_applet_class_init (CharpickAppletClass *self_class)
{
......@@ -772,6 +793,7 @@ charpick_applet_class_init (CharpickAppletClass *self_class)
object_class->constructed = charpick_applet_constructed;
object_class->dispose = charpick_applet_dispose;
object_class->finalize = charpick_applet_finalize;
}
static void
......
......@@ -136,7 +136,8 @@ add_palette_cb (GtkDialog *dialog, int response_id, charpick_data *curr_data)
if (curr_data->chartable == NULL) {
curr_data->chartable = list;
curr_data->charlist = curr_data->chartable->data;
g_free (curr_data->charlist);
curr_data->charlist = g_strdup (curr_data->chartable->data);
build_table (curr_data);
if (g_settings_is_writable (curr_data->settings, KEY_CURRENT_LIST))
......@@ -198,7 +199,9 @@ edit_palette_cb (GtkDialog *dialog, int response_id, charpick_data *curr_data)
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, new, 1, new, -1);
if (g_ascii_strcasecmp (curr_data->charlist, charlist) == 0) {
curr_data->charlist = new;
g_free (curr_data->charlist);
curr_data->charlist = g_strdup (new);
build_table (curr_data);
if (g_settings_is_writable (curr_data->settings, KEY_CURRENT_LIST))
......@@ -288,8 +291,9 @@ delete_palette (GtkButton *button, charpick_data *curr_data)
curr_data->chartable = g_list_remove (curr_data->chartable, charlist);
if (g_ascii_strcasecmp (curr_data->charlist, charlist) == 0) {
g_free (curr_data->charlist);
curr_data->charlist = curr_data->chartable != NULL ?
curr_data->chartable->data : "";
g_strdup (curr_data->chartable->data) : g_strdup ("");
if (g_settings_is_writable (curr_data->settings, KEY_CURRENT_LIST))
g_settings_set_string (curr_data->settings, KEY_CURRENT_LIST, curr_data->charlist);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment