GdkInput list not modifiable from GdkInput->function



Hi

  There is a strong disadvantage in current GTK1.0 releases (upto current 1.0.6)
that handler of GdkInput is not allowed to modify GdkInput handlers list
as otherwise list/memory corruption can occur. Under GTK1.1 it appears OK now as
the whole GdkInput system has been rewritten.
  This is a major fault as there is no way to register/unregister new GdkInputs
otherway. Maybe doing gtk_main_quit() and restarting gtk_main after each event
but as I remember it had some disadvantage (not sure for now). This patch was
written more than a year ago, see the timestamp :-) , but unfortunately it
has somehow lost between.
  This patch has only A LITTLE performance cost as the GdkInput handlers list is
copied before the processing starts.


                                                        Lace
--- gtk+-0.99.0/gdk/gdk.c-0.99.0	Thu Dec 11 17:45:15 1997
+++ gtk+-0.99.0/gdk/gdk.c	Mon Jan  5 10:15:20 1998
@@ -1381,7 +1381,7 @@
 static gint
 gdk_event_wait ()
 {
-  GList *list;
+  GList *list,*listc,*listi;
   GdkInput *input;
   GdkInputCondition condition;
   SELECT_MASK readfds;
@@ -1445,12 +1445,20 @@
 		return TRUE;
 	    }
 
-	  list = inputs;
+	  listc=NULL;
+	  for (list=inputs;list;list=list->next)
+	    listc=g_list_prepend(listc,list->data);
+
+	  list = listc;
 	  while (list)
 	    {
 	      input = list->data;
 	      list = list->next;
 
+	      for (listi=inputs;listi;listi=listi->next)
+		if (listi->data==input) break;
+	      if (!listi) continue;
+
 	      condition = 0;
 	      if (FD_ISSET (input->source, &readfds))
 		condition |= GDK_INPUT_READ;
@@ -1462,6 +1470,7 @@
 	      if (condition && input->function)
 		(* input->function) (input->data, input->source, condition);
 	    }
+	g_list_free(listc);
 	}
     }
   else


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