diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-12-20 16:51:41 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-12-20 16:51:41 +0900 |
commit | 7f8dc0d8b65066b13c99941c86598cfbe4a0910b (patch) | |
tree | ed53f374d87a015d48fec18c392d72d11a8f8b32 /plugins | |
parent | 607b0dde4c246cd31f4f4e579ff6b8c928693ad5 (diff) | |
download | glade-7f8dc0d8b65066b13c99941c86598cfbe4a0910b.tar.gz |
* plugins/gtk+/glade-gtk.c, plugins/gtk+/glade-column-types.[ch]: Added
glade_column_type_new() to create a GladeColumnType struct properly using
g_slice_new0(). An occurance of allocating the struct with g_new0 was causing
Glade to crash when freeing the block with g_slice_free (bug 637563). Many
big thanks to Benjamin Otte for tracking down the problem.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtk+/glade-column-types.c | 24 | ||||
-rw-r--r-- | plugins/gtk+/glade-column-types.h | 2 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk.c | 4 |
3 files changed, 21 insertions, 9 deletions
diff --git a/plugins/gtk+/glade-column-types.c b/plugins/gtk+/glade-column-types.c index 8b3b72b2..91fffe1f 100644 --- a/plugins/gtk+/glade-column-types.c +++ b/plugins/gtk+/glade-column-types.c @@ -145,18 +145,28 @@ glade_column_list_copy (GList *list) for (l = list; l; l = g_list_next (l)) { - GladeColumnType *new_data = g_slice_new0 (GladeColumnType); GladeColumnType *data = l->data; - - new_data->type_name = g_strdup (data->type_name); - new_data->column_name = g_strdup (data->column_name); - + GladeColumnType *new_data = + glade_column_type_new (data->type_name, data->column_name); + retval = g_list_prepend (retval, new_data); } return g_list_reverse (retval); } +GladeColumnType * +glade_column_type_new (const gchar *type_name, + const gchar *column_name) +{ + GladeColumnType *column = g_slice_new0 (GladeColumnType); + + column->type_name = g_strdup (type_name); + column->column_name = g_strdup (column_name); + + return column; +} + void glade_column_type_free (GladeColumnType *column) { @@ -323,9 +333,7 @@ eprop_column_append (GladeEditorProperty *eprop, if (columns) columns = glade_column_list_copy (columns); - data = g_slice_new0 (GladeColumnType); - data->column_name = g_strdup (column_name); - data->type_name = g_strdup (type_name); + data = glade_column_type_new (type_name, column_name); columns = g_list_append (columns, data); diff --git a/plugins/gtk+/glade-column-types.h b/plugins/gtk+/glade-column-types.h index f2c3fbc3..1f818fe0 100644 --- a/plugins/gtk+/glade-column-types.h +++ b/plugins/gtk+/glade-column-types.h @@ -41,6 +41,8 @@ GType glade_eprop_column_types_get_type (void) G_GNUC_CONST; void glade_column_list_free (GList *list); GList *glade_column_list_copy (GList *list); +GladeColumnType *glade_column_type_new (const gchar *type_name, + const gchar *column_name); void glade_column_type_free (GladeColumnType *column); GladeColumnType *glade_column_list_find_column (GList *list, const gchar *column_name); diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c index 5bd512f2..f949e668 100644 --- a/plugins/gtk+/glade-gtk.c +++ b/plugins/gtk+/glade-gtk.c @@ -10772,7 +10772,7 @@ glade_gtk_store_read_columns (GladeWidget *widget, GladeXmlNode *node) for (prop = glade_xml_node_get_children_with_comments (columns_node); prop; prop = glade_xml_node_next_with_comments (prop)) { - GladeColumnType *data = g_new0 (GladeColumnType, 1); + GladeColumnType *data; gchar *type, *comment_str, buffer[256]; if (!glade_xml_node_verify_silent (prop, GLADE_TAG_COLUMN) && @@ -10789,6 +10789,8 @@ glade_gtk_store_read_columns (GladeWidget *widget, GladeXmlNode *node) } type = glade_xml_get_property_string_required (prop, GLADE_TAG_TYPE, NULL); + + data = glade_column_type_new (type, NULL); data->type_name = g_strdup (type); data->column_name = column_name[0] ? g_strdup (column_name) : g_ascii_strdown (type, -1); |