[NUI] Fix e.Application null issue (#559)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Tue, 20 Nov 2018 01:57:56 +0000 (10:57 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 20 Nov 2018 01:57:56 +0000 (10:57 +0900)
* [NUI] Fix e.Application null issue

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
* [NUI] Add handler null check

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI/src/internal/Application.cs
src/Tizen.NUI/src/internal/NUICoreBackend.cs

index 55304bb..b9aa6a7 100755 (executable)
@@ -955,8 +955,12 @@ namespace Tizen.NUI
             // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
             DisposeQueue.Instance.Initialize();
 
-            _applicationInitEventHandler?.Invoke(this, new NUIApplicationInitEventArgs());
-
+            if(_applicationInitEventHandler != null)
+            {
+                NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
+                e.Application = this;
+                _applicationInitEventHandler.Invoke(this, e);
+            }
         }
 
         /**
@@ -997,7 +1001,12 @@ namespace Tizen.NUI
         // Callback for Application TerminateSignal
         private void OnNUIApplicationTerminate(IntPtr data)
         {
-            _applicationTerminateEventHandler?.Invoke(this, new NUIApplicationTerminatingEventArgs());
+            if(_applicationTerminateEventHandler != null)
+            {
+                NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
+                e.Application = this;
+                _applicationTerminateEventHandler.Invoke(this, e);
+            }
         }
 
         /**
@@ -1038,7 +1047,12 @@ namespace Tizen.NUI
         // Callback for Application PauseSignal
         private void OnNUIApplicationPause(IntPtr data)
         {
-            _applicationPauseEventHandler?.Invoke(this, new NUIApplicationPausedEventArgs());
+            if(_applicationPauseEventHandler != null)
+            {
+                NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
+                e.Application = this;
+                _applicationPauseEventHandler.Invoke(this, e);
+            }
         }
 
         /**
@@ -1079,7 +1093,12 @@ namespace Tizen.NUI
         // Callback for Application ResumeSignal
         private void OnNUIApplicationResume(IntPtr data)
         {
-            _applicationResumeEventHandler?.Invoke(this, new NUIApplicationResumedEventArgs());
+            if(_applicationResumeEventHandler != null)
+            {
+                NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
+                e.Application = this;
+                _applicationResumeEventHandler.Invoke(this, e);
+            }
         }
 
         /**
@@ -1120,7 +1139,12 @@ namespace Tizen.NUI
         // Callback for Application ResetSignal
         private void OnNUIApplicationReset(IntPtr data)
         {
-            _applicationResetEventHandler?.Invoke(this, new NUIApplicationResetEventArgs());
+            if(_applicationResetEventHandler != null)
+            {
+                NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
+                e.Application = this;
+                _applicationResetEventHandler.Invoke(this, e);
+            }
         }
 
         /**
@@ -1161,7 +1185,12 @@ namespace Tizen.NUI
         // Callback for Application ResizeSignal
         private void OnNUIApplicationResize(IntPtr data)
         {
-            _applicationResizeEventHandler?.Invoke(this, new NUIApplicationResizedEventArgs());
+            if(_applicationResizeEventHandler != null)
+            {
+                NUIApplicationResizedEventArgs e = new NUIApplicationResizedEventArgs();
+                e.Application = this;
+                _applicationResizeEventHandler.Invoke(this, e);
+            }
         }
 
         /**
@@ -1202,7 +1231,12 @@ namespace Tizen.NUI
         // Callback for Application LanguageChangedSignal
         private void OnNUIApplicationLanguageChanged(IntPtr data)
         {
-            _applicationLanguageChangedEventHandler?.Invoke(this, new NUIApplicationLanguageChangedEventArgs());
+            if(_applicationLanguageChangedEventHandler != null)
+            {
+                NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
+                e.Application = this;
+                _applicationLanguageChangedEventHandler.Invoke(this, e);
+            }
         }
 
         /**
@@ -1243,7 +1277,12 @@ namespace Tizen.NUI
         // Callback for Application RegionChangedSignal
         private void OnNUIApplicationRegionChanged(IntPtr data)
         {
-            _applicationRegionChangedEventHandler?.Invoke(this, new NUIApplicationRegionChangedEventArgs());
+            if(_applicationRegionChangedEventHandler != null)
+            {
+                NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
+                e.Application = this;
+                _applicationRegionChangedEventHandler.Invoke(this, e);
+            }
         }
 
         /**
@@ -1374,9 +1413,13 @@ namespace Tizen.NUI
         // Callback for Application AppControlSignal
         private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
         {
-            NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
-            e.VoidP = voidp;
-            _applicationAppControlEventHandler?.Invoke(this, e);
+            if(_applicationAppControlEventHandler != null)
+            {
+                NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
+                e.VoidP = voidp;
+                e.Application = this;
+                _applicationAppControlEventHandler.Invoke(this, e);
+            }
         }
 
         private static Application _instance; // singleton
index 25ff2fc..c9ea92a 100755 (executable)
@@ -147,8 +147,6 @@ namespace Tizen.NUI
             _application.AppControl += OnAppControl;
 
             _application.MainLoop();
-
-            DisposeQueue.Instance.ProcessDisposables();
             _application.Dispose();
         }
 
@@ -161,7 +159,7 @@ namespace Tizen.NUI
         {
             Log.Info("NUI", "NUICorebackend OnRegionChanged Called");
             var handler = Handlers[EventType.RegionFormatChanged] as Action<RegionFormatChangedEventArgs>;
-            handler?.Invoke( new RegionFormatChangedEventArgs(e.Application.GetRegion()));
+            handler?.Invoke( new RegionFormatChangedEventArgs((source as Application)?.GetRegion()));
         }
 
         /// <summary>
@@ -203,7 +201,7 @@ namespace Tizen.NUI
         {
             Log.Info("NUI", "NUICorebackend OnLanguageChanged Called");
             var handler = Handlers[EventType.LocaleChanged] as Action<LocaleChangedEventArgs>;
-            handler?.Invoke( new LocaleChangedEventArgs(e.Application.GetLanguage()));
+            handler?.Invoke( new LocaleChangedEventArgs((source as Application)?.GetLanguage()));
         }
 
         /// <summary>