I one of my little projects, I'm using a TCheckListBox.
Since I have more data attached to each item, I created my own simple class with the additional information and I attach it to the items in the list.
However under Cocoa I keep getting crashes (SYSTEM$_$TOBJECT_$__$$_INHERITSFROM$TCLASS$$BOOLEAN), even though it works fine under Windows and Linux.
I suspect there is something wrong with Objects and the checkboxes in the CheckboxListbox under Cocoa - but it could also be my own mistake, so I'm trying to get verification in the forum before posting a bug report.
Attached a sample project, where I reproduced the issue in a very simple program.
The application works correct under Linux (GTK/2) and Windows.
TMyClass = class
something:integer;
end;
....
CheckListBox1.Items.AddObject('some item text here',tmpMyClass);
CheckListBox1.Checked[CheckListBox1.Count-1]:=true;
....
procedure TForm1.CheckListBox1Click(Sender: TObject);
begin
if (CheckListBox1.ItemIndex>-1) and (CheckListBox1.Items.Objects[CheckListBox1.ItemIndex]<>nil) then
begin
lblValue_Checklistbox.Caption:='value='+IntToStr(TMyClass(CheckListBox1.Items.Objects[CheckListBox1.ItemIndex]).something);
cbChecklistbox.Checked:=CheckListBox1.Checked[CheckListBox1.ItemIndex];
end;
end;
...
This works perfectly fine under Linux (GTK/2) and Windows, but under Cocoa things will crash left, right and center.
When assigning "true", to the checked[] property, things crash (SYSTEM$_$TOBJECT_$__$$_INHERITSFROM$TCLASS$$BOOLEAN);
CheckListBox1.Checked[CheckListBox1.Count-1]:=true;
When assigning the value "false" the checkbox remains checked even though reading the value always results in "false".
If the user unchecks and checks the item I do get the same crash again.
I've also tried AddItem, but this results in the same problem.
CheckListBox1.AddItem('some item text here',tmpMyClass);
I suspect that the objects are used for the checked[] values. Either that or I'm doing it completely wrong (which is an option as well of course).
So what am I doing wrong, or is this indeed a bug in the Cocoa widgetset?