[comp.windows.x] Returning from and re-entering X applications

dfs@wind.bellcore.com (Deborah Swayne) (05/06/89)

I'm still struggling with trying to figure out how to return from and
re-enter an X application program, all while running S, an interactive
statistics program.

swick@ATHENA.MIT.EDU (Ralph R. Swick) answered my question as follows:

>> should I keep track of a static variable and not
>> perform the Toolkit initialization more than once?

> right.

but alas, this is too terse for me.  Can anyone offer more specific help?

** To intiallize, I'm now doing all this:

if (is_initd == 0) {
        is_initd = 1;
        XtToolkitInitialize();
        }
argvv = (char **) XtCalloc(
        (unsigned) (argcc + 1), (unsigned) sizeof(*argvv));
argvv[0] = "spin";
argvv[1] = NULL;

display = XtOpenDisplay((XtAppContext) NULL, (String) NULL, argvv[0],
        "XDataViewer", (XrmOptionDescRec *) NULL, (Cardinal) 0,
        &argcc, argvv);

scrn = DefaultScreenOfDisplay(display);

i = 0;
XtSetArg(args[i], XtNscreen, scrn); i++;
XtSetArg(args[i], XtNargc, argcc); i++;
XtSetArg(args[i], XtNargv, argvv); i++;
shell = XtAppCreateShell(argvv[0], "XDataViewer",
        applicationShellWidgetClass, display, args, (Cardinal) i);

** On exit, the possibilities seem endless.  I've tried, I think, all
** combinations and permutations of the following:

XFreeGC(display, xor_GC);
XtDestroyApplicationContext(XtWidgetToApplicationContext(shell));
XCloseDisplay(display);
XtCloseDisplay(display);
XtUnrealizeWidget(shell);
XtDestroyWidget(shell);
XtFree(argvv);
return();

** and I get some improvement, but I still can't go in and out more than a
** couple of times without various sorts of error messages, mostly the
** ever-helpful "System terminating: bad address."