From e42ecade8c3418f160f6959e8ffaff2db3a01a04 Mon Sep 17 00:00:00 2001 From: Daekwang Ryu Date: Thu, 17 Dec 2020 15:52:14 +0900 Subject: [PATCH] [NUI] Fix CA2002 Do not lock on objects with weak identity https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2002 --- src/Tizen.NUI/src/internal/Application.cs | 340 +++++++++------------ src/Tizen.NUI/src/internal/Builder.cs | 28 +- src/Tizen.NUI/src/internal/ComponentApplication.cs | 26 +- .../src/internal/Interop/NDalicPINVOKE.cs | 5 +- src/Tizen.NUI/src/internal/ObjectRegistry.cs | 52 ++-- src/Tizen.NUI/src/internal/PageTurnView.cs | 104 +++---- .../src/public/BaseComponents/Scrollable.cs | 78 ++--- src/Tizen.NUI/src/public/PropertyNotification.cs | 24 +- .../src/public/UIComponents/ScrollViewEvent.cs | 32 +- 9 files changed, 273 insertions(+), 416 deletions(-) diff --git a/src/Tizen.NUI/src/internal/Application.cs b/src/Tizen.NUI/src/internal/Application.cs index 2d23bdd..f77d1e5 100755 --- a/src/Tizen.NUI/src/internal/Application.cs +++ b/src/Tizen.NUI/src/internal/Application.cs @@ -620,32 +620,26 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationInitEventHandler == null) { - // Restricted to only one listener - if (_applicationInitEventHandler == null) - { - _applicationInitEventHandler += value; - _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit); - initSignal = this.InitSignal(); - initSignal?.Connect(_applicationInitEventCallbackDelegate); - } + _applicationInitEventHandler += value; + _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit); + initSignal = this.InitSignal(); + initSignal?.Connect(_applicationInitEventCallbackDelegate); } } remove { - lock (this) + if (_applicationInitEventHandler != null) { - if (_applicationInitEventHandler != null) - { - initSignal?.Disconnect(_applicationInitEventCallbackDelegate); - initSignal?.Dispose(); - initSignal = null; - } - - _applicationInitEventHandler -= value; + initSignal?.Disconnect(_applicationInitEventCallbackDelegate); + initSignal?.Dispose(); + initSignal = null; } + + _applicationInitEventHandler -= value; } } @@ -678,33 +672,27 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationTerminateEventHandler == null) { - // Restricted to only one listener - if (_applicationTerminateEventHandler == null) - { - _applicationTerminateEventHandler += value; - - _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate); - terminateSignal = this.TerminateSignal(); - terminateSignal?.Connect(_applicationTerminateEventCallbackDelegate); - } + _applicationTerminateEventHandler += value; + + _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate); + terminateSignal = this.TerminateSignal(); + terminateSignal?.Connect(_applicationTerminateEventCallbackDelegate); } } remove { - lock (this) + if (_applicationTerminateEventHandler != null) { - if (_applicationTerminateEventHandler != null) - { - terminateSignal?.Disconnect(_applicationTerminateEventCallbackDelegate); - terminateSignal?.Dispose(); - terminateSignal = null; - } - - _applicationTerminateEventHandler -= value; + terminateSignal?.Disconnect(_applicationTerminateEventCallbackDelegate); + terminateSignal?.Dispose(); + terminateSignal = null; } + + _applicationTerminateEventHandler -= value; } } @@ -733,33 +721,27 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationPauseEventHandler == null) { - // Restricted to only one listener - if (_applicationPauseEventHandler == null) - { - _applicationPauseEventHandler += value; - - _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause); - pauseSignal = this.PauseSignal(); - pauseSignal?.Connect(_applicationPauseEventCallbackDelegate); - } + _applicationPauseEventHandler += value; + + _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause); + pauseSignal = this.PauseSignal(); + pauseSignal?.Connect(_applicationPauseEventCallbackDelegate); } } remove { - lock (this) + if (_applicationPauseEventHandler != null) { - if (_applicationPauseEventHandler != null) - { - pauseSignal?.Disconnect(_applicationPauseEventCallbackDelegate); - pauseSignal?.Dispose(); - pauseSignal = null; - } - - _applicationPauseEventHandler -= value; + pauseSignal?.Disconnect(_applicationPauseEventCallbackDelegate); + pauseSignal?.Dispose(); + pauseSignal = null; } + + _applicationPauseEventHandler -= value; } } @@ -782,33 +764,27 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationResumeEventHandler == null) { - // Restricted to only one listener - if (_applicationResumeEventHandler == null) - { - _applicationResumeEventHandler += value; - - _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume); - resumeSignal = this.ResumeSignal(); - resumeSignal?.Connect(_applicationResumeEventCallbackDelegate); - } + _applicationResumeEventHandler += value; + + _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume); + resumeSignal = this.ResumeSignal(); + resumeSignal?.Connect(_applicationResumeEventCallbackDelegate); } } remove { - lock (this) + if (_applicationResumeEventHandler != null) { - if (_applicationResumeEventHandler != null) - { - resumeSignal?.Disconnect(_applicationResumeEventCallbackDelegate); - resumeSignal?.Dispose(); - resumeSignal = null; - } - - _applicationResumeEventHandler -= value; + resumeSignal?.Disconnect(_applicationResumeEventCallbackDelegate); + resumeSignal?.Dispose(); + resumeSignal = null; } + + _applicationResumeEventHandler -= value; } } @@ -831,33 +807,27 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationResetEventHandler == null) { - // Restricted to only one listener - if (_applicationResetEventHandler == null) - { - _applicationResetEventHandler += value; - - _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset); - resetSignal = this.ResetSignal(); - resetSignal?.Connect(_applicationResetEventCallbackDelegate); - } + _applicationResetEventHandler += value; + + _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset); + resetSignal = this.ResetSignal(); + resetSignal?.Connect(_applicationResetEventCallbackDelegate); } } remove { - lock (this) + if (_applicationResetEventHandler != null) { - if (_applicationResetEventHandler != null) - { - resetSignal?.Disconnect(_applicationResetEventCallbackDelegate); - resetSignal?.Dispose(); - resetSignal = null; - } - - _applicationResetEventHandler -= value; + resetSignal?.Disconnect(_applicationResetEventCallbackDelegate); + resetSignal?.Dispose(); + resetSignal = null; } + + _applicationResetEventHandler -= value; } } @@ -880,33 +850,27 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationLanguageChangedEventHandler == null) { - // Restricted to only one listener - if (_applicationLanguageChangedEventHandler == null) - { - _applicationLanguageChangedEventHandler += value; - - _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged); - languageChangedSignal = this.LanguageChangedSignal(); - languageChangedSignal?.Connect(_applicationLanguageChangedEventCallbackDelegate); - } + _applicationLanguageChangedEventHandler += value; + + _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged); + languageChangedSignal = this.LanguageChangedSignal(); + languageChangedSignal?.Connect(_applicationLanguageChangedEventCallbackDelegate); } } remove { - lock (this) + if (_applicationLanguageChangedEventHandler != null) { - if (_applicationLanguageChangedEventHandler != null) - { - languageChangedSignal?.Disconnect(_applicationLanguageChangedEventCallbackDelegate); - languageChangedSignal?.Dispose(); - languageChangedSignal = null; - } - - _applicationLanguageChangedEventHandler -= value; + languageChangedSignal?.Disconnect(_applicationLanguageChangedEventCallbackDelegate); + languageChangedSignal?.Dispose(); + languageChangedSignal = null; } + + _applicationLanguageChangedEventHandler -= value; } } @@ -929,33 +893,27 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationRegionChangedEventHandler == null) { - // Restricted to only one listener - if (_applicationRegionChangedEventHandler == null) - { - _applicationRegionChangedEventHandler += value; - - _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged); - regionChangedSignal = this.RegionChangedSignal(); - regionChangedSignal?.Connect(_applicationRegionChangedEventCallbackDelegate); - } + _applicationRegionChangedEventHandler += value; + + _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged); + regionChangedSignal = this.RegionChangedSignal(); + regionChangedSignal?.Connect(_applicationRegionChangedEventCallbackDelegate); } } remove { - lock (this) + if (_applicationRegionChangedEventHandler != null) { - if (_applicationRegionChangedEventHandler != null) - { - regionChangedSignal?.Disconnect(_applicationRegionChangedEventCallbackDelegate); - regionChangedSignal?.Dispose(); - regionChangedSignal = null; - } - - _applicationRegionChangedEventHandler -= value; + regionChangedSignal?.Disconnect(_applicationRegionChangedEventCallbackDelegate); + regionChangedSignal?.Dispose(); + regionChangedSignal = null; } + + _applicationRegionChangedEventHandler -= value; } } @@ -978,47 +936,38 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationBatteryLowEventHandler == null) { - // Restricted to only one listener - if (_applicationBatteryLowEventHandler == null) - { - _applicationBatteryLowEventHandler += value; - - _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow); - batteryLowSignal = this.BatteryLowSignal(); - batteryLowSignal?.Connect(_applicationBatteryLowEventCallbackDelegate); - } + _applicationBatteryLowEventHandler += value; + + _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow); + batteryLowSignal = this.BatteryLowSignal(); + batteryLowSignal?.Connect(_applicationBatteryLowEventCallbackDelegate); } } remove { - lock (this) + if (_applicationBatteryLowEventHandler != null) { - if (_applicationBatteryLowEventHandler != null) - { - batteryLowSignal?.Disconnect(_applicationBatteryLowEventCallbackDelegate); - batteryLowSignal?.Dispose(); - batteryLowSignal = null; - } - - _applicationBatteryLowEventHandler -= value; + batteryLowSignal?.Disconnect(_applicationBatteryLowEventCallbackDelegate); + batteryLowSignal?.Dispose(); + batteryLowSignal = null; } + + _applicationBatteryLowEventHandler -= value; } } // Callback for Application BatteryLowSignal private void OnNUIApplicationBatteryLow(BatteryStatus status) { - lock (this) - { - NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs(); + NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs(); - // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data - e.BatteryStatus = status; - _applicationBatteryLowEventHandler?.Invoke(this, e); - } + // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data + e.BatteryStatus = status; + _applicationBatteryLowEventHandler?.Invoke(this, e); } /** @@ -1029,47 +978,38 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationMemoryLowEventHandler == null) { - // Restricted to only one listener - if (_applicationMemoryLowEventHandler == null) - { - _applicationMemoryLowEventHandler += value; - - _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow); - memoryLowSignal = this.MemoryLowSignal(); - memoryLowSignal?.Connect(_applicationMemoryLowEventCallbackDelegate); - } + _applicationMemoryLowEventHandler += value; + + _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow); + memoryLowSignal = this.MemoryLowSignal(); + memoryLowSignal?.Connect(_applicationMemoryLowEventCallbackDelegate); } } remove { - lock (this) + if (_applicationMemoryLowEventHandler != null) { - if (_applicationMemoryLowEventHandler != null) - { - memoryLowSignal?.Disconnect(_applicationMemoryLowEventCallbackDelegate); - memoryLowSignal?.Dispose(); - memoryLowSignal = null; - } - - _applicationMemoryLowEventHandler -= value; + memoryLowSignal?.Disconnect(_applicationMemoryLowEventCallbackDelegate); + memoryLowSignal?.Dispose(); + memoryLowSignal = null; } + + _applicationMemoryLowEventHandler -= value; } } // Callback for Application MemoryLowSignal private void OnNUIApplicationMemoryLow(MemoryStatus status) { - lock (this) - { - NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs(); + NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs(); - // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data - e.MemoryStatus = status; - _applicationMemoryLowEventHandler?.Invoke(this, e); - } + // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data + e.MemoryStatus = status; + _applicationMemoryLowEventHandler?.Invoke(this, e); } /** @@ -1080,33 +1020,27 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationAppControlEventHandler == null) { - // Restricted to only one listener - if (_applicationAppControlEventHandler == null) - { - _applicationAppControlEventHandler += value; - - _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl); - appControlSignal = this.AppControlSignal(); - appControlSignal?.Connect(_applicationAppControlEventCallbackDelegate); - } + _applicationAppControlEventHandler += value; + + _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl); + appControlSignal = this.AppControlSignal(); + appControlSignal?.Connect(_applicationAppControlEventCallbackDelegate); } } remove { - lock (this) + if (_applicationAppControlEventHandler != null) { - if (_applicationAppControlEventHandler != null) - { - appControlSignal?.Disconnect(_applicationAppControlEventCallbackDelegate); - appControlSignal?.Dispose(); - appControlSignal = null; - } - - _applicationAppControlEventHandler -= value; + appControlSignal?.Disconnect(_applicationAppControlEventCallbackDelegate); + appControlSignal?.Dispose(); + appControlSignal = null; } + + _applicationAppControlEventHandler -= value; } } diff --git a/src/Tizen.NUI/src/internal/Builder.cs b/src/Tizen.NUI/src/internal/Builder.cs index f4d619c..8dbee95 100755 --- a/src/Tizen.NUI/src/internal/Builder.cs +++ b/src/Tizen.NUI/src/internal/Builder.cs @@ -49,31 +49,25 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_builderQuitEventHandler == null) { - // Restricted to only one listener - if (_builderQuitEventHandler == null) - { - _builderQuitEventHandler += value; - - _builderQuitEventCallbackDelegate = new QuitEventCallbackDelegate(OnQuit); - quitSignal = this.QuitSignal(); - quitSignal?.Connect(_builderQuitEventCallbackDelegate); - } + _builderQuitEventHandler += value; + + _builderQuitEventCallbackDelegate = new QuitEventCallbackDelegate(OnQuit); + quitSignal = this.QuitSignal(); + quitSignal?.Connect(_builderQuitEventCallbackDelegate); } } remove { - lock (this) + if (_builderQuitEventHandler != null) { - if (_builderQuitEventHandler != null) - { - quitSignal?.Disconnect(_builderQuitEventCallbackDelegate); - } - - _builderQuitEventHandler -= value; + quitSignal?.Disconnect(_builderQuitEventCallbackDelegate); } + + _builderQuitEventHandler -= value; } } diff --git a/src/Tizen.NUI/src/internal/ComponentApplication.cs b/src/Tizen.NUI/src/internal/ComponentApplication.cs index c7cd493..c13ecb1 100755 --- a/src/Tizen.NUI/src/internal/ComponentApplication.cs +++ b/src/Tizen.NUI/src/internal/ComponentApplication.cs @@ -92,30 +92,24 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_applicationCreateNativeEventHandler == null) { - // Restricted to only one listener - if (_applicationCreateNativeEventHandler == null) - { - _applicationCreateNativeEventHandler += value; - - _applicationCreateNativeEventCallbackDelegate = new NUIComponentApplicationCreatenativeEventCallbackDelegate(OnApplicationCreateNative); - Connect(_applicationCreateNativeEventCallbackDelegate); - } + _applicationCreateNativeEventHandler += value; + + _applicationCreateNativeEventCallbackDelegate = new NUIComponentApplicationCreatenativeEventCallbackDelegate(OnApplicationCreateNative); + Connect(_applicationCreateNativeEventCallbackDelegate); } } remove { - lock (this) + if (_applicationCreateNativeEventHandler != null) { - if (_applicationCreateNativeEventHandler != null) - { - Disconnect(_applicationCreateNativeEventCallbackDelegate); - } - - _applicationCreateNativeEventHandler -= value; + Disconnect(_applicationCreateNativeEventCallbackDelegate); } + + _applicationCreateNativeEventHandler -= value; } } diff --git a/src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs b/src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs index a8d274f..63cb1d1 100755 --- a/src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs +++ b/src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs @@ -151,6 +151,7 @@ namespace Tizen.NUI [global::System.ThreadStatic] private static global::System.Exception pendingException = null; private static int numExceptionsPending = 0; + private static readonly object exceptionPendingLock = new object(); /// 3 public static bool Pending @@ -171,7 +172,7 @@ namespace Tizen.NUI if (pendingException != null) throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); pendingException = e; - lock (typeof(NDalicPINVOKE)) + lock (exceptionPendingLock) { numExceptionsPending++; } @@ -187,7 +188,7 @@ namespace Tizen.NUI { e = pendingException; pendingException = null; - lock (typeof(NDalicPINVOKE)) + lock (exceptionPendingLock) { numExceptionsPending--; } diff --git a/src/Tizen.NUI/src/internal/ObjectRegistry.cs b/src/Tizen.NUI/src/internal/ObjectRegistry.cs index 5d8f786..da8dae8 100755 --- a/src/Tizen.NUI/src/internal/ObjectRegistry.cs +++ b/src/Tizen.NUI/src/internal/ObjectRegistry.cs @@ -88,30 +88,24 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_objectRegistryObjectCreatedEventHandler == null) { - // Restricted to only one listener - if (_objectRegistryObjectCreatedEventHandler == null) - { - _objectRegistryObjectCreatedEventHandler += value; - - _objectRegistryObjectCreatedEventCallbackDelegate = new ObjectCreatedEventCallbackDelegate(OnObjectCreated); - this.ObjectCreatedSignal().Connect(_objectRegistryObjectCreatedEventCallbackDelegate); - } + _objectRegistryObjectCreatedEventHandler += value; + + _objectRegistryObjectCreatedEventCallbackDelegate = new ObjectCreatedEventCallbackDelegate(OnObjectCreated); + this.ObjectCreatedSignal().Connect(_objectRegistryObjectCreatedEventCallbackDelegate); } } remove { - lock (this) + if (_objectRegistryObjectCreatedEventHandler != null) { - if (_objectRegistryObjectCreatedEventHandler != null) - { - this.ObjectCreatedSignal().Disconnect(_objectRegistryObjectCreatedEventCallbackDelegate); - } - - _objectRegistryObjectCreatedEventHandler -= value; + this.ObjectCreatedSignal().Disconnect(_objectRegistryObjectCreatedEventCallbackDelegate); } + + _objectRegistryObjectCreatedEventHandler -= value; } } @@ -134,30 +128,24 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_objectRegistryObjectDestroyedEventHandler == null) { - // Restricted to only one listener - if (_objectRegistryObjectDestroyedEventHandler == null) - { - _objectRegistryObjectDestroyedEventHandler += value; - - _objectRegistryObjectDestroyedEventCallbackDelegate = new ObjectDestroyedEventCallbackDelegate(OnObjectDestroyed); - this.ObjectDestroyedSignal().Connect(_objectRegistryObjectDestroyedEventCallbackDelegate); - } + _objectRegistryObjectDestroyedEventHandler += value; + + _objectRegistryObjectDestroyedEventCallbackDelegate = new ObjectDestroyedEventCallbackDelegate(OnObjectDestroyed); + this.ObjectDestroyedSignal().Connect(_objectRegistryObjectDestroyedEventCallbackDelegate); } } remove { - lock (this) + if (_objectRegistryObjectDestroyedEventHandler != null) { - if (_objectRegistryObjectDestroyedEventHandler != null) - { - this.ObjectDestroyedSignal().Disconnect(_objectRegistryObjectDestroyedEventCallbackDelegate); - } - - _objectRegistryObjectDestroyedEventHandler -= value; + this.ObjectDestroyedSignal().Disconnect(_objectRegistryObjectDestroyedEventCallbackDelegate); } + + _objectRegistryObjectDestroyedEventHandler -= value; } } diff --git a/src/Tizen.NUI/src/internal/PageTurnView.cs b/src/Tizen.NUI/src/internal/PageTurnView.cs index 465142a..ff1a6e0 100755 --- a/src/Tizen.NUI/src/internal/PageTurnView.cs +++ b/src/Tizen.NUI/src/internal/PageTurnView.cs @@ -195,30 +195,24 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_pageTurnViewPagePanStartedEventHandler == null) { - // Restricted to only one listener - if (_pageTurnViewPagePanStartedEventHandler == null) - { - _pageTurnViewPagePanStartedEventHandler += value; - - _pageTurnViewPagePanStartedCallbackDelegate = new PagePanStartedCallbackDelegate(OnPagePanStarted); - this.PagePanStartedSignal().Connect(_pageTurnViewPagePanStartedCallbackDelegate); - } + _pageTurnViewPagePanStartedEventHandler += value; + + _pageTurnViewPagePanStartedCallbackDelegate = new PagePanStartedCallbackDelegate(OnPagePanStarted); + this.PagePanStartedSignal().Connect(_pageTurnViewPagePanStartedCallbackDelegate); } } remove { - lock (this) + if (_pageTurnViewPagePanStartedEventHandler != null) { - if (_pageTurnViewPagePanStartedEventHandler != null) - { - this.PagePanStartedSignal().Disconnect(_pageTurnViewPagePanStartedCallbackDelegate); - } - - _pageTurnViewPagePanStartedEventHandler -= value; + this.PagePanStartedSignal().Disconnect(_pageTurnViewPagePanStartedCallbackDelegate); } + + _pageTurnViewPagePanStartedEventHandler -= value; } } @@ -241,30 +235,24 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_pageTurnViewPagePanFinishedEventHandler == null) { - // Restricted to only one listener - if (_pageTurnViewPagePanFinishedEventHandler == null) - { - _pageTurnViewPagePanFinishedEventHandler += value; - - _pageTurnViewPagePanFinishedCallbackDelegate = new PagePanFinishedCallbackDelegate(OnPagePanFinished); - this.PagePanFinishedSignal().Connect(_pageTurnViewPagePanFinishedCallbackDelegate); - } + _pageTurnViewPagePanFinishedEventHandler += value; + + _pageTurnViewPagePanFinishedCallbackDelegate = new PagePanFinishedCallbackDelegate(OnPagePanFinished); + this.PagePanFinishedSignal().Connect(_pageTurnViewPagePanFinishedCallbackDelegate); } } remove { - lock (this) + if (_pageTurnViewPagePanFinishedEventHandler != null) { - if (_pageTurnViewPagePanFinishedEventHandler != null) - { - this.PagePanFinishedSignal().Disconnect(_pageTurnViewPagePanFinishedCallbackDelegate); - } - - _pageTurnViewPagePanFinishedEventHandler -= value; + this.PagePanFinishedSignal().Disconnect(_pageTurnViewPagePanFinishedCallbackDelegate); } + + _pageTurnViewPagePanFinishedEventHandler -= value; } } @@ -288,30 +276,24 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_pageTurnViewPageTurnStartedEventHandler == null) { - // Restricted to only one listener - if (_pageTurnViewPageTurnStartedEventHandler == null) - { - _pageTurnViewPageTurnStartedEventHandler += value; - - _pageTurnViewPageTurnStartedCallbackDelegate = new PageTurnStartedCallbackDelegate(OnPageTurnStarted); - this.PageTurnStartedSignal().Connect(_pageTurnViewPageTurnStartedCallbackDelegate); - } + _pageTurnViewPageTurnStartedEventHandler += value; + + _pageTurnViewPageTurnStartedCallbackDelegate = new PageTurnStartedCallbackDelegate(OnPageTurnStarted); + this.PageTurnStartedSignal().Connect(_pageTurnViewPageTurnStartedCallbackDelegate); } } remove { - lock (this) + if (_pageTurnViewPageTurnStartedEventHandler != null) { - if (_pageTurnViewPageTurnStartedEventHandler != null) - { - this.PageTurnStartedSignal().Disconnect(_pageTurnViewPageTurnStartedCallbackDelegate); - } - - _pageTurnViewPageTurnStartedEventHandler -= value; + this.PageTurnStartedSignal().Disconnect(_pageTurnViewPageTurnStartedCallbackDelegate); } + + _pageTurnViewPageTurnStartedEventHandler -= value; } } @@ -338,30 +320,24 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_pageTurnViewPageTurnFinishedEventHandler == null) { - // Restricted to only one listener - if (_pageTurnViewPageTurnFinishedEventHandler == null) - { - _pageTurnViewPageTurnFinishedEventHandler += value; - - _pageTurnViewPageTurnFinishedCallbackDelegate = new PageTurnFinishedCallbackDelegate(OnPageTurnFinished); - this.PageTurnFinishedSignal().Connect(_pageTurnViewPageTurnFinishedCallbackDelegate); - } + _pageTurnViewPageTurnFinishedEventHandler += value; + + _pageTurnViewPageTurnFinishedCallbackDelegate = new PageTurnFinishedCallbackDelegate(OnPageTurnFinished); + this.PageTurnFinishedSignal().Connect(_pageTurnViewPageTurnFinishedCallbackDelegate); } } remove { - lock (this) + if (_pageTurnViewPageTurnFinishedEventHandler != null) { - if (_pageTurnViewPageTurnFinishedEventHandler != null) - { - this.PageTurnFinishedSignal().Disconnect(_pageTurnViewPageTurnFinishedCallbackDelegate); - } - - _pageTurnViewPageTurnFinishedEventHandler -= value; + this.PageTurnFinishedSignal().Disconnect(_pageTurnViewPageTurnFinishedCallbackDelegate); } + + _pageTurnViewPageTurnFinishedEventHandler -= value; } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/Scrollable.cs b/src/Tizen.NUI/src/public/BaseComponents/Scrollable.cs index 6d245a6..bce42a6 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Scrollable.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Scrollable.cs @@ -237,30 +237,24 @@ namespace Tizen.NUI.BaseComponents { add { - lock (this) + // Restricted to only one listener + if (_scrollableStartedEventHandler == null) { - // Restricted to only one listener - if (_scrollableStartedEventHandler == null) - { - _scrollableStartedEventHandler += value; - - _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted); - this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate); - } + _scrollableStartedEventHandler += value; + + _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted); + this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate); } } remove { - lock (this) + if (_scrollableStartedEventHandler != null) { - if (_scrollableStartedEventHandler != null) - { - this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate); - } - - _scrollableStartedEventHandler -= value; + this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate); } + + _scrollableStartedEventHandler -= value; } } @@ -272,30 +266,24 @@ namespace Tizen.NUI.BaseComponents { add { - lock (this) + // Restricted to only one listener + if (_scrollableUpdatedEventHandler == null) { - // Restricted to only one listener - if (_scrollableUpdatedEventHandler == null) - { - _scrollableUpdatedEventHandler += value; - - _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated); - this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate); - } + _scrollableUpdatedEventHandler += value; + + _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated); + this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate); } } remove { - lock (this) + if (_scrollableUpdatedEventHandler != null) { - if (_scrollableUpdatedEventHandler != null) - { - this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate); - } - - _scrollableUpdatedEventHandler -= value; + this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate); } + + _scrollableUpdatedEventHandler -= value; } } @@ -308,30 +296,24 @@ namespace Tizen.NUI.BaseComponents { add { - lock (this) + // Restricted to only one listener + if (_scrollableCompletedEventHandler == null) { - // Restricted to only one listener - if (_scrollableCompletedEventHandler == null) - { - _scrollableCompletedEventHandler += value; - - _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted); - this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate); - } + _scrollableCompletedEventHandler += value; + + _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted); + this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate); } } remove { - lock (this) + if (_scrollableCompletedEventHandler != null) { - if (_scrollableCompletedEventHandler != null) - { - this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate); - } - - _scrollableCompletedEventHandler -= value; + this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate); } + + _scrollableCompletedEventHandler -= value; } } diff --git a/src/Tizen.NUI/src/public/PropertyNotification.cs b/src/Tizen.NUI/src/public/PropertyNotification.cs index 4853ae2..48eea3e 100755 --- a/src/Tizen.NUI/src/public/PropertyNotification.cs +++ b/src/Tizen.NUI/src/public/PropertyNotification.cs @@ -66,30 +66,24 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_propertyNotificationNotifyEventHandler == null) { - // Restricted to only one listener - if (_propertyNotificationNotifyEventHandler == null) - { - _propertyNotificationNotifyEventHandler += value; + _propertyNotificationNotifyEventHandler += value; - _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify); - this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate); - } + _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify); + this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate); } } remove { - lock (this) + if (_propertyNotificationNotifyEventHandler != null) { - if (_propertyNotificationNotifyEventHandler != null) - { - this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate); - } - - _propertyNotificationNotifyEventHandler -= value; + this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate); } + + _propertyNotificationNotifyEventHandler -= value; } } diff --git a/src/Tizen.NUI/src/public/UIComponents/ScrollViewEvent.cs b/src/Tizen.NUI/src/public/UIComponents/ScrollViewEvent.cs index 304bad3..0aacaa3 100755 --- a/src/Tizen.NUI/src/public/UIComponents/ScrollViewEvent.cs +++ b/src/Tizen.NUI/src/public/UIComponents/ScrollViewEvent.cs @@ -46,34 +46,28 @@ namespace Tizen.NUI { add { - lock (this) + // Restricted to only one listener + if (_scrollViewSnapStartedEventHandler == null) { - // Restricted to only one listener - if (_scrollViewSnapStartedEventHandler == null) - { - _scrollViewSnapStartedEventHandler += value; + _scrollViewSnapStartedEventHandler += value; - _scrollViewSnapStartedCallbackDelegate = new SnapStartedCallbackDelegate(OnSnapStarted); - ScrollViewSnapStartedSignal snapStarted = this.SnapStartedSignal(); - snapStarted?.Connect(_scrollViewSnapStartedCallbackDelegate); - snapStarted?.Dispose(); - } + _scrollViewSnapStartedCallbackDelegate = new SnapStartedCallbackDelegate(OnSnapStarted); + ScrollViewSnapStartedSignal snapStarted = this.SnapStartedSignal(); + snapStarted?.Connect(_scrollViewSnapStartedCallbackDelegate); + snapStarted?.Dispose(); } } remove { - lock (this) + if (_scrollViewSnapStartedEventHandler != null) { - if (_scrollViewSnapStartedEventHandler != null) - { - ScrollViewSnapStartedSignal snapStarted = this.SnapStartedSignal(); - snapStarted?.Disconnect(_scrollViewSnapStartedCallbackDelegate); - snapStarted?.Dispose(); - } - - _scrollViewSnapStartedEventHandler -= value; + ScrollViewSnapStartedSignal snapStarted = this.SnapStartedSignal(); + snapStarted?.Disconnect(_scrollViewSnapStartedCallbackDelegate); + snapStarted?.Dispose(); } + + _scrollViewSnapStartedEventHandler -= value; } } -- 2.7.4