Browse Source

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 years ago
parent
commit
9c444f5339

+ 13
- 5
src/com/dmdirc/addons/ui_swing/DMDircEventQueue.java View File

39
 import java.awt.event.MouseEvent;
39
 import java.awt.event.MouseEvent;
40
 
40
 
41
 import java.awt.event.WindowEvent;
41
 import java.awt.event.WindowEvent;
42
+import java.util.concurrent.atomic.AtomicReference;
42
 import javax.swing.JPopupMenu;
43
 import javax.swing.JPopupMenu;
43
 import javax.swing.KeyStroke;
44
 import javax.swing.KeyStroke;
44
 import javax.swing.MenuSelectionManager;
45
 import javax.swing.MenuSelectionManager;
78
         if (tracingThread == null) {
79
         if (tracingThread == null) {
79
             super.dispatchEvent(event);
80
             super.dispatchEvent(event);
80
         } else {
81
         } else {
81
-            this.tracingThread.eventDispatched(event);
82
+            if (tracingThread != null) {
83
+                tracingThread.eventDispatched(event);
84
+            }
82
             super.dispatchEvent(event);
85
             super.dispatchEvent(event);
83
-            this.tracingThread.eventProcessed(event);
86
+            if (tracingThread != null) {
87
+                tracingThread.eventProcessed(event);
88
+            }
84
         }
89
         }
85
 
90
 
86
         if (event instanceof MouseEvent) {
91
         if (event instanceof MouseEvent) {
96
         final boolean tracing = IdentityManager.getGlobalConfig().
101
         final boolean tracing = IdentityManager.getGlobalConfig().
97
                 getOptionBool(controller.getDomain(), "debugEDT");
102
                 getOptionBool(controller.getDomain(), "debugEDT");
98
         if (tracing) {
103
         if (tracing) {
99
-            this.tracingThread = new TracingEventQueueThread(100);
100
-            this.tracingThread.start();
104
+            tracingThread = new TracingEventQueueThread(100);
105
+            tracingThread.start();
101
         } else {
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 View File

49
     private long thresholdDelay;
49
     private long thresholdDelay;
50
     private Map<AWTEvent, Long> eventTimeMap;
50
     private Map<AWTEvent, Long> eventTimeMap;
51
     private ThreadMXBean threadBean;
51
     private ThreadMXBean threadBean;
52
+    private boolean running = false;
52
 
53
 
53
     /**
54
     /**
54
      * Instantiates a new tracing thread.
55
      * Instantiates a new tracing thread.
142
     /** {@inheritDoc} */
143
     /** {@inheritDoc} */
143
     @Override
144
     @Override
144
     public void run() {
145
     public void run() {
145
-        while (true) {
146
+        running = true;
147
+        while (running) {
146
             long currTime = System.currentTimeMillis();
148
             long currTime = System.currentTimeMillis();
147
             synchronized (this) {
149
             synchronized (this) {
148
                 for (Map.Entry<AWTEvent, Long> entry : this.eventTimeMap.
150
                 for (Map.Entry<AWTEvent, Long> entry : this.eventTimeMap.
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 View File

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

Loading…
Cancel
Save