[patch] for gtkselection.c



There are some patches for gtkselectin.c which fixes
	g_list_remove_link (A, B)
to
	A = g_list_remove_link (A, B)

but I think that is not enough.
If B has removed from A, B->next is illegal.

Following patch includes this.

I'm sorry if this bug is already fixed.


                                  -Takashi Matsuda
                                   matsu@arch.comp.kyutech.ac.jp

-------8<-----------8<------------8<------------8<------------8<---------

--- gtk+971025/gtk/gtkselection.c	Thu Sep 25 10:29:12 1997
+++ gtk+971025.xim/gtk/gtkselection.c	Tue Nov  4 16:51:05 1997
@@ -205,7 +205,8 @@
 	  if (selection_info)
 	    {
 	      old_owner = selection_info->widget;
-	      g_list_remove_link (current_selections, tmp_list);
+	      current_selections = g_list_remove_link (current_selections, 
+	      					       tmp_list);
 	      g_free (selection_info);
 	    }
 	}
@@ -296,7 +297,8 @@
 	      handler->data = data;
 	    }
 	  else
-	    g_list_remove_link (selection_handlers, tmp_list);
+	    selection_handlers = g_list_remove_link (selection_handlers, 
+	    					     tmp_list);
 	  return;
 	}
       tmp_list = tmp_list->next;
@@ -332,6 +334,7 @@
 gtk_selection_remove_all (GtkWidget *widget)
 {
   GList *tmp_list;
+  GList *next;
   GtkSelectionInfo *selection_info;
   GList *selection_handlers;
   GtkSelectionHandler *handler;
@@ -341,21 +344,24 @@
   tmp_list = current_incrs;
   while (tmp_list)
     {
+      next = tmp_list->next;
       if (((GtkIncrInfo *)tmp_list->data)->widget == widget)
 	{
-	  g_list_remove_link (current_incrs, tmp_list);
+	  current_incrs = g_list_remove_link (current_incrs, tmp_list);
 	}
-      tmp_list = tmp_list->next;
+      tmp_list = next;
     }
 
   tmp_list = current_retrievals;
   while (tmp_list)
     {
+      next = tmp_list->next;
       if (((GtkRetrievalInfo *)tmp_list->data)->widget == widget)
 	{
-	  g_list_remove_link (current_retrievals, tmp_list);
+	  current_retrievals = g_list_remove_link (current_retrievals, 
+	  					   tmp_list);
 	}
-      tmp_list = tmp_list->next;
+      tmp_list = next;
     }
   
   /* Disclaim ownership of any selections */
@@ -363,6 +369,7 @@
   tmp_list = current_selections;
   while (tmp_list)
     {
+      next = tmp_list->next;
       selection_info = (GtkSelectionInfo *)tmp_list->data;
       
       if (selection_info->widget == widget)
@@ -370,11 +377,12 @@
 	  gdk_selection_owner_set (NULL, 
 				   selection_info->selection,
 				   GDK_CURRENT_TIME, FALSE);
-	  g_list_remove_link (current_selections, tmp_list);
+	  current_selections = g_list_remove_link (current_selections, 
+	  					   tmp_list);
 	  g_free (selection_info);
 	}
       
-      tmp_list = tmp_list->next;
+      tmp_list = next;
     }
 
   /* Now remove all handlers */
@@ -602,7 +610,7 @@
   if (tmp_list == NULL || selection_info->time > event->time)
     return TRUE;
 
-  g_list_remove_link (current_selections, tmp_list);
+  current_selections = g_list_remove_link (current_selections, tmp_list);
   g_free (selection_info);
 
   return TRUE;





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