: m_before(wxClassInfo::sm_first)
, m_handle(wxDllLoader::LoadLibrary( libname ))
, m_after(wxClassInfo::sm_first)
- , m_count(1)
+ , m_linkcount(1)
+ , m_objcount(0)
{
if( m_handle != 0 )
{
RegisterModules();
}
else
- --m_count; // Flag us for deletion
+ --m_linkcount; // Flag us for deletion
}
wxDLManifestEntry::~wxDLManifestEntry()
wxDllLoader::UnloadLibrary(m_handle);
}
+bool wxDLManifestEntry::UnrefLib()
+{
+ wxASSERT_MSG( m_objcount == 0, _T("Library unloaded before all objects were destroyed") );
+ if( m_linkcount == 0 || --m_linkcount == 0 )
+ {
+ delete this;
+ return TRUE;
+ }
+ return FALSE;
+}
// ------------------------
// Private methods
// the library is. We do have to keep a copy of the module's pointer
// though, as there is currently no way to Unregister it without it.
- wxASSERT_MSG( m_count == 1,
+ wxASSERT_MSG( m_linkcount == 1,
_T("RegisterModules should only be called for the first load") );
for(wxClassInfo *info = m_after; info != m_before; info = info->m_next)
oldNode = node;
} while( node );
- --m_count; // Flag us for deletion
+ --m_linkcount; // Flag us for deletion
break;
}
}
if( entry )
{
- entry->Ref();
+ entry->RefLib();
}
else
{
}
else
{
- wxCHECK_MSG( !entry->Unref(), 0,
+ wxCHECK_MSG( !entry->UnrefLib(), 0,
_T("Currently linked library is, ..not loaded??") );
entry = 0;
}
wxDLManifestEntry *entry = (wxDLManifestEntry*) ms_manifest.Get(libname);
if( entry )
- return entry->Unref();
+ return entry->UnrefLib();
wxLogDebug(_T("Attempt to Unlink library '%s' (which is not linked)."), libname.c_str());
return 0;
if( m_entry != 0 )
{
- m_entry->Ref();
+ m_entry->RefLib();
}
else
{
if( (wxDLManifestEntry*)node->GetData() == m_entry )
break;
- if( m_entry && m_entry->Unref() )
+ if( m_entry && m_entry->UnrefLib() )
delete node;
}