Set TextNode to null after destroying it

This commit is contained in:
Haselnussbomber 2025-11-12 00:23:08 +01:00
parent e1fde804ec
commit f635c149a2
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1

View file

@ -257,7 +257,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
/// <param name="toRemove">The resources to remove.</param> /// <param name="toRemove">The resources to remove.</param>
internal void RemoveEntry(DtrBarEntry toRemove) internal void RemoveEntry(DtrBarEntry toRemove)
{ {
this.RemoveNode(toRemove.TextNode); this.RemoveNode(toRemove);
if (toRemove.Storage != null) if (toRemove.Storage != null)
{ {
@ -542,9 +542,10 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
return true; return true;
} }
private void RemoveNode(AtkTextNode* node) private void RemoveNode(DtrBarEntry data)
{ {
var dtr = this.GetDtr(); var dtr = this.GetDtr();
var node = data.TextNode;
if (dtr == null || dtr->RootNode == null || dtr->UldManager.NodeList == null || node == null) return; if (dtr == null || dtr->RootNode == null || dtr->UldManager.NodeList == null || node == null) return;
if (this.eventHandles.TryGetValue(node->AtkResNode.NodeId, out var eventHandles)) if (this.eventHandles.TryGetValue(node->AtkResNode.NodeId, out var eventHandles))
@ -565,6 +566,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
if (tmpPrevNode != null) if (tmpPrevNode != null)
tmpPrevNode->NextSiblingNode = tmpNextNode; tmpPrevNode->NextSiblingNode = tmpNextNode;
node->AtkResNode.Destroy(true); node->AtkResNode.Destroy(true);
data.TextNode = null;
dtr->RootNode->ChildCount = (ushort)(dtr->RootNode->ChildCount - 1); dtr->RootNode->ChildCount = (ushort)(dtr->RootNode->ChildCount - 1);
Log.Debug("Set last sibling of DTR and updated child count"); Log.Debug("Set last sibling of DTR and updated child count");