Fix Delegate invoke to copy arguments values to each call instead of passing as reference
This commit is contained in:
@@ -105,7 +105,7 @@ public:
|
|||||||
OnSet(other._asset);
|
OnSet(other._asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetReference(AssetReference&& other)
|
AssetReference(AssetReference&& other) noexcept
|
||||||
{
|
{
|
||||||
OnSet(other._asset);
|
OnSet(other._asset);
|
||||||
other.OnSet(nullptr);
|
other.OnSet(nullptr);
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Binds a static function.
|
/// Binds a static function.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
template<ReturnType (*Method)(Params...)>
|
template<ReturnType(*Method)(Params...)>
|
||||||
void Bind()
|
void Bind()
|
||||||
{
|
{
|
||||||
if (_lambda)
|
if (_lambda)
|
||||||
@@ -288,6 +288,7 @@ protected:
|
|||||||
// Single allocation for list of binded functions. Thread-safe access via atomic operations. Removing binded function simply clears the entry to handle function unregister during invocation.
|
// Single allocation for list of binded functions. Thread-safe access via atomic operations. Removing binded function simply clears the entry to handle function unregister during invocation.
|
||||||
intptr volatile _ptr = 0;
|
intptr volatile _ptr = 0;
|
||||||
intptr volatile _size = 0;
|
intptr volatile _size = 0;
|
||||||
|
typedef void (*StubSignature)(void*, Params...);
|
||||||
#else
|
#else
|
||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
@@ -297,7 +298,6 @@ protected:
|
|||||||
// Holds pointer to Data with Functions and Locker. Thread-safe access via atomic operations.
|
// Holds pointer to Data with Functions and Locker. Thread-safe access via atomic operations.
|
||||||
intptr volatile _data = 0;
|
intptr volatile _data = 0;
|
||||||
#endif
|
#endif
|
||||||
typedef void (*StubSignature)(void*, Params...);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Delegate()
|
Delegate()
|
||||||
@@ -811,7 +811,7 @@ public:
|
|||||||
auto function = (StubSignature)Platform::AtomicRead((intptr volatile*)&bindings->_function);
|
auto function = (StubSignature)Platform::AtomicRead((intptr volatile*)&bindings->_function);
|
||||||
auto callee = (void*)Platform::AtomicRead((intptr volatile*)&bindings->_callee);
|
auto callee = (void*)Platform::AtomicRead((intptr volatile*)&bindings->_callee);
|
||||||
if (function != nullptr && function == (StubSignature)Platform::AtomicRead((intptr volatile*)&bindings->_function))
|
if (function != nullptr && function == (StubSignature)Platform::AtomicRead((intptr volatile*)&bindings->_function))
|
||||||
function(callee, Forward<Params>(params)...);
|
function(callee, params...);
|
||||||
++bindings;
|
++bindings;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -823,7 +823,7 @@ public:
|
|||||||
{
|
{
|
||||||
const FunctionType& item = i->Item;
|
const FunctionType& item = i->Item;
|
||||||
ASSERT_LOW_LAYER(item._function);
|
ASSERT_LOW_LAYER(item._function);
|
||||||
item._function(item._callee, Forward<Params>(params)...);
|
item._function(item._callee, params...);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,7 +319,6 @@ inline T&& Forward(typename TRemoveReference<T>::Type& t) noexcept
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
inline T&& Forward(typename TRemoveReference<T>::Type&& t) noexcept
|
inline T&& Forward(typename TRemoveReference<T>::Type&& t) noexcept
|
||||||
{
|
{
|
||||||
static_assert(!TIsLValueReference<T>::Value, "Can not forward an rvalue as an lvalue.");
|
|
||||||
return static_cast<T&&>(t);
|
return static_cast<T&&>(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user