mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-20 09:05:51 +00:00
#3231: evaluate prop.get and expression errors with the footage source
prop.get and Session::expression_errors (Reveal Expression Errors, the viewer's error banner) built their expression context without the footage source, so an expression that reads footage pixels (sampleImage) gave a different value or a spurious error there while it worked in the render and in expr.errors (#1000). expr_tools::eval_ctx builds the render's context (expression host and footage source) for a comp at a time; expr.errors, prop.get, Session::expression_errors and the script value query all use it. Fixes #3231
This commit is contained in:
1 parent
bb2d2005ce
commit
fc9eca99a0
5 files changed
+71
-11
No files matched your search
@@ -2,7 +2,7 @@
|
||||
//! Language menu (the ⓕ button next to an expression), written from the public Expression
|
||||
//! Language Reference.
|
||||
|
||||
use effectcraft_project::{Expression, ItemId, Layer, Property};
|
||||
use effectcraft_project::{Comp, Expression, ItemId, Layer, Property};
|
||||
use effectcraft_render::EvalCtx;
|
||||
use effectcraft_time::Tick;
|
||||
use serde::Serialize;
|
||||
@@ -42,8 +42,16 @@ impl ExprError {
|
||||
/// expressions and the syntax errors that disabled others.
|
||||
pub fn errors(s: &Session, cid: ItemId, t: Tick) -> Vec<ExprError> {
|
||||
let Some(comp) = s.project.comp(cid) else { return vec![] };
|
||||
let ctx = EvalCtx { footage: Some(s.footage.as_ref()), expr: s.expr.as_deref(), ..EvalCtx::new(&s.project, cid, comp, t) };
|
||||
errors_in(&ctx, s.expr_check, || true).unwrap_or_default()
|
||||
errors_in(&eval_ctx(s, cid, comp, t), s.expr_check, || true).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The context to evaluate expressions of comp `cid` at comp time `t` as the render does for the
|
||||
/// comp at top level: with the session's expression host and its footage source, so
|
||||
/// `sampleImage()` reads footage pixels instead of failing or sampling transparent (#1000,
|
||||
/// #3231). `expr.errors`, `prop.get`, [`Session::expression_errors`] and the script value query
|
||||
/// all evaluate through this one context.
|
||||
pub fn eval_ctx<'a>(s: &'a Session, cid: ItemId, comp: &'a Comp, t: Tick) -> EvalCtx<'a> {
|
||||
EvalCtx { footage: Some(s.footage.as_ref()), expr: s.expr.as_deref(), ..EvalCtx::new(&s.project, cid, comp, t) }
|
||||
}
|
||||
|
||||
/// Evaluate diagnostics against an immutable snapshot. Background callers can cancel between
|
||||
|
||||
Reference in new issue
Block a user