mirror of
https://github.com/Ryujinx-NX/Ryujinx.git
synced 2024-11-14 21:17:43 -07:00
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:
parent
01daefe38d
commit
40039c5631
@ -6,7 +6,8 @@ namespace Ryujinx.Common
|
|||||||
public class ReactiveObject<T>
|
public class ReactiveObject<T>
|
||||||
{
|
{
|
||||||
private ReaderWriterLock _readerWriterLock = new ReaderWriterLock();
|
private ReaderWriterLock _readerWriterLock = new ReaderWriterLock();
|
||||||
private T _value;
|
private bool _isInitialized = false;
|
||||||
|
private T _value;
|
||||||
|
|
||||||
public event EventHandler<ReactiveEventArgs<T>> Event;
|
public event EventHandler<ReactiveEventArgs<T>> Event;
|
||||||
|
|
||||||
@ -25,12 +26,15 @@ namespace Ryujinx.Common
|
|||||||
_readerWriterLock.AcquireWriterLock(Timeout.Infinite);
|
_readerWriterLock.AcquireWriterLock(Timeout.Infinite);
|
||||||
|
|
||||||
T oldValue = _value;
|
T oldValue = _value;
|
||||||
|
|
||||||
_value = value;
|
bool oldIsInitialized = _isInitialized;
|
||||||
|
|
||||||
|
_isInitialized = true;
|
||||||
|
_value = value;
|
||||||
|
|
||||||
_readerWriterLock.ReleaseWriterLock();
|
_readerWriterLock.ReleaseWriterLock();
|
||||||
|
|
||||||
if (oldValue == null || !oldValue.Equals(_value))
|
if (!oldIsInitialized || !oldValue.Equals(_value))
|
||||||
{
|
{
|
||||||
Event?.Invoke(this, new ReactiveEventArgs<T>(oldValue, value));
|
Event?.Invoke(this, new ReactiveEventArgs<T>(oldValue, value));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user