mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-06 06:52:36 +02:00
IDE: load desktops: check file version when loading old data, cleaning up old data
git-svn-id: trunk@49806 -
This commit is contained in:
parent
aebdc634cf
commit
c36aa6da8e
@ -1778,19 +1778,19 @@ begin
|
||||
FDesktops.Clear;
|
||||
FDesktops.SetConfig(FXMLCfg, FConfigStore);
|
||||
CurPath := 'Desktops/';
|
||||
FActiveDesktopName := '';
|
||||
if FXMLCfg.HasPath(CurPath, True) then
|
||||
begin
|
||||
// New path under Desktops/. Default=1 forces reading default values always.
|
||||
// Default=1 forces reading default values always.
|
||||
FDebugDesktopName := FXMLCfg.GetValue(CurPath+'DebugDesktop', '');
|
||||
FActiveDesktopName := FXMLCfg.GetValue(CurPath+'ActiveDesktop', '');
|
||||
j := FXMLCfg.GetValue(CurPath+'Count', 1);
|
||||
for i := 1 to j do
|
||||
FDesktops.AddFromCfg(CurPath+'Desktop'+IntToStr(i)+'/');
|
||||
end;
|
||||
|
||||
FActiveDesktopName := FXMLCfg.GetValue(CurPath+'ActiveDesktop', '');
|
||||
end else
|
||||
FActiveDesktopName := '';
|
||||
|
||||
//load default desktop - backwards compatibility - or create a new default desktop
|
||||
if FFileVersion<109 then begin
|
||||
//load old default desktop - backwards compatibility - or create a new default desktop
|
||||
CurPath := 'Desktop/'; // New place: Desktop/
|
||||
if not FXMLCfg.HasPath(CurPath, True) then
|
||||
CurPath := Path+'Desktop/'; // Old place: EnvironmentOptions/Desktop/
|
||||
@ -1802,6 +1802,11 @@ begin
|
||||
ActiveDesktop.SetConfig(FXMLCfg, FConfigStore);
|
||||
ActiveDesktop.Load(CurPath);
|
||||
end;
|
||||
end;
|
||||
if FFileVersion<=109 then begin
|
||||
FXMLCfg.DeletePath('Desktop');
|
||||
FXMLCfg.DeletePath(CurPath+'Desktop');
|
||||
end;
|
||||
|
||||
Desktop.Assign(ActiveDesktop, False);
|
||||
|
||||
@ -2107,13 +2112,10 @@ begin
|
||||
FDesktops[i].Save(CurPath+'Desktop'+IntToStr(i+1)+'/');
|
||||
end;
|
||||
|
||||
FXMLCfg.DeletePath('Desktop/');
|
||||
|
||||
FXMLCfg.Flush;
|
||||
FileUpdated;
|
||||
except
|
||||
on E: Exception do begin
|
||||
// ToDo
|
||||
DebugLn('[TEnvironmentOptions.Save] error writing "',Filename,'": ',E.Message);
|
||||
end;
|
||||
end;
|
||||
@ -2465,7 +2467,8 @@ begin
|
||||
end;
|
||||
|
||||
function TEnvironmentOptions.GetActiveDesktop: TDesktopOpt;
|
||||
procedure _UseDefault;
|
||||
|
||||
procedure ChooseDefault;
|
||||
begin
|
||||
//use default desktop name
|
||||
if Assigned(IDEDockMaster) then
|
||||
@ -2473,19 +2476,20 @@ function TEnvironmentOptions.GetActiveDesktop: TDesktopOpt;
|
||||
else
|
||||
FActiveDesktopName := 'default';
|
||||
end;
|
||||
|
||||
begin
|
||||
if FActiveDesktopName <> '' then
|
||||
begin
|
||||
Result := FDesktops.Find(FActiveDesktopName);
|
||||
if Assigned(Result) and Result.Compatible then//the selected desktop is supported (docked/docked)
|
||||
if Assigned(Result) and Result.Compatible then
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//the selected desktop is unsupported (docked/undocked)
|
||||
// -> use default
|
||||
_UseDefault;
|
||||
ChooseDefault;
|
||||
Result := FDesktops.Find(FActiveDesktopName);
|
||||
if Assigned(Result) and Result.Compatible then//the default desktop exists and is supported
|
||||
if Assigned(Result) and Result.Compatible then
|
||||
Exit;
|
||||
|
||||
//recreate desktop with ActiveDesktopName
|
||||
|
Loading…
Reference in New Issue
Block a user