From dab68d045a87d5679e141f05bc60b083bb71e3b7 Mon Sep 17 00:00:00 2001 From: Joseph Battelle Date: Mon, 1 Feb 2021 23:44:06 -0800 Subject: [PATCH] Close tabs of Secondary Window on window close Prior to this change, for secondary windows, documents were in an inconsistent state when the window was closed. They also failed to re-open. --- IDE/src/IDEApp.bf | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index ef58e26a..beeda77b 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -1241,6 +1241,19 @@ namespace IDE if (mRunningTestScript) return true; + void CloseTabs() + { + WithDocumentTabbedViewsOf(window, scope (tabbedView) => { + tabbedView.CloseTabs(false, true); + }); + } + + void CloseWindow() + { + mMainWindow.SetForeground(); + window.Close(true); + } + List changedList = scope List(); defer ClearAndDeleteItems(changedList); WithSourceViewPanelsOf(window, scope (sourceViewPanel) => @@ -1252,8 +1265,11 @@ namespace IDE changedList.Add(fileName); } }); - if (changedList.Count == 0) + + if (changedList.Count == 0) { + CloseTabs(); return true; + } var aDialog = QuerySaveFiles(changedList, (WidgetWindow)window); aDialog.mDefaultButton = aDialog.AddButton("Save", new (evt) => { @@ -1268,8 +1284,8 @@ namespace IDE }); if (hadError) return; - mMainWindow.SetForeground(); - window.Close(true); + CloseTabs(); + CloseWindow(); }); aDialog.AddButton("Don't Save", new (evt) => { @@ -1279,8 +1295,8 @@ namespace IDE if (sourceViewPanel.HasUnsavedChanges()) _this.RevertSourceViewPanel(sourceViewPanel); }); - mMainWindow.SetForeground(); - window.Close(true); + CloseTabs(); + CloseWindow(); }); aDialog.mEscButton = aDialog.AddButton("Cancel");