Destructor of static objects not called during hot load

In component of your choice, add:

#include <fstream>
struct foo
{
	foo()
	{ 
		std::ofstream ofs("test.txt");
		ofs << "Created" << std::endl; 
	}
	~foo()
	{ 
		std::ofstream ofs("test.txt", std::ios::app);
		ofs << "Destroyed" << std::endl;
	}
} inst;

Expected output in the file is Created followed by Destroyed, yet it only contains Created.

Hey Saironyn-

Can you elaborate on what exactly is happening? I added the struct to an ActorClass and compiled. After the hot reload I did not see Created or Destroyed in the output log in the editor.

Yeah, it seems the log isn’t hooked up yet in neither the constructor nor the destructor. That’s why I used ofstream instead to write to a file :slight_smile:

A hot reload does not necessarily trigger a constructor or destructor on its own. Are you adding an instance of the class to the level prior to the hot reload? Can you explain what you are attempting to do?

Hi Saironyn,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.