mbien commented on code in PR #7668:
URL: https://github.com/apache/netbeans/pull/7668#discussion_r1714442509
##########
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:
speaking without knowing windows clipboard impl details and only from the
concurrency perspective:
if the task length is not predictable, this could build up tasks in the RPs
task queue.
Also if the listener isn't removed immediately, but some time later while
EDT is doing its thing, this might influence the original workaround, no? Is
the workaround still needed?
--
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