dfs@wind.bellcore.com (Deborah Swayne) (04/26/89)
I have started writing an application program using Xlib, Toolkit, Athena widgets and HP widgets. It compiles and runs just fine if I use the XtInitialize() call, but when I try to expand that call into the steps the Toolkit manual recommends, I get core dumps. (I'm not an experienced C programmer, either, so I might be making a C error rather than an X error.) (Why do I wish to expand it, then? I'm trying to call the program from within the New S, using their .C() call, and it quietly dies during XtInitialize(). This is then an effort to debug.) The whole thing is too long to include, so I'll try to abstract what's relevant. Any suggestions? Debby Swayne dfs@bellcore.com /* includes */ int screen; Display *display; /* callbacks */ main(argc, argv) { Widget shell; Widget form; /* other declarations */ XEvent event; Arg args[20]; int i,j,k; int saved_argc = argc; char **saved_argv; /* this works just fine */ /* shell = XtInitialize(argv[0],"XDataViewer",NULL,0,&argc,argv); */ /* In this section I've cannibalized Initialize.c, but not correctly, I * guess. */ XtToolkitInitialize(); display = XtOpenDisplay((XtAppContext) NULL, (String) NULL, NULL, "XDataViewer", (XrmOptionDescRec *) NULL, (Cardinal) 0, &argc, argv); screen = DefaultScreen(display); saved_argv = (char **) XtCalloc( (unsigned) (argc + 1), (unsigned) sizeof(*saved_argv)); for (i = 0; i < argc; i++) saved_argv[i] = argv[i]; saved_argv[i] = NULL; i = 0; XtSetArg(args[i], XtNscreen, (Screen *) screen); i++; XtSetArg(args[i], XtNargc, saved_argc); i++; XtSetArg(args[i], XtNargv, saved_argv); i++; /* * ... and this is where it dies. dbx tells me: * signal SEGV (segmentation violation) in XtWidgetToApplicationContext */ shell = XtAppCreateShell(NULL, "XDataViewer", applicationShellWidgetClass, display, args, (Cardinal) i); /* set up other widgets and callbacks */ XtRealizeWidget(shell); xor_GC = XCreateGC(display, RootWindowOfScreen(XtScreen(shell)), None, NULL); XSetForeground(display, xor_GC, 0xffffffff); XSetBackground(display, xor_GC, WhitePixel(display, screen)); XSetFunction(display, xor_GC, GXxor); XSetPlaneMask(display, xor_GC, BlackPixel(display, screen) ^ WhitePixel(display, screen)); while (1) { if (XtPending()) { XtNextEvent(&event); XtDispatchEvent(&event); } if (is_spinning == 1) spin_once(); } }
converse@EXPO.LCS.MIT.EDU (Donna Converse) (04/27/89)
> It compiles and runs just fine if I use the > XtInitialize() call, but when I try to expand that call into the > steps the > Toolkit manual recommends, I get core dumps. In section 2.1 of the R3 toolkit doc: "Before an application can call any of the Intrinsics functions, it must initialize the X Toolkit by using: XtToolkitInitialize XtCreateApplicationContext XtDisplayInitialize or XtOpenDisplay XtAppCreateShell" Did you forget the second one?