Re: gtk-demo's patch



El lun, 14-01-2002 a las 16:22, Owen Taylor escribió:
> German Poo Caaman~o <gpoo ubiobio cl> writes:
> 
> > I was following the editable_cells.c code of gtk-demo to implement
> > a GtkTreeView editable.  After fight a little, I was discover a
> > little bug on definition of old_text variable.  However, it doesn't
> > have a useful in the program, but confuse.
> > 
> > May I commit?
> 
> This chnage looks right. But old_text will need to be freed afterwords
> as well.  

Ok.  This patch free the memory when the column is G_TYPE_STRING.
Nothing happens if the column is G_TYPE_INT.

Ok to commit it?

-- 
German Poo Caaman~o
mailto:gpoo ubiobio cl
http://www.ubiobio.cl/~gpoo/chilelindo.html
"La historia no se lee, se escribe"
Index: editable_cells.c
===================================================================
RCS file: /cvs/gnome/gtk+/demos/gtk-demo/editable_cells.c,v
retrieving revision 1.2
diff -u -3 -r1.2 editable_cells.c
--- editable_cells.c	2001/11/28 21:19:39	1.2
+++ editable_cells.c	2002/01/18 03:35:51
@@ -152,13 +152,13 @@
   GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
   GtkTreeIter iter;
   
-  gchar old_text[256]; /* ugly? */
+  gchar *old_text;
   gint *column;
   
   column = g_object_get_data (G_OBJECT (cell), "column");
 
   gtk_tree_model_get_iter (model, &iter, path);
-  gtk_tree_model_get (model, &iter, column, old_text, -1);
+  gtk_tree_model_get (model, &iter, column, &old_text, -1);
 
   switch ((gint) column)
     {
@@ -184,6 +184,7 @@
 
 	gtk_list_store_set (GTK_LIST_STORE (model), &iter, column,
 			    new_text, -1);
+	g_free (old_text);
       }
       break;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]