Page 1 of 1

Wrong value for CountGadgetItems at Treegadget

Posted: Wed Aug 14, 2019 11:25 pm
by IB-Software
Example

Code: Select all

If OpenWindow(0, 216, 0, 290, 530, "",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)  
  TreeGadget(1, 30, 30, 230, 380)
  AddGadgetItem(1,-1,"2010",0,0)
  AddGadgetItem(1,-1,"2011",0,0)
  AddGadgetItem(1,-1,"2012",0,2)
  AddGadgetItem(1,-1,"2013",0,0)
  AddGadgetItem(1,-1,"2014",0,2)
  AddGadgetItem(1,-1,"2015",0,2)
  AddGadgetItem(1,-1,"2016",0,2)  
  Debug CountGadgetItems (1)
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow 
EndIf
End

Re: Wrong value for CountGadgetItems at Treegadget

Posted: Sun Aug 18, 2019 3:57 pm
by Shardik
I can't confirm your finding! I have tested your example on these operating systems and all report 7, which is the correct count of entries in the TreeGadget:
- MacOS 10.6.8 'Snow Leopard' with PB 5.46 x86 and PB 5.62 in ASCII and Unicode mode
- MacOS 10.14.6 'Mojave' with PB 5.70 x64
- Linux Mint 19.2 'Tina' x64 with Cinnamon and PB 5.71 x64
- Windows 10 x64 V1809 with PB 5.70 x86

By the way, your code contains an error: in AddGadgetItem() you specify a node level of 2 before having specified a node level of 1. On MacOS (not on Linux and Windows!) you therefore obtain the following output (being unable to expand the nodes):
2010
2011
2013

After replacing value 2 with 1 in AddGadgetItem() and opening the parent nodes the correct output is displayed:
2010
2011
- 2012
2013
- 2014
- 2015
- 2016

Nevertheless in both cases the output of CountGadgetItems() is correct: 7

Re: Wrong value for CountGadgetItems at Treegadget

Posted: Mon Aug 19, 2019 8:28 am
by IB-Software
The error in MacOS is that the value of CountGadgetItems does not match the number of items in the TreeGadget.

I have deliberately specified level 2 as this will cause the error. If you specify a wrong level, PureBasic should either report an error, correct the error (as in Windows) on its own or not create the entries.

But in any case the value of CountGadgetItems must correspond to the number of entries in the TreeGadget.

Re: Wrong value for CountGadgetItems at Treegadget

Posted: Mon Aug 19, 2019 10:16 am
by Shardik
Which version of MacOS are you using and which version of PureBasic? And which value does CountGadgetItems() display with your example from your first posting?

As I have written for Snow Leopard and Mojave, although the output with node level 2 is incorrect, the result returned from CountGadgetItems() is 7 and therefore correct.
IB-Software wrote:If you specify a wrong level, PureBasic should either report an error, correct the error (as in Windows) on its own or not create the entries.
I agree.

Re: Wrong value for CountGadgetItems at Treegadget

Posted: Tue Aug 20, 2019 7:19 am
by IB-Software
I tested with MacOS Mojave and PureBasis 5.70. 3 entries are displayed:

2010
2011
2013

But CountGadgetItems returns 7. This is wrong because only three items are displayed.

Re: Wrong value for CountGadgetItems at Treegadget

Posted: Tue Aug 20, 2019 7:32 am
by Josh
IB-Software wrote:But CountGadgetItems returns 7. This is wrong because only three items are displayed.
What is so hard to understand about the function name CountGadgetItems()? This function does exactly what the name says, it returns how many items the Gadget has.

Again a typical example. Don't know anything, but post in the bugs immediately. Please can a mod move this drama to the garbage?

Re: Wrong value for CountGadgetItems at Treegadget

Posted: Tue Aug 20, 2019 1:00 pm
by IB-Software
Ok, even if the CountGadgetItems function returns the correct value, based on the AddGadgetItem function, although the TreeGadget displays a different number of entries, then the different handling of the "wrong" levels in MacOS and Windows is a bug in any case.

Re: Wrong value for CountGadgetItems at Treegadget

Posted: Tue Aug 20, 2019 5:59 pm
by Bisonte
IB-Software wrote:Ok, even if the CountGadgetItems function returns the correct value, based on the AddGadgetItem function, although the TreeGadget displays a different number of entries, then the different handling of the "wrong" levels in MacOS and Windows is a bug in any case.
This is not a bug, if you "forget" one stage. You go from 0 to 2... there is a little 1 between them....