Skip to content

Commit

Permalink
Prevents views from being asked to close two or more times
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Sep 30, 2021
1 parent d05036c commit 98e1e91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -32,7 +32,7 @@ public abstract class SWTDisplayView extends LayeredDisplayView {
@Override
public Control[] getZoomableControls() { return new Control[] { surfaceComposite }; }

@Override
@Override
public void setFocus() {
if (surfaceComposite != null && !surfaceComposite.isDisposed() && !surfaceComposite.isFocusControl()) {
surfaceComposite.forceFocus();
Expand All @@ -41,13 +41,13 @@ public void setFocus() {

@Override
public void close(final IScope scope) {
if (closing) return;
closing = true;
DEBUG.OUT("Closing " + this.getPartName());
WorkbenchHelper.asyncRun(() -> {
try {
if (getDisplaySurface() != null) { getDisplaySurface().dispose(); }
if (getSite() != null && getSite().getPage() != null) {
getSite().getPage().hideView(SWTDisplayView.this);
}
WorkbenchHelper.hideView(SWTDisplayView.this);
} catch (final Exception e) {}
});

Expand Down
Expand Up @@ -73,6 +73,9 @@ public abstract class GamaViewPart extends ViewPart
/** The root composite. */
private Composite rootComposite;

/** The closing. */
protected volatile boolean closing;

/**
* The Enum UpdatePriority.
*/
Expand Down Expand Up @@ -346,6 +349,8 @@ public void displayTooltip(final String text, final GamaUIColor color) {

@Override
public void close(final IScope scope) {
if (closing) return;
closing = true;
DEBUG.OUT("Closing " + this.getPartName());
WorkbenchHelper.asyncRun(() -> {
try {
Expand Down

0 comments on commit 98e1e91

Please sign in to comment.