Commits

richard_linden committed 3a17484

fix for crash on exit

Comments (0)

Files changed (3)

indra/newview/llchannelmanager.cpp

 {
 	for(std::vector<ChannelElem>::iterator it = mChannelList.begin(); it !=  mChannelList.end(); ++it)
 	{
-		delete (*it).channel;
+		LLScreenChannelBase* channel = it->channel.get();
+		if (!channel) continue;
+
+		delete channel;
 	}
 
 	mChannelList.clear();
 	// calc a number of all offline notifications
 	for(std::vector<ChannelElem>::iterator it = mChannelList.begin(); it !=  mChannelList.end(); ++it)
 	{
+		LLScreenChannelBase* channel = it->channel.get();
+		if (!channel) continue;
+
 		// don't calc notifications for Nearby Chat
-		if((*it).channel->getChannelID() == LLUUID(gSavedSettings.getString("NearByChatChannelUUID")))
+		if(channel->getChannelID() == LLUUID(gSavedSettings.getString("NearByChatChannelUUID")))
 		{
 			continue;
 		}
 
 		// don't calc notifications for channels that always show their notifications
-		if(!(*it).channel->getDisplayToastsAlways())
+		if(!channel->getDisplayToastsAlways())
 		{
-			away_notifications +=(*it).channel->getNumberOfHiddenToasts();
+			away_notifications +=channel->getNumberOfHiddenToasts();
 		}
 	}
 
 
 	ChannelElem new_elem;
 	new_elem.id = channel->getChannelID();
-	new_elem.channel = channel;
+	new_elem.channel = channel->getHandle();
 
 	mChannelList.push_back(new_elem); 
 
 	std::vector<ChannelElem>::iterator it = find(mChannelList.begin(), mChannelList.end(), id); 
 	if(it != mChannelList.end())
 	{
-		return (*it).channel;
+		return (*it).channel.get();
 	}
 
 	return NULL;
 	for (std::vector<ChannelElem>::iterator it = mChannelList.begin();
 			it != mChannelList.end(); it++)
 	{
-		it->channel->setShowToasts(!mute);
+		if (it->channel.get())
+		{
+			it->channel.get()->setShowToasts(!mute);
+		}
 	}
 }
 

indra/newview/llchannelmanager.h

 
 	struct ChannelElem
 	{
-		LLUUID				id;
-		LLScreenChannelBase*	channel;
+		LLUUID							id;
+		LLHandle<LLScreenChannelBase>	channel;
 
-		ChannelElem() : id(LLUUID("")), channel(NULL) { }
+		ChannelElem() { }
 
 		ChannelElem(const ChannelElem &elem)
 		{

indra/newview/llscreenchannel.h

 	
 	// get ID of a channel
 	LLUUID	getChannelID() { return mID; }
+	LLHandle<LLScreenChannelBase> getHandle() { mRootHandle.bind(this); return mRootHandle; }
 
 protected:
 	void	updateBottom();
 	bool		mDisplayToastsAlways;
 	// controls whether a channel shows toasts or not
 	bool		mShowToasts;
+	LLRootHandle<LLScreenChannelBase> mRootHandle;
 	// 
 	EToastAlignment		mToastAlignment;
 	EChannelAlignment	mChannelAlignment;