From: huiyu.eun Date: Wed, 7 Apr 2021 01:38:18 +0000 (+0900) Subject: [NUI] Fix Window.Instance null issue X-Git-Tag: citest_t1~137 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8034260ee002ec917bc711316753c5cb110a798f;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Fix Window.Instance null issue If call Window.Instance before initializing, Window.Instance is always null Signed-off-by: huiyu.eun --- diff --git a/src/Tizen.NUI/src/internal/Application/Application.cs b/src/Tizen.NUI/src/internal/Application/Application.cs index 13f7aab..ab46101 100755 --- a/src/Tizen.NUI/src/internal/Application/Application.cs +++ b/src/Tizen.NUI/src/internal/Application/Application.cs @@ -490,8 +490,8 @@ namespace Tizen.NUI appControlSignal = null; } - win?.Dispose(); - win = null; + window?.Dispose(); + window = null; base.Dispose(type); } @@ -575,7 +575,7 @@ namespace Tizen.NUI private NUIApplicationAppControlEventCallbackDelegate applicationAppControlEventCallbackDelegate; private ApplicationControlSignal appControlSignal; - private Window win; + private Window window; /** * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler @@ -613,6 +613,7 @@ namespace Tizen.NUI { // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread. DisposeQueue.Instance.Initialize(); + Window.Instance = GetWindow(); // Notify that the window is displayed to the app core. if (NUIApplication.IsPreload) @@ -1259,14 +1260,15 @@ namespace Tizen.NUI public Window GetWindow() { - win = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window; - if (win == null) + if (window != null) { - win = new Window(Interop.Application.GetWindow(SwigCPtr), true); + return window; } + window = (Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window) ?? new Window(Interop.Application.GetWindow(SwigCPtr), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return win; + return window; } public static string GetResourcePath() diff --git a/src/Tizen.NUI/src/public/Window/Window.cs b/src/Tizen.NUI/src/public/Window/Window.cs index 2738663..db7bcaa 100755 --- a/src/Tizen.NUI/src/public/Window/Window.cs +++ b/src/Tizen.NUI/src/public/Window/Window.cs @@ -34,8 +34,6 @@ namespace Tizen.NUI /// 3 public partial class Window : BaseHandle { - private static readonly Window instance = Application.Instance?.GetWindow(); - private HandleRef stageCPtr; private Layer rootLayer; private string windowTitle; @@ -264,13 +262,7 @@ namespace Tizen.NUI /// Gets the current window.
/// /// 3 - public static Window Instance - { - get - { - return instance; - } - } + public static Window Instance { get; internal set; } /// /// Gets or sets a window type.