remove backup system setup for the invalid layouts

this hans't helped at all since this sytem has been added
This commit is contained in:
Basile Burg 2019-02-03 15:44:21 +01:00
parent fa7979b764
commit e6204b49e1
1 changed files with 24 additions and 59 deletions

View File

@ -1858,7 +1858,7 @@ end;
procedure TMainForm.SaveDocking; procedure TMainForm.SaveDocking;
var var
xcfg: TXMLConfigStorage; x: TXMLConfigStorage;
i: integer; i: integer;
begin begin
if not fInitialized or not Visible then if not fInitialized or not Visible then
@ -1877,32 +1877,20 @@ begin
end; end;
forceDirectory(getDocPath); forceDirectory(getDocPath);
xcfg := TXMLConfigStorage.Create(getDocPath + 'docking.xml.tmp', false); x := TXMLConfigStorage.Create(getDocPath + 'docking.xml', false);
try try
DockMaster.SaveLayoutToConfig(xcfg); DockMaster.SaveLayoutToConfig(x);
xcfg.WriteToDisk; x.WriteToDisk;
// TODO-cdocking: remove this when AnchorDocking wont save anymore invalid layout
with TMemoryStream.Create do
try
LoadFromFile(getDocPath + 'docking.xml.tmp');
if Size < 10000 then
begin
SaveToFile(getDocPath + 'docking.xml');
SysUtils.DeleteFile(getDocPath + 'docking.xml.tmp');
end;
finally
free;
end;
finally finally
xcfg.Free; x.Free;
end; end;
xcfg := TXMLConfigStorage.Create(getDocPath + 'dockingopts.xml',false); x := TXMLConfigStorage.Create(getDocPath + 'dockingopts.xml',false);
try try
DockMaster.SaveSettingsToConfig(xcfg); DockMaster.SaveSettingsToConfig(x);
xcfg.WriteToDisk; x.WriteToDisk;
finally finally
xcfg.Free; x.Free;
end; end;
end; end;
@ -1956,18 +1944,7 @@ begin
begin begin
x := TXMLConfigStorage.Create(getDocPath + 'dockingopts.xml', true); x := TXMLConfigStorage.Create(getDocPath + 'dockingopts.xml', true);
try try
try DockMaster.LoadSettingsFromConfig(x);
DockMaster.LoadSettingsFromConfig(x);
except
exit;
end;
s := TMemoryStream.Create;
try
x.SaveToStream(s);
s.saveToFile(getDocPath + 'dockingopts.bak')
finally
s.Free;
end;
finally finally
x.Free; x.Free;
end; end;
@ -3637,41 +3614,29 @@ end;
procedure TMainForm.layoutSaveToFile(const fname: string); procedure TMainForm.layoutSaveToFile(const fname: string);
var var
xcfg: TXMLConfigStorage; x: TXMLConfigStorage;
i: integer; i: integer;
w: TDexedWidget;
h: TAnchorDockHostSite;
begin begin
DockMaster.RestoreLayouts.Clear; DockMaster.RestoreLayouts.Clear;
for i:= 0 to fWidgList.Count-1 do for i:= 0 to fWidgList.Count-1 do
begin begin
if not fWidgList.widget[i].isDockable then continue; w := fWidgList.widget[i];
if DockMaster.GetAnchorSite(fWidgList.widget[i]).WindowState = wsMinimized then if not w.isDockable then
DockMaster.GetAnchorSite(fWidgList.widget[i]).Close continue;
else if not DockMaster.GetAnchorSite(fWidgList.widget[i]).HasParent then h := DockMaster.GetAnchorSite(w);
DockMaster.GetAnchorSite(fWidgList.widget[i]).Close; if h.isNotNil and ((h.WindowState = wsMinimized) or (not h.HasParent)) then
h.Close;
end; end;
//
forceDirectory(fname.extractFilePath); forceDirectory(fname.extractFilePath);
xcfg := TXMLConfigStorage.Create(fname + '.tmp', false); x := TXMLConfigStorage.Create(fname, false);
try try
DockMaster.SaveLayoutToConfig(xcfg); DockMaster.SaveLayoutToConfig(x);
xcfg.WriteToDisk; x.WriteToDisk;
// prevent any invalid layout to be saved (AnchorDocking bug)
// TODO-cdocking: remove this when AnchorDocking wont save anymore invalid layout
with TMemoryStream.Create do
try
LoadFromFile(fname + '.tmp');
if Size < 10000 then
begin
SaveToFile(fname);
SysUtils.DeleteFile(fname + '.tmp');
end else
getMessageDisplay.message('prevented an invalid layout to be saved', nil,
amcApp, amkWarn);
finally
free;
end;
finally finally
xcfg.Free; x.Free;
end; end;
end; end;