fix: 收敛旧模块资源释放与诊断

This commit is contained in:
2026-08-15 10:13:08 +08:00
parent 222ae3c08a
commit c49015d390
60 changed files with 4218 additions and 409 deletions
@@ -13,9 +13,13 @@
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
if (disposing)
{
components.Dispose();
ReleaseResourcesForDispose();
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
@@ -666,4 +670,4 @@
private Control.TabControlEx tab_basicInfo;
private DevExpress.XtraEditors.DropDownButton btnPrint;
}
}
}
@@ -64,6 +64,7 @@ namespace Lskj.BaseAccraditation
/// 主表控件
/// </summary>
public MyControl ControlObj;
private bool mResourcesReleased;
#endregion
@@ -191,6 +192,42 @@ namespace Lskj.BaseAccraditation
InitializeComponent();
}
private void ReleaseResourcesForDispose()
{
if (mResourcesReleased)
{
return;
}
mResourcesReleased = true;
PrintUtil.OnAfterPrint -= OnReportPrintAfter;
MyControl control = ControlObj;
ControlObj = null;
if (control != null)
{
control.OnDataSourceBindCallBack -=
OnControlObjOnDataSourceBindCallBack;
control.Dispose();
}
try
{
if (tab_basicInfo != null)
{
tab_basicInfo.ParentControlEx = null;
}
if (SysModel != null && SysModel.DataCaches != null)
{
SysModel.DataCaches.Remove(this);
}
}
catch
{
// A partially disposed child must not stop form cleanup.
}
}
public override void SetFormSize()
{
this.WindowState = FormWindowState.Normal;