From d6d35d970f3a7b4db7e29f7d2eddb0c078cba4a5 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 3 Aug 2012 13:54:35 -0700 Subject: CHUI-263 : Fix crash on exit. LLSingleton like LLConversationLog cannot be an LLFriendObserver at the same time. --- indra/newview/llconversationlog.cpp | 38 +++++++++++++++++++++++++++---------- indra/newview/llconversationlog.h | 9 +++++---- 2 files changed, 33 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp index df9350407d..137b97326c 100644 --- a/indra/newview/llconversationlog.cpp +++ b/indra/newview/llconversationlog.cpp @@ -139,6 +139,31 @@ void LLConversation::setListenIMFloaterOpened() mIMFloaterShowedConnection = LLIMFloater::setIMFloaterShowedCallback(boost::bind(&LLConversation::onIMFloaterShown, this, _1)); } } +/************************************************************************/ +/* LLConversationLogFriendObserver implementation */ +/************************************************************************/ + +// Note : An LLSingleton like LLConversationLog cannot be an LLFriendObserver +// at the same time. +// This is because avatar observers are deleted by the observed object which +// conflicts with the way LLSingleton are deleted. + +class LLConversationLogFriendObserver : public LLFriendObserver +{ +public: + LLConversationLogFriendObserver() {} + virtual ~LLConversationLogFriendObserver() {} + virtual void changed(U32 mask); +}; + +void LLConversationLogFriendObserver::changed(U32 mask) +{ + if (mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE)) + { + LLConversationLog::instance().notifyObservers(); + } +} + /************************************************************************/ /* LLConversationLog implementation */ /************************************************************************/ @@ -148,7 +173,9 @@ LLConversationLog::LLConversationLog() loadFromFile(getFileName()); LLIMMgr::instance().addSessionObserver(this); - LLAvatarTracker::instance().addObserver(this); + + mFriendObserver = new LLConversationLogFriendObserver; + LLAvatarTracker::instance().addObserver(mFriendObserver); } void LLConversationLog::logConversation(const LLConversation& conversation) { @@ -204,15 +231,6 @@ void LLConversationLog::sessionAdded(const LLUUID& session_id, const std::string } } -// LLFriendObserver -void LLConversationLog::changed(U32 mask) -{ - if (mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE)) - { - notifyObservers(); - } -} - void LLConversationLog::cache() { saveToFile(getFileName()); diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h index 18865bb80e..a7457d55e3 100644 --- a/indra/newview/llconversationlog.h +++ b/indra/newview/llconversationlog.h @@ -99,7 +99,7 @@ private: * To distinguish two conversations with the same sessionID it's also needed to compare their creation date. */ -class LLConversationLog : public LLSingleton, LLIMSessionObserver, LLFriendObserver +class LLConversationLog : public LLSingleton, LLIMSessionObserver { friend class LLSingleton; public: @@ -126,8 +126,8 @@ public: virtual void sessionRemoved(const LLUUID& session_id){} // Stub virtual void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id){} // Stub - // LLFriendObserver trigger - virtual void changed(U32 mask); + // Triggered by LLFriendObserver change + void notifyObservers(); /** * public method which is called on viewer exit to save conversation log @@ -137,7 +137,6 @@ public: private: LLConversationLog(); - void notifyObservers(); /** * constructs file name in which conversations log will be saved @@ -152,6 +151,8 @@ private: typedef std::vector conversations_vec_t; std::vector mConversations; std::set mObservers; + + LLFriendObserver* mFriendObserver; // Observer of the LLAvatarTracker instance }; class LLConversationLogObserver -- cgit v1.2.3