Forbade setting a parent on a toplevel.
This commit is contained in:
parent
0fd453fa91
commit
9da5feb0be
|
@ -42,13 +42,18 @@ uiControl *uiControlParent(uiControl *c)
|
||||||
return cb->parent;
|
return cb->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int isToplevel(uiControl *c)
|
||||||
|
{
|
||||||
|
return uiIsA(c, uiWindowType(), 0) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// returns self if self is a window
|
// returns self if self is a window
|
||||||
uiControl *toplevelOwning(uiControl *c)
|
uiControl *toplevelOwning(uiControl *c)
|
||||||
{
|
{
|
||||||
struct controlBase *cb;
|
struct controlBase *cb;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (uiIsA(c, uiWindowType(), 0) != NULL)
|
if (isToplevel(c))
|
||||||
return c;
|
return c;
|
||||||
cb = controlBase(c);
|
cb = controlBase(c);
|
||||||
if (cb->parent == NULL)
|
if (cb->parent == NULL)
|
||||||
|
@ -63,6 +68,8 @@ void uiControlSetParent(uiControl *c, uiControl *parent)
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
if (isToplevel(c))
|
||||||
|
complain("cannot set a parent on a toplevel (uiWindow)");
|
||||||
if (parent != NULL && cb->parent != NULL)
|
if (parent != NULL && cb->parent != NULL)
|
||||||
complain("attempt to reparent uiControl %p (has parent %p, attempt to give parent %p)", c, cb->parent, parent);
|
complain("attempt to reparent uiControl %p (has parent %p, attempt to give parent %p)", c, cb->parent, parent);
|
||||||
if (parent == NULL && cb->parent == NULL)
|
if (parent == NULL && cb->parent == NULL)
|
||||||
|
|
|
@ -98,8 +98,6 @@ static void onDestroy(uiWindow *w)
|
||||||
[windowDelegate unregisterWindow:w];
|
[windowDelegate unregisterWindow:w];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO forbid setting a parent
|
|
||||||
|
|
||||||
static void windowCommitShow(uiControl *c)
|
static void windowCommitShow(uiControl *c)
|
||||||
{
|
{
|
||||||
uiWindow *w = (uiWindow *) c;
|
uiWindow *w = (uiWindow *) c;
|
||||||
|
|
|
@ -15,6 +15,7 @@ extern void uiFree(void *);
|
||||||
|
|
||||||
extern void complain(const char *, ...);
|
extern void complain(const char *, ...);
|
||||||
|
|
||||||
|
extern int isToplevel(uiControl *);
|
||||||
extern uiControl *toplevelOwning(uiControl *);
|
extern uiControl *toplevelOwning(uiControl *);
|
||||||
|
|
||||||
extern void osCommitShow(uiControl *);
|
extern void osCommitShow(uiControl *);
|
||||||
|
|
Loading…
Reference in New Issue