chr
2025-01-03 31a636e735a0addc56e4f4527f500b7aa0874eb5
PdmSwPlugin.Main/SwAddIn/MainControl.cs
@@ -365,19 +365,29 @@
        public void DeActiveHandler()
        {
            foreach (TabItem item in mainTab.tabControl.Items)
            try
            {
                // 向主Control注册事件
                if (item.Content is IActiveDocChangeHandler handler)
                if (mainTab?.tabControl != null)
                {
                    ActiveDocChangeEvent -= handler.OnSwActiveDocChange;
                    ActiveDocSavedEvent -= handler.OnSwActiveDocSaved;
                    ActiveDocCustomPropertyChange -= handler.OnCustomPropertyChange;
                    DocDestroy -= handler.OnDocDestroy;
                    AfterDocDestroy -= handler.AfterDocDestroy;
                    foreach (TabItem item in mainTab.tabControl.Items)
                    {
                        // 向主Control注册事件
                        if (item.Content is IActiveDocChangeHandler handler)
                        {
                            ActiveDocChangeEvent -= handler.OnSwActiveDocChange;
                            ActiveDocSavedEvent -= handler.OnSwActiveDocSaved;
                            ActiveDocCustomPropertyChange -= handler.OnCustomPropertyChange;
                            DocDestroy -= handler.OnDocDestroy;
                            AfterDocDestroy -= handler.AfterDocDestroy;
                        }
                    }
                    PluginInfos.Clear();
                }
            }
            PluginInfos.Clear();
            catch (Exception ex)
            {
                Logger.Error("DeActiveHandler Failed.", ex);
            }
        }
        /// <summary>