eirikbakke commented on code in PR #7668:
URL: https://github.com/apache/netbeans/pull/7668#discussion_r1714512131
##########
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:
> 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?
True. I was assuming that piled-up addFlavorListener/removeFlavorListener
calls would execute quickly as soon as the lock is relinquished... but then
there are also other effects such as the call to fireChange(). Maybe I should
try to guard against funky behavior here.
> Is the workaround still needed?
Reading the [original BugZilla
issue](https://bz.apache.org/netbeans/show_bug.cgi?id=247585), I would think
yes, more likely than not. It's NetBeans trying to be a good citizen among
other native Windows apps, which may themselves be buggy and/or not have
updated their clipboard handling code in the last 10 years.
--
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