Path: utzoo!utgpu!news-server.csri.toronto.edu!neat.cs.toronto.edu!tjhorton Newsgroups: comp.windows.x.motif From: tjhorton@cs.toronto.edu ("Timothy J. Horton") Subject: Re: How to re-manage the same child widget Message-ID: <91May16.230552edt.6244@neat.cs.toronto.edu> Organization: Department of Computer Science, University of Toronto References: <91May16.183920edt.8838@orasis.vis.toronto.edu> Distribution: inet Date: 17 May 91 03:06:10 GMT Lines: 34 Let me get this right the second time tjhorton@vis.toronto.edu ("Timothy J. Horton") writes: >Most motif widgets are like this; they reallocate copies of whatever you give >them via pointers. (using *either* XtSetValues or convenience routines) >Furthermore, if you fetch back resource values via pointers, USING CONVENIENCE ROUTINES SUCH AS "XmTextGetString", ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >most widgets allocate yet another copy of the resource and pass back the new >copy, which you normally have to free explicitly. XtGetValues normally bypasses this copy/free cycle. For instance, XmTextGetString gives you a *copy* of the text widget's internal buffer, wheras XtGetValues on its XmNvalue returns a pointer to the text widget's internal buffer. Thus, getting and setting are different. >I had an application in which I needed to very quickly swap large lists in >and out of a list widget, but couldn't, because the dang list widget always >freed its old list and allocated and copied the new one. I had to write my >own code from scratch to display selection lists without copying them. Someone asked about this -- I just used a drawing area and a scrollbar, and the input callback from the drawing area for item selection. I don't have the code (now belongs to a previous client), but it only took a day to write, except that it required some messy Xlib hacking. Tim