Bindings: Viewport: Don't dispose children in RGSS2/3

This commit is contained in:
Jonas Kulla 2014-10-24 18:55:03 +02:00
parent 1a489aafaf
commit 5549ff78f0
4 changed files with 16 additions and 9 deletions

View File

@ -27,8 +27,7 @@
/* 'Children' are disposables that are disposed together
* with their parent. Currently this is only used by Viewport
* in RGSS1.
* FIXME: Disable this behavior when RGSS2 or 3 */
* in RGSS1. */
inline void
disposableAddChild(VALUE disp, VALUE child)
{
@ -72,6 +71,7 @@ RB_METHOD(disposableDispose)
if (d->isDisposed())
return Qnil;
if (rgssVer == 1)
disposableDisposeChildren(self);
d->dispose();
@ -100,6 +100,7 @@ static void disposableBindingInit(VALUE klass)
/* Make sure we always have access to the original method, even
* if it is overridden by user scripts */
if (rgssVer == 1)
rb_define_alias(klass, "_mkxp_dispose_alias", "dispose");
}

View File

@ -75,6 +75,8 @@ viewportElementInitialize(int argc, VALUE *argv, VALUE self)
if (!NIL_P(viewportObj))
{
viewport = getPrivateDataCheck<Viewport>(viewportObj, ViewportType);
if (rgssVer == 1)
disposableAddChild(viewportObj, self);
}

View File

@ -74,6 +74,7 @@ MRB_METHOD(disposableDispose)
if (d->isDisposed())
return mrb_nil_value();
if (rgssVer == 1)
disposableDisposeChildren(mrb, self);
d->dispose();
@ -100,6 +101,7 @@ 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());
if (rgssVer == 1)
mrb_alias_method(mrb, klass, getMrbData(mrb)->symbols[CS_mkxp_dispose_alias],
mrb_intern_lit(mrb, "dispose"));
}

View File

@ -50,6 +50,8 @@ viewportElementInitialize(mrb_state *mrb, mrb_value self)
if (!mrb_nil_p(viewportObj))
{
viewport = getPrivateDataCheck<Viewport>(mrb, viewportObj, ViewportType);
if (rgssVer == 1)
disposableAddChild(mrb, viewportObj, self);
}