LCL: fixed getting TSpinEdit.Caption before the handle has been created (bug #2075)

git-svn-id: trunk@10547 -
This commit is contained in:
vincents 2007-01-31 12:22:36 +00:00
parent a62c67db39
commit 5bee5ec659
9 changed files with 262 additions and 0 deletions

6
.gitattributes vendored
View File

@ -2816,6 +2816,12 @@ packager/ucomponentmanmain.pas svneol=native#text/pascal
packager/ufrmaddcomponent.lfm svneol=native#text/plain
packager/ufrmaddcomponent.lrs svneol=native#text/pascal
packager/ufrmaddcomponent.pas svneol=native#text/pascal
test/bugs/2075/bug2075.lpi svneol=native#text/plain
test/bugs/2075/bug2075.lpr svneol=native#text/plain
test/bugs/2075/expected.txt svneol=native#text/plain
test/bugs/2075/unit1.lfm svneol=native#text/plain
test/bugs/2075/unit1.lrs svneol=native#text/plain
test/bugs/2075/unit1.pas svneol=native#text/plain
test/bugs/7462/bug7462.lpi svneol=native#text/plain
test/bugs/7462/bug7462.lpr svneol=native#text/plain
test/bugs/7462/expected.txt svneol=native#text/plain

View File

@ -38,6 +38,14 @@ begin
Result:=true; // fpc bug, default value is always 0
end;
function TCustomFloatSpinEdit.RealGetText: TCaption;
begin
if HandleAllocated then
Result:=inherited RealGetText
else
Result:=FloatToStrF(FValue, ffFixed, 20, DecimalPlaces);
end;
procedure TCustomFloatSpinEdit.TextChanged;
var
lPrevValue: single;

View File

@ -65,6 +65,7 @@ type
Procedure UpdateControl;
function ValueIsStored: boolean;
protected
function RealGetText: TCaption; override;
procedure TextChanged; override;
procedure SetDecimals(Num: Integer);
function GetValue: Single;

View File

@ -0,0 +1,65 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="5"/>
<General>
<SessionStorage Value="InIDEConfig"/>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="bug2075.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="bug2075"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<ComponentName Value="Form1"/>
<IsPartOfProject Value="True"/>
<ResourceFilename Value="unit1.lrs"/>
<UnitName Value="Unit1"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<SearchPaths>
<SrcPath Value="$(LazarusDir)\lcl\;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)\"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Linking>
<Debugging>
<UseLineInfoUnit Value="False"/>
</Debugging>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -0,0 +1,18 @@
program bug2075;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms
{ add your units here }, Unit1;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,4 @@
42.42
42.42
1.131
1.131

71
test/bugs/2075/unit1.lfm Normal file
View File

@ -0,0 +1,71 @@
object Form1: TForm1
Left = 615
Height = 127
Top = 326
Width = 218
HorzScrollBar.Page = 217
VertScrollBar.Page = 126
ActiveControl = FloatSpinEdit1
Caption = 'Form1'
OnCreate = FormCreate
object Label1: TLabel
Left = 16
Height = 14
Top = 17
Width = 32
Caption = 'Label1'
Color = clNone
ParentColor = False
end
object Label2: TLabel
Left = 16
Height = 14
Top = 48
Width = 32
Caption = 'Label2'
Color = clNone
ParentColor = False
end
object FloatSpinEdit1: TFloatSpinEdit
Left = 72
Height = 23
Top = 8
Width = 130
Increment = 1
MaxValue = 100
TabOrder = 0
Value = 42.4199981689453
end
object CloseButton: TButton
Left = 72
Height = 25
Top = 88
Width = 75
BorderSpacing.InnerBorder = 4
Caption = 'Close'
OnClick = CloseButtonClick
TabOrder = 1
end
object FloatSpinEdit2: TFloatSpinEdit
Left = 72
Height = 23
Top = 40
Width = 130
DecimalPlaces = 3
Increment = 1
MaxValue = 200
TabOrder = 2
Value = 1.13100004196167
end
object ApplicationProperties1: TApplicationProperties
CaptureExceptions = True
HintColor = clInfoBk
HintHidePause = 2500
HintPause = 500
HintShortCuts = True
ShowHint = True
OnIdle = ApplicationProperties1Idle
left = 8
top = 88
end
end

24
test/bugs/2075/unit1.lrs Normal file
View File

@ -0,0 +1,24 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'g'#2#6'Height'#2''#3'Top'#3'F'#1#5'Width'
+#3#218#0#18'HorzScrollBar.Page'#3#217#0#18'VertScrollBar.Page'#2'~'#13'Activ'
+'eControl'#7#14'FloatSpinEdit1'#7'Caption'#6#5'Form1'#8'OnCreate'#7#10'FormC'
+'reate'#0#6'TLabel'#6'Label1'#4'Left'#2#16#6'Height'#2#14#3'Top'#2#17#5'Widt'
+'h'#2' '#7'Caption'#6#6'Label1'#5'Color'#7#6'clNone'#11'ParentColor'#8#0#0#6
+'TLabel'#6'Label2'#4'Left'#2#16#6'Height'#2#14#3'Top'#2'0'#5'Width'#2' '#7'C'
+'aption'#6#6'Label2'#5'Color'#7#6'clNone'#11'ParentColor'#8#0#0#14'TFloatSpi'
+'nEdit'#14'FloatSpinEdit1'#4'Left'#2'H'#6'Height'#2#23#3'Top'#2#8#5'Width'#3
+#130#0#9'Increment'#5#0#0#0#0#0#0#0#128#255'?'#8'MaxValue'#5#0#0#0#0#0#0#0
+#200#5'@'#8'TabOrder'#2#0#5'Value'#5#0#0#0#0#0#20#174#169#4'@'#0#0#7'TButton'
+#11'CloseButton'#4'Left'#2'H'#6'Height'#2#25#3'Top'#2'X'#5'Width'#2'K'#25'Bo'
+'rderSpacing.InnerBorder'#2#4#7'Caption'#6#5'Close'#7'OnClick'#7#16'CloseBut'
+'tonClick'#8'TabOrder'#2#1#0#0#14'TFloatSpinEdit'#14'FloatSpinEdit2'#4'Left'
+#2'H'#6'Height'#2#23#3'Top'#2'('#5'Width'#3#130#0#13'DecimalPlaces'#2#3#9'In'
+'crement'#5#0#0#0#0#0#0#0#128#255'?'#8'MaxValue'#5#0#0#0#0#0#0#0#200#6'@'#8
+'TabOrder'#2#2#5'Value'#5#0#0#0#0#0#156#196#144#255'?'#0#0#22'TApplicationPr'
+'operties'#22'ApplicationProperties1'#17'CaptureExceptions'#9#9'HintColor'#7
+#8'clInfoBk'#13'HintHidePause'#3#196#9#9'HintPause'#3#244#1#13'HintShortCuts'
+#9#8'ShowHint'#9#6'OnIdle'#7#26'ApplicationProperties1Idle'#4'left'#2#8#3'to'
+'p'#2'X'#0#0#0
]);

65
test/bugs/2075/unit1.pas Normal file
View File

@ -0,0 +1,65 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
Spin, Buttons, LCLProc;
type
{ TForm1 }
TForm1 = class(TForm)
ApplicationProperties1: TApplicationProperties;
CloseButton: TButton;
FloatSpinEdit1: TFloatSpinEdit;
FloatSpinEdit2: TFloatSpinEdit;
Label1: TLabel;
Label2: TLabel;
procedure ApplicationProperties1Idle(Sender: TObject; var Done: Boolean);
procedure CloseButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
DecimalSeparator := '.';
Label1.Caption := FloatSpinEdit1.Caption;
Label2.Caption := FloatSpinEdit2.Caption;
end;
procedure TForm1.CloseButtonClick(Sender: TObject);
begin
Close;
end;
procedure TForm1.ApplicationProperties1Idle(Sender: TObject; var Done: Boolean);
begin
if ParamStr(1)='--runtest' then begin
DebugLn(FloatSpinEdit1.Caption);
DebugLn(Label1.Caption);
DebugLn(FloatSpinEdit2.Caption);
DebugLn(Label2.Caption);
Close;
end;
end;
initialization
{$I unit1.lrs}
end.