diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2022-10-27 13:26:14 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2022-10-27 13:26:14 +0300 |
commit | f86d50b03bf48a3b1bcb87eb9a26487c0ceaef04 (patch) | |
tree | ba98f50b0091f1d33bcb6a10e8deed43c4038ed2 /Mono.Addins | |
parent | 9eaab025099bc82c0fc31379afa95786aa7fcdfa (diff) |
Fix NRE when unloading an add-in
When removing many nodes in a transaction it may happen that a parent
is removed before its children, since the list of nodes to remove is
in a hashset, so there is no defined order. Added a null check to avoid
a crash when that happens.
Diffstat (limited to 'Mono.Addins')
-rw-r--r-- | Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs b/Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs index ba2a245..99cba20 100644 --- a/Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs +++ b/Mono.Addins/Mono.Addins/ExtensionContextTransaction.cs @@ -165,7 +165,9 @@ namespace Mono.Addins { foreach (var node in childrenChanged) { - if (node.NotifyChildrenChanged()) + // It may happen that a node is removed while updating its parent. In this case the parent + // will be set to null, and then there is no need to notify changes + if (node.Parent != null && node.NotifyChildrenChanged()) NotifyExtensionsChangedEvent(node.GetPath()); } } |