More TODO resolution.

This commit is contained in:
Pietro Gagliardi 2015-08-17 12:57:45 -04:00
parent b15554cbd1
commit 478f5d2504
6 changed files with 22 additions and 10 deletions

View File

@ -3,10 +3,12 @@
#import "uipriv_darwin.h" #import "uipriv_darwin.h"
NSMutableArray *allocations; NSMutableArray *allocations;
NSMutableArray *delegates;
void initAlloc(void) void initAlloc(void)
{ {
allocations = [NSMutableArray new]; allocations = [NSMutableArray new];
delegates = [NSMutableArray new];
} }
#define UINT8(p) ((uint8_t *) (p)) #define UINT8(p) ((uint8_t *) (p))
@ -21,6 +23,11 @@ void initAlloc(void)
void uninitAlloc(void) void uninitAlloc(void)
{ {
if ([allocations count] == 0) { if ([allocations count] == 0) {
NSInteger i;
for (i = 0; i < [delegates count]; i++)
[[delegates objectAtIndex:i] release];
[delegates release];
[allocations release]; [allocations release];
return; return;
} }

View File

@ -26,7 +26,6 @@ struct uiButton {
return self; return self;
} }
// TODO have this called
- (void)dealloc - (void)dealloc
{ {
if ([self->buttons count] != 0) if ([self->buttons count] != 0)
@ -103,8 +102,10 @@ uiButton *uiNewButton(const char *text)
[b->button setBezelStyle:NSRoundedBezelStyle]; [b->button setBezelStyle:NSRoundedBezelStyle];
uiDarwinSetControlFont(b->button, NSRegularControlSize); uiDarwinSetControlFont(b->button, NSRegularControlSize);
if (buttonDelegate == nil) if (buttonDelegate == nil) {
buttonDelegate = [buttonDelegateClass new]; buttonDelegate = [buttonDelegateClass new];
[delegates addObject:buttonDelegate];
}
[buttonDelegate registerButton:b]; [buttonDelegate registerButton:b];
uiButtonOnClicked(b, defaultOnClicked, NULL); uiButtonOnClicked(b, defaultOnClicked, NULL);

View File

@ -3,13 +3,13 @@
struct uiCheckbox { struct uiCheckbox {
uiDarwinControl c; uiDarwinControl c;
NSButton *button; // TODO rename to checkbox? NSButton *button;
void (*onToggled)(uiCheckbox *, void *); void (*onToggled)(uiCheckbox *, void *);
void *onToggledData; void *onToggledData;
}; };
@interface checkboxDelegateClass : NSObject { @interface checkboxDelegateClass : NSObject {
NSMapTable *buttons; // TODO rename to checkboxes? NSMapTable *buttons;
} }
- (IBAction)onToggled:(id)sender; - (IBAction)onToggled:(id)sender;
- (void)registerCheckbox:(uiCheckbox *)c; - (void)registerCheckbox:(uiCheckbox *)c;
@ -26,7 +26,6 @@ struct uiCheckbox {
return self; return self;
} }
// TODO have this called
- (void)dealloc - (void)dealloc
{ {
if ([self->buttons count] != 0) if ([self->buttons count] != 0)
@ -117,8 +116,10 @@ uiCheckbox *uiNewCheckbox(const char *text)
[c->button setBordered:NO]; [c->button setBordered:NO];
uiDarwinSetControlFont(c->button, NSRegularControlSize); uiDarwinSetControlFont(c->button, NSRegularControlSize);
if (checkboxDelegate == nil) if (checkboxDelegate == nil) {
checkboxDelegate = [checkboxDelegateClass new]; checkboxDelegate = [checkboxDelegateClass new];
[delegates addObject:checkboxDelegate];
}
[checkboxDelegate registerCheckbox:c]; [checkboxDelegate registerCheckbox:c];
uiCheckboxOnToggled(c, defaultOnToggled, NULL); uiCheckboxOnToggled(c, defaultOnToggled, NULL);

View File

@ -28,7 +28,6 @@ struct uiEntry {
return self; return self;
} }
// TODO have this called
- (void)dealloc - (void)dealloc
{ {
if ([self->entries count] != 0) if ([self->entries count] != 0)
@ -131,8 +130,10 @@ uiEntry *uiNewEntry(void)
[e->textfield setSelectable:YES]; // otherwise the setting is masked by the editable default of YES [e->textfield setSelectable:YES]; // otherwise the setting is masked by the editable default of YES
finishNewTextField(e->textfield, YES); finishNewTextField(e->textfield, YES);
if (entryDelegate == nil) if (entryDelegate == nil) {
entryDelegate = [entryDelegateClass new]; entryDelegate = [entryDelegateClass new];
[delegates addObject:entryDelegate];
}
[entryDelegate registerEntry:e]; [entryDelegate registerEntry:e];
uiEntryOnChanged(e, defaultOnChanged, NULL); uiEntryOnChanged(e, defaultOnChanged, NULL);

View File

@ -46,6 +46,7 @@ extern void finishNewTextField(NSTextField *, BOOL);
extern uiWindow *windowFromNSWindow(NSWindow *); extern uiWindow *windowFromNSWindow(NSWindow *);
// alloc.m // alloc.m
extern NSMutableArray *delegates;
extern void initAlloc(void); extern void initAlloc(void);
extern void uninitAlloc(void); extern void uninitAlloc(void);

View File

@ -29,7 +29,6 @@ struct uiWindow {
return self; return self;
} }
// TODO have this called
- (void)dealloc - (void)dealloc
{ {
if ([self->windows count] != 0) if ([self->windows count] != 0)
@ -191,8 +190,10 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
// the only thing that closes the window is us anyway // the only thing that closes the window is us anyway
[w->window setReleasedWhenClosed:YES]; [w->window setReleasedWhenClosed:YES];
if (windowDelegate == nil) if (windowDelegate == nil) {
windowDelegate = [windowDelegateClass new]; windowDelegate = [windowDelegateClass new];
[delegates addObject:windowDelegate];
}
[windowDelegate registerWindow:w]; [windowDelegate registerWindow:w];
uiWindowOnClosing(w, defaultOnClosing, NULL); uiWindowOnClosing(w, defaultOnClosing, NULL);