From 65dc6bc577bae2f6563c65818e72e7605339d4ef Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 22 Dec 2009 13:43:57 +0300 Subject: [PATCH 1/4] IDEADEV-42059 (CME at com.intellij.openapi.vcs.impl.VcsInitialization.execute) --- .../openapi/vcs/impl/VcsInitialization.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsInitialization.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsInitialization.java index 2705f6d60d0f..7af934338ec6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsInitialization.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/VcsInitialization.java @@ -15,6 +15,8 @@ */ package com.intellij.openapi.vcs.impl; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; @@ -26,10 +28,15 @@ import java.util.LinkedList; import java.util.List; public class VcsInitialization { + private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.impl.VcsInitialization"); + private final Project myProject; private final List> myList; + private final Object myLock; + private boolean myInitStarted; - public VcsInitialization(Project project) { + public VcsInitialization(final Project project) { + myLock = new Object(); myProject = project; myList = new LinkedList>(); @@ -41,16 +48,28 @@ public class VcsInitialization { } public void add(final VcsInitObject vcsInitObject, final Runnable runnable) { - myList.add(new Pair(vcsInitObject, runnable)); + synchronized (myLock) { + if (myInitStarted) { + LOG.info("Registering startup activity AFTER initialization ", new Throwable()); + // post startup are normally called on awt thread + ApplicationManager.getApplication().invokeLater(runnable); + } + myList.add(new Pair(vcsInitObject, runnable)); + } } public void execute() { - Collections.sort(myList, new Comparator>() { + final List> list; + synchronized (myLock) { + list = myList; + myInitStarted = true; // list would not be modified starting from this point + } + Collections.sort(list, new Comparator>() { public int compare(Pair o1, Pair o2) { return new Integer(o1.getFirst().getOrder()).compareTo(new Integer(o2.getFirst().getOrder())); } }); - for (Pair pair : myList) { + for (Pair pair : list) { pair.getSecond().run(); } } From ca28f4cdd83899c11bba036a1a554a912839f145 Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 22 Dec 2009 14:53:02 +0300 Subject: [PATCH 2/4] Progress window: correctly set cancle button text, r=sleaner --- .../com/intellij/openapi/progress/util/ProgressWindow.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java index 0900e9fb8a0a..89a85a68ab4a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java @@ -102,7 +102,6 @@ public class ProgressWindow extends BlockingProgressIndicator implements Disposa else { myDialog = new MyDialog(shouldShowBackground, myProject, myCancelText); } - myDialog.changeCancelButtonText(myCancelText); Disposer.register(this, myDialog); @@ -494,6 +493,9 @@ public class ProgressWindow extends BlockingProgressIndicator implements Disposa private void createCenterPanel() { // Cancel button (if any) + if (myCancelText != null) { + myCancelButton.setText(myCancelText); + } myCancelButton.setVisible(myShouldShowCancel); myBackgroundButton.setVisible(myShouldShowBackground); From 16488bf6645673328d6e2ddb271ec9bfd0e330a3 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Tue, 22 Dec 2009 15:20:15 +0300 Subject: [PATCH 3/4] abstract the way 'package-path' is calculated --- .../impl/javaCompiler/BackendCompilerWrapper.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java index 3cc3def8a9ad..88f8743aa6b2 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java @@ -730,8 +730,7 @@ public class BackendCompilerWrapper { if (paths == null || paths.isEmpty()) { return; } - final String prefix = packagePrefix != null && packagePrefix.length() > 0 ? packagePrefix.replace('.', '/') + "/" : ""; - final String filePath = "/" + prefix + VfsUtil.getRelativePath(srcFile, sourceRoot, '/'); + final String filePath = "/" + calcPackagePath(srcFile, sourceRoot, packagePrefix); for (final CompiledClass cc : paths) { myCompileContext.getProgressIndicator().checkCanceled(); if (LOG.isDebugEnabled()) { @@ -768,6 +767,18 @@ public class BackendCompilerWrapper { } } + /** + * + * @param srcFile + * @param sourceRoot + * @param packagePrefix + * @return A 'package'-path to a given src file relative to a specified root. "/" slashes must be used + */ + protected String calcPackagePath(VirtualFile srcFile, VirtualFile sourceRoot, String packagePrefix) { + final String prefix = packagePrefix != null && packagePrefix.length() > 0 ? packagePrefix.replace('.', '/') + "/" : ""; + return prefix + VfsUtil.getRelativePath(srcFile, sourceRoot, '/'); + } + @Nullable private Pair moveToRealLocation(String tempOutputDir, String pathToClass, VirtualFile sourceFile, final List filesToRefresh) { final Module module = myCompileContext.getModuleByFile(sourceFile); From 1addaed91e94bab47548b3fd0d7204f11a382d8f Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Tue, 22 Dec 2009 15:52:54 +0300 Subject: [PATCH 4/4] fix ReadAccess assertion --- .../src/com/intellij/debugger/engine/JVMNameUtil.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java b/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java index 87bb3488a304..f5e40da93aea 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java @@ -20,8 +20,10 @@ import com.intellij.debugger.DebuggerManager; import com.intellij.debugger.SourcePosition; import com.intellij.debugger.engine.evaluation.EvaluateException; import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Ref; import com.intellij.psi.*; import com.intellij.psi.jsp.JspFile; @@ -213,8 +215,12 @@ public class JVMNameUtil { throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("error.class.not.loaded", getDisplayName(process))); } - public String getDisplayName(DebugProcessImpl debugProcess) { - return getSourcePositionClassDisplayName(debugProcess, mySourcePosition); + public String getDisplayName(final DebugProcessImpl debugProcess) { + return ApplicationManager.getApplication().runReadAction(new Computable() { + public String compute() { + return getSourcePositionClassDisplayName(debugProcess, mySourcePosition); + } + }); } }