[Lazarus] ComboBox bug?

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Sep 23 12:13:17 CEST 2011


 


Hans-Peter Diettrich <DrDiettrich1 at aol.com> hat am 23. September 2011 um 05:40
geschrieben:

> 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? 
Nothing. 
 
 

>
> >   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? 
Why not  if (FSelStart>0) or (fSelLength>0)? 
 
 

>
> line 183:
> {------------------------------------------------------------------------------
>    Method: TCustomComboBox.DoChange
> Not followed by DoChange - should be moved, removed or corrected 
fixed  
 
 

>
> line 675:
>    // ToDo
> Looks like Done (in InitializeWnd) 
removed 
 
 

>
> line 737:
> {------------------------------------------------------------------------------
>    function TCustomComboBox.GetDroppedDown: Boolean;
> Should read "SetDroppedDown" - complete or remove 
removed 
 

>
> line 1064:
>      Result := FReadOnly <> false;
> Should read: Result := FReadOnly; 
IMO such things are the programmers choice.
If we would start changing such things we would have to reject many patches.  
 
 

>
>
> 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?] 
I think it should be mentioned wherever applicable. Of course it is enough to
add a link to a place where it is explained in detail.  
  
Mattias
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110923/8797f859/attachment-0003.html>


More information about the Lazarus mailing list