Hi,
I believe I’ve found a bizarre bug and I’m struggling to think of an answer.
In short, I’m using a plugin that has a runtime and editor module. A key runtime file has a TSharedPtr<IEditorAccess>
with a get and set method. An editor class’ constructor calls the set method.
The TSharedPtr<IEditorAccess>
is defined in the CPP file as TSharedPtr<IEditorAccess> URuntimeClass::EditorAccess = nullptr;
. Every time a hot reload occurs, this line is run, nullifying the pointer without the editor class’s constructor running again to set it.
I also believe the resource being pointed to isn’t destroyed as no logs or breakpoints run in the class’ destructor.
Some solutions I’ve thought of:
- Disable the
xxx = nullptr
during hot reloads. However, not sure if hot reloads are detectable - Create the
IEditorAccess
during theGet
method, if the variable is null. However, if the previous resource isn’t GC’d then this would be a memory leak? - Try a different smart pointer. Maybe one from the standard library that will definitely clean up the resource
- Disallow hot reloading for the plugin. Not sure if this is even possible
Is there any way around this or possible solutions I could try?
Kind regards,
James