mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-26 08:41:39 +01:00
fixed saving non loaded property
git-svn-id: trunk@8643 -
This commit is contained in:
parent
cdba5bcbeb
commit
ee01d36329
@ -42,3 +42,9 @@ or you can set ploReadOnIdle in TIEdit.Link.Options:
|
|||||||
Then the RTTI control will call LoadFromProperty everytime the Application gets
|
Then the RTTI control will call LoadFromProperty everytime the Application gets
|
||||||
idle.
|
idle.
|
||||||
|
|
||||||
|
BEWARE:
|
||||||
|
The on idle update will not load the property, if the control is focused.
|
||||||
|
You can use this:
|
||||||
|
// update focused control
|
||||||
|
GetPropertyLinkOfComponent(ActiveControl).LoadFromProperty;
|
||||||
|
|
||||||
|
|||||||
@ -76,7 +76,7 @@ type
|
|||||||
TPropertyLinkOptions = set of TPropertyLinkOption;
|
TPropertyLinkOptions = set of TPropertyLinkOption;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
DefaultLinkOptions = [ploReadOnIdle,ploAutoSave];
|
DefaultLinkOptions = [ploReadOnIdle,ploAutoSave];
|
||||||
|
|
||||||
Type
|
Type
|
||||||
|
|
||||||
@ -101,6 +101,7 @@ Type
|
|||||||
FOnTestEditor: TPropertyEditorFilterFunc;
|
FOnTestEditor: TPropertyEditorFilterFunc;
|
||||||
FOptions: TPropertyLinkOptions;
|
FOptions: TPropertyLinkOptions;
|
||||||
FOwner: TComponent;
|
FOwner: TComponent;
|
||||||
|
FPropertyLoaded: boolean;
|
||||||
FSaveEnabled: boolean;
|
FSaveEnabled: boolean;
|
||||||
FTIElementName: string;
|
FTIElementName: string;
|
||||||
FTIObject: TPersistent;
|
FTIObject: TPersistent;
|
||||||
@ -181,6 +182,7 @@ Type
|
|||||||
property Options: TPropertyLinkOptions read FOptions write SetOptions default DefaultLinkOptions;
|
property Options: TPropertyLinkOptions read FOptions write SetOptions default DefaultLinkOptions;
|
||||||
property Owner: TComponent read FOwner;
|
property Owner: TComponent read FOwner;
|
||||||
property SaveEnabled: boolean read FSaveEnabled write FSaveEnabled;
|
property SaveEnabled: boolean read FSaveEnabled write FSaveEnabled;
|
||||||
|
property PropertyLoaded: boolean read FPropertyLoaded write FPropertyLoaded;
|
||||||
property TIObject: TPersistent read FTIObject write SetTIObject;
|
property TIObject: TPersistent read FTIObject write SetTIObject;
|
||||||
property TIPropertyName: string read FTIPropertyName write SetTIPropertyName;
|
property TIPropertyName: string read FTIPropertyName write SetTIPropertyName;
|
||||||
property TIElementName: string read FTIElementName write SetTIElementName;
|
property TIElementName: string read FTIElementName write SetTIElementName;
|
||||||
@ -1648,6 +1650,7 @@ begin
|
|||||||
then
|
then
|
||||||
raise Exception('TCustomPropertyLink.SetObjectAndProperty invalid identifier "'+NewPropertyName+'"');
|
raise Exception('TCustomPropertyLink.SetObjectAndProperty invalid identifier "'+NewPropertyName+'"');
|
||||||
if (NewPersistent<>TIObject) or (NewPropertyName<>TIPropertyName) then begin
|
if (NewPersistent<>TIObject) or (NewPropertyName<>TIPropertyName) then begin
|
||||||
|
FPropertyLoaded:=false;
|
||||||
if (FTIObject is TComponent) then begin
|
if (FTIObject is TComponent) then begin
|
||||||
AComponent:=TComponent(FTIObject);
|
AComponent:=TComponent(FTIObject);
|
||||||
AComponent.RemoveFreeNotification(FLinkNotifier);
|
AComponent.RemoveFreeNotification(FLinkNotifier);
|
||||||
@ -1677,6 +1680,7 @@ var
|
|||||||
OldEditorExisted: Boolean;
|
OldEditorExisted: Boolean;
|
||||||
begin
|
begin
|
||||||
if (FEditor<>nil) or (FTIObject=nil) or (FTIPropertyName='') then exit;
|
if (FEditor<>nil) or (FTIObject=nil) or (FTIPropertyName='') then exit;
|
||||||
|
FPropertyLoaded:=false;
|
||||||
//debugln('TCustomPropertyLink.CreateEditor A ',FTIObject.ClassName+':'+FTIPropertyName);
|
//debugln('TCustomPropertyLink.CreateEditor A ',FTIObject.ClassName+':'+FTIPropertyName);
|
||||||
OldEditorExisted:=FEditor<>nil;
|
OldEditorExisted:=FEditor<>nil;
|
||||||
CreateHook;
|
CreateHook;
|
||||||
@ -1775,6 +1779,7 @@ end;
|
|||||||
|
|
||||||
procedure TCustomPropertyLink.SaveToProperty;
|
procedure TCustomPropertyLink.SaveToProperty;
|
||||||
begin
|
begin
|
||||||
|
if Self=nil then exit;
|
||||||
if (not SaveEnabled) then exit;
|
if (not SaveEnabled) then exit;
|
||||||
if (Owner<>nil)
|
if (Owner<>nil)
|
||||||
and ([csDesigning,csDestroying,csLoading]*Owner.ComponentState<>[]) then exit;
|
and ([csDesigning,csDestroying,csLoading]*Owner.ComponentState<>[]) then exit;
|
||||||
@ -1784,12 +1789,14 @@ end;
|
|||||||
|
|
||||||
procedure TCustomPropertyLink.EditingDone;
|
procedure TCustomPropertyLink.EditingDone;
|
||||||
begin
|
begin
|
||||||
If ploAutoSave in Options then
|
if Self=nil then exit;
|
||||||
|
if (ploAutoSave in Options) and PropertyLoaded then
|
||||||
SaveToProperty;
|
SaveToProperty;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomPropertyLink.SetAsText(const NewText: string);
|
procedure TCustomPropertyLink.SetAsText(const NewText: string);
|
||||||
begin
|
begin
|
||||||
|
if NewText='333' then DumpStack;
|
||||||
try
|
try
|
||||||
if (FTIElementName='') then
|
if (FTIElementName='') then
|
||||||
FEditor.SetValue(AliasValues.AliasToValue(NewText))
|
FEditor.SetValue(AliasValues.AliasToValue(NewText))
|
||||||
@ -2058,8 +2065,10 @@ end;
|
|||||||
|
|
||||||
procedure TCustomPropertyLink.LoadFromProperty;
|
procedure TCustomPropertyLink.LoadFromProperty;
|
||||||
begin
|
begin
|
||||||
|
if Self=nil then exit;
|
||||||
if (Owner<>nil) and (csDestroying in Owner.ComponentState) then exit;
|
if (Owner<>nil) and (csDestroying in Owner.ComponentState) then exit;
|
||||||
CreateEditor;
|
CreateEditor;
|
||||||
|
FPropertyLoaded:=true;
|
||||||
if Assigned(OnLoadFromProperty) then OnLoadFromProperty(Self);
|
if Assigned(OnLoadFromProperty) then OnLoadFromProperty(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -1511,7 +1511,8 @@ begin
|
|||||||
|
|
||||||
if (Instance is TForm) then begin
|
if (Instance is TForm) then begin
|
||||||
AForm:=TForm(Instance);
|
AForm:=TForm(Instance);
|
||||||
if (FMainForm = nil) and not (AForm.FormStyle in [fsMDIChild, fsSplash]) then begin
|
if (FMainForm = nil) and not (AForm.FormStyle in [fsMDIChild, fsSplash])
|
||||||
|
then begin
|
||||||
FMainForm := AForm;
|
FMainForm := AForm;
|
||||||
AForm.HandleNeeded;
|
AForm.HandleNeeded;
|
||||||
end else begin
|
end else begin
|
||||||
|
|||||||
@ -39,8 +39,8 @@ begin
|
|||||||
ChildSizing.ShrinkVertical:=crsScaleChilds;
|
ChildSizing.ShrinkVertical:=crsScaleChilds;
|
||||||
ChildSizing.EnlargeHorizontal:=crsHomogenousChildResize;
|
ChildSizing.EnlargeHorizontal:=crsHomogenousChildResize;
|
||||||
ChildSizing.EnlargeVertical:=crsHomogenousChildResize;
|
ChildSizing.EnlargeVertical:=crsHomogenousChildResize;
|
||||||
ChildSizing.LeftRightSpacing:=5;
|
ChildSizing.LeftRightSpacing:=6;
|
||||||
ChildSizing.TopBottomSpacing:=5;
|
ChildSizing.TopBottomSpacing:=6;
|
||||||
SetInitialBounds(0,0,150,100);
|
SetInitialBounds(0,0,150,100);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -49,8 +49,8 @@ begin
|
|||||||
ChildSizing.ShrinkVertical:=crsScaleChilds;
|
ChildSizing.ShrinkVertical:=crsScaleChilds;
|
||||||
ChildSizing.EnlargeHorizontal:=crsHomogenousChildResize;
|
ChildSizing.EnlargeHorizontal:=crsHomogenousChildResize;
|
||||||
ChildSizing.EnlargeVertical:=crsHomogenousChildResize;
|
ChildSizing.EnlargeVertical:=crsHomogenousChildResize;
|
||||||
ChildSizing.LeftRightSpacing:=5;
|
ChildSizing.LeftRightSpacing:=6;
|
||||||
ChildSizing.TopBottomSpacing:=5;
|
ChildSizing.TopBottomSpacing:=6;
|
||||||
SetInitialBounds(0,0,150,100);
|
SetInitialBounds(0,0,150,100);
|
||||||
TabStop := True;
|
TabStop := True;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user