Tilemap/VX: Ensure proxy objects don't outlive their parents
Either of these would previously crash (same for VX): tm = Tilemap.new at = tm.autotiles tm = nil GC.start at[0] = Bitmap.new(1, 1) tm = Tilemap.new at = tm.autotiles tm.dispose at[0] = Bitmap.new(1, 1) Funnily, this makes RMXP itself crash too, but crashing is never acceptable except for possibly resource exhaustion.
This commit is contained in:
parent
e9d0d0566b
commit
9758e660c4
9 changed files with 41 additions and 12 deletions
|
@ -94,6 +94,10 @@ RB_METHOD(tilemapInitialize)
|
|||
|
||||
rb_iv_set(autotilesObj, "array", ary);
|
||||
|
||||
/* Circular reference so both objects are always
|
||||
* alive at the same time */
|
||||
rb_iv_set(autotilesObj, "tilemap", self);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@ RB_METHOD(tilemapVXInitialize)
|
|||
|
||||
rb_iv_set(autotilesObj, "array", ary);
|
||||
|
||||
/* Circular reference so both objects are always
|
||||
* alive at the same time */
|
||||
rb_iv_set(autotilesObj, "tilemap", self);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue