EventDispatchThread.java (run): Stop running when interrupted.
* java/awt/EventDispatchThread.java (run): Stop running when interrupted. * java/awt/EventQueue.java (pop): Stop dispatch thread when done. Reset the queue after transferring its contents. (push): Start a new dispatch thread if none is running. From-SVN: r75977
This commit is contained in:
parent
5ed5fd905c
commit
101900aa28
3 changed files with 31 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2004-01-16 Fernando Nasser <fnasser@redhat.com>
|
||||||
|
|
||||||
|
* java/awt/EventDispatchThread.java (run): Stop running when
|
||||||
|
interrupted.
|
||||||
|
* java/awt/EventQueue.java (pop): Stop dispatch thread when done.
|
||||||
|
Reset the queue after transferring its contents.
|
||||||
|
(push): Start a new dispatch thread if none is running.
|
||||||
|
|
||||||
2004-01-16 Olga Rodimina <rodimina@redhat.com>
|
2004-01-16 Olga Rodimina <rodimina@redhat.com>
|
||||||
|
|
||||||
* gnu/java/awt/peer/gtk/GdkGraphics2D.java:
|
* gnu/java/awt/peer/gtk/GdkGraphics2D.java:
|
||||||
|
|
|
@ -62,8 +62,18 @@ class EventDispatchThread extends Thread
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AWTEvent evt = queue.getNextEvent();
|
AWTEvent evt = queue.getNextEvent();
|
||||||
|
if (isInterrupted ())
|
||||||
|
{
|
||||||
|
// We are interrupted when we should finish executing
|
||||||
|
return;
|
||||||
|
}
|
||||||
queue.dispatchEvent(evt);
|
queue.dispatchEvent(evt);
|
||||||
}
|
}
|
||||||
|
catch (InterruptedException ie)
|
||||||
|
{
|
||||||
|
// We are interrupted when we should finish executing
|
||||||
|
return;
|
||||||
|
}
|
||||||
catch (Throwable x)
|
catch (Throwable x)
|
||||||
{
|
{
|
||||||
System.err.println("Exception during event dispatch:");
|
System.err.println("Exception during event dispatch:");
|
||||||
|
|
|
@ -301,8 +301,8 @@ public class EventQueue
|
||||||
/**
|
/**
|
||||||
* Allows a custom EventQueue implementation to replace this one.
|
* Allows a custom EventQueue implementation to replace this one.
|
||||||
* All pending events are transferred to the new queue. Calls to postEvent,
|
* All pending events are transferred to the new queue. Calls to postEvent,
|
||||||
* getNextEvent, and peekEvent are forwarded to the pushed queue until it
|
* getNextEvent, and peekEvent and others are forwarded to the pushed queue
|
||||||
* is removed with a pop().
|
* until it is removed with a pop().
|
||||||
*
|
*
|
||||||
* @exception NullPointerException if newEventQueue is null.
|
* @exception NullPointerException if newEventQueue is null.
|
||||||
*/
|
*/
|
||||||
|
@ -320,6 +320,10 @@ public class EventQueue
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure we have a live dispatch thread to drive the queue */
|
||||||
|
if (dispatchThread == null)
|
||||||
|
dispatchThread = new EventDispatchThread(this);
|
||||||
|
|
||||||
int i = next_out;
|
int i = next_out;
|
||||||
while (i != next_in)
|
while (i != next_in)
|
||||||
{
|
{
|
||||||
|
@ -361,6 +365,13 @@ public class EventQueue
|
||||||
if (++i == queue.length)
|
if (++i == queue.length)
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
// Empty the queue so it can be reused
|
||||||
|
next_in = 0;
|
||||||
|
next_out = 0;
|
||||||
|
|
||||||
|
// Tell our EventDispatchThread that it can end execution
|
||||||
|
dispatchThread.interrupt ();
|
||||||
|
dispatchThread = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue