fix(legacy): finalize hosted module lifecycle cleanup
This commit is contained in:
@@ -631,7 +631,15 @@ namespace Lskj.Control
|
||||
|
||||
internal void ReleaseResourcesForDispose()
|
||||
{
|
||||
DisposeGridResources();
|
||||
// 模块级清理只解除事件和菜单引用。GridControl/GridView 的生命周期
|
||||
// 由真正的 WinForms 父容器负责,并在 Dispose(bool) 中统一结束。
|
||||
DetachGridViewEventHandlers();
|
||||
if (gridViewRightMenu != null)
|
||||
{
|
||||
gridViewRightMenu.ReleaseResourcesForDispose();
|
||||
gridViewRightMenu = null;
|
||||
}
|
||||
ParentControl = null;
|
||||
}
|
||||
|
||||
private void DetachGridViewEventHandlers()
|
||||
@@ -658,6 +666,13 @@ namespace Lskj.Control
|
||||
gridView.ShowFilterPopupCheckedListBox -= OnShowFilterPopupCheckedListBox;
|
||||
gridView.DataSourceChanged -= OnGridDataSourceChanged;
|
||||
gridView.RowCellStyle -= GridView_RowCellStyle;
|
||||
// These handlers are attached dynamically by SetGridRowColors and
|
||||
// AddHeadquarters. They are not part of the constructor hookup, so
|
||||
// removing only the static handlers above leaves a GridView event
|
||||
// delegate rooted to this GridControlEx after module close.
|
||||
gridView.RowCellStyle -= OnGridViewRowCellStyle;
|
||||
gridView.RowStyle -= OnGridViewRowStyle;
|
||||
gridView.CellValueChanged -= onCellValueChanged;
|
||||
gridView.CustomRowFilter -= GridView_CustomRowFilter;
|
||||
gridView.EndGrouping -= GridView_EndGrouping;
|
||||
gridView.ShowingEditor -= GridView_ShowingEditor;
|
||||
@@ -735,6 +750,52 @@ namespace Lskj.Control
|
||||
customFont.Dispose();
|
||||
customFont = null;
|
||||
}
|
||||
|
||||
// Dispose 完成后,包装对象不应继续保留已释放的 DevExpress 控件、
|
||||
// 数据表和模块字典。尤其是左右联动事件链仍可能短暂持有包装对象,
|
||||
// 这里主动断开引用可以避免已关闭页签继续保留整棵控件对象图。
|
||||
gridView = null;
|
||||
gridControl = null;
|
||||
GridRowColorsTable = null;
|
||||
ChartTable = null;
|
||||
rightMenuButtonTable = null;
|
||||
InitGridColumsTab = null;
|
||||
ModuleEnclosure?.Clear();
|
||||
ModuleEnclosure = null;
|
||||
mControlSourceDic?.Clear();
|
||||
mControlSourceDic = null;
|
||||
mControlList?.Clear();
|
||||
mControlList = null;
|
||||
ColumnList?.Clear();
|
||||
ColumnList = null;
|
||||
AutoPadDataReleColList?.Clear();
|
||||
AutoPadDataReleColList = null;
|
||||
ImageList?.Clear();
|
||||
ImageList = null;
|
||||
RepeatedVerificationNames?.Clear();
|
||||
RepeatedVerificationNames = null;
|
||||
PromptMessage?.Clear();
|
||||
PromptMessage = null;
|
||||
_CheckedList?.Clear();
|
||||
_CheckedList = null;
|
||||
modifyThePosition?.Clear();
|
||||
modifyThePosition = null;
|
||||
ColumnsList?.Clear();
|
||||
ColumnsList = null;
|
||||
SelectedDataSource?.Clear();
|
||||
SelectedDataSource = null;
|
||||
ProgressBarColumn?.Clear();
|
||||
ProgressBarColumn = null;
|
||||
ManuallyAddData?.Clear();
|
||||
ManuallyAddData = null;
|
||||
FrozenColumns = null;
|
||||
CurrentOperGridView = null;
|
||||
CurrentOperModel = null;
|
||||
HeaderColumnSift = null;
|
||||
sumPanel = null;
|
||||
PopupEdit = null;
|
||||
CustomGroupBandEx = null;
|
||||
CustomGroupTreeBandEx = null;
|
||||
}
|
||||
|
||||
private void PrepareForColumnRebuild()
|
||||
@@ -3825,7 +3886,7 @@ namespace Lskj.Control
|
||||
DllName = "",
|
||||
Id = this.Model.ModuleCode,
|
||||
Name = this.Model.FormText,
|
||||
BeforePage = ERPInfo.Instance.PageControl.SelectedTabPage
|
||||
BeforePage = ERPInfo.Instance.CurrentModulePage
|
||||
};
|
||||
module.ModuleForm = frmGridSift;
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
@@ -3842,8 +3903,8 @@ namespace Lskj.Control
|
||||
tp.Controls.Add(frmGridSift);
|
||||
tp.ShowCloseButton = DefaultBoolean.True;
|
||||
tp.Dock = DockStyle.Fill;
|
||||
ERPInfo.Instance.PageControl.TabPages.Add(tp);
|
||||
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
|
||||
ERPInfo.Instance.AddModulePage(tp);
|
||||
ERPInfo.Instance.CurrentModulePage = tp;
|
||||
ERPInfo.Instance.ModuleForms.Add(guid, module);
|
||||
frmGridSift.Show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user