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,7 +71,8 @@ RB_METHOD(disposableDispose)
if (d->isDisposed())
return Qnil;
disposableDisposeChildren(self);
if (rgssVer == 1)
disposableDisposeChildren(self);
d->dispose();
@ -100,7 +100,8 @@ static void disposableBindingInit(VALUE klass)
/* 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");
if (rgssVer == 1)
rb_define_alias(klass, "_mkxp_dispose_alias", "dispose");
}
template<class C>

View File

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

View File

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

View File

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