And integrated the cycle-checking code. Woo it's got tests! Now we need to worry about the OS-side test code, assuming I don't have any more pesky TODOs to fix immediately...

This commit is contained in:
Pietro Gagliardi 2020-05-11 21:02:04 -04:00
parent b1d733e9a2
commit 19a776e446
3 changed files with 10 additions and 3 deletions

View File

@ -237,6 +237,10 @@ void uiControlSetParent(uiControl *c, uiControl *parent)
uiprivProgrammerErrorReparenting("a", "another", uiprivFunc);
return;
}
if (parentHasCycle(c, parent)) {
uiprivProgrammerErrorControlParentCycle(uiprivFunc);
return;
}
c->parent = parent;
}

View File

@ -75,4 +75,7 @@
uiprivProgrammerError("%s(): cannot set a control with %s parent to have %s parent", \
func, current, next)
#define uiprivProgrammerErrorControlParentCycle(func) \
uiprivProgrammerError("%s(): cannot create a parent cycle", func)
// }

View File

@ -435,7 +435,7 @@ Test(ControlParentCyclesDisallowed_TwoControls)
d = uiNewControl(testControlType(), NULL);
uiControlSetParent(c, d);
ctx = beginCheckProgrammerError("TODO");
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot create a parent cycle");
uiControlSetParent(d, c);
endCheckProgrammerError(ctx);
@ -457,7 +457,7 @@ Test(ControlParentCyclesDisallowed_ThreeControls)
uiControlSetParent(c, d);
uiControlSetParent(d, e);
ctx = beginCheckProgrammerError("TODO");
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot create a parent cycle");
uiControlSetParent(e, c);
endCheckProgrammerError(ctx);
@ -475,7 +475,7 @@ Test(ControlCannotBeItsOwnParent)
void *ctx;
c = uiNewControl(testControlType(), NULL);
ctx = beginCheckProgrammerError("TODO");
ctx = beginCheckProgrammerError("uiControlSetParent(): cannot create a parent cycle");
uiControlSetParent(c, c);
endCheckProgrammerError(ctx);
uiControlFree(c);