增加dispose调用

This commit is contained in:
ww-rm
2025-03-03 21:39:35 +08:00
parent f22132124c
commit ede65c9c98

View File

@@ -112,7 +112,6 @@ namespace SpineViewer.Controls
var skelPath = skelPaths[i]; var skelPath = skelPaths[i];
worker.ReportProgress((int)((i + 1) * 100.0) / totalCount, $"正在处理 {i + 1}/{totalCount}");
try try
{ {
var spine = Spine.Spine.New(version, skelPath); var spine = Spine.Spine.New(version, skelPath);
@@ -126,6 +125,8 @@ namespace SpineViewer.Controls
Program.Logger.Error("Failed to load {}", skelPath); Program.Logger.Error("Failed to load {}", skelPath);
error++; error++;
} }
worker.ReportProgress((int)((i + 1) * 100.0) / totalCount, $"已处理 {i + 1}/{totalCount}");
} }
if (error > 0) if (error > 0)
@@ -271,7 +272,11 @@ namespace SpineViewer.Controls
foreach (var i in listView.SelectedIndices.Cast<int>().OrderByDescending(x => x)) foreach (var i in listView.SelectedIndices.Cast<int>().OrderByDescending(x => x))
{ {
lock (Spines) { spines.RemoveAt(i); } lock (Spines)
{
spines[i].Dispose();
spines.RemoveAt(i);
}
listView.Items.RemoveAt(i); listView.Items.RemoveAt(i);
} }
} }
@@ -311,14 +316,18 @@ namespace SpineViewer.Controls
if (listView.Items.Count <= 0) if (listView.Items.Count <= 0)
return; return;
if (MessageBox.Show($"确认移除所有 {listView.Items.Count} 项吗?", "操作确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) if (MessageBox.Show($"确认移除所有 {listView.Items.Count} 项吗?", "操作确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{ return;
lock (Spines) { spines.Clear(); }
listView.Items.Clear();
if (PropertyGrid is not null)
PropertyGrid.SelectedObject = null;
}
}
lock (Spines)
{
foreach (var spine in spines)
spine.Dispose();
spines.Clear();
}
listView.Items.Clear();
if (PropertyGrid is not null)
PropertyGrid.SelectedObject = null;
}
} }
} }