Fix crash when using attributes cache after hot-reload in editor
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
class FLAXENGINE_API MAssembly
|
class FLAXENGINE_API MAssembly
|
||||||
{
|
{
|
||||||
|
friend MCore;
|
||||||
friend MDomain;
|
friend MDomain;
|
||||||
friend Scripting;
|
friend Scripting;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
class FLAXENGINE_API MEvent
|
class FLAXENGINE_API MEvent
|
||||||
{
|
{
|
||||||
friend MClass;
|
friend MClass;
|
||||||
|
friend MCore;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if USE_MONO
|
#if USE_MONO
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
class FLAXENGINE_API MField
|
class FLAXENGINE_API MField
|
||||||
{
|
{
|
||||||
friend MClass;
|
friend MClass;
|
||||||
|
friend MCore;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if USE_MONO
|
#if USE_MONO
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class FLAXENGINE_API MMethod
|
|||||||
friend MClass;
|
friend MClass;
|
||||||
friend MProperty;
|
friend MProperty;
|
||||||
friend MEvent;
|
friend MEvent;
|
||||||
|
friend MCore;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if USE_MONO
|
#if USE_MONO
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
class FLAXENGINE_API MProperty
|
class FLAXENGINE_API MProperty
|
||||||
{
|
{
|
||||||
friend MClass;
|
friend MClass;
|
||||||
|
friend MCore;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if USE_MONO
|
#if USE_MONO
|
||||||
|
|||||||
@@ -336,7 +336,46 @@ void MCore::ReloadScriptingAssemblyLoadContext()
|
|||||||
{
|
{
|
||||||
// Clear any cached class attributes (see https://github.com/FlaxEngine/FlaxEngine/issues/1108)
|
// Clear any cached class attributes (see https://github.com/FlaxEngine/FlaxEngine/issues/1108)
|
||||||
for (auto e : CachedClassHandles)
|
for (auto e : CachedClassHandles)
|
||||||
|
{
|
||||||
|
e.Value->_hasCachedAttributes = false;
|
||||||
e.Value->_attributes.Clear();
|
e.Value->_attributes.Clear();
|
||||||
|
}
|
||||||
|
for (auto e : CachedAssemblyHandles)
|
||||||
|
{
|
||||||
|
MAssembly* a = e.Value;
|
||||||
|
if (!a->IsLoaded() || !a->_hasCachedClasses)
|
||||||
|
continue;
|
||||||
|
for (auto q : a->GetClasses())
|
||||||
|
{
|
||||||
|
MClass* c = q.Value;
|
||||||
|
c->_hasCachedAttributes = false;
|
||||||
|
c->_attributes.Clear();
|
||||||
|
if (c->_hasCachedMethods)
|
||||||
|
{
|
||||||
|
for (MMethod* m : c->GetMethods())
|
||||||
|
{
|
||||||
|
m->_hasCachedAttributes = false;
|
||||||
|
m->_attributes.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c->_hasCachedFields)
|
||||||
|
{
|
||||||
|
for (MField* f : c->GetFields())
|
||||||
|
{
|
||||||
|
f->_hasCachedAttributes = false;
|
||||||
|
f->_attributes.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c->_hasCachedProperties)
|
||||||
|
{
|
||||||
|
for (MProperty* p : c->GetProperties())
|
||||||
|
{
|
||||||
|
p->_hasCachedAttributes = false;
|
||||||
|
p->_attributes.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void* ReloadScriptingAssemblyLoadContextPtr = GetStaticMethodPointer(TEXT("ReloadScriptingAssemblyLoadContext"));
|
static void* ReloadScriptingAssemblyLoadContextPtr = GetStaticMethodPointer(TEXT("ReloadScriptingAssemblyLoadContext"));
|
||||||
CallStaticMethod<void>(ReloadScriptingAssemblyLoadContextPtr);
|
CallStaticMethod<void>(ReloadScriptingAssemblyLoadContextPtr);
|
||||||
|
|||||||
Reference in New Issue
Block a user