From a1fd6b5d48cfc6db08fa91e2373c72b2e316d770 Mon Sep 17 00:00:00 2001 From: andrey zaytsev Date: Fri, 25 Mar 2011 08:47:43 +0300 Subject: [PATCH] search/replace: copy model before adding to update queue to prevent race condition --- .../find/impl/livePreview/LivePreviewControllerBase.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreviewControllerBase.java b/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreviewControllerBase.java index abe5c374252b..31845dd7dcc9 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreviewControllerBase.java +++ b/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreviewControllerBase.java @@ -133,10 +133,11 @@ public class LivePreviewControllerBase implements LivePreview.Delegate, FindUtil myUserActivityDelay = userActivityDelay; } - public void updateInBackground(final FindModel findModel, final boolean allowedToChangedEditorSelection) { + public void updateInBackground(FindModel findModel, final boolean allowedToChangedEditorSelection) { myLivePreviewAlarm.cancelAllRequests(); if (findModel == null) return; final boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode(); + final FindModel copy = (FindModel)findModel.clone(); Runnable request = new Runnable() { @Override public void run() { @@ -151,7 +152,7 @@ public class LivePreviewControllerBase implements LivePreview.Delegate, FindUtil } else { ApplicationManager.getApplication().invokeAndWait(denyReplace, ModalityState.NON_MODAL); } - mySearchResults.updateThreadSafe(findModel, allowedToChangedEditorSelection, null); + mySearchResults.updateThreadSafe(copy, allowedToChangedEditorSelection, null); } }; if (unitTestMode) {