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 {
@Nullable
public static ProgressIndicatorProvider ourInstance;
public static volatile ProgressIndicatorProvider ourInstance;
@Nullable
public static ProgressIndicatorProvider getInstance() {
@@ -36,22 +36,27 @@ public abstract class ProgressIndicatorProvider {
@Nullable
public static ProgressIndicator getGlobalProgressIndicator() {
return ourInstance != null ? ourInstance.getProgressIndicator() : null;
ProgressIndicatorProvider provider = ourInstance;
return provider != null ? provider.getProgressIndicator() : null;
}
public abstract NonCancelableSection startNonCancelableSection();
@NotNull
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 void checkCanceled() throws ProcessCanceledException {
// smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
if (ourNeedToCheckCancel && ourInstance != null) {
ourInstance.doCheckCanceled();
ourNeedToCheckCancel = false;
if (ourNeedToCheckCancel) {
ProgressIndicatorProvider provider = ourInstance;
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() {
if (ourInstance == null) {
ourInstance = ServiceManager.getService(ProgressManager.class);
ProgressManager progressManager = ourInstance;
if (progressManager == null) {
ourInstance = progressManager = ServiceManager.getService(ProgressManager.class);
}
return ourInstance;
return progressManager;
}
public abstract boolean hasProgressIndicator();