From bbbe83a3a2a9071ea48d0e25a4638fee5cb3ea30 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Wed, 7 Oct 2015 00:33:16 -0400 Subject: Fixing window hang Window and media subsystems were being closed too early after `show`, causing Ruby garbage collection to hang when freeing objects relying on those systems. --- ext/ruby2d/ruby2d.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c index 1c4442a..625215a 100644 --- a/ext/ruby2d/ruby2d.c +++ b/ext/ruby2d/ruby2d.c @@ -26,6 +26,9 @@ struct sound_data { Sound snd; }; +static void close_window() { + S2D_Close(window); +} static void free_image(struct image_data *data) { S2D_FreeImage(data->img); @@ -212,6 +215,7 @@ static VALUE ruby2d_show(VALUE s) { S2D_Show(window); + atexit(close_window); return Qnil; } -- cgit v1.2.3