Переглянути джерело

Fixes being unable to stop the EDT debugging

Change-Id: Iff5c8a8902eab43eeda4b4c839303ad2ff081be6
Reviewed-on: http://gerrit.dmdirc.com/383
Tested-by: Gregory Holmes <greboid@dmdirc.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.3
Gregory Holmes 14 роки тому
джерело
коміт
9c444f5339

+ 13
- 5
src/com/dmdirc/addons/ui_swing/DMDircEventQueue.java Переглянути файл

@@ -39,6 +39,7 @@ import java.awt.event.KeyEvent;
39 39
 import java.awt.event.MouseEvent;
40 40
 
41 41
 import java.awt.event.WindowEvent;
42
+import java.util.concurrent.atomic.AtomicReference;
42 43
 import javax.swing.JPopupMenu;
43 44
 import javax.swing.KeyStroke;
44 45
 import javax.swing.MenuSelectionManager;
@@ -78,9 +79,13 @@ public final class DMDircEventQueue extends EventQueue implements
78 79
         if (tracingThread == null) {
79 80
             super.dispatchEvent(event);
80 81
         } else {
81
-            this.tracingThread.eventDispatched(event);
82
+            if (tracingThread != null) {
83
+                tracingThread.eventDispatched(event);
84
+            }
82 85
             super.dispatchEvent(event);
83
-            this.tracingThread.eventProcessed(event);
86
+            if (tracingThread != null) {
87
+                tracingThread.eventProcessed(event);
88
+            }
84 89
         }
85 90
 
86 91
         if (event instanceof MouseEvent) {
@@ -96,10 +101,13 @@ public final class DMDircEventQueue extends EventQueue implements
96 101
         final boolean tracing = IdentityManager.getGlobalConfig().
97 102
                 getOptionBool(controller.getDomain(), "debugEDT");
98 103
         if (tracing) {
99
-            this.tracingThread = new TracingEventQueueThread(100);
100
-            this.tracingThread.start();
104
+            tracingThread = new TracingEventQueueThread(100);
105
+            tracingThread.start();
101 106
         } else {
102
-            tracingThread = null;
107
+            if (tracingThread != null) {
108
+                tracingThread.cancel();
109
+                tracingThread = null;
110
+            }
103 111
         }
104 112
     }
105 113
 

+ 10
- 1
src/com/dmdirc/addons/ui_swing/TracingEventQueueThread.java Переглянути файл

@@ -49,6 +49,7 @@ class TracingEventQueueThread extends Thread {
49 49
     private long thresholdDelay;
50 50
     private Map<AWTEvent, Long> eventTimeMap;
51 51
     private ThreadMXBean threadBean;
52
+    private boolean running = false;
52 53
 
53 54
     /**
54 55
      * Instantiates a new tracing thread.
@@ -142,7 +143,8 @@ class TracingEventQueueThread extends Thread {
142 143
     /** {@inheritDoc} */
143 144
     @Override
144 145
     public void run() {
145
-        while (true) {
146
+        running = true;
147
+        while (running) {
146 148
             long currTime = System.currentTimeMillis();
147 149
             synchronized (this) {
148 150
                 for (Map.Entry<AWTEvent, Long> entry : this.eventTimeMap.
@@ -161,4 +163,11 @@ class TracingEventQueueThread extends Thread {
161 163
             }
162 164
         }
163 165
     }
166
+
167
+    /**
168
+     * Cancels this thread.
169
+     */
170
+    public void cancel() {
171
+        running = false;
172
+    }
164 173
 }

+ 2
- 0
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelSettingsDialog.java Переглянути файл

@@ -78,6 +78,7 @@ public final class ChannelSettingsDialog extends StandardDialog implements
78 78
     private ChannelSettingsDialog(final Channel newChannel,
79 79
             final Window parentWindow) {
80 80
         super(parentWindow, ModalityType.MODELESS);
81
+        final long time = System.currentTimeMillis();
81 82
 
82 83
         channel = newChannel;
83 84
         identity = IdentityManager.getChannelConfig(channel.getServer().
@@ -85,6 +86,7 @@ public final class ChannelSettingsDialog extends StandardDialog implements
85 86
 
86 87
         initComponents();
87 88
         initListeners();
89
+        System.out.println(System.currentTimeMillis() - time);
88 90
     }
89 91
 
90 92
     /**

Завантаження…
Відмінити
Зберегти