ObjGameKit  Diff

Differences From Artifact [c9b84695dd]:

To Artifact [2b13daa365]:

  • File src/OGKDisplay.m — part of check-in [4719f25709] at 2012-08-26 12:17:52 on branch trunk — Only call al_*_destroy if Allegro is initialized.

    Otherwise, it would crash if al_uinstall_system() has already been
    called. Handling it this way eliminates the need to dealloc all objects
    before calling al_uninstall_system(), which meant that it was the users
    repsonsibility to call al_uninstall_system() after the user made sure
    all objects are deallocated. Now the user does not get to see any
    al_*() function. (user: js, size: 3719) [annotate] [blame] [check-ins using]


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

@implementation OGKDisplay
+ (void)initialize
{
	if (self != [OGKDisplay class])
		return;

	if (!al_install_system(ALLEGRO_VERSION_INT, NULL))
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];

	mutex = [[OFMutex alloc] init];
	displays = [[OFMutableArray alloc] init];
	allegroDisplays = [[OFDataArray alloc]
	    initWithItemSize: sizeof(ALLEGRO_DISPLAY*)];







|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

@implementation OGKDisplay
+ (void)initialize
{
	if (self != [OGKDisplay class])
		return;

	if (!al_init())
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];

	mutex = [[OFMutex alloc] init];
	displays = [[OFMutableArray alloc] init];
	allegroDisplays = [[OFDataArray alloc]
	    initWithItemSize: sizeof(ALLEGRO_DISPLAY*)];
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

		[allegroDisplays removeItemAtIndex: index];
		[displays removeObjectAtIndex: index];
	} @finally {
		[mutex unlock];
	}

	if (display != NULL)
		al_destroy_display(display);
}

- (void)setWindowTitle: (OFString*)title
{
	al_set_window_title(display,
	    [title cStringWithEncoding: OF_STRING_ENCODING_NATIVE]);







|







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

		[allegroDisplays removeItemAtIndex: index];
		[displays removeObjectAtIndex: index];
	} @finally {
		[mutex unlock];
	}

	if (display != NULL && al_is_system_installed())
		al_destroy_display(display);
}

- (void)setWindowTitle: (OFString*)title
{
	al_set_window_title(display,
	    [title cStringWithEncoding: OF_STRING_ENCODING_NATIVE]);