Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Maupin <ermaup@microsoft.com>2019-01-28 20:19:28 +0300
committerEric Maupin <ermaup@microsoft.com>2019-02-15 21:00:44 +0300
commit81b032777944761fd0c1de398ad77700df65539b (patch)
treebc45aee7ac75d08a6910171166a17f507656be81 /Xamarin.PropertyEditing.Mac
parent687934e61ad8db63cd62d6b1e2df0988204e7c21 (diff)
[mac] Set ViewModel to null on removed
Imagine properties A and B with the same editor type. Both properties are initially shown and then removed as the selected object is cleared. The order in which the editors are queued and dequeued for reuse is an unknown, so we can not depend on a behavior. Imagine then that property A is re-shown, but not B. It's possible that the editor for B is reused for property A. Without the change, you now have two editors hooked up to A's events. Besides keeping the VM alive, if any of the events trigger UI tasks that require a superview/window, they will fail and crash.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs10
1 files changed, 8 insertions, 2 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs b/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs
index e5eec20..5f5cc3e 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs
@@ -43,6 +43,14 @@ namespace Xamarin.PropertyEditing.Mac
set { this.label.StringValue = value; }
}
+ public override void ViewWillMoveToSuperview (NSView newSuperview)
+ {
+ if (newSuperview == null && EditorView != null)
+ EditorView.ViewModel = null;
+
+ base.ViewWillMoveToSuperview (newSuperview);
+ }
+
private UnfocusableTextField label = new UnfocusableTextField {
Alignment = NSTextAlignment.Right,
TranslatesAutoresizingMaskIntoConstraints = false
@@ -53,7 +61,5 @@ namespace Xamarin.PropertyEditing.Mac
set { this.label.TextColor = value; }
}
#endif
-
- private readonly IHostResourceProvider hostResources;
}
}