FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TMenu::DelItems
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
TMenu::DelItems
Posted: Fri Jan 05, 2018 03:50 PM
Hello,
In my program I see that TMenu::DelItems goes in infinite loop, I look the code, and I see:
Code (fw): Select all Collapse
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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: TMenu::DelItems
Posted: Fri Jan 05, 2018 08: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 (fw): Select all Collapse
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
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: TMenu::DelItems
Posted: Sat Jan 06, 2018 11:12 AM
After some tests I use a version like this:
Code (fw): Select all Collapse
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

Continue the discussion