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.
This commit is contained in:
Thog 2020-01-05 17:35:55 +01:00 committed by GitHub
parent 01daefe38d
commit 40039c5631
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,7 @@ namespace Ryujinx.Common
public class ReactiveObject<T>
{
private ReaderWriterLock _readerWriterLock = new ReaderWriterLock();
private bool _isInitialized = false;
private T _value;
public event EventHandler<ReactiveEventArgs<T>> Event;
@ -26,11 +27,14 @@ namespace Ryujinx.Common
T oldValue = _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));
}