View Issue Details

IDProjectCategoryView StatusLast Update
0025158LazarusLCLpublic2013-10-30 20:20
ReporterBobi Hot Assigned ToBart Broersma  
Status resolvedResolutionfixed 
Target Version1.2.0 
Summary0025158: TRadioGroup with set value ItemIndex at design time miss after saving and building
DescriptionTRadioGroup with set value ItemIndex at design time miss after saving and (or) building (starting) aplication.
Steps To ReproduceMake a new form.
Place TRadioGroup with many possibilities (1, 2, 3, 4, 5...).
Set value ItemIndex at design time (to 5). After saving and (or) building this value was reset to zero (0, not -1).
Additional InformationI do not observe befour this.
TagsNo tags attached.
Fixed in Revisionr43163
Attached Files


Bobi Hot

2013-10-07 02:03


TRadioGroupErr1199.PNG (19,701 bytes)   
TRadioGroupErr1199.PNG (19,701 bytes)   


2013-10-07 09:13

reporter   ~0070600

Probably caused by r42772

Bart Broersma

2013-10-07 11:35

developer   ~0070605

> Probably caused by r42772
I don't see anything in that revision that would explain that for me...

It's easy to check.
@Bobi: can you try r42771 and see the bug has gone?
If so try r42772 and see if the bug appears.

Zeljan Rikalo

2013-10-07 11:39

developer   ~0070606

@Bobi Hot: Please, always attach compileable example. It's waste of time for developers to create example projects for every issue which does not have it.


2013-10-07 12:22

reporter   ~0070607

Didn't check if existed before that, but I could reproduce it latest svn here:

procedure TCustomRadioGroup.UpdateInternalObjectList;
Line sets itemindex to zero

if (FItemIndex>=FItems.Count) then FItemIndex:=FItems.Count-1;

Zeljan Rikalo

2013-10-07 14:11

developer   ~0070611

So what to do ? Keep FItemIndex and set it after UpdateItems if it's in range ?
Or better remember what item was "ItemIndex" and set that item as ItemIndex (since eg. list was changed, some items added or removed) ?

Bart Broersma

2013-10-07 15:55

developer   ~0070616

This piece of code was called too, before I made that change.
Only relevant change now is that UpdateItems (which adds or removes radiobuttons) is also called inside Items.BeginUpdate/Items.EndUpdate (which is necessary, otherwise: crash).

  if (FItemIndex>=FItems.Count) then FItemIndex:=FItems.Count-1

This line can only happen if you have ItemIndex set to Count-1 (last item) and then remove one item from the list.

Bart Broersma

2013-10-07 16:06

developer   ~0070618

Target 1.2 (it's a regression).

Bart Broersma

2013-10-07 19:19

developer   ~0070624

Please test and close if OK.
And yes, it was my revision that broke it in the first place.

Bobi Hot

2013-10-29 09:30

reporter (321,822 bytes)

Bobi Hot

2013-10-29 09:50

reporter   ~0071018

I was busy to give up project and now I can to try some other and replay to You.
1.The project is save correctly. I open .lfm and property is setting right:
ItemIndex = 4
2. But then running programm is set to zero (0)? I debug and at initialize
TCustomRadioGroup.SetItemIndex(Value : integer);
is set with correct value (4). But showing window is back set with zero index, less to enter again to this procedure? I make show to label.caption in OnCreate and value is "0".
3. I try with other visual components which have ItemIndex property (TComboBox,TListBox) and they work properly.
4. I attach .zip file ( with initialy test project to see this. (I do not see where is :) )

Bart Broersma

2013-10-29 13:31

developer   ~0071023

@Bobi: the issue is fixed in trunk and merged (r43266) in fixes branch:
r43223 TRadioGroup: fix resetting ItemIndex to -1 when calling Items.Assign (regression introduced by me in r42772).

Which Lazarus version and which revision are you using?

Bart Broersma

2013-10-29 19:11

developer   ~0071028

I tested with r43338 of Fixes_1_2 branch (1.99pre-release) and it behaves as expected.

Bobi Hot

2013-10-30 19:49

reporter   ~0071045

I use Lazarus 1.1.99 pre release.
Thanks for fixed . I was haste to be correct before final release.
I transfer source from 1.3-43331 and work pretty. :)

Bart Broersma

2013-10-30 20:20

developer   ~0071046

Please close.

Issue History

Date Modified Username Field Change
2013-10-07 02:03 Bobi Hot New Issue
2013-10-07 02:03 Bobi Hot File Added: TRadioGroupErr1199.PNG
2013-10-07 09:13 ocean Note Added: 0070600
2013-10-07 11:17 Jonas Maebe Project FPC => Lazarus
2013-10-07 11:35 Bart Broersma Note Added: 0070605
2013-10-07 11:39 Zeljan Rikalo Note Added: 0070606
2013-10-07 12:22 ocean Note Added: 0070607
2013-10-07 14:11 Zeljan Rikalo Note Added: 0070611
2013-10-07 15:55 Bart Broersma Note Added: 0070616
2013-10-07 16:06 Bart Broersma LazTarget => 1.2
2013-10-07 16:06 Bart Broersma Note Added: 0070618
2013-10-07 16:06 Bart Broersma Product Version 2.6.2 =>
2013-10-07 16:06 Bart Broersma Target Version => 1.2.0
2013-10-07 19:19 Bart Broersma Fixed in Revision => r43163
2013-10-07 19:19 Bart Broersma Note Added: 0070624
2013-10-07 19:19 Bart Broersma Status new => resolved
2013-10-07 19:19 Bart Broersma Resolution open => fixed
2013-10-07 19:19 Bart Broersma Assigned To => Bart Broersma
2013-10-29 09:30 Bobi Hot File Added:
2013-10-29 09:50 Bobi Hot Note Added: 0071018
2013-10-29 13:31 Bart Broersma Note Added: 0071023
2013-10-29 13:31 Bart Broersma Status resolved => feedback
2013-10-29 19:11 Bart Broersma Note Added: 0071028
2013-10-30 19:49 Bobi Hot Note Added: 0071045
2013-10-30 19:49 Bobi Hot Status feedback => assigned
2013-10-30 20:20 Bart Broersma Note Added: 0071046
2013-10-30 20:20 Bart Broersma Status assigned => resolved