impress195: #i112510# Stop leaking task pane FocusManager singleton.

This commit is contained in:
Andre Fischer
2010-07-14 14:03:14 +02:00
parent a800b0d9fd
commit cff2fd0093
2 changed files with 13 additions and 7 deletions

19
sd/source/ui/toolpanel/TaskPaneFocusManager.cxx Normal file → Executable file
View File

@@ -31,9 +31,9 @@
#include "TaskPaneFocusManager.hxx" #include "TaskPaneFocusManager.hxx"
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <vos/mutex.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/event.hxx> #include <vcl/event.hxx>
#include <rtl/instance.hxx>
#include <hash_map> #include <hash_map>
namespace { namespace {
@@ -70,16 +70,23 @@ class FocusManager::LinkMap
FocusManager* FocusManager::spInstance = NULL;
FocusManager& FocusManager::Instance (void) FocusManager& FocusManager::Instance (void)
{ {
static FocusManager* spInstance = NULL;
if (spInstance == NULL) if (spInstance == NULL)
{ {
::vos::OGuard aGuard (::Application::GetSolarMutex()); ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
if (spInstance == NULL) if (spInstance == NULL)
spInstance = new FocusManager (); {
static FocusManager aInstance;
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
spInstance = &aInstance;
}
}
else
{
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
} }
return *spInstance; return *spInstance;
} }

1
sd/source/ui/toolpanel/TaskPaneFocusManager.hxx Normal file → Executable file
View File

@@ -103,7 +103,6 @@ public:
bool TransferFocus (::Window* pSource, const KeyCode& rCode); bool TransferFocus (::Window* pSource, const KeyCode& rCode);
private: private:
static FocusManager* spInstance;
class LinkMap; class LinkMap;
::std::auto_ptr<LinkMap> mpLinks; ::std::auto_ptr<LinkMap> mpLinks;