This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix to EventQueue 1/7


There are 7 error in the EventQueue code, can you find them? :-)

Just kidding, but this is indeed the first of seven patches to fix very small problems in handling the stack of threads. The code there is really nice and the people who developed it (probably long time ago) did an excellent job, even not having the code that uses it to be able to test what they did. Now that I have the means to test it I am giving the final polishing.

Anyway, this patch fixes something easily reproducible: we currently can't handle a modal Dialog shown from a modal Dialog. With this patch applied we can. Any number of levels.

Regards to all.


2004-01-13 Fernando Nasser <fnasser@redhat.com>


* java/awt/EventQueue.java (isDispatchThread): Do check on top of stack. (push): Make sure push is performed at the top of the thread stack.
Index: java/awt/EventQueue.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/EventQueue.java,v
retrieving revision 1.11
diff -c -p -r1.11 EventQueue.java
*** java/awt/EventQueue.java	11 Aug 2003 18:26:08 -0000	1.11
--- java/awt/EventQueue.java	13 Jan 2004 16:38:44 -0000
*************** public class EventQueue
*** 269,280 ****
    }
  
    /**
!    * Return true if the current thread is the AWT event dispatch
     * thread.
     */
    public static boolean isDispatchThread()
    {
!     EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue(); 
      return (Thread.currentThread() == eq.dispatchThread);
    }
  
--- 269,285 ----
    }
  
    /**
!    * Return true if the current thread is the current AWT event dispatch
     * thread.
     */
    public static boolean isDispatchThread()
    {
!     EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
!     
!     /* Find last EventQueue in chain */ 
!     while (eq.next != null)
!       eq = eq.next;
! 
      return (Thread.currentThread() == eq.dispatchThread);
    }
  
*************** public class EventQueue
*** 305,310 ****
--- 310,324 ----
    {
      if (newEventQueue == null)
        throw new NullPointerException ();
+ 
+     /* Make sure we are at the top of the stack because callers can
+        only get a reference to the one at the bottom using
+        Toolkit.getDefaultToolkit().getSystemEventQueue() */
+     if (next != null)
+       {
+         next.push (newEventQueue);
+         return;
+       }
  
      int i = next_out;
      while (i != next_in)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]