src/Misc/EFTools/DesignXmlCore/Base/Shell/TreeGridDesignerToolWindow.cs
/// <summary>
///     Document we are tracking selection on is closing, ensure we clean everything up.
/// </summary>
Document we are tracking selection on is closing, ensure we clean everything up.
Document we are tracking selection on is closing ensure we clean everything up .
private void OnDocumentClosing(object sender, EventArgs args)
        {
            Debug.Assert(_currentDocData != null, "null docData in DocumentClosing event");
            if (_currentDocData != null)
            {
                try
                {
                    if (_treeProvider != null)
                    {
                        _treeProvider.Root = null;
                    }
                    _currentSelection = null;
                    _currentBrowseObject = null;
                    Debug.Assert(_currentDocData.Store != null, "unable to remove column event handlers");
                    if (_currentDocData.Store != null)
                    {
                        _treeControl.RemoveColumnEventHandlers();
                    }
                    DoSelectionChanged((object)null);
                }
                finally
                {
                    _currentDocData.DocumentClosing -= OnDocumentClosing;
                    _currentDocData = null;
                }
            }
        }
private void OnDocumentClosing ( object sender , EventArgs args ) { Debug . Assert ( _currentDocData != null , " " ) ; if ( _currentDocData != null ) { try { if ( _treeProvider != null ) { _treeProvider . Root = null ; } _currentSelection = null ; _currentBrowseObject = null ; Debug . Assert ( _currentDocData . Store != null , " " ) ; if ( _currentDocData . Store != null ) { _treeControl . RemoveColumnEventHandlers ( ) ; } DoSelectionChanged ( ( object ) null ) ; } finally { _currentDocData . DocumentClosing -= OnDocumentClosing ; _currentDocData = null ; } } }
Document we are tracking selection on is closing, ensure we clean everything up.
Document we are tracking selection on is closing ensure we clean everything up .
// clear tree data, causes event handlers to be removed from our branches. // clear cached selection // disable column event handlers // NOTE: It's important to cast here, otherwise a wrong overload would be called // and selection container would not be cleared leading to strange problems - e.g. // properties window might call refresh on disposed store etc. // Unsubscribe from document closing event
sender
object
args
EventArgs