From f74eaa0b7590e58ea3ac6376461dceac0d4a9faf Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Fri, 27 Mar 2015 04:19:45 +0100 Subject: [PATCH] temp fix, docking, prevent any invalid layout to be saved --- src/ce_main.pas | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/ce_main.pas b/src/ce_main.pas index 75b891c5..95d36f2e 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -585,10 +585,21 @@ begin end; // forceDirectory(getCoeditDocPath); - xcfg := TXMLConfigStorage.Create(getCoeditDocPath + 'docking.xml',false); + xcfg := TXMLConfigStorage.Create(getCoeditDocPath + 'docking.xml.tmp', false); try DockMaster.SaveLayoutToConfig(xcfg); xcfg.WriteToDisk; + // TODO: this when AnchorDocking wiont save anymore invalid layout + with TMemoryStream.Create do try + LoadFromFile(getCoeditDocPath + 'docking.xml.tmp'); + if Size < 10000 then + begin + SaveToFile(getCoeditDocPath + 'docking.xml'); + SysUtils.DeleteFile(getCoeditDocPath + 'docking.xml.tmp'); + end; + finally + free; + end; finally xcfg.Free; end; @@ -1455,7 +1466,6 @@ var xcfg: TXMLConfigStorage; i: NativeInt; begin - // TODO-cbugfix: possible loading AV, xml saved after undocking some widgets, xml file abnormal size, seems to be related to Anchordocking itself, not its usage. for i:= 0 to fWidgList.Count-1 do begin if not fWidgList.widget[i].isDockable then continue; @@ -1466,10 +1476,24 @@ begin end; // forceDirectory(extractFilePath(aFilename)); - xcfg := TXMLConfigStorage.Create(aFilename, false); + xcfg := TXMLConfigStorage.Create(aFilename + '.tmp', false); try DockMaster.SaveLayoutToConfig(xcfg); xcfg.WriteToDisk; + // prevent any invalid layout to be saved (AnchorDocking bug) + // TODO: remove this when AnchorDocking wiont save anymore invalid layout + with TMemoryStream.Create do try + LoadFromFile(aFilename + '.tmp'); + if Size < 10000 then + begin + SaveToFile(aFilename); + SysUtils.DeleteFile(aFilename + '.tmp'); + end else + getMessageDisplay.message('prevented an invalid layout to be saved', nil, + amcApp, amkWarn); + finally + free; + end; finally xcfg.Free; end;