IDEA-117507 NullPointerException on startup of IDEA 13

This commit is contained in:
Maxim.Mossienko
2014-07-18 20:20:01 +02:00
parent 5cc3a16d56
commit e442926004
2 changed files with 16 additions and 10 deletions
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
*/ */
public abstract class ProgressIndicatorProvider { public abstract class ProgressIndicatorProvider {
@Nullable @Nullable
public static ProgressIndicatorProvider ourInstance; public static volatile ProgressIndicatorProvider ourInstance;
@Nullable @Nullable
public static ProgressIndicatorProvider getInstance() { public static ProgressIndicatorProvider getInstance() {
@@ -36,22 +36,27 @@ public abstract class ProgressIndicatorProvider {
@Nullable @Nullable
public static ProgressIndicator getGlobalProgressIndicator() { public static ProgressIndicator getGlobalProgressIndicator() {
return ourInstance != null ? ourInstance.getProgressIndicator() : null; ProgressIndicatorProvider provider = ourInstance;
return provider != null ? provider.getProgressIndicator() : null;
} }
public abstract NonCancelableSection startNonCancelableSection(); public abstract NonCancelableSection startNonCancelableSection();
@NotNull @NotNull
public static NonCancelableSection startNonCancelableSectionIfSupported() { public static NonCancelableSection startNonCancelableSectionIfSupported() {
return ourInstance != null ? ourInstance.startNonCancelableSection() : NonCancelableSection.EMPTY; ProgressIndicatorProvider provider = ourInstance;
return provider != null ? provider.startNonCancelableSection() : NonCancelableSection.EMPTY;
} }
public static volatile boolean ourNeedToCheckCancel = false; public static volatile boolean ourNeedToCheckCancel = false;
public static void checkCanceled() throws ProcessCanceledException { public static void checkCanceled() throws ProcessCanceledException {
// smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds // smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
if (ourNeedToCheckCancel && ourInstance != null) { if (ourNeedToCheckCancel) {
ourInstance.doCheckCanceled(); ProgressIndicatorProvider provider = ourInstance;
ourNeedToCheckCancel = false; if (provider != null) {
provider.doCheckCanceled();
ourNeedToCheckCancel = false;
}
} }
} }
} }
@@ -50,13 +50,14 @@ public abstract class ProgressManager {
}; };
} }
private static ProgressManager ourInstance; private static volatile ProgressManager ourInstance;
public static ProgressManager getInstance() { public static ProgressManager getInstance() {
if (ourInstance == null) { ProgressManager progressManager = ourInstance;
ourInstance = ServiceManager.getService(ProgressManager.class); if (progressManager == null) {
ourInstance = progressManager = ServiceManager.getService(ProgressManager.class);
} }
return ourInstance; return progressManager;
} }
public abstract boolean hasProgressIndicator(); public abstract boolean hasProgressIndicator();