diff --git a/src/OGKBitmap.m b/src/OGKBitmap.m index df47771..bd22216 100644 --- a/src/OGKBitmap.m +++ b/src/OGKBitmap.m @@ -32,8 +32,7 @@ ogk_color_t OGK_COLOR_BLACK = { 0, 0, 0, 1 }; if (self != [OGKBitmap class]) return; - if (!al_install_system(ALLEGRO_VERSION_INT, NULL) || - !al_init_image_addon()) + if (!al_init() || !al_init_image_addon()) @throw [OFInitializationFailedException exceptionWithClass: self]; } @@ -79,6 +78,12 @@ ogk_color_t OGK_COLOR_BLACK = { 0, 0, 0, 1 }; return self; } +- (void)dealloc +{ + if (bitmap != NULL && al_is_system_installed()) + al_destroy_bitmap(bitmap); +} + - (void)drawAtPosition: (of_point_t)position { al_draw_bitmap(bitmap, position.x, position.y, 0); diff --git a/src/OGKDisplay.m b/src/OGKDisplay.m index ee97c0d..645cb46 100644 --- a/src/OGKDisplay.m +++ b/src/OGKDisplay.m @@ -30,7 +30,7 @@ static OFDataArray *allegroDisplays = nil; if (self != [OGKDisplay class]) return; - if (!al_install_system(ALLEGRO_VERSION_INT, NULL)) + if (!al_init()) @throw [OFInitializationFailedException exceptionWithClass: self]; @@ -108,7 +108,7 @@ static OFDataArray *allegroDisplays = nil; [mutex unlock]; } - if (display != NULL) + if (display != NULL && al_is_system_installed()) al_destroy_display(display); } diff --git a/src/OGKEventQueue.m b/src/OGKEventQueue.m index b28e498..8a8c537 100644 --- a/src/OGKEventQueue.m +++ b/src/OGKEventQueue.m @@ -33,7 +33,7 @@ static int mouse_retain_count = 0; if (self != [OGKEventQueue class]) return; - if (!al_install_system(ALLEGRO_VERSION_INT, NULL)) + if (!al_init()) @throw [OFInitializationFailedException exceptionWithClass: self]; } @@ -49,7 +49,8 @@ static int mouse_retain_count = 0; - (void)dealloc { - al_destroy_event_queue(eventQueue); + if (al_is_system_installed()) + al_destroy_event_queue(eventQueue); } - (void)handleNextEvent diff --git a/test/TestMain.m b/test/TestMain.m index 0641a34..c72736c 100644 --- a/test/TestMain.m +++ b/test/TestMain.m @@ -116,13 +116,4 @@ OF_APPLICATION_DELEGATE(TestMain) } } } - -- (void)applicationWillTerminate -{ - /* Make sure they don't get deallocated after al_uninstall_system() */ - display = nil; - eventQueue = nil; - - al_uninstall_system(); -} @end