I have created a UObject subclass that wraps an object from an external library. I have a “normal” C++ pointer to the external object, and I can initialize that object whenever I first need it (by calling the appropriate external creation method).
I can also clear the pointer in the copy constructor (so that the copied UObject will create its own new object when needed).
But what I can’t work out is how to call the external library destructor method when my UObject is garbage collected. And I really want to call the external library object free method, because insde the object there’s open sockets, and a thread, and a lot of other stuff that I really want to go away when my UObject is no longer used.
Overriding the C++ destructor doesn’t seem to work (compiler errors) and searching the net also hasn’t turned anything up.
So either I’m searching for the wrong keywords, or I should be going about what I want to do in a completely different way.
Can anyone enlighten me?
(And please note that even though I have 30+ years of C++ developer experience I am a Unreal noob, so in case I’m asking a bleedin’ obvious question please point me in the right diretion…)