File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 33import java .awt .Component ;
44import java .util .ArrayList ;
55import java .util .List ;
6+ import java .util .UUID ;
67
78import javax .swing .JPanel ;
89import javax .swing .SwingUtilities ;
@@ -32,6 +33,8 @@ public class InfoTab implements IMessageEditorTab {
3233
3334 int triggerTime = 1 ;
3435 boolean debug = false ;
36+ private UUID currentTaskId = null ;
37+
3538
3639 public byte [] getOriginContent () {
3740 return originContent ;
@@ -125,6 +128,14 @@ public void setMessage(byte[] content, boolean isRequest) {
125128 } else if (ByteArrayUtils .equals (originContent , content )) {
126129 return ;
127130 } else {
131+ UUID taskId = UUID .randomUUID ();
132+ currentTaskId = taskId ;
133+
134+ //setMessage() 就是在 EDT中调用的
135+ InfoTableModel model = ((InfoPanel ) panel ).getTable ().getInfoTableModel ();
136+ model .clear ();
137+ model .addNewInfoEntry (new InfoEntry ("Loading..." , InfoEntry .Type_URL ));
138+
128139 originContent = content ;
129140 SwingWorker <List <InfoEntry >, Void > worker = new SwingWorker <List <InfoEntry >, Void >() {
130141 /*
@@ -167,6 +178,11 @@ protected List<InfoEntry> doInBackground() {
167178
168179 @ Override
169180 protected void done () {
181+
182+ if (!taskId .equals (currentTaskId )) {
183+ return ; // 丢弃旧任务的结果
184+ }
185+
170186 try {
171187 List <InfoEntry > newEntries = get ();
172188 InfoTableModel model = ((InfoPanel ) panel ).getTable ().getInfoTableModel ();
You can’t perform that action at this time.
0 commit comments