]> Nishi Git Mirror - gwion.git/commitdiff
:art: Check for null tick
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Fri, 6 Dec 2019 15:15:03 +0000 (16:15 +0100)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Fri, 6 Dec 2019 15:15:03 +0000 (16:15 +0100)
src/lib/modules.c
tests/UsrUgen/null_tick.gw [new file with mode: 0644]

index f6e7bee8a7e60b3081926fc029243dbf0386bad4..48d692a91ff8311882afe190cce039d61a300b3a 100644 (file)
@@ -247,13 +247,16 @@ static INSTR(UsrUGenTick) {
   if(uu->shred)
     free_vm_shred(uu->shred);
   UGEN(o)->module.gen.tick = usrugen_tick;
+  const VM_Code code = *(VM_Code*)(shred->reg-offset);
+  release(o, shred);
+  if(!code)
+    Except(shred, "[NullTickException]");
   uu->shred = new_vm_shred(shred->info->vm->gwion->mp, *(VM_Code*)(shred->reg-offset));
   ADD_REF(*(VM_Code*)(shred->reg - offset));
   uu->shred->info->vm = shred->info->vm;
   code_prepare(uu->shred->code);
   shreduler_ini(uu->shred->info->vm->shreduler, uu->shred);
   uu->prep = instr->m_val ? member_prep : global_prep;
-  release(o, shred);
   *(M_Object*)(shred->reg - SZ_INT) = o;
 }
 
diff --git a/tests/UsrUgen/null_tick.gw b/tests/UsrUgen/null_tick.gw
new file mode 100644 (file)
index 0000000..6b2d769
--- /dev/null
@@ -0,0 +1,3 @@
+#! [contains] NullTickException
+typedef float ptr_t(float);
+ptr_t ptr ~= UsrUGen u;