On 14/04/2021 16:40, Scott Morgan via Iup-users wrote: > On 14/04/2021 15:47, Scott Morgan via Iup-users wrote: >> Running into an issue with IUP unexpectedly exiting app >> >> Simple Lua script: >> >> dlg = iup.dialog{iup.list{expand="YES",showdragdrop="YES"}} >> dlg:showxy(iup.CENTER,iup.CENTER) >> iup.MainLoop() >> >> Now click on the lower area of the list box (below the empty list item >> placeholder), the executable quits without warning. >> >> Remove the showdragdrop setting and everything works fine. >> >> This is on Win10. > > Further examination suggests the problem is around src/win/iupwin_list.c > line 1098. > > The result of winListGetItemData isn't checked (returns NULL in this > situation) and immediately used on the next line (itemdata->hBitmap) > > My guess would be to drop that immediate use on 1099, and change lines > 1116,1117 to check and use the itemdata value directly. >
Even more examination: I think the problem is the way the iupwinListDND function (src/win/iupwin_list.c) handles the "_IUPLIST_DRAGITEM" attribute. After the drag operation is done with that attribute is set to NULL, in other words 0 (zero), which is the same as the first item of the list. So there's no way to tell if the drag operation has been finished. So you have the following sequence: 1. DL_BEGINDRAG starts off and finds the drag item (idDrag) is -1 (no item), so it 'unsets' _IUPLIST_DRAGITEM (line 1074): iupAttributeSet(ih, "_IUPLIST_DRAGITEM", NULL); 2. DL_DROPPED comes along and retrieves _IUPLIST_DRAGITEM (line 1092), which is now 0, the first item of the list. 3. Unaware of the mistake, DL_DROPPED continues on, first calling iupListCallDragDropCb (line 1096), which provides the callback function with incorrect data, and if that ends with IUP_CONTINUE, moves onto doing the wrong thing. Result: Crash on an empty list, or the first item of the list gets moved to the end. So possibly the fix is to 'unset' _IUPLIST_DRAGITEM to -1 (lines 1074, 1129, 1135), and check for that after line 1092 in the DL_DROPPED section. For now, in my script, I've registered a callback that checks the length of the list and returns iup.IGNORE if it's 0. Stops the crash, but still allows the item rotation. Scott P.S. No worries Scuri, there's always too many projects :)
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users