Skip to content

Commit

Permalink
#716 Fix "context.feedback_value.color" not containing nil if no colo…
Browse files Browse the repository at this point in the history
…r set
  • Loading branch information
helgoboss committed May 31, 2023
1 parent f854595 commit 7ba6232
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main/src/domain/lua_midi_source_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@ impl<'a> MidiSourceScript for LuaMidiSourceScript<'a> {
self.env
.raw_set(self.y_key.clone(), y_value)
.map_err(|_| "couldn't set y variable")?;
let context_lua_value = self.lua.as_ref().to_value(&context).unwrap();
let mut serialize_options = mlua::SerializeOptions::new();
// This is important, otherwise e.g. a None color ends up as some userdata and not nil.
serialize_options.serialize_none_to_null = false;
serialize_options.serialize_unit_to_null = false;
let context_lua_value = self
.lua
.as_ref()
.to_value_with(&context, serialize_options)
.unwrap();
self.env
.raw_set(self.context_key.clone(), context_lua_value)
.map_err(|_| "couldn't set context variable")?;
Expand Down

0 comments on commit 7ba6232

Please sign in to comment.