[comp.windows.x.motif] motif scrolled list bug

aho@scam.Berkeley.EDU (alex ho) (05/06/91)

I am getting some interesting behavior with the motif scrolled list
widget.  The stripped code for my program is below.

(1) If you run the program as listed, you don't see two lines of
      text in the string widget. Only "string one" is visible.
    If you now resize the widget just a tad, the second line now
      becomes visible.
    Now select the second line of text. You should get a core dump.
(2) However, if you run the program and click on "string one"
      before resizing and then click on "string two" after resizing,
      you don't get a core dump.
(3) If you now take the line commented "traversal line" below and 
      comment it out and recompile...
    You still only see "string one". (What happened to string two?)
    However, if you click on "string two" after resizing, you don't
      dump core.

Can anyone please explain to me what is happening?
What is XmNtraveralOn doing?
Is there anyway to make it so that both strings show up when I add them
  to the list?

I saw this using the motif libraries version 1.1 on a decstation 3100
running cc (no optimization) and under xsaber.  It also happened to
me on a sun 4/110.

I'd really appreciate it if someone who understood the internals
of the scrolled list widget could send me a patch...

THANKS!

.alex
aho@ic.berkeley.edu


/* cut here */

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <Xm/List.h>

XtAppContext app_context;
Widget toplevel, slist;

main (argc, argv)
   int argc;
   char *argv[];
{
   Arg args[5];
   int n;

   toplevel = XtAppInitialize  (&app_context, "phooey", NULL, 0, &argc, argv,
				NULL, args, 0);

   n = 0;
   XtSetArg (args[n], XmNwidth, 300); n++;
   XtSetArg (args[n], XmNheight, 150); n++;

   XtSetArg (args[n], XmNtraversalOn, False); n++;  /* traversal line */

   slist = XmCreateScrolledList (toplevel, "slist", args, n); 
   XtManageChild (slist);

   XtRealizeWidget (toplevel);

   additem ("string one");
   additem ("string two");

   XtAppMainLoop (app_context);
}

additem (line)
   char *line;
{
   XmString string;

   printf ("%s\n", line);

   string = XmStringCreateSimple (line);
   XmListDeselectAllItems (slist);
   XmListAddItem (slist, string, (int) 0);
}