View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0027042||Lazarus||LCL||public||2014-11-14 13:16||2015-05-09 14:23|
|Reporter||Reinhard Berger||Assigned To||Bart Broersma|
|Product Version||1.2.3 (SVN)||Product Build|
|Target Version||1.2.8||Fixed in Version||1.2.8|
|Summary||0027042: Property "RadioGroup.Controls[x] not in sync with RadioGroup.items[x]|
|Description||In Lazarus 1.1 the 2 properties |
"RadioGroup.items" and "RadioGroup.controls" was in sync
means value  from items was the same as value  from controls.
Since V1.3 this 2 properties are out of sync.
Poperty items : =item#0
Property : controls.caption
The item 0000003 with name "item#3" is also not there (cut off) since the "Hidden Radio" is inserted before.
Also shomehow in debug mode a empty line will be inserted before item#0 (see attached photo)
|Steps To Reproduce||Create a value of Tradiogroups and name it.|
|Additional Information||As seen on picture on lazarus 1.1 all was in sync.|
1st left window shows laz 1.1 (win32) (Release)
2nd window to right shows laz 1.3 (win32) (Release)
3nd window to right shows laz 1.3 qt (linux) (Release)
4th window to right shows laz 1.3 qt (Linux) (Debug)
|Tags||No tags attached.|
|Fixed in Revision||r46964|
|Widgetset||GTK 2, Win32/Win64, QT|
TRadioBug.zip (391,627 bytes)
Can you find a revision that broke it?
> Since V1.3 this 2 properties are out of sync.
Your Product Version says 1.2.3. So, the error is already in 1.2.x series, not only in 1.3 trunk?
||This is ugly bug, it must be fixed asap.|
||Posible candidates: r41551, and related 42772, 42774, 43223 ?|
||I don't see any problem with r41551, it doesn't have anything to do with items, but others ....well Bart, you have to dig in ;)|
Sorry, I meant r42772, and related 42774, 43223 (not r41551)
||Looking at the pictures, I see that 1.1 did not have the HiddenRadioButton, so this will make ControlCount always be Items.Count + 1|
radiogroup.diff (598 bytes)
Index: lcl/include/radiogroup.inc =================================================================== --- lcl/include/radiogroup.inc (revision 46786) +++ lcl/include/radiogroup.inc (working copy) @@ -232,6 +232,9 @@ ARadioButton.Checked := (i = FItemIndex); ARadioButton.Visible := true; end; + //FHiddenButton must remain the last item in Controls, so that Controls is in sync with Items + Self.RemoveControl(FHiddenButton); + Self.InsertControl(FHiddenButton); FHiddenButton.Checked := (FItemIndex = -1); UpdateTabStops; end;
radiogroup.diff (598 bytes)
Setting the parent of FHiddenButton causes the out-of-sync issue.
Possible fix (but rather ugly hack) attached.
r41582 (V1.1) doesn't show this.
next Version i have is r45510 (1.2) there this bug appears for me the first time until now.
Setting FHiddenButton.Parent := Self already exists since r5951 (in the year 2004).
It's unclear to me why it did not end up in TRadioGroup.Controls before...
> This is ugly bug, it must be fixed asap
Apart from it being a little odd, what exactly is the problem with it?
Does any code rely on Controls[x] <=> Items[x]?
If you need to access the radiobuttons and need to have them in sync you could use Components instead.
It is the index of the controls which is then out of sync.
By using this example :
If you use lazarus 1.1 and use "Radiogroup1.Controls.Enabled:=false"
it will set the correct 1st (called : item#1) to disable.
If you use laz 1.2/1.3 and set "Radiogroup1.Controls.Enabled:=false"
it will not work, since it sets the hidden radiobutton to disable and not the visible (correct) one.
If you want to disable under laz 1.2/1.3 the "item#1" you need to inc the index from 1 to 2.
Means "Radiogroup1.Controls.Enabled:=false" will work.
Ok not a big problem when you know it, but i'm sure not all people know that since they count the visible "items" in design mode and later in code trying to set index does not work.
ALso if you compile your prog with different version of lazarus the result is different then.
Don't know what happens when you use a delphi code and compile it.
Output should be the same an all versions without need to modify the source code all the time.
> Means "Radiogroup1.Controls.Enabled:=false" will work.
Well, valid argument.
Does Delphi guarantee that this works (as in:is it by design) or does it happen to work (just because it's a side effect of the actual implementation)?
We can fix it (sort of), see my patch, but ControlCount will always be > Items.Count (at least from the moment on that an item was added to the list), which is not compatible with Delphi's implementation...
|2014-11-14 13:16||Reinhard Berger||New Issue|
|2014-11-14 13:16||Reinhard Berger||File Added: tradio.jpg|
|2014-11-14 13:16||Reinhard Berger||File Added: TRadioBug.zip|
|2014-11-14 13:39||Juha Manninen||Note Added: 0079146|
|2014-11-14 15:27||Juha Manninen||Note Edited: 0079146||View Revisions|
|2014-11-14 16:12||Zeljan Rikalo||Note Added: 0079147|
|2014-11-14 17:09||Bart Broersma||Note Added: 0079149|
|2014-11-14 17:35||Zeljan Rikalo||Note Added: 0079150|
|2014-11-14 18:09||Bart Broersma||Note Added: 0079151|
|2014-11-14 18:11||Bart Broersma||Note Edited: 0079151||View Revisions|
|2014-11-14 18:52||Bart Broersma||Note Added: 0079152|
|2014-11-14 19:49||Bart Broersma||File Added: radiogroup.diff|
|2014-11-14 19:50||Bart Broersma||Note Added: 0079153|
|2014-11-14 22:38||Reinhard Berger||Note Added: 0079155|
|2014-11-15 18:32||Bart Broersma||Note Added: 0079165|
|2014-11-15 18:51||Bart Broersma||Note Added: 0079166|
|2014-11-15 18:57||Bart Broersma||Note Edited: 0079166||View Revisions|
|2014-11-15 21:33||Reinhard Berger||Note Added: 0079167|
|2014-11-15 22:31||Bart Broersma||Note Added: 0079168|
|2014-11-19 20:08||Bart Broersma||Assigned To||=> Bart Broersma|
|2014-11-19 20:08||Bart Broersma||Status||new => assigned|
|2014-11-22 15:48||Bart Broersma||Fixed in Revision||=> r46964|
|2014-11-22 15:48||Bart Broersma||LazTarget||=> -|
|2014-11-22 15:48||Bart Broersma||Status||assigned => resolved|
|2014-11-22 15:48||Bart Broersma||Fixed in Version||=> 1.2.8|
|2014-11-22 15:48||Bart Broersma||Resolution||open => fixed|
|2014-11-22 15:48||Bart Broersma||Target Version||=> 1.2.8|
|2015-05-09 14:23||Bart Broersma||Status||resolved => closed|