Bindings: Fix inconsistency in Viewport dispose (RGSS1)

As noted, on Viewport dispose, RMXP always calls the core
dispose method for child objects regardless of whether
user scripts override it in sub classes.

Implement this behavior in mkxp to prevent infinite recursion.
This commit is contained in:
Jonas Kulla 2014-10-24 18:29:08 +02:00
parent 8b31f97bb4
commit 1a489aafaf
4 changed files with 11 additions and 5 deletions

View File

@ -52,9 +52,8 @@ disposableDisposeChildren(VALUE disp)
if (NIL_P(children))
return;
ID dispFun = rb_intern("dispose");
ID dispFun = rb_intern("_mkxp_dispose_alias");
/* Note: RMXP doesn't call overridden 'dispose' methods here */
for (long i = 0; i < RARRAY_LEN(children); ++i)
rb_funcall2(rb_ary_entry(children, i), dispFun, 0, 0);
}
@ -98,6 +97,10 @@ static void disposableBindingInit(VALUE klass)
{
_rb_define_method(klass, "dispose", disposableDispose<C>);
_rb_define_method(klass, "disposed?", disposableIsDisposed<C>);
/* Make sure we always have access to the original method, even
* if it is overridden by user scripts */
rb_define_alias(klass, "_mkxp_dispose_alias", "dispose");
}
template<class C>

View File

@ -55,7 +55,7 @@ struct
SYMD(default_color),
SYMD(default_out_color),
SYMD(children),
SYMD(dispose)
SYMD(_mkxp_dispose_alias)
};
static elementsN(symData);

View File

@ -56,7 +56,7 @@ enum CommonSymbol
CSdefault_color,
CSdefault_out_color,
CSchildren,
CSdispose,
CS_mkxp_dispose_alias,
CommonSymbolsMax
};

View File

@ -60,7 +60,7 @@ disposableDisposeChildren(mrb_state *mrb, mrb_value disp)
for (mrb_int i = 0; i < RARRAY_LEN(children); ++i)
mrb_funcall_argv(mrb, mrb_ary_entry(children, i),
mrbData->symbols[CSdispose], 0, 0);
mrbData->symbols[CS_mkxp_dispose_alias], 0, 0);
}
template<class C>
@ -99,6 +99,9 @@ static void disposableBindingInit(mrb_state *mrb, RClass *klass)
{
mrb_define_method(mrb, klass, "dispose", disposableDispose<C>, MRB_ARGS_NONE());
mrb_define_method(mrb, klass, "disposed?", disposableIsDisposed<C>, MRB_ARGS_NONE());
mrb_alias_method(mrb, klass, getMrbData(mrb)->symbols[CS_mkxp_dispose_alias],
mrb_intern_lit(mrb, "dispose"));
}
template<class C>