Skip to content

fix stopping and removing animclip when deleting them #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import javax.swing.Action;
import javax.swing.SwingUtilities;
import org.openide.actions.DeleteAction;
import org.openide.actions.RenameAction;
import org.openide.awt.Actions;
Expand Down Expand Up @@ -162,19 +163,20 @@ public void stop() {

@Override
public void destroy() throws IOException {
super.destroy();
super.destroy();
final AnimComposer control = jmeControl.getLookup().lookup(AnimComposer.class);
try {
lookupContents.remove(this.animClip);
lookupContents.remove(this);
SceneApplication.getApplication().enqueue(() -> {
control.removeAnimClip(this.animClip);
return null;
}).get();
setChanged();
} catch (InterruptedException | ExecutionException ex) {
Exceptions.printStackTrace(ex);
if (playing) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stops the animation if it's playing

control.removeCurrentAction(AnimComposer.DEFAULT_LAYER);
jmeControl.setAnimClip(null);

}
lookupContents.remove(JmeAnimClip.this.animClip);
lookupContents.remove(this);
SceneApplication.getApplication().enqueue( () -> {
control.removeAnimClip(this.animClip);
SwingUtilities.invokeLater(() -> jmeControl.refresh(false));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to refresh after the anim has been removed from the control

});
setChanged();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ protected List<Object> createKeys() {

@Override
protected Node[] createNodes(Object key) {
if (key instanceof AnimClip) {
return new Node[]{ new JmeAnimClip(jmeAnimComposer, (AnimClip)key, dataObject).setReadOnly(readOnly)};
if (key instanceof AnimClip animClip) {
return new Node[]{ new JmeAnimClip(jmeAnimComposer, animClip, dataObject).setReadOnly(readOnly)};
} else {
return new Node[]{ Node.EMPTY };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void setGlobalSpeed(final float speed) {
Exceptions.printStackTrace(ex);
}
}

@Override
public Action[] getActions(boolean context) {
return new Action[]{
Expand All @@ -149,4 +149,10 @@ public Node[] createNodes(Object key, DataObject key2, boolean cookie) {
JmeAnimClipChildren children = new JmeAnimClipChildren(this);
return new Node[]{ new JmeAnimComposer((AnimComposer)key, children, key2)};
}

@Override
public void refresh(boolean immediate) {
((JmeAnimClipChildren) jmeChildren).refreshChildren(immediate);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refresh only happens if they are JmeSpatialChildren per default 🤷

super.refresh(immediate);
}
}