diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2012-08-03 14:02:01 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-08-04 01:57:11 +0200 |
commit | 4e648b8e7c65fd8c382baf6b6798cdedfac5cdd8 (patch) | |
tree | 54117d9e82a40d480cbbee7feb7d28a1d3f63fd8 /tubes | |
parent | f2c7d7aea4ec8c1f9f38e1d00c14dadca67b863e (diff) |
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
Diffstat (limited to 'tubes')
-rw-r--r-- | tubes/inc/tubes/collaboration.hxx | 3 | ||||
-rw-r--r-- | tubes/source/contacts.cxx | 16 |
2 files changed, 16 insertions, 3 deletions
diff --git a/tubes/inc/tubes/collaboration.hxx b/tubes/inc/tubes/collaboration.hxx index 5a3dddc89987..31eff7a4b937 100644 --- a/tubes/inc/tubes/collaboration.hxx +++ b/tubes/inc/tubes/collaboration.hxx @@ -23,7 +23,8 @@ public: Collaboration() {} virtual ~Collaboration() {} - virtual TeleConference* GetConference() const = 0; + virtual TeleConference* GetConference() = 0; + virtual sal_uInt64 GetId() = 0; virtual void SetCollaboration( TeleConference* pConference ) = 0; // TODO: I think this could be moved to TeleManager later. virtual void SendFile( TpContact* pContact, const OUString& rURL ) = 0; 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 <vcl/dialog.hxx> #include <vcl/unohelp.hxx> +#include <map> #include <vector> #include <boost/ptr_container/ptr_vector.hpp> #include <telepathy-glib/telepathy-glib.h> +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(); } } |