From 7c7ccf27d1638577290ebefcc16dded9390f5f21 Mon Sep 17 00:00:00 2001
From: Merov Linden <merov@lindenlab.com>
Date: Fri, 29 Mar 2013 17:22:53 -0700
Subject: [PATCH] CHUI-807 : Add more defensive coding. Also trace in log the
 sessions created so we'll have a better idea of what people do with
 conversations if we see that crash again.

---
 indra/llui/lltabcontainer.cpp | 13 ++++++++-----
 indra/newview/llimview.cpp    |  2 ++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index 6f895ed939a..fd981557047 100644
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -1215,9 +1215,11 @@ void LLTabContainer::removeTabPanel(LLPanel* child)
 				removeChild( tuple->mButton );
 			}
  			delete tuple->mButton;
+            tuple->mButton = NULL;
 
  			removeChild( tuple->mTabPanel );
 // 			delete tuple->mTabPanel;
+            tuple->mTabPanel = NULL;
 			
 			mTabList.erase( iter );
 			delete tuple;
@@ -1279,9 +1281,11 @@ void LLTabContainer::deleteAllTabs()
 
 		removeChild( tuple->mButton );
 		delete tuple->mButton;
+        tuple->mButton = NULL;
 
  		removeChild( tuple->mTabPanel );
 // 		delete tuple->mTabPanel;
+        tuple->mTabPanel = NULL;
 	}
 
 	// Actually delete the tuples themselves
@@ -1484,9 +1488,8 @@ BOOL LLTabContainer::setTab(S32 which)
 		{
 			LLTabTuple* tuple = *iter;
 			BOOL is_selected = ( tuple == selected_tuple );
-            
             // Although the selected tab must be complete, we may have hollow LLTabTuple tucked in the list
-            if (tuple->mButton)
+            if (tuple && tuple->mButton)
             {
                 tuple->mButton->setUseEllipses(mUseTabEllipses);
                 tuple->mButton->setHAlign(mFontHalign);
@@ -1494,7 +1497,7 @@ BOOL LLTabContainer::setTab(S32 which)
                 // RN: this limits tab-stops to active button only, which would require arrow keys to switch tabs
                 tuple->mButton->setTabStop( is_selected );
             }
-            if (tuple->mTabPanel)
+            if (tuple && tuple->mTabPanel)
             {
                 tuple->mTabPanel->setVisible( is_selected );
                 //tuple->mTabPanel->setFocus(is_selected); // not clear that we want to do this here.
@@ -1525,7 +1528,7 @@ BOOL LLTabContainer::setTab(S32 which)
 					else
 					{
 						S32 available_width_with_arrows = getRect().getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + tabcntr_arrow_btn_size  + tabcntr_arrow_btn_size + 1);
-						S32 running_tab_width = tuple->mButton->getRect().getWidth();
+						S32 running_tab_width = (tuple && tuple->mButton ? tuple->mButton->getRect().getWidth() : 0);
 						S32 j = i - 1;
 						S32 min_scroll_pos = i;
 						if (running_tab_width < available_width_with_arrows)
@@ -1533,7 +1536,7 @@ BOOL LLTabContainer::setTab(S32 which)
 							while (j >= 0)
 							{
 								LLTabTuple* other_tuple = getTab(j);
-								running_tab_width += other_tuple->mButton->getRect().getWidth();
+								running_tab_width += (other_tuple && other_tuple->mButton ? other_tuple->mButton->getRect().getWidth() : 0);
 								if (running_tab_width > available_width_with_arrows)
 								{
 									break;
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index e237cb7f9ea..56b80ef57b6 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -2800,6 +2800,8 @@ LLUUID LLIMMgr::addSession(
 		return LLUUID::null;
 	}
 
+    llinfos << "LLIMMgr::addSession, name = " << name << llendl;
+    
 	LLUUID session_id = computeSessionID(dialog,other_participant_id);
 
 	if (floater_id.notNull())
-- 
GitLab