diff --git a/modules/decima-ext-model-viewer/src/main/java/com/shade/decima/model/viewer/ModelViewport.java b/modules/decima-ext-model-viewer/src/main/java/com/shade/decima/model/viewer/ModelViewport.java index b8f806387..589ec9d7a 100644 --- a/modules/decima-ext-model-viewer/src/main/java/com/shade/decima/model/viewer/ModelViewport.java +++ b/modules/decima-ext-model-viewer/src/main/java/com/shade/decima/model/viewer/ModelViewport.java @@ -51,6 +51,7 @@ public class ModelViewport extends AWTGLCanvas implements Disposable { private boolean softShading = true; private OutlineDialog outlineDialog; + private Model model; public ModelViewport(@NotNull Camera camera) { super(createData()); @@ -112,6 +113,8 @@ public void initGL() { } catch (IOException e) { throw new UncheckedIOException(e); } + + modelRenderer.setModel(model); } @Override @@ -162,25 +165,31 @@ public void paintGL() { } @Override - public void dispose() { - outlineRenderer.dispose(); - gridRenderer.dispose(); - modelRenderer.dispose(); - debugRenderer.dispose(); + public void removeNotify() { + if (initCalled) { + outlineRenderer.dispose(); + gridRenderer.dispose(); + modelRenderer.dispose(); + debugRenderer.dispose(); + + glDisable(GL_DEBUG_OUTPUT); + glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + glDebugMessageCallback(null, 0); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, false); + } + + super.removeNotify(); + } + @Override + public void dispose() { if (outlineDialog != null) { outlineDialog.dispose(); outlineDialog = null; } - if (!initCalled) { - return; - } - - glDisable(GL_DEBUG_OUTPUT); - glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - glDebugMessageCallback(null, 0); - glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, false); + // Will be disposed in ModelRenderer#dispose() + model = null; } public boolean isShowOutline() { @@ -224,14 +233,15 @@ public Camera getCamera() { @Nullable public Model getModel() { - return modelRenderer.getModel(); + return model; } public void setModel(@Nullable Model model) { - final Model oldModel = modelRenderer.getModel(); + final Model oldModel = this.model; if (oldModel != model) { modelRenderer.setModel(model); + this.model = model; firePropertyChange("model", oldModel, model); } } diff --git a/modules/platform-ui/src/main/java/com/shade/platform/ui/editors/stack/EditorStack.java b/modules/platform-ui/src/main/java/com/shade/platform/ui/editors/stack/EditorStack.java index 4421ec884..885337d12 100644 --- a/modules/platform-ui/src/main/java/com/shade/platform/ui/editors/stack/EditorStack.java +++ b/modules/platform-ui/src/main/java/com/shade/platform/ui/editors/stack/EditorStack.java @@ -471,6 +471,7 @@ public boolean isDataFlavorSupported(DataFlavor flavor) { return tabFlavor.equals(flavor); } + @NotNull @Override public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (isDataFlavorSupported(flavor)) { diff --git a/modules/platform-ui/src/main/java/com/shade/platform/ui/editors/stack/EditorStackContainer.java b/modules/platform-ui/src/main/java/com/shade/platform/ui/editors/stack/EditorStackContainer.java index d2763c034..6053f7fa1 100644 --- a/modules/platform-ui/src/main/java/com/shade/platform/ui/editors/stack/EditorStackContainer.java +++ b/modules/platform-ui/src/main/java/com/shade/platform/ui/editors/stack/EditorStackContainer.java @@ -39,7 +39,7 @@ public SplitResult split(int orientation, double position, boolean leading) { removeAll(); add(pane, BorderLayout.CENTER); - validate(); + invalidate(); pane.setResizeWeight(position); pane.setDividerLocation(position); @@ -65,11 +65,9 @@ public void compact() { leaf = container.getComponent(0); } - if (leaf != null) { + if (leaf != null && getComponent(0) != leaf) { removeAll(); add(leaf, BorderLayout.CENTER); - - revalidate(); invalidate(); }