fix(winforms): release module grid resources
This commit is contained in:
@@ -165,6 +165,9 @@ namespace Lskj.Control
|
||||
/// 按钮形式展示的右键
|
||||
/// </summary>
|
||||
private List<SimpleButton> RightButtons = new List<SimpleButton>();
|
||||
// Fonts assigned to dynamic controls are not reliably reclaimed by the
|
||||
// DevExpress/WinForms control tree, so keep ownership explicit.
|
||||
private readonly List<Font> _ownedFonts = new List<Font>();
|
||||
/// <summary>
|
||||
/// 附加右键菜单集合
|
||||
/// </summary>
|
||||
@@ -1298,7 +1301,9 @@ namespace Lskj.Control
|
||||
if (FontSize > 0)
|
||||
{
|
||||
//this.gcMain.GridView.Appearance.Row.Font = new Font("微软雅黑", FontSize);
|
||||
this.gcMain.GridView.Appearance.Row.Font = new Font(this.gcMain.GridView.Appearance.Row.Font.FontFamily, FontSize);
|
||||
Font rowFont = new Font(this.gcMain.GridView.Appearance.Row.Font.FontFamily, FontSize);
|
||||
this.gcMain.GridView.Appearance.Row.Font = rowFont;
|
||||
_ownedFonts.Add(rowFont);
|
||||
}
|
||||
if (SysModel.RowHeight > 0)
|
||||
{
|
||||
@@ -3792,6 +3797,27 @@ namespace Lskj.Control
|
||||
}
|
||||
gcMain.Model = null;
|
||||
gcMain.SysModel = null;
|
||||
|
||||
try
|
||||
{
|
||||
gcMain.ReleaseResourcesForDispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Resource cleanup must not block the module close path.
|
||||
}
|
||||
try
|
||||
{
|
||||
if (!gcMain.IsDisposed)
|
||||
{
|
||||
gcMain.Dispose();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// A partially disposed grid must not block the module close path.
|
||||
}
|
||||
gcMain = null;
|
||||
}
|
||||
}
|
||||
catch
|
||||
@@ -3826,8 +3852,9 @@ namespace Lskj.Control
|
||||
m_dragRowShadow.Dispose();
|
||||
m_dragRowShadow = null;
|
||||
}
|
||||
DisposeDynamicRightButtons();
|
||||
DisposeOwnedFonts();
|
||||
ButtonModeRightMenus.Clear();
|
||||
RightButtons.Clear();
|
||||
itemCommonList.Clear();
|
||||
LineStatus.Clear();
|
||||
_leftGridSearchObj = null;
|
||||
@@ -4053,6 +4080,39 @@ namespace Lskj.Control
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeDynamicRightButtons()
|
||||
{
|
||||
foreach (SimpleButton button in RightButtons.ToList())
|
||||
{
|
||||
try
|
||||
{
|
||||
button.Click -= OnModuleClick;
|
||||
button.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Cleanup must continue for the remaining controls.
|
||||
}
|
||||
}
|
||||
RightButtons.Clear();
|
||||
}
|
||||
|
||||
private void DisposeOwnedFonts()
|
||||
{
|
||||
foreach (Font font in _ownedFonts.ToList())
|
||||
{
|
||||
try
|
||||
{
|
||||
font.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// A partially disposed font must not stop module cleanup.
|
||||
}
|
||||
}
|
||||
_ownedFonts.Clear();
|
||||
}
|
||||
|
||||
private void Txt_SweepCode_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
try
|
||||
@@ -5785,7 +5845,9 @@ namespace Lskj.Control
|
||||
{
|
||||
GridRightMenuModel menuModel = new GridRightMenuModel(item);
|
||||
SimpleButton button = new SimpleButton();
|
||||
button.Font = new Font("宋体", 9);
|
||||
Font buttonFont = new Font("宋体", 9);
|
||||
button.Font = buttonFont;
|
||||
_ownedFonts.Add(buttonFont);
|
||||
button.Text = menuModel.MenuName;
|
||||
button.Height = 24;
|
||||
//按钮最小大小
|
||||
|
||||
Reference in New Issue
Block a user