>>>>> On Fri, 20 Aug 2004 10:56:16 -0500, "Dave Williss" <[EMAIL PROTECTED]> said:
Dave> ----- Original Message ----- Dave> From: "Martin Simmons" <[EMAIL PROTECTED]> Dave> To: <[EMAIL PROTECTED]> Dave> Cc: <[EMAIL PROTECTED]> Dave> Sent: Friday, August 20, 2004 4:39 AM Dave> Subject: Re: [Lesstif-discuss] Error in XmList >> >>>>> On Thu, 19 Aug 2004 16:57:07 -0500, "Dave Williss" Dave> <[EMAIL PROTECTED]> said: >> Dave> There is an error in XmList... >> Dave> Starting condition: You have a list with one item and it's Dave> selected. Dave> Call XmListAddItemUnselected() to add another item before it. Dave> Then XmListDeletePos() to delete the old item. >> Dave> Problem: When adding the new item, it does not adjust the Dave> List_SelectedIndices, so the list still thinks item 1 (the first Dave> one) is highlighted when actually it's item 2. >> >> Look like this could be related to bug # 916711 >> >> Dave> http://sourceforge.net/tracker/index.php?func=detail&aid=916711&group_id=8596&atid=108596 >> Dave> Could be related, but this one is more nasty. When you add an item and then Dave> delete the selected item, we're OK with ending up with nothing selected. Dave> What's nasty here is that even though nothing is selected, when you call Dave> XmListGetSelectedPos, it still says that there's one item selected and Dave> returns a list of one random number (unitialized garbage from the malloc Dave> that was never filled in - if built for debugging, I think it has the value Dave> of 0xbaadf00d). We then try to use this item to index into an array of Dave> stuff and KA BOOM! Dave> A solution to this specific problem is pretty simple. In Dave> XmListGetSelectedPos, we add selected items to the return list using j as an Dave> array index. When we're done, j is the real number of selected items and Dave> that's what it should return for the count. Dave> That would solve this problem but hide the real problem which is that Dave> something isn't keeping track of the number of selected items correctly in Dave> the first place. Right. I think the underlying bug is that changing the items should retain the selected *items*, not the selected *indices*. If it did that then adding an item would adjust the selected indices from { 1 } to { 2 } and deleting item 2 would adjust the selected indices to nothing. I think that's what the Motif spec requires (e.g. the doc for the XmNselectedItems resource mentions it being updated in certain cases). __Martin ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ Lesstif-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/lesstif-discuss

