diff --git a/darwin/main.m b/darwin/main.m index 2c934330..6faef4f4 100644 --- a/darwin/main.m +++ b/darwin/main.m @@ -159,12 +159,13 @@ void uiMain(void) [realNSApp() run]; } -void uiMainSteps(void) +void uiMainSteps(void (*f)(void *), void *data) { isRunning = ^{ return stepsIsRunning; }; stepsIsRunning = YES; + (*f)(data); } // see also: diff --git a/test/main.c b/test/main.c index 803326b5..e69feee7 100644 --- a/test/main.c +++ b/test/main.c @@ -39,6 +39,12 @@ uiTab *mainTab; uiBox *(*newhbox)(void); uiBox *(*newvbox)(void); +static void stepsLoop(void *data) +{ + while (uiMainStep(1)) + ; +} + int main(int argc, char *argv[]) { uiInitOptions o; @@ -161,11 +167,8 @@ int main(int argc, char *argv[]) uiControlShow(uiControl(w)); if (!steps) uiMain(); - else { - uiMainSteps(); - while (uiMainStep(1)) - ; - } + else + uiMainSteps(stepsLoop, NULL); printf("after uiMain()\n"); uiUninit(); printf("after uiUninit()\n"); diff --git a/ui.h b/ui.h index 6b7a1e8b..4fdd9e3e 100644 --- a/ui.h +++ b/ui.h @@ -45,7 +45,7 @@ _UI_EXTERN void uiUninit(void); _UI_EXTERN void uiFreeInitError(const char *err); _UI_EXTERN void uiMain(void); -_UI_EXTERN void uiMainSteps(void); +_UI_EXTERN void uiMainSteps(void (*f)(void *), void *data); _UI_EXTERN int uiMainStep(int wait); _UI_EXTERN void uiQuit(void);