Add wxDynamicLibrary::Attach()

This is symmetric with Detach() and can be useful and doesn't cost
anything to have.
This commit is contained in:
Vadim Zeitlin
2021-01-25 00:10:10 +01:00
parent e094734a89
commit 4de8857c85
2 changed files with 20 additions and 3 deletions

View File

@@ -242,6 +242,9 @@ public:
// library couldn't be loaded but simply returns NULL
static wxDllType RawLoad(const wxString& libname, int flags = wxDL_DEFAULT);
// attach to an existing handle
void Attach(wxDllType h) { Unload(); m_handle = h; }
// detach the library object from its handle, i.e. prevent the object from
// unloading the library in its dtor -- the caller is now responsible for
// doing this

View File

@@ -147,9 +147,23 @@ public:
wxPluginCategory cat = wxDL_PLUGIN_GUI);
/**
Detaches this object from its library handle, i.e.\ the object will not
unload the library any longer in its destructor but it is now the
callers responsibility to do this using Unload().
Attaches the object to an existing handle.
This allows to give ownership of an existing handle, possibly obtained
from Detach(), to this object, so that it will unload it when destroyed.
@since 3.1.5
*/
void Attach(wxDllType h);
/**
Detaches this object from its library handle.
This means that the object will not unload the library any longer in
its destructor but it is now the callers responsibility to do this
using static Unload().
@see Attach()
*/
wxDllType Detach();