[comp.windows.x] Returning from an X application program

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

I'm calling an X application program from inside S, an interactive
statistics program.  I am using a combination of Toolkit programs,
widgets, and Xlib calls.  I'm doing fine with the startup, but I'm having
trouble stopping.  I need to return rather than exiting, but I would like
to shut down the entire X program, and I can't figure out how.  (This is
inarticulate, I know -- I don't really know how to say what I want to say.)

To start up, I'm using

        XtToolkitInitialize();
        display = XtOpenDisplay((XtAppContext) NULL, (String) NULL, argvv[0],
                "", (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], "",
                applicationShellWidgetClass, display, args, (Cardinal) i);

and then defining all the widgets and callbacks, setting up the GC, and
realizing the shell.

To shut down, I'm experimenting with

        XtDestroyApplicationContext(XtWidgetToApplicationContext(shell));
        XtDestroyWidget(shell);
        XtFree(argvv);
        return(0);

Well, this leaves ok, but what if I want to restart the application during
the same S session?  Then I get this:

	X Toolkit Warning: Initializing Resource Lists twice
	X Toolkit Warning: Intializing Translation manager twice.
	System terminating: bad address

So what should I do here?  Can I un-initialize the Resource Lists and the
Translation manager?  Or should I keep track of a static variable and not
perform the Toolkit initialization more than once?  How are other people
managing this procedure?  The documentation is just confusing me ...

Debby Swayne
dfs@bellcore.com

swick@ATHENA.MIT.EDU (Ralph R. Swick) (05/04/89)

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

right.