From 40039c5631fe5b2a024fd6ecd2bf97f832da1cfe Mon Sep 17 00:00:00 2001 From: Thog Date: Sun, 5 Jan 2020 17:35:55 +0100 Subject: [PATCH] Fix ReactiveObject initial event not being propagated with boolean types (#860) * Fix ReactiveObject initial event not being propagated with boolean types. This fix the logger configuration initial state being ignored. --- Ryujinx.Common/ReactiveObject.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Ryujinx.Common/ReactiveObject.cs b/Ryujinx.Common/ReactiveObject.cs index be30e9b2..8495c78f 100644 --- a/Ryujinx.Common/ReactiveObject.cs +++ b/Ryujinx.Common/ReactiveObject.cs @@ -6,7 +6,8 @@ namespace Ryujinx.Common public class ReactiveObject { private ReaderWriterLock _readerWriterLock = new ReaderWriterLock(); - private T _value; + private bool _isInitialized = false; + private T _value; public event EventHandler> Event; @@ -25,12 +26,15 @@ namespace Ryujinx.Common _readerWriterLock.AcquireWriterLock(Timeout.Infinite); T oldValue = _value; - - _value = value; + + bool oldIsInitialized = _isInitialized; + + _isInitialized = true; + _value = value; _readerWriterLock.ReleaseWriterLock(); - if (oldValue == null || !oldValue.Equals(_value)) + if (!oldIsInitialized || !oldValue.Equals(_value)) { Event?.Invoke(this, new ReactiveEventArgs(oldValue, value)); }