Re: [Iup-users] Issue with iup.list and showdragdrop

2021-04-15 Thread Scott Morgan via Iup-users
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


Re: [Iup-users] Issue with iup.list and showdragdrop

2021-04-15 Thread Antonio Scuri
  Yes, I'm ok. Just busy with tons of tasks in other projects.

  As soon as I have some time I'll respond all messages. Sorry for the
delay.

Best,
Scuri

Em qui., 15 de abr. de 2021 14:29, Ranier Vilela 
escreveu:

> De: Scott Morgan via Iup-users 
> Enviado: quinta-feira, 15 de abril de 2021 13:35
> Para: iup-users@lists.sourceforge.net
> Cc: Scott Morgan
> Assunto: Re: [Iup-users] Issue with iup.list and showdragdrop
>
> On 14/04/2021 22:54, Ranier Vilela wrote:
> > De: Scott Morgan via Iup-users 
> >>
> >> 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)
> >
> > Correct, winListGetItemData can return NULL.
> > It's needed protect itemdata against NULL.
> >
>
> >Should I file a ticket somewhere?
> No. That is on that list.
> Scuri is responsible for the development team.
> Unfortunately it is absent for some time.
>
> Is everything okay Scuri?
>
> I wish you are well,
> Ranier Vilela
>
> ___
> Iup-users mailing list
> Iup-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
___
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users


Re: [Iup-users] Issue with iup.list and showdragdrop

2021-04-15 Thread Ranier Vilela
De: Scott Morgan via Iup-users 
Enviado: quinta-feira, 15 de abril de 2021 13:35
Para: iup-users@lists.sourceforge.net
Cc: Scott Morgan
Assunto: Re: [Iup-users] Issue with iup.list and showdragdrop

On 14/04/2021 22:54, Ranier Vilela wrote:
> De: Scott Morgan via Iup-users 
>>
>> 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)
>
> Correct, winListGetItemData can return NULL.
> It's needed protect itemdata against NULL.
>

>Should I file a ticket somewhere?
No. That is on that list.
Scuri is responsible for the development team.
Unfortunately it is absent for some time.

Is everything okay Scuri?

I wish you are well,
Ranier Vilela

___
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users


Re: [Iup-users] Issue with iup.list and showdragdrop

2021-04-15 Thread Scott Morgan via Iup-users
On 14/04/2021 22:54, Ranier Vilela wrote:
> De: Scott Morgan via Iup-users 
>>
>> 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)
>
> Correct, winListGetItemData can return NULL.
> It's needed protect itemdata against NULL.
> 

Should I file a ticket somewhere?

Scott




___
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users


Re: [Iup-users] Issue with iup.list and showdragdrop

2021-04-14 Thread Ranier Vilela
De: Scott Morgan via Iup-users 
Enviado: quarta-feira, 14 de abril de 2021 15:40
Para: iup-users@lists.sourceforge.net
Cc: Scott Morgan
Assunto: Re: [Iup-users] Issue with iup.list and showdragdrop

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)
Correct, winListGetItemData can return NULL.
It's needed protect itemdata against NULL.

regards,
Ranier Vilela

___
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users


Re: [Iup-users] Issue with iup.list and showdragdrop

2021-04-14 Thread Scott Morgan via Iup-users
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.

Scott


___
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users