Index: src/OGKBitmap.m ================================================================== --- src/OGKBitmap.m +++ src/OGKBitmap.m @@ -30,12 +30,11 @@ + (void)initialize { 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]; } + (void)setTarget: (id)target @@ -76,10 +75,16 @@ @throw [OFInitializationFailedException exceptionWithClass: [self class]]; 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); } Index: src/OGKDisplay.m ================================================================== --- src/OGKDisplay.m +++ src/OGKDisplay.m @@ -28,11 +28,11 @@ + (void)initialize { if (self != [OGKDisplay class]) return; - if (!al_install_system(ALLEGRO_VERSION_INT, NULL)) + if (!al_init()) @throw [OFInitializationFailedException exceptionWithClass: self]; mutex = [[OFMutex alloc] init]; displays = [[OFMutableArray alloc] init]; @@ -106,11 +106,11 @@ [displays removeObjectAtIndex: index]; } @finally { [mutex unlock]; } - if (display != NULL) + if (display != NULL && al_is_system_installed()) al_destroy_display(display); } - (void)setWindowTitle: (OFString*)title { Index: src/OGKEventQueue.m ================================================================== --- src/OGKEventQueue.m +++ src/OGKEventQueue.m @@ -31,11 +31,11 @@ + (void)initialize { if (self != [OGKEventQueue class]) return; - if (!al_install_system(ALLEGRO_VERSION_INT, NULL)) + if (!al_init()) @throw [OFInitializationFailedException exceptionWithClass: self]; } - init @@ -47,11 +47,12 @@ return self; } - (void)dealloc { - al_destroy_event_queue(eventQueue); + if (al_is_system_installed()) + al_destroy_event_queue(eventQueue); } - (void)handleNextEvent { OGKEvent *event = [[OGKEvent alloc] init]; Index: test/TestMain.m ================================================================== --- test/TestMain.m +++ test/TestMain.m @@ -114,15 +114,6 @@ [self handleEvents]; [self draw]; } } } - -- (void)applicationWillTerminate -{ - /* Make sure they don't get deallocated after al_uninstall_system() */ - display = nil; - eventQueue = nil; - - al_uninstall_system(); -} @end