diff --git a/components/education/eduenvoptsframe.pas b/components/education/eduenvoptsframe.pas index 949b313ec1..c00e4638b3 100644 --- a/components/education/eduenvoptsframe.pas +++ b/components/education/eduenvoptsframe.pas @@ -40,10 +40,11 @@ type FEnabled: boolean; procedure SetEnabled(const AValue: boolean); public + constructor Create; destructor Destroy; override; function Load(Config: TConfigStorage): TModalResult; override; function Save(Config: TConfigStorage): TModalResult; override; - property Enabled: boolean read FEnabled write SetEnabled; + property Enabled: boolean read FEnabled write SetEnabled default true; end; { TEduEnvFrame } @@ -94,17 +95,20 @@ procedure TEduEnvFrame.ReadSettings(AOptions: TAbstractIDEOptions); begin debugln(['TEduEnvFrame.ReadSettings ',EduGeneralOptions.Enabled]); EnableCheckBox.Checked:=EduGeneralOptions.Enabled; + DebugLn(['TEduEnvFrame.ReadSettings ',EnableCheckBox.Checked,' ',EduGeneralOptions.Enabled]); end; procedure TEduEnvFrame.WriteSettings(AOptions: TAbstractIDEOptions); begin debugln(['TEduEnvFrame.WriteSettings ',EnableCheckBox.Checked]); EduGeneralOptions.Enabled:=EnableCheckBox.Checked; + if EducationOptions.Save<>mrOk then + DebugLn(['TEduEnvFrame.WriteSettings Failed']); end; class function TEduEnvFrame.SupportedOptionsClass: TAbstractIDEOptionsClass; begin - Result := TEduOptions; + Result := nil; end; { TEduGeneralOptions } @@ -116,6 +120,13 @@ begin Changed; end; +constructor TEduGeneralOptions.Create; +begin + inherited Create; + Name:='General'; + FEnabled:=true; +end; + destructor TEduGeneralOptions.Destroy; begin if EduGeneralOptions=Self then EduGeneralOptions:=nil; @@ -124,14 +135,14 @@ end; function TEduGeneralOptions.Load(Config: TConfigStorage): TModalResult; begin + FEnabled:=Config.GetValue('Enabled',True); Result:=inherited Load(Config); - FEnabled:=Config.GetValue('Enabled',true); end; function TEduGeneralOptions.Save(Config: TConfigStorage): TModalResult; begin - Result:=inherited Save(Config); Config.SetDeleteValue('Enabled',Enabled,true); + Result:=inherited Save(Config); end; initialization diff --git a/components/education/eduoptions.pas b/components/education/eduoptions.pas index 3b6042b7a8..372fb4acdd 100644 --- a/components/education/eduoptions.pas +++ b/components/education/eduoptions.pas @@ -24,8 +24,8 @@ unit EduOptions; interface uses - Classes, SysUtils, LazConfigStorage, Controls, Forms, BaseIDEIntf, FileUtil, - LazIDEIntf, IDEOptionsIntf; + Classes, SysUtils, LCLProc, LazConfigStorage, Controls, Forms, BaseIDEIntf, + FileUtil, LazIDEIntf, IDEOptionsIntf; resourcestring EduRSEducation = 'Education'; @@ -206,9 +206,12 @@ begin Child:=Childs[i]; if (Child.Name='') or (not IsValidIdent(Child.Name)) then continue; Config.AppendBasePath(Child.Name); - Result:=Child.Load(Config); - if Result<>mrOK then exit; - Config.UndoAppendBasePath; + try + Result:=Child.Load(Config); + if Result<>mrOK then exit; + finally + Config.UndoAppendBasePath; + end; end; Result:=mrOk; end; @@ -222,9 +225,12 @@ begin Child:=Childs[i]; if (Child.Name='') or (not IsValidIdent(Child.Name)) then continue; Config.AppendBasePath(Child.Name); - Result:=Child.Save(Config); - if Result<>mrOK then exit; - Config.UndoAppendBasePath; + try + Result:=Child.Save(Config); + if Result<>mrOK then exit; + finally + Config.UndoAppendBasePath; + end; end; Result:=mrOk; end; @@ -295,7 +301,7 @@ end; function TEduOptions.Load: TModalResult; begin - Result:=LoadFromFile(GetFullFilename); + Result:=LoadFromFile(Filename); FLastSavedChangeStep:=TEduOptsRootNode(Root).ChangeStep; end;