Xref: utzoo comp.windows.x:36962 comp.windows.open-look:1545 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsm!mls From: merlyn@attunix.att.com (Steve Humphrey) Newsgroups: comp.windows.x,comp.windows.open-look Subject: Re: OL Flat Checkbox Widget Woes Message-ID: <1991May29.182035.26184@cbnewsm.att.com> Date: 29 May 91 18:20:35 GMT References: Sender: mls@cbnewsm.att.com (mike.siemon) Followup-To: comp.windows.open-look Organization: AT&T Bell Laboratories Lines: 65 > I'm having a terrible time using the OL flat checkbox widget. I've > included at the bottom the sample program I wrote to try my hand at using > the flat checkbox. When I run it as is, it gives me a bus error. > I use dbx to trace it, I get the following dump: > warning: core file read error: address not in data space > `FCheckBox`DrawLabel() at 0xf7731774 > ... > > typedef struct _Item > { > String label; > } Item; > > static Item items[] = { > {"CSE100"}, > ... > > n = 0; > XtSetArg (args[n], XtNitems, items); n++; > XtSetArg (args[n], XtNnumItems, NUM_ITEMS); n++; > > rs_flat_checkbox = XtCreateManagedWidget( > "rs_flat_checkbox", > flatCheckBoxWidgetClass, > toplevel, > args, n); > ... I tried your code exactly as sent; it works fine on my '386 running the OPEN LOOK 4.0 toolkit (equivalent to the OpenWindows 2.5 OLIT). I have not tried it yet on a Sun. However, the problem MAY be in the definition of the Item structure. Now the ``Open Look at UNIX'' book has exactly the same problem, and I thought John Miller tested his examples on a Sun, so something else may be wrong. The XtNitems resource takes an array of items, each of which is defined by a structure of XtArgVal's. This parallels the way attributes are passed in regular XtCreateWidget or XtSetValues calls, for exactly the same reason: The widgets (or Intrinsics) do not know a priori the type of each value, thus the values must be coerced to a common type for passing from the client to the widget. So the correct code fragment from the above should be: > typedef struct _Item > { > XtArgVal label; > } Item; > > static Item items[] = { > { (XtArgVal)"CSE100" }, > ... XtArgVal is defined as a "long" on Suns, versus the "char*" definition of String. Now I would think this would be OK, but I'm not familiar with native types of a SPARC chip. Even if it turns out this is not the problem at hand, I suggest using the XtArgVal type in the definition of the XtNitems array's structure. Eventually this *will* save you a core dump. Steve Humphrey UNIX System Laboratories