Yesterday i posted this bug about tooltips appearing too fast:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24763
However, i was taking a look at the ToolTipManager.java source, and
noticed the logic apparently is already there.
So i started investigating the problem, and found something. In a few
words: ToolTipManager uses javax.swing.Timer to schedule the
appearance of the tooltip, as you may know. The problem happens
because when it calls Timer.restart(), restart() starts a new thread
before _really_ stopping the previous one.
It calls:
stop()
start()
However, because of the whole nature of wait/notifys/threads, when
that start() is executed, stop() has only notified the other thread -
it doesn't mean the other thread _really_ stopped.
So, you end up with 2 threads in the 'start' state. One of them will
block at the 'wait()' code, the other just moves on and shows the
tooltip -- too early.
The attached patch i'm sending apparently fixes this problem. I don't
know if it's the best way to fix it, though; take a look at what it
does and see if it's useful.
Cheers,
J.V.
------------------------------------------------------------------------
--- javax/swing/Timer.java 2005-11-10 15:09:08.224949882 +0000
+++ javax/swing/Timer.java-jv 2005-11-10 15:07:12.523395499 +0000
@@ -78,8 +78,10 @@
// Ignored
}
- if (!running)
+ if (!running) {
+ setInterrupting(false);
return;
+ }
queueEvent();
@@ -159,6 +161,7 @@
* as scheduled. Should only be checked/set with queueLock held.
*/
boolean running;
+ private boolean interrupting = false;
/**
* The delay between subsequent repetetive events.
@@ -379,6 +382,14 @@
return running;
}
+ private synchronized void setInterrupting(boolean aStatus) {
+ interrupting = aStatus;
+ }
+
+ private synchronized boolean isInterrupting() {
+ return interrupting;
+ }
+
/**
* Add the action listener
*
@@ -414,6 +425,17 @@
*/
public void start()
{
+
+ while (isInterrupting()) {
+ //do nothing
+ try {
+ synchronized (queueLock) {
+ queueLock.notifyAll();
+ }
+ } catch(Exception e) {
+ }
+ }
+
synchronized (queueLock)
{
if (!running)
@@ -432,6 +454,7 @@
{
synchronized (queueLock)
{
+ setInterrupting(true);
running = false;
queue = 0;
queueLock.notifyAll();
------------------------------------------------------------------------
_______________________________________________
Classpath mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/classpath