fix #133 - hang on reloading docking.xml

This commit is contained in:
Basile Burg 2017-04-29 10:02:00 +02:00
parent 3951dffd16
commit 8972a689a7
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 10 additions and 6 deletions

View File

@ -431,7 +431,7 @@ type
procedure InitOptionsMenu; procedure InitOptionsMenu;
procedure LoadSettings; procedure LoadSettings;
procedure SaveSettings; procedure SaveSettings;
procedure LoadDocking; function LoadDocking: boolean;
procedure SaveDocking; procedure SaveDocking;
procedure LoadLastDocsAndProj; procedure LoadLastDocsAndProj;
procedure SaveLastDocsAndProj; procedure SaveLastDocsAndProj;
@ -1432,8 +1432,8 @@ begin
end; end;
// load existing or default docking // load existing or default docking
if FileExists(getCoeditDocPath + 'docking.xml') then if FileExists(getCoeditDocPath + 'docking.xml') and LoadDocking() then
LoadDocking begin end
else else
begin begin
Height := 0; Height := 0;
@ -1588,7 +1588,8 @@ begin
DockMaster.SaveLayoutToConfig(xcfg); DockMaster.SaveLayoutToConfig(xcfg);
xcfg.WriteToDisk; xcfg.WriteToDisk;
// TODO-cdocking: remove this when AnchorDocking wont save anymore invalid layout // TODO-cdocking: remove this when AnchorDocking wont save anymore invalid layout
with TMemoryStream.Create do try with TMemoryStream.Create do
try
LoadFromFile(getCoeditDocPath + 'docking.xml.tmp'); LoadFromFile(getCoeditDocPath + 'docking.xml.tmp');
if Size < 10000 then if Size < 10000 then
begin begin
@ -1611,11 +1612,12 @@ begin
end; end;
end; end;
procedure TCEMainForm.LoadDocking; function TCEMainForm.LoadDocking: boolean;
var var
xcfg: TXMLConfigStorage; xcfg: TXMLConfigStorage;
str: TMemoryStream; str: TMemoryStream;
begin begin
result := false;
if fileExists(getCoeditDocPath + 'docking.xml') then if fileExists(getCoeditDocPath + 'docking.xml') then
begin begin
xcfg := TXMLConfigStorage.Create(getCoeditDocPath + 'docking.xml', true); xcfg := TXMLConfigStorage.Create(getCoeditDocPath + 'docking.xml', true);
@ -1656,6 +1658,7 @@ begin
xcfg.Free; xcfg.Free;
end; end;
end; end;
result := true;
end; end;
procedure TCEMainForm.FreeRunnableProc; procedure TCEMainForm.FreeRunnableProc;
@ -3176,7 +3179,8 @@ begin
xcfg.WriteToDisk; xcfg.WriteToDisk;
// prevent any invalid layout to be saved (AnchorDocking bug) // prevent any invalid layout to be saved (AnchorDocking bug)
// TODO-cdocking: remove this when AnchorDocking wont save anymore invalid layout // TODO-cdocking: remove this when AnchorDocking wont save anymore invalid layout
with TMemoryStream.Create do try with TMemoryStream.Create do
try
LoadFromFile(fname + '.tmp'); LoadFromFile(fname + '.tmp');
if Size < 10000 then if Size < 10000 then
begin begin