The destruction of a dialog may trigger the destruction of another, if
the other is the next, it will be invalid too.
Best,
Scuri
Em 20 de fev de 2018 9:57 AM, "Ranier VF" <ranier_...@hotmail.com> escreveu:
> Hi,
> Take a look in this version:
>
> --- a\src\iup_dlglist.c Tue Feb 13 10:05:14 2018
> +++ b\src\iup_dlglist.c Tue Feb 20 09:48:43 2018
> @@ -112,24 +112,14 @@
>
> void iupDlgListDestroyAll(void)
> {
> - int i = 0, count;
> - Ihandle** ih_array = (Ihandle**)malloc(idlg_count * sizeof(Ihandle*));
> Idiallst *list;
> - for (list = idlglist; list; list = list->next)
> - {
> - if (iupObjectCheck(list->ih))
> - {
> - ih_array[i] = list->ih;
> - i++;
> - }
> - }
> + Idiallst *next;
>
> - count = i;
> - for (i = 0; i < count; i++)
> + list = idlglist;
> + while(list)
> {
> - if (iupObjectCheck(ih_array[i]))
> - IupDestroy(ih_array[i]); /* this will also destroy the list */
> + next = list->next; /* Save next item, IupDestroy may can free
> list->next */
> + IupDestroy(list->ih); /* iupObjectCheck is called in IupDestroy */
> + list = next;
> }
> -
> - free(ih_array);
> }
>
> list->next is preseved in case IupDestroy invalidate.
>
> Best regards,
> Ranier Vilela
> ________________________________________
> De: Antonio Scuri <antonio.sc...@gmail.com>
> Enviado: segunda-feira, 19 de fevereiro de 2018 19:37
> Para: IUP discussion list.
> Assunto: Re: [Iup-users] iupDlgListDestroyAll optimized version
>
> Yes, because when a dialog is destroyed the idlglist list is updated, so
> list->next will be invalid.
>
> Best,
> Scuri
>
>
> 2018-02-13 11:13 GMT-02:00 Ranier VF <ranier_...@hotmail.com<mailto:
> ranier_...@hotmail.com>>:
> Hi,
> Is there really any special reason, for what
> iupDlgListDestroyAll do not be like that?
>
> --- a\src\iup_dlglist.c Tue Feb 13 11:05:14 2018
> +++ b\src\iup_dlglist.c Tue Feb 13 11:11:25 2018
> @@ -112,24 +112,9 @@
>
> void iupDlgListDestroyAll(void)
> {
> - int i = 0, count;
> - Ihandle** ih_array = (Ihandle**)malloc(idlg_count * sizeof(Ihandle*));
> Idiallst *list;
> for (list = idlglist; list; list = list->next)
> {
> - if (iupObjectCheck(list->ih))
> - {
> - ih_array[i] = list->ih;
> - i++;
> - }
> + IupDestroy(list->ih); /* iupObjectCheck is called in IupDestroy */
> }
> -
> - count = i;
> - for (i = 0; i < count; i++)
> - {
> - if (iupObjectCheck(ih_array[i]))
> - IupDestroy(ih_array[i]); /* this will also destroy the list */
> - }
> -
> - free(ih_array);
> }
>
> Best regards,
> Ranier Vilela
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Iup-users mailing list
> Iup-users@lists.sourceforge.net<mailto:Iup-users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Iup-users mailing list
> Iup-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users