From 201421bcbf5bea3fb3e70a84ae1f3d66767307df Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 29 Sep 2014 18:53:52 +0000 Subject: [PATCH] LCL: TXML/IniPropStorage: do not load/save at designtime git-svn-id: trunk@46350 - --- lcl/inipropstorage.pas | 5 ++++- lcl/propertystorage.pas | 8 +++++--- lcl/xmlpropstorage.pas | 5 ++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lcl/inipropstorage.pas b/lcl/inipropstorage.pas index f5250ba32f..e7e5714e90 100644 --- a/lcl/inipropstorage.pas +++ b/lcl/inipropstorage.pas @@ -88,7 +88,8 @@ begin FreeStorage; end; FReadOnly:=ReadOnly; - FInifile:=IniFileClass.Create(GetIniFileName); + if not (csDesigning in ComponentState) then + FInifile:=IniFileClass.Create(GetIniFileName); end; Inc(FCount); end; @@ -107,6 +108,8 @@ function TCustomIniPropStorage.GetIniFileName: string; begin If (FIniFileName<>'') then Result:=FIniFileName + else if csDesigning in ComponentState then + raise Exception.Create('TCustomIniPropStorage.GetIniFileName: missing Filename') else {$ifdef unix} Result:=IncludeTrailingPathDelimiter(GetEnvironmentVariableUTF8('HOME')) diff --git a/lcl/propertystorage.pas b/lcl/propertystorage.pas index 6c72aa24d3..c6f5557217 100644 --- a/lcl/propertystorage.pas +++ b/lcl/propertystorage.pas @@ -521,7 +521,7 @@ end; procedure TCustomPropertyStorage.Save; begin - if Active then begin + if Active and not (csDesigning in ComponentState) then begin StorageNeeded(False); Try if Assigned(FOnSavingProperties) then @@ -540,7 +540,7 @@ end; procedure TCustomPropertyStorage.Restore; begin - if Active then begin + if Active and not (csDesigning in ComponentState) then begin FSaved := False; StorageNeeded(True); try @@ -577,6 +577,7 @@ begin StoreObjectsProps(Owner,AStoredList); except // ignore any exceptions + // ToDo: Why? // ToDo: warn if unable to write file end; finally @@ -610,6 +611,7 @@ begin LoadObjectsProps(Owner,L); except { ignore any exceptions } + // ToDo: Why? end; finally Free; @@ -693,7 +695,7 @@ function TCustomPropertyStorage.ReadInteger(const Ident: string; DefaultValue: L begin StorageNeeded(True); try - Result := DoReadInteger(RootSection, Ident, DefaultValue); + Result := DoReadInteger(RootSection, Ident, DefaultValue); finally FreeStorage; end; diff --git a/lcl/xmlpropstorage.pas b/lcl/xmlpropstorage.pas index 59d996fe54..5b7fc2dd00 100644 --- a/lcl/xmlpropstorage.pas +++ b/lcl/xmlpropstorage.pas @@ -119,7 +119,8 @@ end; procedure TCustomXMLPropStorage.StorageNeeded(ReadOnly: Boolean); begin - If (FXML=Nil) then begin + If (FXML=Nil) and not (csDesigning in ComponentState) then + begin FXML:=TPropStorageXMLConfig.Create(nil); FXML.FileName := GetXMLFileName; end; @@ -142,6 +143,8 @@ function TCustomXMLPropStorage.GetXMLFileName: string; begin if (FFileName<>'') then Result:=FFileName + else if csDesigning in ComponentState then + raise Exception.Create('TCustomXMLPropStorage.GetXMLFileName: missing Filename') else {$ifdef unix} Result:=IncludeTrailingPathDelimiter(GetEnvironmentVariableUTF8('HOME'))