fix(legacy): release hosted module resources safely

This commit is contained in:
2026-08-30 18:12:09 +08:00
parent 641d3c232d
commit 769aa52241
7 changed files with 362 additions and 12 deletions
@@ -126,6 +126,7 @@ namespace Lskj.Control.Model
// 控件,不调用 Control.Dispose,也不扫描全局控件集合,因而
// 不会影响仍然打开的模块或共享的 GridView 生命周期。
ReleaseGridControlRuntimeReferences(moduleControls);
ReleaseLookupControlRuntimeReferences(moduleControls);
foreach (GridView gridView in gridViews)
{
@@ -204,6 +205,33 @@ namespace Lskj.Control.Model
}
}
private static void ReleaseLookupControlRuntimeReferences(
IEnumerable<WinFormsControl> moduleControls)
{
if (moduleControls == null)
{
return;
}
foreach (Lskj.Control.LabelMultiAutoTextEdit4 lookupControl in
moduleControls.OfType<Lskj.Control.LabelMultiAutoTextEdit4>())
{
if (lookupControl == null)
{
continue;
}
try
{
lookupControl.ReleaseLookupFormForDispose();
}
catch (Exception exception)
{
TraceCleanupFailure("release lookup helper form", exception);
}
}
}
private static List<WinFormsControl> CollectModuleControls(
WinFormsControl moduleRoot,
XtraTabPage modulePage)