Re: [Lazarus] ComboBox bug?

2011-09-23 Thread Mattias Gaertner

 


Hans-Peter Diettrich drdiettri...@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 (FSelStart0) or (fSelLength0)? 
 
 


 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
 --
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox bug?

2011-09-23 Thread Hans-Peter Diettrich

Mattias Gaertner schrieb:
Hans-Peter Diettrich drdiettri...@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.


Obviously - but why?


Thanks for the fixes :-)



  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.


I'm using the LCL since many years now, and I never noticed whether the 
LCL components use Ansi or UTF-8 strings. What's the default, and where 
is it (or should be) described?


DoDi


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox bug?

2011-09-23 Thread Mattias Gaertner
On Fri, 23 Sep 2011 16:23:02 +0200
Hans-Peter Diettrich drdiettri...@aol.com wrote:

 Mattias Gaertner schrieb:
  Hans-Peter Diettrich drdiettri...@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.
 
 Obviously - but why?

What else do you expect to happen?

 
[...]
 I'm using the LCL since many years now, and I never noticed whether the 
 LCL components use Ansi or UTF-8 strings. What's the default, and where 
 is it (or should be) described?

I guess with 'Ansi' you mean system encoding. Where does the LCL use
system encoding?

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox bug?

2011-09-23 Thread Hans-Peter Diettrich

Mattias Gaertner schrieb:

On Fri, 23 Sep 2011 16:23:02 +0200
Hans-Peter Diettrich drdiettri...@aol.com wrote:


Mattias Gaertner schrieb:
Hans-Peter Diettrich drdiettri...@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.

Obviously - but why?


What else do you expect to happen?


I wonder e.g. why ItemIndex is not tested before all further processing. 
When nothing has been selected before sorting, then after sorting 
nothing should be/become selected as well.




[...]
I'm using the LCL since many years now, and I never noticed whether the 
LCL components use Ansi or UTF-8 strings. What's the default, and where 
is it (or should be) described?


I guess with 'Ansi' you mean system encoding. Where does the LCL use
system encoding?


I'm just asking. I think that I've seen such behaviour somewhere, will 
watch for concrete occurences.


DoDi


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox bug?

2011-09-23 Thread Mattias Gaertner
On Fri, 23 Sep 2011 22:24:15 +0200
Hans-Peter Diettrich drdiettri...@aol.com wrote:

 Mattias Gaertner schrieb:
  On Fri, 23 Sep 2011 16:23:02 +0200
  Hans-Peter Diettrich drdiettri...@aol.com wrote:
  
  Mattias Gaertner schrieb:
  Hans-Peter Diettrich drdiettri...@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.
  Obviously - but why?
  
  What else do you expect to happen?
 
 I wonder e.g. why ItemIndex is not tested before all further processing. 
 When nothing has been selected before sorting, then after sorting 
 nothing should be/become selected as well.

ItemIndex -1 means the text does not exist in the list.


Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] ComboBox bug?

2011-09-22 Thread Hans-Peter Diettrich
During the revision of the StdCtrls documentation I came across an 
possible bug in TCustomComboBox.


Whenever the Sorted property is changed (SetSorted), UpdateSorted is 
called. It looks like UpdateSorted *always* sorts the list, as long as 
no handle (widget) has been created. This misbehaviour should affect at 
least the list items in design mode.


Can somebody confirm?

DoDi


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox bug?

2011-09-22 Thread Mattias Gaertner
On Thu, 22 Sep 2011 19:26:25 +0200
Hans-Peter Diettrich drdiettri...@aol.com wrote:

 During the revision of the StdCtrls documentation I came across an 
 possible bug in TCustomComboBox.
 
 Whenever the Sorted property is changed (SetSorted), UpdateSorted is 
 called. It looks like UpdateSorted *always* sorts the list, as long as 
 no handle (widget) has been created. This misbehaviour should affect at 
 least the list items in design mode.

What would be the right behavior?

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox bug?

2011-09-22 Thread Hans-Peter Diettrich

Mattias Gaertner schrieb:

Whenever the Sorted property is changed (SetSorted), UpdateSorted is 
called. It looks like UpdateSorted *always* sorts the list, as long as 
no handle (widget) has been created. This misbehaviour should affect at 
least the list items in design mode.


What would be the right behavior?


When Sorted is False, the items should not be sorted.

DoDi


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox bug?

2011-09-22 Thread Mattias Gaertner
On Thu, 22 Sep 2011 22:48:52 +0200
Hans-Peter Diettrich drdiettri...@aol.com wrote:

 Mattias Gaertner schrieb:
 
  Whenever the Sorted property is changed (SetSorted), UpdateSorted is 
  called. It looks like UpdateSorted *always* sorts the list, as long as 
  no handle (widget) has been created. This misbehaviour should affect at 
  least the list items in design mode.
  
  What would be the right behavior?
 
 When Sorted is False, the items should not be sorted.


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.

lIndex := FItems.IndexOf(lText);
if lIndex = 0 then
  ItemIndex := lIndex;
  end;
end;


Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox bug?

2011-09-22 Thread Hans-Peter Diettrich

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


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox Bug

2011-06-25 Thread Bart
See if Suse 11.4 comes with a program called gtk-demo (Suse 10.0 does).
(Just try running it form a commandline).

It has a combobox demo in it, with sources.
You could modify the source to make the combobox empty, build, run and
see if the bug is also present.
Then you can sent in a report to their bugracker.

Bart

On 6/24/11, David Copeland david.copel...@jsidata.ca wrote:
 Okay, thanks, but I have no idea what to say the bug is.


 On Fri, 2011-06-24 at 21:50 +0200, zeljko wrote:
 On Friday 24 of June 2011 19:51:35 David Copeland wrote:

  On Fri, 2011-06-24 at 19:41 +0200, Mattias Gaertner wrote:

   Then you found a buggy gtk theme.

   I don't know, if the LCL gtk2 interface can work around

   this.

   What Linux distribution is this?

 

  openSuse 11.4.


 There's a lot of bugs in oxygen-gtk theme, open issue at their
 tracker.

 zeljko

 --




 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] ComboBox Bug

2011-06-24 Thread David Copeland
Hi,

I believe I have found a ComboBox bug, but I don't how I should
categorize it. If you click on the expand list down arrow of the
control, the program is terminated and the following message is
displayed. 

david.copeland@dbc:~/projects/test ./CBBug
The program 'CBBug' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAlloc (insufficient resources for operation)'.
  (Details: serial 6119 error_code 11 request_code 53 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error()
function.)
david.copeland@dbc:~/projects/test 

My environment is ...

Lazarus version: SVN 31344. 
Widgetset: GTK2.
FPC version: 2.4.2
OS: openSuse 11.4

To reproduce the behaviour I created an app with one form containing
just the ComboBox. The Items list is empty. However, If I add lines to
Items, even a blank line, the above does not occur. 

I can send my test project if needed.

Regards,
Dave Copeland.




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox Bug

2011-06-24 Thread Mattias Gaertner
On Fri, 24 Jun 2011 11:48:08 -0400
David Copeland david.copel...@jsidata.ca wrote:

 Hi,
 
 I believe I have found a ComboBox bug, but I don't how I should
 categorize it. If you click on the expand list down arrow of the
 control, the program is terminated and the following message is
 displayed. 
 
 david.copeland@dbc:~/projects/test ./CBBug
 The program 'CBBug' received an X Window System error.
 This probably reflects a bug in the program.
 The error was 'BadAlloc (insufficient resources for operation)'.
   (Details: serial 6119 error_code 11 request_code 53 minor_code 0)
   (Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error()
 function.)

It works here.

Please test with ./CBBug --sync
And please test with some other themes to make sure it is a LCL bug
and not a buggy gtk theme engine.
Finally test with another window manager (do not confuse it with
another widget set).


 david.copeland@dbc:~/projects/test 
 
 My environment is ...
 
 Lazarus version: SVN 31344. 
 Widgetset: GTK2.
 FPC version: 2.4.2
 OS: openSuse 11.4
 
 To reproduce the behaviour I created an app with one form containing
 just the ComboBox. The Items list is empty. However, If I add lines to
 Items, even a blank line, the above does not occur. 
 
 I can send my test project if needed.

If it is just an empty combobox on a form you don't need to send it.

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox Bug

2011-06-24 Thread David Copeland
On Fri, 2011-06-24 at 18:22 +0200, Mattias Gaertner wrote:
  function.)
 
 It works here.
 
 Please test with ./CBBug --sync
 And please test with some other themes to make sure it is a LCL bug
 and not a buggy gtk theme engine.
 Finally test with another window manager (do not confuse it with
 another widget set).
 
 

Okay, will do.

 If it is just an empty combobox on a form you don't need to send it.

Yes, it's just that.

 
 Mattias
 




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox Bug

2011-06-24 Thread David Copeland
On Fri, 2011-06-24 at 18:22 +0200, Mattias Gaertner wrote: 
 Please test with ./CBBug --sync

No change, same problem.

 And please test with some other themes to make sure it is a LCL bug
 and not a buggy gtk theme engine.

I found a way to change the GTK Style. It was oxygen-gtk. When I
change it to either Raleigh or Sonar (the only other choices) the
problem does not occur.

 Finally test with another window manager (do not confuse it with
 another widget set).
 
I tried Ice, also, the problem does not occur.

Dave.




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox Bug

2011-06-24 Thread Mattias Gaertner
On Fri, 24 Jun 2011 13:22:49 -0400
David Copeland david.copel...@jsidata.ca wrote:

 On Fri, 2011-06-24 at 18:22 +0200, Mattias Gaertner wrote: 
  Please test with ./CBBug --sync
 
 No change, same problem.
 
  And please test with some other themes to make sure it is a LCL bug
  and not a buggy gtk theme engine.
 
 I found a way to change the GTK Style. It was oxygen-gtk. When I
 change it to either Raleigh or Sonar (the only other choices) the
 problem does not occur.

Then you found a buggy gtk theme.
I don't know, if the LCL gtk2 interface can work around
this.
What Linux distribution is this?

 
  Finally test with another window manager (do not confuse it with
  another widget set).
  
 I tried Ice, also, the problem does not occur.


Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox Bug

2011-06-24 Thread David Copeland
On Fri, 2011-06-24 at 19:41 +0200, Mattias Gaertner wrote:

 Then you found a buggy gtk theme.
 I don't know, if the LCL gtk2 interface can work around
 this.
 What Linux distribution is this?
 
openSuse 11.4.





--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] ComboBox Bug

2011-06-24 Thread zeljko
On Friday 24 of June 2011 19:51:35 David Copeland wrote:
 On Fri, 2011-06-24 at 19:41 +0200, Mattias Gaertner wrote:
  Then you found a buggy gtk theme.
  I don't know, if the LCL gtk2 interface can work around
  this.
  What Linux distribution is this?
 
 openSuse 11.4.

There's a lot of bugs in oxygen-gtk theme, open issue at their tracker.
zeljko
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus