[Lazarus] ComboBox bug?
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Fri Sep 23 05:40:31 CEST 2011
Mattias Gaertner schrieb:
> procedure TCustomComboBox.UpdateSorted;
> var
> lText: string;
> lIndex: integer;
> begin
> if HandleAllocated then
> TWSCustomComboBoxClass(WidgetSetClass).Sort(Self, Items, FSorted)
> else if FItems is TStringList then
> begin
> // remember text
> lText := Text;
> TStringList(FItems).Sorted := FSorted;
>
> When not FSorted then items are not sorted.
You're right.
But the following then is also evitable (but does no harm):
> lIndex := FItems.IndexOf(lText);
> if lIndex >= 0 then
> ItemIndex := lIndex;
What if lIndex=-1?
> end;
> end;
I stumbled across more such near-wrong code and comments, not worth bug
reports (in customcombobox.inc):
line 55:
if FSelStart <> FSelLength then
Why not: if FSelLength > 0?
line 183:
{------------------------------------------------------------------------------
Method: TCustomComboBox.DoChange
Not followed by DoChange - should be moved, removed or corrected
line 675:
// ToDo
Looks like Done (in InitializeWnd)
line 737:
{------------------------------------------------------------------------------
function TCustomComboBox.GetDroppedDown: Boolean;
Should read "SetDroppedDown" - complete or remove
line 1064:
Result := FReadOnly <> false;
Should read: Result := FReadOnly;
Another (general) one:
I found sometimes wrong descriptions for ...Length of strings,
mentioning *byte* count instead of count in *logical* UTF-8 chars. How
should such descriptions finally read?
1) Should a logical character count be implied, so that only really
different (byte/AnsiChar) counts should be mentioned explicitly?
2) Should count in [logical?] [UTF-8?] characters be mentioned wherever
applicable? [what about possible future change to Unicode/UTF-16?]
DoDi
More information about the Lazarus
mailing list