--- rpl/modules/motif/XtAppMainLoop.rplc 2017/07/06 10:18:04 1.2 +++ rpl/modules/motif/XtAppMainLoop.rplc 2017/07/30 21:59:40 1.4 @@ -15,23 +15,26 @@ declareExternalFunction(XtAppMainLoop) pullFromStack(appObject, external); returnOnError(freeObject(appObject)); - if (subType(appObject) ne APPCONTEXT) then + ifIsExternal(appObject, APPCONTEXT) then + orElse executionError("Type mismatch"); returnOnError(freeObject(appObject)); endIf + intrinsic(pshcntxt); + doUntil - if (XtAppPending(target((sXtAppContext *) - objectContainer(appObject)).context) ne 0) then - XtAppNextEvent(target((sXtAppContext *) - objectContainer(appObject)).context, &event); + if (XtAppPending(target(objectContainer(sXtAppContext, + appObject)).context) ne 0) then + XtAppNextEvent(target(objectContainer(sXtAppContext, + appObject)).context, &event); if (event.type eq DestroyNotify) then if (event.xdestroywindow.window eq - XtWindow(target((sXtAppContext *) - objectContainer(appObject)).widget)) then - XtAppSetExitFlag(target((sXtAppContext *) - objectContainer(appObject)).context); + XtWindow(target(objectContainer(sXtAppContext, + appObject)).widget)) then + XtAppSetExitFlag(target(objectContainer( + sXtAppContext, appObject)).context); endIf endIf @@ -40,13 +43,15 @@ declareExternalFunction(XtAppMainLoop) pollSignalsAndInterrupts(); usleep(10000); endIf - repeatUntil(XtAppGetExitFlag(target((sXtAppContext *) - objectContainer(appObject)).context) or + repeatUntil(XtAppGetExitFlag(target( + objectContainer(sXtAppContext, appObject)).context) or (stopRequest eq -1) or (exitMainLoop ne 0)) - XtDestroyApplicationContext(target((sXtAppContext *) - objectContainer(appObject)).context); + intrinsic(pulcntxt); + + XtDestroyApplicationContext(target( + objectContainer(sXtAppContext, appObject)).context); orElse executionError("Application not initialized"); returnOnError();