Skip to content

Commit

Permalink
Avoid using environment when deserializing commands before tree attac…
Browse files Browse the repository at this point in the history
…hment (#1133)
  • Loading branch information
shueja authored Jan 9, 2025
1 parent 985c68a commit 1dca2ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/document/CommandStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
NamedCommand,
WaitCommand
} from "./2025/DocumentTypes";
import { Env } from "./DocumentManager";
import { Env, EnvConstructors } from "./DocumentManager";
import { ExpressionStore } from "./ExpressionStore";

export type CommandGroupType = "sequential" | "parallel" | "deadline" | "race";
Expand Down Expand Up @@ -109,7 +109,7 @@ export const CommandStore = types
}
}))
.actions((self) => ({
deserialize(ser: Command) {
deserialize(ser: Command, constructor: EnvConstructors["CommandStore"]) {
self.commands.clear();
self.name = "";
if (ser === undefined || ser === null) {
Expand All @@ -123,9 +123,8 @@ export const CommandStore = types
self.time.deserialize(ser.data.waitTime);
} else {
ser.data.commands.forEach((c) => {
const command: ICommandStore =
getEnv<Env>(self).create.CommandStore(c);
command.deserialize(c);
const command: ICommandStore = constructor(c);
command.deserialize(c, constructor);
self.commands.push(command);
});
}
Expand Down
9 changes: 6 additions & 3 deletions src/document/EventMarkerStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "./2025/DocumentTypes";
import { CommandStore } from "./CommandStore";
import { WaypointScope } from "./ConstraintStore";
import { Env } from "./DocumentManager";
import { Env, EnvConstructors } from "./DocumentManager";
import { ExpressionStore } from "./ExpressionStore";
import { IChoreoTrajectoryStore } from "./path/ChoreoTrajectoryStore";
import { IHolonomicPathStore } from "./path/HolonomicPathStore";
Expand Down Expand Up @@ -145,10 +145,13 @@ export const EventMarkerStore = types
setName(name: string) {
self.name = name;
},
deserialize(ser: EventMarker) {
deserialize(
ser: EventMarker,
commandConstructor: EnvConstructors["CommandStore"]
) {
self.name = ser.name;
self.from.deserialize(ser.from);
self.event.deserialize(ser.event);
self.event.deserialize(ser.event, commandConstructor);
},
setSelected(selected: boolean) {
if (selected && !self.selected) {
Expand Down
2 changes: 1 addition & 1 deletion src/document/path/HolonomicPathStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const HolonomicPathStore = types
const toAdd = getEnv<Env>(self).create.EventMarkerStore(m);

self.markers.push(toAdd);
toAdd.deserialize(m);
toAdd.deserialize(m, getEnv<Env>(self).create.CommandStore);
return toAdd;
},
setSnapshot(snap: ChoreoPath<number>) {
Expand Down

0 comments on commit 1dca2ce

Please sign in to comment.