You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by eb...@apache.org on 2024/09/27 20:28:49 UTC
(netbeans) 01/02: Get rid of some dead code in NbClipboard.
This is an automated email from the ASF dual-hosted git repository.
ebakke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
commit 8bb527abc4d4260352c5be2f6bdd903b0596d2b4
Author: Eirik Bakke <eb...@ultorg.com>
AuthorDate: Mon Aug 12 16:49:42 2024 -0400
Get rid of some dead code in NbClipboard.
The fields lastWindowActivated, lastWindowDeactivated, and lastWindowDeactivatedSource, and the related conditions were no longer in actual use; this can be seen by reading through the code.
It seems the condition that once used lastWindowActivated was at some point replaced by a call to Task.waitFinished. So there wasn't a mistake; just some unused code left around. See the relevant commit from 2012: https://github.com/eirikbakke/netbeans-releases/commit/6de619c#diff-69d67e2e5b062ae995069c62294958e6e24a42c599cc6684c47f89b086c20278
---
.../o.n.bootstrap/src/org/netbeans/NbClipboard.java | 17 +++--------------
.../unit/src/org/netbeans/NbClipboardNativeTest.java | 4 ++--
2 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/platform/o.n.bootstrap/src/org/netbeans/NbClipboard.java b/platform/o.n.bootstrap/src/org/netbeans/NbClipboard.java
index 7d44bc5d88c..1f9025e133f 100644
--- a/platform/o.n.bootstrap/src/org/netbeans/NbClipboard.java
+++ b/platform/o.n.bootstrap/src/org/netbeans/NbClipboard.java
@@ -60,9 +60,6 @@ implements LookupListener, FlavorListener, AWTEventListener
private Lookup.Result<ExClipboard.Convertor> result;
final boolean slowSystemClipboard;
private Transferable last;
- private long lastWindowActivated;
- private long lastWindowDeactivated;
- private Reference<Object> lastWindowDeactivatedSource = new WeakReference<>(null);
private volatile Task setContentsTask = Task.EMPTY;
private volatile Task getContentsTask = Task.EMPTY;
private boolean anyWindowIsActivated = true;
@@ -279,14 +276,12 @@ implements LookupListener, FlavorListener, AWTEventListener
getContentsTask.waitFinished ();
}
- final void activateWindowHack (boolean reschedule) {
+ /** Used by tests only. */
+ final void activateWindowHack () {
// if WINDOW_DEACTIVATED is followed immediatelly with
// WINDOW_ACTIVATED then it is JDK bug described in
// issue 41098.
- lastWindowActivated = System.currentTimeMillis();
- if (reschedule) {
- scheduleGetFromSystemClipboard(true);
- }
+ scheduleGetFromSystemClipboard(true);
}
private void logFlavors (Transferable trans, Level level, boolean content) {
@@ -340,8 +335,6 @@ implements LookupListener, FlavorListener, AWTEventListener
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
@@ -356,10 +349,6 @@ implements LookupListener, FlavorListener, AWTEventListener
fireChange();
}
anyWindowIsActivated = true;
- if (System.currentTimeMillis() - lastWindowDeactivated < 100 &&
- ev.getSource() == lastWindowDeactivatedSource.get()) {
- activateWindowHack (false);
- }
if (log.isLoggable (Level.FINE)) {
log.log (Level.FINE, "window activated scheduling update"); // NOI18N
}
diff --git a/platform/o.n.bootstrap/test/unit/src/org/netbeans/NbClipboardNativeTest.java b/platform/o.n.bootstrap/test/unit/src/org/netbeans/NbClipboardNativeTest.java
index c7121e0679b..1649d5ada25 100644
--- a/platform/o.n.bootstrap/test/unit/src/org/netbeans/NbClipboardNativeTest.java
+++ b/platform/o.n.bootstrap/test/unit/src/org/netbeans/NbClipboardNativeTest.java
@@ -146,7 +146,7 @@ public class NbClipboardNativeTest extends NbTestCase implements ClipboardListen
// just simulate initial switch to NetBeans main window
- ec.activateWindowHack (true);
+ ec.activateWindowHack ();
waitFinished (ec);
if (listenerCalls == 0) {
@@ -179,7 +179,7 @@ public class NbClipboardNativeTest extends NbTestCase implements ClipboardListen
if (slowClipboardHack ()) {
assertEquals ("The getContents rechecked the clipboard just for the first time, not now, so the content is the same", "data2", s);
- ec.activateWindowHack (true);
+ ec.activateWindowHack ();
Thread.sleep (200);
t = this.ec.getContents(this);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists