From fff86431e3a9b153a615f74b5cd6d17484763686 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 14 Apr 2015 12:51:20 -0400 Subject: [PATCH] Made the necessary previous commits changes on the Mac OS X backend. Untested yet. --- newcontrol_darwin.m | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/newcontrol_darwin.m b/newcontrol_darwin.m index 560a934c..7c19061e 100644 --- a/newcontrol_darwin.m +++ b/newcontrol_darwin.m @@ -32,22 +32,19 @@ static void singleSetParent(uiControl *c, uiParent *parent) { singleView *s = (singleView *) (c->internal); NSView *parentView; - - s->parent = parent; - parentView = (NSView *) uiParentHandle(s->parent); - [parentView addSubview:s->immediate]; - uiParentUpdate(s->parent); -} - -static void singleRemoveParent(uiControl *c) -{ - singleView *s = (singleView *) (c->internal); uiParent *oldparent; oldparent = s->parent; - s->parent = NULL; - [s->immediate removeFromSuperview]; - uiParentUpdate(oldparent); + s->parent = parent; + if (oldparent != NULL) { + [s->immediate removeFromSuperview]; + uiParentUpdate(oldparent); + } + if (s->parent != NULL) { + parentView = (NSView *) uiParentHandle(s->parent); + [parentView addSubview:s->immediate]; + uiParentUpdate(s->parent); + } } // also good for NSBox and NSProgressIndicator @@ -209,7 +206,6 @@ uiControl *uiDarwinNewControl(Class class, BOOL inScrollView, BOOL scrollViewHas c->destroy = singleDestroy; c->handle = singleHandle; c->setParent = singleSetParent; - c->removeParent = singleRemoveParent; c->preferredSize = singlePreferredSize; c->resize = singleResize; c->visible = singleVisible;