Merge branch 'master' of github.com:andlabs/libui
This commit is contained in:
commit
c856ff1976
|
@ -23,13 +23,10 @@ void initAlloc(void)
|
|||
void uninitAlloc(void)
|
||||
{
|
||||
NSMutableString *str;
|
||||
NSUInteger i;
|
||||
NSValue *v;
|
||||
|
||||
// delegates might have mapTables allocated
|
||||
// TODO verify they are empty
|
||||
for (i = 0; i < [delegates count]; i++)
|
||||
[[delegates objectAtIndex:i] release];
|
||||
[delegates release];
|
||||
if ([allocations count] == 0) {
|
||||
[allocations release];
|
||||
|
|
|
@ -103,7 +103,7 @@ uiButton *uiNewButton(const char *text)
|
|||
uiDarwinSetControlFont(b->button, NSRegularControlSize);
|
||||
|
||||
if (buttonDelegate == nil) {
|
||||
buttonDelegate = [buttonDelegateClass new];
|
||||
buttonDelegate = [[buttonDelegateClass new] autorelease];
|
||||
[delegates addObject:buttonDelegate];
|
||||
}
|
||||
[buttonDelegate registerButton:b];
|
||||
|
|
|
@ -118,7 +118,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
|||
uiDarwinSetControlFont(c->button, NSRegularControlSize);
|
||||
|
||||
if (checkboxDelegate == nil) {
|
||||
checkboxDelegate = [checkboxDelegateClass new];
|
||||
checkboxDelegate = [[checkboxDelegateClass new] autorelease];
|
||||
[delegates addObject:checkboxDelegate];
|
||||
}
|
||||
[checkboxDelegate registerCheckbox:c];
|
||||
|
|
|
@ -135,7 +135,7 @@ uiCombobox *uiNewCombobox(void)
|
|||
options:nil];
|
||||
|
||||
if (comboboxDelegate == nil) {
|
||||
comboboxDelegate = [comboboxDelegateClass new];
|
||||
comboboxDelegate = [[comboboxDelegateClass new] autorelease];
|
||||
[delegates addObject:comboboxDelegate];
|
||||
}
|
||||
[comboboxDelegate registerCombobox:c];
|
||||
|
|
|
@ -175,7 +175,7 @@ uiEditableCombobox *uiNewEditableCombobox(void)
|
|||
uiDarwinSetControlFont(c->cb, NSRegularControlSize);
|
||||
|
||||
if (comboboxDelegate == nil) {
|
||||
comboboxDelegate = [editableComboboxDelegateClass new];
|
||||
comboboxDelegate = [[editableComboboxDelegateClass new] autorelease];
|
||||
[delegates addObject:comboboxDelegate];
|
||||
}
|
||||
[comboboxDelegate registerCombobox:c];
|
||||
|
|
|
@ -158,7 +158,7 @@ uiEntry *uiNewEntry(void)
|
|||
e->textfield = newEditableTextField();
|
||||
|
||||
if (entryDelegate == nil) {
|
||||
entryDelegate = [entryDelegateClass new];
|
||||
entryDelegate = [[entryDelegateClass new] autorelease];
|
||||
[delegates addObject:entryDelegate];
|
||||
}
|
||||
[entryDelegate registerEntry:e];
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
static BOOL canQuit = NO;
|
||||
static NSAutoreleasePool *globalPool;
|
||||
static applicationClass* app;
|
||||
static appDelegate* delegate;
|
||||
|
||||
@implementation applicationClass
|
||||
|
||||
|
@ -101,15 +103,14 @@ uiInitOptions options;
|
|||
|
||||
const char *uiInit(uiInitOptions *o)
|
||||
{
|
||||
globalPool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
@autoreleasepool {
|
||||
options = *o;
|
||||
[applicationClass sharedApplication];
|
||||
app = [[applicationClass sharedApplication] retain];
|
||||
// don't check for a NO return; something (launch services?) causes running from application bundles to always return NO when asking to change activation policy, even if the change is to the same activation policy!
|
||||
// see https://github.com/andlabs/ui/issues/6
|
||||
[realNSApp() setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
[realNSApp() setDelegate:[appDelegate new]];
|
||||
delegate = [appDelegate new];
|
||||
[realNSApp() setDelegate:delegate];
|
||||
|
||||
initAlloc();
|
||||
|
||||
|
@ -118,20 +119,26 @@ const char *uiInit(uiInitOptions *o)
|
|||
[realNSApp() setMainMenu:[appDelegate().menuManager makeMenubar]];
|
||||
|
||||
setupFontPanel();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
globalPool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void uiUninit(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[appDelegate() release];
|
||||
[realNSApp() setDelegate:nil];
|
||||
[realNSApp() release];
|
||||
uninitAlloc();
|
||||
if (!globalPool) {
|
||||
userbug("You must call uiInit() first!");
|
||||
}
|
||||
[globalPool release];
|
||||
|
||||
@autoreleasepool {
|
||||
[delegate release];
|
||||
[realNSApp() setDelegate:nil];
|
||||
[app release];
|
||||
uninitAlloc();
|
||||
}
|
||||
}
|
||||
|
||||
void uiFreeInitError(const char *err)
|
||||
|
|
|
@ -138,7 +138,7 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max)
|
|||
[cell setSliderType:NSLinearSlider];
|
||||
|
||||
if (sliderDelegate == nil) {
|
||||
sliderDelegate = [sliderDelegateClass new];
|
||||
sliderDelegate = [[sliderDelegateClass new] autorelease];
|
||||
[delegates addObject:sliderDelegate];
|
||||
}
|
||||
[sliderDelegate registerSlider:s];
|
||||
|
|
15
darwin/tab.m
15
darwin/tab.m
|
@ -35,8 +35,8 @@ struct uiTab {
|
|||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
self->view = v;
|
||||
self->pageID = o;
|
||||
self->view = [v retain];
|
||||
self->pageID = [o retain];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -189,14 +189,14 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
|
|||
|
||||
uiControlSetParent(child, uiControl(t));
|
||||
|
||||
view = [[NSView alloc] initWithFrame:NSZeroRect];
|
||||
view = [[[NSView alloc] initWithFrame:NSZeroRect] autorelease];
|
||||
// TODO if we turn off the autoresizing mask, nothing shows up; didn't this get documented somewhere?
|
||||
uiDarwinControlSetSuperview(uiDarwinControl(child), view);
|
||||
uiDarwinControlSyncEnableState(uiDarwinControl(child), uiControlEnabledToUser(uiControl(t)));
|
||||
|
||||
// the documentation says these can be nil but the headers say these must not be; let's be safe and make them non-nil anyway
|
||||
pageID = [NSObject new];
|
||||
page = [[tabPage alloc] initWithView:view pageID:pageID];
|
||||
page = [[[tabPage alloc] initWithView:view pageID:pageID] autorelease];
|
||||
page.c = child;
|
||||
|
||||
// don't hug, just in case we're a stretchy tab
|
||||
|
@ -206,16 +206,11 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
|
|||
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationVertical);
|
||||
|
||||
[t->pages insertObject:page atIndex:n];
|
||||
[page release]; // no need for initial reference
|
||||
|
||||
i = [[NSTabViewItem alloc] initWithIdentifier:pageID];
|
||||
i = [[[NSTabViewItem alloc] initWithIdentifier:pageID] autorelease];
|
||||
[i setLabel:toNSString(name)];
|
||||
[i setView:view];
|
||||
[t->tabview insertTabViewItem:i atIndex:n];
|
||||
// TODO release i?
|
||||
|
||||
[pageID release]; // no need for initial reference
|
||||
[view release];
|
||||
|
||||
tabRelayout(t);
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||
[w->window setReleasedWhenClosed:NO];
|
||||
|
||||
if (windowDelegate == nil) {
|
||||
windowDelegate = [windowDelegateClass new];
|
||||
windowDelegate = [[windowDelegateClass new] autorelease];
|
||||
[delegates addObject:windowDelegate];
|
||||
}
|
||||
[windowDelegate registerWindow:w];
|
||||
|
|
Loading…
Reference in New Issue