TMenu::DelItems

TMenu::DelItems

Postby AntoninoP » Fri Jan 05, 2018 3:50 pm

Hello,
In my program I see that TMenu::DelItems goes in infinite loop, I look the code, and I see:
Code: Select all  Expand view
METHOD DelItems() CLASS TMenu

   while Len( ::aMenuItems ) > 0
      ATail( ::aMenuItems ):End()  //Destroy()
   end

return nil

Someone has remove Destroy and has put End, The problem is that Destroy removes the item from aMenuItems, End does not do it.
In this way it calls End of the last item forever.
I Will change my calls, but I think it need to be fixed...
Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: TMenu::DelItems

Postby cnavarro » Fri Jan 05, 2018 8:58 pm

Antonino:
Can you give a small example of how you use the method?

If you need use this method directly from a line of your code, use this modification in your TMenu class, and use ::DelITems( .F. )
Note that the End method calls the Destroy method
In any case, I will review its operation

Code: Select all  Expand view


METHOD DelItems( lEnd ) CLASS TMenu

   DEFAULT lEnd   := .T.
   while Len( ::aMenuItems ) > 0
      if lEnd
         ATail( ::aMenuItems ):End()
      else
         ATail( ::aMenuItems ):Destroy()
      endif
   end

return nil

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TMenu::DelItems

Postby AntoninoP » Sat Jan 06, 2018 11:12 am

After some tests I use a version like this:
Code: Select all  Expand view
proc MenuDelItems( oMenu )
   LOCAL i
   for i:=len(oMenu:aItems) to 1 step -1
      oMenu:DelItem(i)
   next
   oMenu:aItems := {}

PS. I do not have to hand code I recreated from memory
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests