@@ -391,6 +391,8 @@ public void run() {
391391 if (done || resultChanged ) {
392392 lastSize = newSize [0 ];
393393 lastProvCount = newProvCount ;
394+ model .remove (toRemove );
395+ model .add (toAdd );
394396 attrCopier .checkWrongCase (toRemove , toAdd );
395397 if ( isCanceled ) {
396398 LOG .log (
@@ -403,17 +405,6 @@ public void run() {
403405 Level .FINE ,
404406 "Worker for text {0} finished after {1} ms." , //NOI18N
405407 new Object []{text , System .currentTimeMillis () - createTime });
406- /* NB: model.remove and model.add must happen inside
407- the invokeLater runnable, guarded by !isCanceled,
408- so that
409- (a) the remove and add are a single EDT turn (no
410- intervening repaint/keystroke between them),
411- and
412- (b) a Worker that was cancelled after
413- getSymbolNames cannot mutate the live model
414- one final time. The cancel flag is set from
415- the EDT in setListModel, so checking it on
416- the EDT here is race-free. */
417408 SwingUtilities .invokeLater (() -> {
418409 if (done ) {
419410 final Pair <String , String > nameAndScope = Utils .splitNameAndScope (text );
@@ -427,8 +418,6 @@ public void run() {
427418 nameAndScope .second ());
428419 }
429420 if (!isCanceled ) {
430- model .remove (toRemove );
431- model .add (toAdd );
432421 enableOK (panel .setModel (model , done ));
433422 }
434423 });
0 commit comments