Xref: utzoo comp.windows.x:35348 comp.windows.x.motif:2573 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!pacbell.com!ucsd!nprdc!apple From: apple@nprdc.navy.mil (Jim Apple) Newsgroups: comp.windows.x,comp.windows.x.motif Subject: Wcl/Motif question ( WcCallback seg faults ) Message-ID: <14109@arctic.nprdc.navy.mil> Date: 12 Apr 91 18:03:53 GMT Sender: news@nprdc.navy.mil Reply-To: apple@nprdc.navy.mil (Jim Apple) Organization: Navy Personnel R&D Center, San Diego Lines: 170 I need some help with WcCallback, I'm trying to use WcCallback and XtSetValues to update a XmList widget. But it seg faults when it gets to the XtSetValues call. Below is a short example of a resource file and the main.c file. Configuration: Wcl-1.05 and motif 1.1 Any Help would be great. Thanks in advance ---------------------- Wcl resource file ------------------ ! !PaperLess Wcl ! paperless.wcChildren: main paperless.title: PaperLess *main.wcConstructor: XmCreateForm *main.wcChildren: courseList *main.height: 500 *main.width: 750 *courseList.wcTrace: True *courseList.wcConstructor: XmCreateScrolledList *courseList.wcCallback: CreateCourseListCB( ) *courseListSW.leftAttachment: ATTACH_FORM *courseListSW.rightAttachment: ATTACH_FORM *courseListSW.topAttachment: ATTACH_POSITION *courseListSW.topPosition: 6 main.c CreateCourseListCB() is at the end of the file ------- #include #include #include #include #define MAX_ARGS 50 void CreateCourseListCB(); extern void MriRegisterMotif(); static void RegisterTable ( app ) XtAppContext app; { #define RCN( name, class ) WcRegisterClassName ( app, name, class ); #define RCP( name, class ) WcRegisterClassPtr ( app, name, class ); /* -- register widget classes */ RCN( "Table", tableWidgetClass ); RCP( "tableWidgetClass", tableWidgetClass ); } /* as defined in the resource file */ Widget courseList; /****************************************************************************** * MAIN function ******************************************************************************/ main ( argc, argv ) int argc; char* argv[]; { char* appClass; XtAppContext app; Widget appShell; appClass = (char*) XtMalloc ( strlen ( argv[0] ) + 1 ); strcpy (appClass, argv[0]); /* initialize first letter to make class, or first two if ** first is already capitalized, or don't worry about it. */ if (islower(appClass[0])) appClass[0] = toupper(appClass[0]); else if (islower(appClass[1])) appClass[1] = toupper(appClass[1]); /* -- Intialize Toolkit creating the application shell */ appShell = XtInitialize ( argv[0], appClass, /* app name and class */ NULL, 0, /* description of cmd line options */ &argc, argv ); app = XtWidgetToApplicationContext(appShell); /* -- Register all application specific callbacks and widget classes */ RegisterTable ( app ); /* register CreateCourseListCB */ WcRegisterCallback(app, "CreateCourseListCB", CreateCourseListCB, NULL); /* -- Register all Motif classes and constructors */ MriRegisterMotif ( app ); /* -- Create widget tree below toplevel shell using Xrm database */ WcWidgetCreation ( appShell ); /* -- Realize the widget tree and enter the main application loop */ XtRealizeWidget ( appShell ); XtMainLoop ( ); } /***************************************************************************** CreateCourseList() *****************************************************************************/ void CreateCourseListCB( w, ignored, unused) Widget w; caddr_t ignored; caddr_t unused; { Arg args[MAX_ARGS]; int argn = 0; int i = 0; XmString courses[5]; static char *course_list_items[3] = { "C 102-2001 test", "A 101-1001 test", "B 102-2001 test", }; for(i = 0; i < 3; i++) { courses[i] = (XmString )XmStringCreateLtoR(course_list_items[i],XmSTRING_DEFAULT_CHARSET); } XtSetArg(args[argn], XmNitems, (XtArgVal) courses); argn++; XtSetArg(args[argn], XmNitemCount, (XtArgVal) 3 ); argn++; XtSetValues(courseList,args,argn); } Jim Apple apple@nprdc.navy.mil WB1DOG ...}ucsd!nprdc!apple