X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d2980921209fdf004244a72ebf88658987e2a986..e0176dd9fb716ad0a1a8804f0a93e16048f09054:/src/common/dynload.cpp diff --git a/src/common/dynload.cpp b/src/common/dynload.cpp index ebff36b860..5bb2496dff 100644 --- a/src/common/dynload.cpp +++ b/src/common/dynload.cpp @@ -87,6 +87,7 @@ wxPluginLibrary::wxPluginLibrary(const wxString &libname, int flags) if( m_handle != 0 ) { + UpdateClasses(); RegisterModules(); } else @@ -101,6 +102,7 @@ wxPluginLibrary::~wxPluginLibrary() if( m_handle != 0 ) { UnregisterModules(); + RestoreClasses(); } } @@ -118,7 +120,7 @@ bool wxPluginLibrary::UnrefLib() wxASSERT_MSG( m_objcount == 0, _T("Library unloaded before all objects were destroyed") ); - if ( --m_linkcount == 0 ) + if ( m_linkcount == 0 || --m_linkcount == 0 ) { delete this; return TRUE; @@ -131,6 +133,31 @@ bool wxPluginLibrary::UnrefLib() // Private methods // ------------------------ +void wxPluginLibrary::UpdateClasses() +{ + for (wxClassInfo *info = m_after; info != m_before; info = info->m_next) + { + if( info->m_className ) + { + // Hash all the class names into a local table too so + // we can quickly find the entry they correspond to. + (*ms_classes)[info->m_className] = this; + } + } +} + +void wxPluginLibrary::RestoreClasses() +{ + // Check if there is a need to restore classes. + if (!ms_classes) + return; + + for(wxClassInfo *info = m_after; info != m_before; info = info->m_next) + { + ms_classes->erase(ms_classes->find(info->m_className)); + } +} + void wxPluginLibrary::RegisterModules() { // Plugin libraries might have wxModules, Register and initialise them if @@ -199,7 +226,8 @@ void wxPluginLibrary::UnregisterModules() for ( it = m_wxmodules.begin(); it != m_wxmodules.end(); ++it ) wxModule::UnregisterModule( *it ); - WX_CLEAR_LIST(wxModuleList, m_wxmodules); + // NB: content of the list was deleted by UnregisterModule calls above: + m_wxmodules.clear(); } @@ -434,7 +462,7 @@ wxLibrary::wxLibrary(wxDllType handle) // Some system may use a local heap for library. get_first = (t_get_first)GetSymbol(_T("wxGetClassFirst")); - // It is a wxWindows DLL. + // It is a wxWidgets DLL. if (get_first) PrepareClasses(get_first()); }