trynna fix click handler being garbage collected
This commit is contained in:
+1
-10
@@ -60,11 +60,8 @@ struct Block {
|
||||
Block() : proc(mrb_nil_value()) {}
|
||||
|
||||
void set_proc(mrb_value new_proc) {
|
||||
if (!mrb_nil_p(proc))
|
||||
mrb_gc_unregister(mrb, proc);
|
||||
proc = new_proc;
|
||||
if (!mrb_nil_p(proc))
|
||||
mrb_gc_protect(mrb, proc);
|
||||
mrb_gc_protect(mrb, proc);
|
||||
}
|
||||
|
||||
Block(const Block &) = delete;
|
||||
@@ -76,16 +73,10 @@ struct Block {
|
||||
mrb_value result = mrb_funcall_argv(mrb, proc, mrb_intern_cstr(mrb, "call"), argc, argv);
|
||||
return result;
|
||||
}
|
||||
|
||||
~Block() {
|
||||
mrb_gc_unregister(mrb, proc);
|
||||
}
|
||||
};
|
||||
|
||||
inline void run_string(const char *code, size_t length) {
|
||||
int ai = mrb_gc_arena_save(mrb);
|
||||
mrb_load_nstring(mrb, code, length);
|
||||
mrb_gc_arena_restore(mrb, ai);
|
||||
}
|
||||
}; // namespace Ruby
|
||||
|
||||
|
||||
Reference in New Issue
Block a user