When setting the XmNvalue resource of an XmText, the underlying value doesn't
change if the same pointer is passed repeatedly, even if the text it points to
has changed.
The problem is that SetValues() in Text.c is capturing the caller's pointer and
comparing it for subsequent settings. I also see that Initialize() spuriously
attempts to free this pointer (but luckily the test in the if is wrong, so it
never actually happens!).
The example below illustrates the problem. It includes an XmTextField for
comparison. In OpenMotif, it prints
Text contains "first text"
TextField contains "first text"
Text contains "second text"
TextField contains "second text"
but in LessTif 0.93.18 it prints
Text contains "first text"
TextField contains "first text"
Text contains "first text"
TextField contains "second text"
------------------------- text-value-same-address.c --------------------------
#include <Xm/Xm.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/RowColumn.h>
#include <stdio.h>
XtAppContext app;
Widget toplevel, layout, text, textf;
int
main(int argc, char **argv)
{
char textvalue[256];
char *checktextvalue;
toplevel = XtVaAppInitialize(&app, "Text", NULL, 0,
&argc, argv,
NULL, NULL);
layout = XtVaCreateManagedWidget("one",
xmRowColumnWidgetClass,
toplevel,
NULL);
text = XtVaCreateManagedWidget("text",
xmTextWidgetClass,
layout,
NULL);
textf = XtVaCreateManagedWidget("textf",
xmTextFieldWidgetClass,
layout,
NULL);
XtRealizeWidget(toplevel);
strcpy(textvalue, "first text");
XtVaSetValues(text, XmNvalue, textvalue, NULL);
XtVaSetValues(textf, XmNvalue, textvalue, NULL);
strcpy(textvalue, "scrub text");
XtVaGetValues(text, XmNvalue, &checktextvalue, NULL);
printf("Text contains \"%s\"\n", checktextvalue);
strcpy(textvalue, "scrub textf");
XtVaGetValues(textf, XmNvalue, &checktextvalue, NULL);
printf("TextField contains \"%s\"\n", checktextvalue);
strcpy(textvalue, "second text");
XtVaSetValues(text, XmNvalue, textvalue, NULL);
XtVaSetValues(textf, XmNvalue, textvalue, NULL);
strcpy(textvalue, "more scrub text");
XtVaGetValues(text, XmNvalue, &checktextvalue, NULL);
printf("Text contains \"%s\"\n", checktextvalue);
strcpy(textvalue, "more scrub textf");
XtVaGetValues(textf, XmNvalue, &checktextvalue, NULL);
printf("TextField contains \"%s\"\n", checktextvalue);
XtAppMainLoop(app);
}
------------------------------------------------------------------------------
__Martin
_______________________________________________
Lesstif mailing list
[EMAIL PROTECTED]
https://terror.hungry.com/mailman/listinfo/lesstif