Fix crash when using attributes cache after hot-reload in editor
This commit is contained in:
@@ -336,7 +336,46 @@ void MCore::ReloadScriptingAssemblyLoadContext()
|
||||
{
|
||||
// Clear any cached class attributes (see https://github.com/FlaxEngine/FlaxEngine/issues/1108)
|
||||
for (auto e : CachedClassHandles)
|
||||
{
|
||||
e.Value->_hasCachedAttributes = false;
|
||||
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"));
|
||||
CallStaticMethod<void>(ReloadScriptingAssemblyLoadContextPtr);
|
||||
|
||||
Reference in New Issue
Block a user