From 4e648b8e7c65fd8c382baf6b6798cdedfac5cdd8 Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Fri, 3 Aug 2012 14:02:01 +0200 Subject: tubes: create contacts dialog instance for each document separately This solves a crash when static dialog instance was destroyed on closing of one document but then was used in another document. Change-Id: I6ac9edb1de83f638bdf4ce7c0814fcbdf4b4b1e5 --- tubes/source/contacts.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tubes/source') diff --git a/tubes/source/contacts.cxx b/tubes/source/contacts.cxx index 540e8a6f4725..9245b55284b4 100644 --- a/tubes/source/contacts.cxx +++ b/tubes/source/contacts.cxx @@ -42,10 +42,13 @@ #include #include +#include #include #include #include +namespace { + ResId TubesResId( sal_uInt32 nId ) { static ResMgr* pResMgr = NULL; @@ -56,7 +59,6 @@ ResId TubesResId( sal_uInt32 nId ) return ResId( nId, *pResMgr ); } -namespace { class TubeContacts : public ModelessDialog { FixedLine maLabel; @@ -261,12 +263,22 @@ IMPL_LINK_NOARG( TubeContacts, BtnListenHdl ) return 0; } +TubeContacts* ContactsFactory( Collaboration* pCollaboration ) +{ + // Mapping contacts dialog instance for each document + static std::map< sal_uInt64, TubeContacts* > aDialogsMap; + sal_uInt64 Id = pCollaboration->GetId(); + if (aDialogsMap.find( Id ) == aDialogsMap.end()) + aDialogsMap[ Id ] = new TubeContacts( pCollaboration ); + return aDialogsMap[ Id ]; +} + } // anonymous namespace namespace tubes { void createContacts( Collaboration* pCollaboration ) { - static TubeContacts *pContacts = new TubeContacts( pCollaboration ); + TubeContacts* pContacts = ContactsFactory( pCollaboration ); pContacts->Populate(); } } -- cgit