diff --git a/src/Main/Base/Project/Src/Commands/FileMenuCommands.cs b/src/Main/Base/Project/Src/Commands/FileMenuCommands.cs
index a7b07b2a690..f5e0bb27d30 100644
--- a/src/Main/Base/Project/Src/Commands/FileMenuCommands.cs
+++ b/src/Main/Base/Project/Src/Commands/FileMenuCommands.cs
@@ -40,8 +40,7 @@ public class CloseSolution : AbstractMenuCommand
public override void Run()
{
ProjectService.SaveSolutionPreferences();
- WorkbenchSingleton.Workbench.CloseAllViews();
- if (WorkbenchSingleton.Workbench.WorkbenchWindowCollection.Count == 0) {
+ if (WorkbenchSingleton.Workbench.CloseAllSolutionViews()) {
ProjectService.CloseSolution();
}
}
diff --git a/src/Main/Base/Project/Src/Gui/IWorkbench.cs b/src/Main/Base/Project/Src/Gui/IWorkbench.cs
index 5f4afa32e3e..3e44abe3804 100644
--- a/src/Main/Base/Project/Src/Gui/IWorkbench.cs
+++ b/src/Main/Base/Project/Src/Gui/IWorkbench.cs
@@ -163,6 +163,14 @@ bool IsActiveWindow {
///
void CloseAllViews();
+ ///
+ /// Closes all views related to current solution.
+ ///
+ ///
+ /// True if all views were closed properly, false if closing was aborted.
+ ///
+ bool CloseAllSolutionViews();
+
///
/// Is called, when a workbench view was opened
///
diff --git a/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs b/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
index a5431e6c7d3..724deb80bab 100644
--- a/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
+++ b/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
@@ -17,6 +17,7 @@
using System.Windows.Navigation;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
+using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui
{
@@ -433,6 +434,46 @@ public void CloseAllViews()
}
}
+ public bool CloseAllSolutionViews()
+ {
+ bool isSolutionWindow;
+ bool result = true;
+
+ WorkbenchSingleton.AssertMainThread();
+ try
+ {
+ closeAll = true;
+ foreach (IWorkbenchWindow window in this.WorkbenchWindowCollection.ToArray())
+ {
+ isSolutionWindow = false;
+ foreach (IViewContent content in window.ViewContents)
+ {
+ foreach (OpenedFile file in content.Files)
+ {
+ if (ProjectService.OpenSolution.FindProjectContainingFile(file.FileName) != null)
+ {
+ isSolutionWindow = true;
+ break;
+ }
+ }
+
+ if (isSolutionWindow)
+ break;
+ }
+
+ if (isSolutionWindow)
+ result = window.CloseWindow(false) && result;
+ }
+ }
+ finally
+ {
+ closeAll = false;
+ OnActiveWindowChanged(this, EventArgs.Empty);
+ }
+
+ return result;
+ }
+
#region ViewContent Memento Handling
string viewContentMementosFileName;