fred@hpcvlx.HP.COM (Fred Taft) (08/15/88)
When using XtGetValues(), you need to remember that there are two ways to
have the resulting value returned:
1) It will be returned in the arglist's value slot, if this value has
been set to NULL before the call to XtGetValues().
2) It will be returned in the location pointed to by the address stored
in the arglist's value slot, if this value has been set to a non-NULL
value before the call to XtGetValues().
In your case, for the first call, the value has been set to NULL, so
XtGetValues() returns the queried value in the arglist. However, for the
second call, you now have a non-NULL value in your arglist, so the toolkit
assumes that you have supplied a pointer to a variable into which the
value is to be stored; thus, it is not surprizing that your program dumps
core!swick@ATHENA.MIT.EDU (Ralph R. Swick) (08/16/88)
Date: 12 Aug 88 20:09:19 GMT
From: coltoff@burdvax.prc.unisys.com (Joel Coltoff)
The only thing I noticed is that if you use XtGetValues()
twice in the same function you need to say arg[0].values = 0;
before you call it or it dumps core.
Nope. You have to store a pointer to the desired destination in
the arglist for XtGetValues. See section 11.8.1. Storing a NULL
pointer appears to work because of some backwards compatibility
code that will disappear from a (unspecified) future release.rob@cetia.UUCP (05/16/89)
I know this has come up before but this may be new information.
Anyway, on our system which is M68K based, when using the scrollbar widget,
top always comes back from XtGetValues with a zero value.
However, if i, temporarily, remove the following lines of code from
XtGetValues() in lib/Xt/Resource.c
/* Get constraint values if necessary */
if (w->core.constraints != NULL) {
ConstraintWidgetClass cwc;
cwc = (ConstraintWidgetClass) XtClass(w->core.parent);
GetValues(w->core.constraints,
(XrmResourceList *)(cwc->constraint_class.resources),
cwc->constraint_class.num_resources, args, num_args);
}
then the value returned in top is as expected.
Why should this be? (and is it relevant?)
robrob@cetia.UUCP (Rob Gordon) (05/16/89)
I know this has come up before but this may be new information.
Anyway, on our system which is M68K based, when using the scrollbar widget,
top always comes back from XtGetValues with a zero value.
However, if i, temporarily, remove the following lines of code from
XtGetValues() in lib/Xt/Resource.c
/* Get constraint values if necessary */
if (w->core.constraints != NULL) {
ConstraintWidgetClass cwc;
cwc = (ConstraintWidgetClass) XtClass(w->core.parent);
GetValues(w->core.constraints,
(XrmResourceList *)(cwc->constraint_class.resources),
cwc->constraint_class.num_resources, args, num_args);
}
then the value returned in top is as expected.
Why should this be? (and is it relevant?)
rob
--
Rob Gordon
rob@inset.co.uk
...!mcvax!ukc!inset!robharish@csl.ncsu.edu (Harish Hiriyannaiah) (08/20/89)
I am having trouble using XtGetValues. Here's a piece of code that doesn't
work right.
------------------------ Begin file handler.c ------------------------
#include "xdisp.h"
static Arg size_args[2] =
{
{XtNheight,NUL},
{XtNwidth,NUL}
};
void topcall(widget,client,call)
Widget widget;
caddr_t client,call;
{
int height,width;
XtSetArg(size_args[0],XtNheight,(XtArgVal)&height);
XtSetArg(size_args[1],XtNwidth,(XtArgVal)&width);
XtGetValues(widget,size_args,(Cardinal) 2);
printf("Height = %d, Width = %d\n",height,width);
}
----------------------------End file handler.c---------------------
xdisp.h contains all the proper inclusions like Intrinsic.h etc. The printf
statement spits out garbage.
The environment is DEC VaxStation 3100 running Ultrix 3.1. Incidentally, the
include files used are the ones in /usr/include/mit/X11, and the libraries
used are libX11.a libXmu.a libXt.a and libXaw.a .
harish pu. hi. harish@ecelet.ncsu.edu
harish@ecebucolix.ncsu.eduswick@ATHENA.MIT.EDU (Ralph R. Swick) (08/28/89)
> I am having trouble using XtGetValues. Here's a piece of code that doesn't > work right. >... > > int height,width; > > XtSetArg(size_args[0],XtNheight,(XtArgVal)&height); > XtSetArg(size_args[1],XtNwidth,(XtArgVal)&width); height and width are of type Dimension. Dimension and int may or may not be the same, depending on the implementation. In the implementation you are using they are almost certainly not the same.