diff options
| author | Thog <me@thog.eu> | 2020-01-05 17:35:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-05 17:35:55 +0100 |
| commit | 40039c5631fe5b2a024fd6ecd2bf97f832da1cfe (patch) | |
| tree | 6b2691e5f8b651d95b9ac471e8408ecec43684fa | |
| parent | 01daefe38d0caff072579cb688dba5b9e3670fa4 (diff) | |
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.
| -rw-r--r-- | Ryujinx.Common/ReactiveObject.cs | 12 |
1 files 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<T> { private ReaderWriterLock _readerWriterLock = new ReaderWriterLock(); - private T _value; + private bool _isInitialized = false; + private T _value; public event EventHandler<ReactiveEventArgs<T>> 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<T>(oldValue, value)); } |
