src/share/classes/sun/awt/SunToolkit.java

Print this page

        

@@ -542,31 +542,31 @@
             }, PeerEvent.ULTIMATE_PRIORITY_EVENT);
         postEvent(targetToAppContext(e.getSource()), pe);
     }
 
     protected static final Lock flushLock = new ReentrantLock();
-    private static boolean isFlushingPendingEvents = false;
+    private static int flushNestingLevel = 0;
 
     /*
      * Flush any pending events which haven't been posted to the AWT
      * EventQueue yet.
      */
     public static void flushPendingEvents()  {
         flushLock.lock();
         try {
             // Don't call flushPendingEvents() recursively
-            if (!isFlushingPendingEvents) {
-                isFlushingPendingEvents = true;
+            ++flushNestingLevel;
+            if (flushNestingLevel == 1) {
                 AppContext appContext = AppContext.getAppContext();
                 PostEventQueue postEventQueue =
                     (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
                 if (postEventQueue != null) {
                     postEventQueue.flush();
                 }
             }
         } finally {
-            isFlushingPendingEvents = false;
+            --flushNestingLevel;
             flushLock.unlock();
         }
     }
 
     public static boolean isPostEventQueueEmpty()  {