Check project disposed state

This commit is contained in:
Alexander Lobas
2012-04-19 22:17:09 +04:00
parent 88aa20e791
commit b02bdc0609
3 changed files with 13 additions and 7 deletions
@@ -193,7 +193,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
}
catch (RuntimeException e) {
myPSIChangeListener.clear();
showError("Parsing error", e.getCause());
showError("Parsing error", e.getCause() == null ? e : e.getCause());
}
}
@@ -289,7 +289,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
RenderUtil.renderLayout(myModule, layoutXmlText, myFile, null, target, facet, config, xdpi, ydpi, theme, 10000, true);
if (ApplicationManagerEx.getApplicationEx().isInternal()) {
System.out.println("Render time: " + (System.currentTimeMillis() - time));
System.out.println("Render time: " + (System.currentTimeMillis() - time)); // XXX
}
if (result == null) {
@@ -303,8 +303,10 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
@Override
public void run() {
try {
hideProgress();
runnable.run();
if (!getProject().isDisposed()) {
hideProgress();
runnable.run();
}
}
catch (Throwable e) {
myPSIChangeListener.clear();
@@ -54,14 +54,14 @@ public class ExternalPSIChangeListener extends PsiTreeChangeAdapter {
public void start() {
if (!myRunState) {
myRunState = true;
PsiManager.getInstance(myFile.getProject()).addPsiTreeChangeListener(this);
PsiManager.getInstance(myDesigner.getProject()).addPsiTreeChangeListener(this);
}
}
public void stop() {
if (myRunState) {
myRunState = false;
PsiManager.getInstance(myFile.getProject()).removePsiTreeChangeListener(this);
PsiManager.getInstance(myDesigner.getProject()).removePsiTreeChangeListener(this);
clear();
}
}
@@ -107,7 +107,7 @@ public class ExternalPSIChangeListener extends PsiTreeChangeAdapter {
myAlarm.addRequest(new Runnable() {
@Override
public void run() {
if (myRunState && myInitialize) {
if (myRunState && myInitialize && !myDesigner.getProject().isDisposed()) {
runnable.run();
}
}
@@ -316,6 +316,10 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
}
public final void showError(@NotNull String message, @NotNull Throwable e) {
if (getProject().isDisposed()) {
return;
}
while (e instanceof InvocationTargetException) {
if (e.getCause() == null) {
break;