A small bug fix in gtkimmulticontext.c



While testing GTK+ 2.0, I find a small bug in
gtk+/gtk/gtkimmulticontext.c:gtk_im_multicontext_get_slave().  The line

      gtk_im_multicontext_set_slave (multicontext, _gtk_im_module_create (global_context_id), FALSE);

creates a new slave GtkIMContext but it is not un-referenced.  This results
in the GtkIMContext's finalize() method never being called since there will
always be a reference to it in memory.

The fix is very simple and I have attached it in the mail.

Regards,

Yao Zhang

Index: gtkimmulticontext.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkimmulticontext.c,v
retrieving revision 1.18
diff -u -r1.18 gtkimmulticontext.c
--- gtkimmulticontext.c 2002/02/14 16:18:32     1.18
+++ gtkimmulticontext.c 2002/03/17 03:11:25
@@ -217,6 +217,8 @@
 {
   if (!multicontext->slave)
     {
+      GtkIMContext *slave;
+
       if (!global_context_id)
        {
          const char *locale;
@@ -229,7 +231,9 @@
          global_context_id = _gtk_im_module_get_default_context_id (locale);
        }
 
-      gtk_im_multicontext_set_slave (multicontext, _gtk_im_module_create (global_context_id), FALSE);
+      slave = _gtk_im_module_create (global_context_id);
+      gtk_im_multicontext_set_slave (multicontext, slave, FALSE);
+      g_object_unref(slave);
       multicontext->context_id = global_context_id;
     }



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