From f502ccf7489d22cf88fc3596666b462dde388a1a Mon Sep 17 00:00:00 2001 From: Lluis Sanchez Gual Date: Sat, 29 Nov 2014 19:25:36 +0100 Subject: [PATCH] [Mac] Fix crash when checking if a widget has a native parent --- Xwt.Mac/Xwt.Mac/MacEngine.cs | 6 +++++- Xwt/Xwt.Backends/XwtWidgetBackend.cs | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Xwt.Mac/Xwt.Mac/MacEngine.cs b/Xwt.Mac/Xwt.Mac/MacEngine.cs index 5f62df0d..8ad82e6c 100644 --- a/Xwt.Mac/Xwt.Mac/MacEngine.cs +++ b/Xwt.Mac/Xwt.Mac/MacEngine.cs @@ -124,6 +124,7 @@ namespace Xwt.Mac RegisterBackend (); RegisterBackend (); RegisterBackend (); + RegisterBackend (); } public override void RunApplication () @@ -194,7 +195,10 @@ namespace Xwt.Mac public override bool HasNativeParent (Widget w) { - ViewBackend wb = (ViewBackend)Toolkit.GetBackend (w); + var b = (IWidgetBackend) Toolkit.GetBackend (w); + if (b is XwtWidgetBackend) + b = ((XwtWidgetBackend)b).NativeBackend; + ViewBackend wb = (ViewBackend)b; return wb.Widget.Superview != null; } diff --git a/Xwt/Xwt.Backends/XwtWidgetBackend.cs b/Xwt/Xwt.Backends/XwtWidgetBackend.cs index 506c429e..6cb4c1a0 100644 --- a/Xwt/Xwt.Backends/XwtWidgetBackend.cs +++ b/Xwt/Xwt.Backends/XwtWidgetBackend.cs @@ -117,6 +117,10 @@ namespace Xwt.Backends Font = new Xwt.Drawing.Font (value); } } + + public IWidgetBackend NativeBackend { + get { return BackendHost.Backend; } + } object IWidgetBackend.NativeWidget { get { return BackendHost.Backend.NativeWidget; }