From: Eunki, Hong Date: Tue, 30 May 2023 09:17:11 +0000 (+0900) Subject: [NUI] Double buffered ProcessorOnceEvent so we allow attach event during invoke X-Git-Tag: submit/tizen/20230531.055555~1^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb1716f85534d212e19ed180a1c8b4a14432d671;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Double buffered ProcessorOnceEvent so we allow attach event during invoke When we load cached image, `ResourceLoaded` signal invoked immediate. So, `ResourceLoaded` can be called during `UpdateImage(object, EventArgs)`. But since we make null after invoke + C# didn't invoke event during invoking. That mean, attached `UpdateImage()` information disapeared. So we need to allow `UpdateImage()` event invoke during `ProcessorOnceEvent` invoking. Signed-off-by: Eunki, Hong --- diff --git a/src/Tizen.NUI/src/internal/Common/ProcessorController.cs b/src/Tizen.NUI/src/internal/Common/ProcessorController.cs index e4a847dbb..3a968a223 100755 --- a/src/Tizen.NUI/src/internal/Common/ProcessorController.cs +++ b/src/Tizen.NUI/src/internal/Common/ProcessorController.cs @@ -41,6 +41,11 @@ namespace Tizen.NUI internal ProcessorController(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { + onceEventIndex = 0u; + internalProcessorOnceEvent = new EventHandler[2]; + internalProcessorOnceEvent[0] = null; + internalProcessorOnceEvent[1] = null; + processorCallback = new ProcessorEventHandler(Process); Interop.ProcessorController.SetCallback(SwigCPtr, processorCallback); } @@ -50,7 +55,21 @@ namespace Tizen.NUI private ProcessorEventHandler processorCallback = null; - public event EventHandler ProcessorOnceEvent; + private uint onceEventIndex; + // Double buffered once event processing + private EventHandler[] internalProcessorOnceEvent; + + public event EventHandler ProcessorOnceEvent + { + add + { + internalProcessorOnceEvent[onceEventIndex] += value; + } + remove + { + internalProcessorOnceEvent[onceEventIndex] -= value; + } + } public event EventHandler ProcessorEvent; public event EventHandler LayoutProcessorEvent; @@ -68,15 +87,20 @@ namespace Tizen.NUI public void Process() { - ProcessorOnceEvent?.Invoke(this, null); - ProcessorOnceEvent = null; + // Let us add once event into 1 index during 0 event invoke + onceEventIndex = 1; + internalProcessorOnceEvent[0]?.Invoke(this, null); + internalProcessorOnceEvent[0] = null; + ProcessorEvent?.Invoke(this, null); LayoutProcessorEvent?.Invoke(this, null); - // To avoid ImageView's properties mismatched problem, - // We need to invoke events now which attached during LayoutProcessor. - ProcessorOnceEvent?.Invoke(this, null); - ProcessorOnceEvent = null; + // Let us add once event into 0 index during 1 event invoke + // Note : To avoid ImageView's properties mismatched problem, + // We need to invoke events now which attached during internalProcessorOnceEvent[0] and LayoutProcessor. + onceEventIndex = 0; + internalProcessorOnceEvent[1]?.Invoke(this, null); + internalProcessorOnceEvent[1] = null; } /// @@ -86,7 +110,8 @@ namespace Tizen.NUI protected override void Dispose(DisposeTypes type) { Interop.ProcessorController.RemoveCallback(SwigCPtr, processorCallback); - ProcessorOnceEvent = null; + internalProcessorOnceEvent[0] = null; + internalProcessorOnceEvent[1] = null; ProcessorEvent = null; LayoutProcessorEvent = null; GC.SuppressFinalize(this); diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index ae1272a53..3e520a33d 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -1498,8 +1498,9 @@ namespace Tizen.NUI.BaseComponents /// private void UpdateImage(object source, EventArgs e) { - UpdateImage(); + // Note : To allow event attachment during UpdateImage, let we make flag as false before call UpdateImage(). imagePropertyUpdateProcessAttachedFlag = false; + UpdateImage(); } ///