Only send one SetSceneUnits call (#1981)
We only intended to send this once, at the start of execution. But the execute function is recursive, so it was sending many SetSceneUnits calls. Fixes https://github.com/KittyCAD/modeling-app/issues/1971
This commit is contained in:
@ -994,9 +994,8 @@ impl ExecutorContext {
|
||||
}
|
||||
}
|
||||
|
||||
/// Execute a AST's program.
|
||||
#[async_recursion(?Send)]
|
||||
pub async fn execute(
|
||||
/// Execute an AST's program.
|
||||
pub async fn execute_outer(
|
||||
program: crate::ast::types::Program,
|
||||
memory: &mut ProgramMemory,
|
||||
_options: BodyType,
|
||||
@ -1013,7 +1012,17 @@ pub async fn execute(
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
execute(program, memory, _options, ctx).await
|
||||
}
|
||||
|
||||
/// Execute an AST's program.
|
||||
#[async_recursion(?Send)]
|
||||
pub(crate) async fn execute(
|
||||
program: crate::ast::types::Program,
|
||||
memory: &mut ProgramMemory,
|
||||
_options: BodyType,
|
||||
ctx: &ExecutorContext,
|
||||
) -> Result<ProgramMemory, KclError> {
|
||||
let pipe_info = PipeInfo::default();
|
||||
|
||||
// Iterate over the body of the program.
|
||||
@ -1299,7 +1308,7 @@ mod tests {
|
||||
units: kittycad::types::UnitLength::Mm,
|
||||
is_mock: false,
|
||||
};
|
||||
let memory = execute(program, &mut mem, BodyType::Root, &ctx).await?;
|
||||
let memory = execute_outer(program, &mut mem, BodyType::Root, &ctx).await?;
|
||||
|
||||
Ok(memory)
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ pub async fn execute_wasm(
|
||||
is_mock,
|
||||
};
|
||||
|
||||
let memory = kcl_lib::executor::execute(program, &mut mem, kcl_lib::executor::BodyType::Root, &ctx)
|
||||
let memory = kcl_lib::executor::execute_outer(program, &mut mem, kcl_lib::executor::BodyType::Root, &ctx)
|
||||
.await
|
||||
.map_err(String::from)?;
|
||||
// The serde-wasm-bindgen does not work here because of weird HashMap issues so we use the
|
||||
|
@ -41,7 +41,7 @@ async fn execute_and_snapshot(code: &str, units: kittycad::types::UnitLength) ->
|
||||
let mut mem: kcl_lib::executor::ProgramMemory = Default::default();
|
||||
let ctx = kcl_lib::executor::ExecutorContext::new(ws, units.clone()).await?;
|
||||
|
||||
let _ = kcl_lib::executor::execute(program, &mut mem, kcl_lib::executor::BodyType::Root, &ctx).await?;
|
||||
let _ = kcl_lib::executor::execute_outer(program, &mut mem, kcl_lib::executor::BodyType::Root, &ctx).await?;
|
||||
|
||||
let (x, y) = kcl_lib::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
|
||||
|
@ -41,7 +41,8 @@ async fn setup(code: &str, name: &str) -> Result<(ExecutorContext, Program, uuid
|
||||
let program = parser.ast()?;
|
||||
let mut mem: kcl_lib::executor::ProgramMemory = Default::default();
|
||||
let ctx = kcl_lib::executor::ExecutorContext::new(ws, kittycad::types::UnitLength::Mm).await?;
|
||||
let memory = kcl_lib::executor::execute(program.clone(), &mut mem, kcl_lib::executor::BodyType::Root, &ctx).await?;
|
||||
let memory =
|
||||
kcl_lib::executor::execute_outer(program.clone(), &mut mem, kcl_lib::executor::BodyType::Root, &ctx).await?;
|
||||
|
||||
// We need to get the sketch ID.
|
||||
// Get the sketch group ID from memory.
|
||||
|
Reference in New Issue
Block a user