Uncle! (was [gtk-list] [patch] for gtkselection.c)




OK, I think my nose has been rubbed in my incompetence enough
now. ;-(  Any further fixes to gtkselection.c should be made
against the following patch, which represents the version
currently in CVS.

Regards,
                                        Owen

Index: gtkselection.c
===================================================================
RCS file: /home/cvs/gtk+/gtk/gtkselection.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -c -u -r1.1 -r1.3
/usr/bin/diff: conflicting specifications of output style
--- gtkselection.c	1997/09/18 14:49:49	1.1
+++ gtkselection.c	1997/11/04 17:33:14	1.3
@@ -205,7 +205,9 @@
 	  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_list_free (tmp_list);
 	      g_free (selection_info);
 	    }
 	}
@@ -228,8 +230,9 @@
 	    }
 	}
       /* If another widget in the application lost the selection,
-	 send it a GDK_SELECTION_CLEAR event */
-      if (old_owner)
+       *  send it a GDK_SELECTION_CLEAR event, unless we're setting
+       *  the owner to None, in which case an event will be sent */
+      if (old_owner && (widget != NULL))
 	{
 	  GdkEventSelection event;
 	  
@@ -238,7 +241,7 @@
 	  event.selection = selection;
 	  event.time = time;
 
-	  gdk_event_put ((GdkEvent *) &event);
+	  gtk_widget_event (widget, (GdkEvent *) &event);
 	}
       return TRUE;
     }
@@ -296,7 +299,12 @@
 	      handler->data = data;
 	    }
 	  else
-	    g_list_remove_link (selection_handlers, tmp_list);
+	    {
+	      selection_handlers = g_list_remove_link (selection_handlers, 
+						       tmp_list);
+	      g_list_free (tmp_list);
+	      g_free (handler);
+	    }
 	  return;
 	}
       tmp_list = tmp_list->next;
@@ -332,6 +340,7 @@
 gtk_selection_remove_all (GtkWidget *widget)
 {
   GList *tmp_list;
+  GList *next;
   GtkSelectionInfo *selection_info;
   GList *selection_handlers;
   GtkSelectionHandler *handler;
@@ -341,21 +350,28 @@
   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);
+	  /* structure will be freed in timeout */
+	  g_list_free (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);
+	  /* structure will be freed in timeout */
+	  g_list_free (tmp_list);
 	}
-      tmp_list = tmp_list->next;
+      tmp_list = next;
     }
   
   /* Disclaim ownership of any selections */
@@ -363,6 +379,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 +387,13 @@
 	  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_list_free (tmp_list);
 	  g_free (selection_info);
 	}
       
-      tmp_list = tmp_list->next;
+      tmp_list = next;
     }
 
   /* Now remove all handlers */
@@ -385,6 +404,7 @@
   tmp_list = selection_handlers;
   while (tmp_list)
     {
+      next = tmp_list->next;
       handler = (GtkSelectionHandler *)tmp_list->data;
 
       if (handler->remove_func)
@@ -392,7 +412,7 @@
 
       g_free (handler);
 
-      tmp_list = tmp_list->next;
+      tmp_list = next;
     }
 
   g_list_free (selection_handlers);
@@ -594,7 +614,6 @@
       if ((selection_info->selection == event->selection) &&
 	  (selection_info->widget == widget))
 	break;
-
       
       tmp_list = tmp_list->next;
     }
@@ -602,7 +621,8 @@
   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_list_free (tmp_list);
   g_free (selection_info);
 
   return TRUE;
@@ -915,6 +935,7 @@
   if (info->num_incrs == 0)
     {
       current_incrs = g_list_remove_link (current_incrs, tmp_list);
+      g_list_free (tmp_list);
       /* Let the timeout free it */
     }
   
@@ -950,7 +971,10 @@
   if (!tmp_list || info->idle_time >= 5)
     {
       if (tmp_list && info->idle_time >= 5)
-	current_incrs = g_list_remove_link (current_incrs, tmp_list);
+	{
+	  current_incrs = g_list_remove_link (current_incrs, tmp_list);
+	  g_list_free (tmp_list);
+	}
       
       g_free (info->conversions);
       /* FIXME: we should check if requestor window is still in use,
@@ -1012,6 +1036,8 @@
   if (event->property == GDK_NONE)
     {
       current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
+      g_list_free (tmp_list);
+      /* structure will be freed in timeout */
       gtk_selection_retrieval_report (info,
 				      GDK_NONE, 0, NULL, -1);
 
@@ -1036,6 +1062,7 @@
     {
       /* We don't delete the info structure - that will happen in timeout */
       current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
+      g_list_free (tmp_list);
 
       info->offset = length;
       gtk_selection_retrieval_report (info,
@@ -1114,6 +1141,7 @@
     {
       /* Info structure will be freed in timeout */
       current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
+      g_list_free (tmp_list);
       gtk_selection_retrieval_report (info,
 				      type, format, 
 				      (type == GDK_NONE) ?  NULL : info->buffer,
@@ -1178,6 +1206,7 @@
       if (tmp_list && info->idle_time >= 5)
 	{
 	  current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
+	  g_list_free (tmp_list);
 	  gtk_selection_retrieval_report (info, GDK_NONE, 0, NULL, -1);
 	}
       
@@ -1268,7 +1297,7 @@
  *   arguments:
  *     widget:      selection owner
  *     selection:   selection requested
- *     target:      targt requested
+ *     target:      target requested
  *     buffer:      buffer to write results into
  *     length:      size of buffer
  *     type:        type atom



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