mbien commented on code in PR #7668:
URL: https://github.com/apache/netbeans/pull/7668#discussion_r1715532007


##########
platform/o.n.bootstrap/src/org/netbeans/NbClipboard.java:
##########
@@ -340,26 +336,31 @@ public void eventDispatched(AWTEvent ev) {
             return;
 
         if (ev.getID() == WindowEvent.WINDOW_DEACTIVATED) {
-            lastWindowDeactivated = System.currentTimeMillis();
-            lastWindowDeactivatedSource = new WeakReference<>(ev.getSource());
             anyWindowIsActivated = false;
             if( Utilities.isWindows() ) {
-                //#247585 - even listening to clipboard changes when the 
window isn't active
-                //may throw a MS Windows error as the 'clipboard copy' action 
doesn't have enough time to finish
-                systemClipboard.removeFlavorListener(this);
+                /* Avoid calling add/removeFlavorListener from the Event 
Dispatch Thread, as these
+                methods are synchronized and may block while the expensive
+                systemClipboard.getContents() method is being called. I once 
saw the EDT blocked on
+                removeFlavorListener this way for several seconds. */
+                RP.post(() -> {
+                    //#247585 - even listening to clipboard changes when the 
window isn't active
+                    //may throw a MS Windows error as the 'clipboard copy' 
action doesn't have enough time to finish
+                    systemClipboard.removeFlavorListener(this);
+                });

Review Comment:
   ah this is for the main window. So this should not happen very often or in 
quick succession. Might be no concern.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to