Skip to content

Commit 0114be2

Browse files
committed
viewer#2985 Odd crash when notifying voice observers
Crash points at enableDisableCallBtn, but button's floater was cleaned earlier and has a removeObserver call so an observer record should be long gone. Likely something else is going on. Went over various callbacks and made sure they are cleaned. But in case floater somehow remained, added mSession = nullptr.
1 parent cbd7130 commit 0114be2

15 files changed

+86
-38
lines changed

indra/newview/llappviewer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5151,10 +5151,7 @@ void LLAppViewer::sendLogoutRequest()
51515151
gLogoutMaxTime = LOGOUT_REQUEST_TIME;
51525152
mLogoutRequestSent = true;
51535153

5154-
if(LLVoiceClient::instanceExists())
5155-
{
5156-
LLVoiceClient::getInstance()->setVoiceEnabled(false);
5157-
}
5154+
LLVoiceClient::setVoiceEnabled(false);
51585155
}
51595156
}
51605157

indra/newview/llchiclet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ bool LLChicletPanel::postBuild()
511511
LLScriptFloaterManager::getInstance()->addNewObjectCallback(boost::bind(&LLChicletPanel::objectChicletCallback, this, _1));
512512
LLScriptFloaterManager::getInstance()->addToggleObjectFloaterCallback(boost::bind(&LLChicletPanel::objectChicletCallback, this, _1));
513513
LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLChicletPanel::findChiclet<LLChiclet>, this, _1));
514-
LLVoiceChannel::setCurrentVoiceChannelChangedCallback(boost::bind(&LLChicletPanel::onCurrentVoiceChannelChanged, this, _1));
514+
mVoiceChannelChanged = LLVoiceChannel::setCurrentVoiceChannelChangedCallback(boost::bind(&LLChicletPanel::onCurrentVoiceChannelChanged, this, _1));
515515

516516
mLeftScrollButton=getChild<LLButton>("chicklet_left_scroll_button");
517517
LLTransientFloaterMgr::getInstance()->addControlView(mLeftScrollButton);

indra/newview/llchiclet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,8 @@ class LLChicletPanel : public LLPanel
822822
S32 mMinWidth;
823823
bool mShowControls;
824824
static const S32 s_scroll_ratio;
825+
826+
boost::signals2::connection mVoiceChannelChanged;
825827
};
826828

827829
template<class T>

indra/newview/llconversationlog.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@ LLConversationLog::LLConversationLog() :
190190
{
191191
}
192192

193+
LLConversationLog::~LLConversationLog()
194+
{
195+
if (mLoggingEnabled)
196+
{
197+
if (LLIMMgr::instanceExists())
198+
{
199+
LLIMMgr::instance().removeSessionObserver(this);
200+
}
201+
LLAvatarTracker::instance().removeObserver(mFriendObserver);
202+
}
203+
if (mAvatarNameCacheConnection.connected())
204+
{
205+
mAvatarNameCacheConnection.disconnect();
206+
}
207+
}
208+
193209
void LLConversationLog::enableLogging(S32 log_mode)
194210
{
195211
mLoggingEnabled = log_mode > 0;

indra/newview/llconversationlog.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,7 @@ class LLConversationLog : public LLSingleton<LLConversationLog>, LLIMSessionObse
166166

167167
private:
168168

169-
virtual ~LLConversationLog()
170-
{
171-
if (mAvatarNameCacheConnection.connected())
172-
{
173-
mAvatarNameCacheConnection.disconnect();
174-
}
175-
}
169+
virtual ~LLConversationLog();
176170

177171
void enableLogging(S32 log_mode);
178172

indra/newview/llfloaterimsession.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ void LLFloaterIMSession::onClose(bool app_quitting)
638638
// Last change:
639639
// EXT-3516 X Button should end IM session, _ button should hide
640640
gIMMgr->leaveSession(mSessionID);
641+
mSession = nullptr; // leaveSession should have deleted it.
641642
// *TODO: Study why we need to restore the floater before we close it.
642643
// Might be because we want to save some state data in some clean open state.
643644
LLFloaterIMSessionTab::restoreFloater();

indra/newview/llfloaterimsessiontab.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ LLFloaterIMSessionTab::LLFloaterIMSessionTab(const LLSD& session_id)
8080
{
8181
setAutoFocus(false);
8282
mSession = LLIMModel::getInstance()->findIMSession(mSessionID);
83+
LLIMMgr::instance().addSessionObserver(this);
8384

8485
mCommitCallbackRegistrar.add("IMSession.Menu.Action",
8586
boost::bind(&LLFloaterIMSessionTab::onIMSessionMenuItemClicked, this, _2));
@@ -102,6 +103,7 @@ LLFloaterIMSessionTab::LLFloaterIMSessionTab(const LLSD& session_id)
102103
LLFloaterIMSessionTab::~LLFloaterIMSessionTab()
103104
{
104105
delete mRefreshTimer;
106+
LLIMMgr::instance().removeSessionObserver(this);
105107

106108
LLFloaterIMContainer* im_container = LLFloaterIMContainer::findInstance();
107109
if (im_container)
@@ -440,7 +442,10 @@ void LLFloaterIMSessionTab::enableDisableCallBtn()
440442

441443
bool enable = false;
442444

443-
if (mSessionID.notNull() && mSession && mSession->mSessionInitialized && mSession->mCallBackEnabled)
445+
if (mSessionID.notNull()
446+
&& mSession
447+
&& mSession->mSessionInitialized
448+
&& mSession->mCallBackEnabled)
444449
{
445450
if (mVoiceButtonHangUpMode)
446451
{
@@ -450,9 +455,10 @@ void LLFloaterIMSessionTab::enableDisableCallBtn()
450455
else
451456
{
452457
// We allow to start call from this state only
453-
if (mSession->mVoiceChannel &&
454-
!mSession->mVoiceChannel->callStarted() &&
455-
LLVoiceClient::instanceExists())
458+
if (LLVoiceClient::instanceExists() &&
459+
mSession->mVoiceChannel &&
460+
!mSession->mVoiceChannel->callStarted()
461+
)
456462
{
457463
LLVoiceClient* client = LLVoiceClient::getInstance();
458464
if (client->voiceEnabled() && client->isVoiceWorking())
@@ -1366,6 +1372,14 @@ LLView* LLFloaterIMSessionTab::getChatHistory()
13661372
return mChatHistory;
13671373
}
13681374

1375+
void LLFloaterIMSessionTab::sessionRemoved(const LLUUID& session_id)
1376+
{
1377+
if (session_id == mSessionID)
1378+
{
1379+
mSession = nullptr;
1380+
}
1381+
}
1382+
13691383
bool LLFloaterIMSessionTab::handleKeyHere(KEY key, MASK mask )
13701384
{
13711385
bool handled = false;

indra/newview/llfloaterimsessiontab.h

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class LLPanelEmojiComplete;
4545

4646
class LLFloaterIMSessionTab
4747
: public LLTransientDockableFloater
48+
, public LLIMSessionObserver
4849
{
4950
using super = LLTransientDockableFloater;
5051

@@ -76,13 +77,13 @@ class LLFloaterIMSessionTab
7677
bool isNearbyChat() {return mIsNearbyChat;}
7778

7879
// LLFloater overrides
79-
/*virtual*/ void onOpen(const LLSD& key);
80-
/*virtual*/ bool postBuild();
81-
/*virtual*/ void draw();
82-
/*virtual*/ void setVisible(bool visible);
83-
/*virtual*/ void setFocus(bool focus);
84-
/*virtual*/ void closeFloater(bool app_quitting = false);
85-
/*virtual*/ void deleteAllChildren();
80+
void onOpen(const LLSD& key) override;
81+
bool postBuild() override;
82+
void draw() override;
83+
void setVisible(bool visible) override;
84+
void setFocus(bool focus) override;
85+
void closeFloater(bool app_quitting = false) override;
86+
void deleteAllChildren() override;
8687

8788
// Handle the left hand participant list widgets
8889
void addConversationViewParticipant(LLConversationItem* item, bool update_view = true);
@@ -98,7 +99,7 @@ class LLFloaterIMSessionTab
9899
virtual void updateMessages() {}
99100
LLConversationItem* getCurSelectedViewModelItem();
100101
void forceReshape();
101-
virtual bool handleKeyHere( KEY key, MASK mask );
102+
virtual bool handleKeyHere( KEY key, MASK mask ) override;
102103
bool isMessagePaneExpanded(){return mMessagePaneExpanded;}
103104
void setMessagePaneExpanded(bool expanded){mMessagePaneExpanded = expanded;}
104105
void restoreFloater();
@@ -108,6 +109,13 @@ class LLFloaterIMSessionTab
108109

109110
LLView* getChatHistory();
110111

112+
// LLIMSessionObserver triggers
113+
virtual void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id, bool has_offline_msg) override {}; // Stub
114+
virtual void sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) override {}; // Stub
115+
virtual void sessionRemoved(const LLUUID& session_id) override;
116+
virtual void sessionVoiceOrIMStarted(const LLUUID& session_id) override {}; // Stub
117+
virtual void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id) override {}; // Stub
118+
111119
protected:
112120

113121
// callback for click on any items of the visual states menu
@@ -139,8 +147,8 @@ class LLFloaterIMSessionTab
139147
virtual void enableDisableCallBtn();
140148

141149
// process focus events to set a currently active session
142-
/* virtual */ void onFocusReceived();
143-
/* virtual */ void onFocusLost();
150+
void onFocusReceived() override;
151+
void onFocusLost() override;
144152

145153
// prepare chat's params and out one message to chatHistory
146154
void appendMessage(const LLChat& chat, const LLSD& args = LLSD());
@@ -212,7 +220,7 @@ class LLFloaterIMSessionTab
212220
void getSelectedUUIDs(uuid_vec_t& selected_uuids);
213221

214222
/// Refreshes the floater at a constant rate.
215-
virtual void refresh() = 0;
223+
virtual void refresh() override = 0;
216224

217225
/**
218226
* Adjusts chat history height to fit vertically with input chat field

indra/newview/llimview.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,6 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id,
796796

797797
void LLIMModel::LLIMSession::initVoiceChannel(const LLSD& voiceChannelInfo)
798798
{
799-
800799
if (mVoiceChannel)
801800
{
802801
if (mVoiceChannel->isThisVoiceChannel(voiceChannelInfo))
@@ -2344,7 +2343,7 @@ LLCallDialogManager::~LLCallDialogManager()
23442343

23452344
void LLCallDialogManager::initSingleton()
23462345
{
2347-
LLVoiceChannel::setCurrentVoiceChannelChangedCallback(LLCallDialogManager::onVoiceChannelChanged);
2346+
mVoiceChannelChanged = LLVoiceChannel::setCurrentVoiceChannelChangedCallback(LLCallDialogManager::onVoiceChannelChanged);
23482347
}
23492348

23502349
// static

indra/newview/llimview.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,8 @@ class LLCallDialogManager : public LLSingleton<LLCallDialogManager>
548548
std::string mCurrentSessionlName;
549549
LLIMModel::LLIMSession* mSession;
550550
LLVoiceChannel::EState mOldState;
551+
552+
boost::signals2::connection mVoiceChannelChanged;
551553
};
552554

553555
class LLCallDialog : public LLDockableFloater

0 commit comments

Comments
 (0)