diff options
Diffstat (limited to 'main')
4 files changed, 53 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentController.cs index 3ea22d5783..c886dd2b76 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentController.cs @@ -411,6 +411,22 @@ namespace MonoDevelop.Ide.Gui.Documents } } + internal void Close () + { + linkedController?.Close (); + OnClosed (); + if (extensionChain != null) { + foreach (var ext in extensionChain.GetAllExtensions ().OfType<DocumentControllerExtension> ()) { + try { + ext.OnClosed (); + } catch (Exception ex) { + LoggingService.LogInternalError (ex); + } + } + } + } + + /// <summary> /// Tries to reuse this controler to display the content identified by the provide descriptor. /// </summary> @@ -1088,6 +1104,13 @@ namespace MonoDevelop.Ide.Gui.Documents Model.Dispose (); } + /// <summary> + /// Invoked when the document that contains this controller has been closed, and before the controller hierarchy is disposed + /// </summary> + protected virtual void OnClosed () + { + } + public IEnumerable<FilePath> GetDocumentFiles () { return OnGetDocumentFiles (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentControllerExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentControllerExtension.cs index c0946ce98e..cdb3903dde 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentControllerExtension.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentControllerExtension.cs @@ -152,6 +152,13 @@ namespace MonoDevelop.Ide.Gui.Documents { } + /// <summary> + /// Invoked when the document that contains this controller has been closed, and before the controller hierarchy is disposed + /// </summary> + internal protected virtual void OnClosed () + { + } + public IEnumerable<object> GetContents (Type type) { return OnGetContents (type); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentView.cs index b78e322bc5..db569a756c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentView.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentView.cs @@ -50,6 +50,7 @@ namespace MonoDevelop.Ide.Gui.Documents bool contentVisible; DocumentView parent; bool disposed; + bool closed; bool hasFocus; bool shown; @@ -292,12 +293,21 @@ namespace MonoDevelop.Ide.Gui.Documents public void Dispose () { + Close (); if (!disposed) { disposed = true; OnDispose (); } } + internal void Close () + { + if (!closed) { + closed = true; + OnClosed (); + } + } + internal virtual void SetActiveChild (DocumentView child) { if (AttachedViews.Contains (child)) { @@ -458,6 +468,12 @@ namespace MonoDevelop.Ide.Gui.Documents SourceController?.Dispose (); } + internal virtual void OnClosed () + { + // If this view was created by a controller, dispose the controller here too. + SourceController?.Close (); + } + internal virtual IEnumerable<DocumentController> GetActiveControllerHierarchy () { if (SourceController != null) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentViewContainer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentViewContainer.cs index b13bddd601..9d56e32092 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentViewContainer.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentViewContainer.cs @@ -282,6 +282,13 @@ namespace MonoDevelop.Ide.Gui.Documents base.OnDispose (); } + internal override void OnClosed () + { + foreach (var c in Views.ToList ()) + c.Close (); + base.OnClosed (); + } + internal override void UpdateContentVisibility (bool parentIsVisible) { base.UpdateContentVisibility (parentIsVisible); |