--- dtrans.orig/source/X11/X11_selection.cxx 2009-05-25 11:39:14.000000000 +0100 +++ dtrans.orig/source/X11/X11_selection.cxx 2009-05-25 11:58:11.000000000 +0100 @@ -203,10 +203,17 @@ // ------------------------------------------------------------------------ +SelectionManager::InstanceHolder::~InstanceHolder() +{ + ::std::hash_map< OUString, SelectionManager*, OUStringHash >::iterator it; + for( it = maInstances.begin(); it != maInstances.end(); ++it ) + delete it->second; +} + ::std::hash_map< OUString, SelectionManager*, OUStringHash >& SelectionManager::getInstances() { - static ::std::hash_map< OUString, SelectionManager*, OUStringHash > aInstances; - return aInstances; + static InstanceHolder aInstanceHolder; + return aInstanceHolder.maInstances; } // ------------------------------------------------------------------------ @@ -470,18 +477,7 @@ #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "SelectionManager::~SelectionManager (%s)\n", m_pDisplay ? DisplayString(m_pDisplay) : "no display" ); #endif - { - MutexGuard aGuard( *Mutex::getGlobalMutex() ); - ::std::hash_map< OUString, SelectionManager*, OUStringHash >::iterator it; - for( it = getInstances().begin(); it != getInstances().end(); ++it ) - if( it->second == this ) - { - getInstances().erase( it ); - break; - } - } - if( m_aThread ) { osl_terminateThread( m_aThread ); --- dtrans.orig/source/X11/X11_selection.hxx 2009-05-25 11:39:14.000000000 +0100 +++ dtrans.orig/source/X11/X11_selection.hxx 2009-05-25 11:58:11.000000000 +0100 @@ -252,6 +252,13 @@ { m_pTarget = rEntry.m_pTarget; m_aRootWindow = rEntry.m_aRootWindow; return *this; } }; + // a struct to hold data associated with each instance to clean-up + struct InstanceHolder + { + ::std::hash_map< ::rtl::OUString, SelectionManager*, ::rtl::OUStringHash > maInstances; + ~InstanceHolder(); + }; + // internal data Display* m_pDisplay; oslThread m_aThread;