From 1c909afe3998778e4cc045c9ab733e8afbf7c25b Mon Sep 17 00:00:00 2001
From: Don Kjer <don@lindenlab.com>
Date: Wed, 2 May 2007 21:24:47 +0000
Subject: svn merge -r 60342:61148
 svn+ssh://svn/svn/linden/branches/maintenance into release

---
 indra/llui/llcombobox.cpp     | 22 ++++++++++------------
 indra/llui/llcombobox.h       |  3 +--
 indra/llui/llfloater.cpp      | 11 +++++++++--
 indra/llui/lllineeditor.cpp   | 10 ++++++----
 indra/llui/llmenugl.cpp       | 16 ++++++++++------
 indra/llui/llpanel.cpp        |  2 +-
 indra/llui/lltabcontainer.cpp |  8 ++++----
 indra/llui/lltexteditor.cpp   | 20 ++++++++++++++------
 indra/llui/llui.cpp           | 18 ++++++++++++++++++
 indra/llui/llviewborder.cpp   |  2 +-
 indra/llui/llviewborder.h     |  2 +-
 11 files changed, 75 insertions(+), 39 deletions(-)

(limited to 'indra/llui')

diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index f548045474..fae13dd700 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -35,8 +35,7 @@ S32 LLCOMBOBOX_WIDTH = 0;
  
 LLComboBox::LLComboBox(	const LLString& name, const LLRect &rect, const LLString& label,
 	void (*commit_callback)(LLUICtrl*,void*),
-	void *callback_userdata,
-	S32 list_width
+	void *callback_userdata
 	)
 :	LLUICtrl(name, rect, TRUE, commit_callback, callback_userdata, 
 			 FOLLOWS_LEFT | FOLLOWS_TOP),
@@ -79,10 +78,7 @@ LLComboBox::LLComboBox(	const LLString& name, const LLRect &rect, const LLString
 	addChild(mButton);
 
 	// Default size, will be set by arrange() call in button callback. 
-	if (list_width == 0)
-	{
-		list_width = mRect.getWidth() + SCROLLBAR_SIZE;
-	}
+	S32 list_width = mRect.getWidth() + SCROLLBAR_SIZE;
 	r.setOriginAndSize(0, 16, list_width, 220);
 
 	// disallow multiple selection
@@ -483,12 +479,14 @@ void LLComboBox::showList()
 	
 	LLRect rect = mList->getRect();
 
+	S32 list_width = mRect.getWidth() + SCROLLBAR_SIZE;
+
 	if (mListPosition == BELOW)
 	{
 		if (rect.getHeight() <= -root_view_local.mBottom)
 		{
 			// Move rect so it hangs off the bottom of this view
-			rect.setLeftTopAndSize(0, 0, rect.getWidth(), rect.getHeight() );
+			rect.setLeftTopAndSize(0, 0, list_width, rect.getHeight() );
 		}
 		else
 		{	
@@ -496,12 +494,12 @@ void LLComboBox::showList()
 			if (-root_view_local.mBottom > root_view_local.mTop - mRect.getHeight())
 			{
 				// Move rect so it hangs off the bottom of this view
-				rect.setLeftTopAndSize(0, 0, rect.getWidth(), llmin(-root_view_local.mBottom, rect.getHeight()));
+				rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight()));
 			}
 			else
 			{
 				// move rect so it stacks on top of this view (clipped to size of screen)
-				rect.setOriginAndSize(0, mRect.getHeight(), rect.getWidth(), llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight()));
+				rect.setOriginAndSize(0, mRect.getHeight(), list_width, llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight()));
 			}
 		}
 	}
@@ -510,7 +508,7 @@ void LLComboBox::showList()
 		if (rect.getHeight() <= root_view_local.mTop - mRect.getHeight())
 		{
 			// move rect so it stacks on top of this view (clipped to size of screen)
-			rect.setOriginAndSize(0, mRect.getHeight(), rect.getWidth(), llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight()));
+			rect.setOriginAndSize(0, mRect.getHeight(), list_width, llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight()));
 		}
 		else
 		{
@@ -518,12 +516,12 @@ void LLComboBox::showList()
 			if (-root_view_local.mBottom > root_view_local.mTop - mRect.getHeight())
 			{
 				// Move rect so it hangs off the bottom of this view
-				rect.setLeftTopAndSize(0, 0, rect.getWidth(), llmin(-root_view_local.mBottom, rect.getHeight()));
+				rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight()));
 			}
 			else
 			{
 				// move rect so it stacks on top of this view (clipped to size of screen)
-				rect.setOriginAndSize(0, mRect.getHeight(), rect.getWidth(), llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight()));
+				rect.setOriginAndSize(0, mRect.getHeight(), list_width, llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight()));
 			}
 		}
 
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index 2b19c3c2e5..02aa0084ed 100644
--- a/indra/llui/llcombobox.h
+++ b/indra/llui/llcombobox.h
@@ -45,8 +45,7 @@ public:
 		const LLRect &rect,
 		const LLString& label,
 		void (*commit_callback)(LLUICtrl*, void*) = NULL,
-		void *callback_userdata = NULL,
-		S32 list_width = 0
+		void *callback_userdata = NULL
 		);
 	virtual ~LLComboBox(); 
 
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index c3364a7a35..40c11c69cc 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -676,7 +676,13 @@ void LLFloater::translate(S32 x, S32 y)
 
 BOOL LLFloater::canSnapTo(LLView* other_view)
 {
-	if (other_view && other_view != getParent())
+	if (NULL == other_view)
+	{
+		llwarns << "other_view is NULL" << llendl;
+		return FALSE;
+	}
+
+	if (other_view != getParent())
 	{
 		LLFloater* other_floaterp = (LLFloater*)other_view;
 		
@@ -2535,6 +2541,7 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater,
 	if (!mTabContainer)
 	{
 		llerrs << "Tab Container used without having been initialized." << llendl;
+		return;
 	}
 
 	if (floaterp->getHost() == this)
@@ -2698,7 +2705,7 @@ void LLMultiFloater::setVisible(BOOL visible)
 BOOL LLMultiFloater::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
 {
 	if (getEnabled()
-		&& mask == (MASK_CONTROL|MASK_SHIFT))
+		&& mask == MASK_CONTROL)
 	{
 		if (key == 'W')
 		{
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 7422a039dd..43ea584aa1 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -691,11 +691,11 @@ S32 LLLineEditor::prevWordPos(S32 cursorPos) const
 S32 LLLineEditor::nextWordPos(S32 cursorPos) const
 {
 	const LLWString& wtext = mText.getWString();
-	while( (cursorPos < getLength()) && isPartOfWord( wtext[cursorPos+1] ) )
+	while( (cursorPos < getLength()) && isPartOfWord( wtext[cursorPos] ) )
 	{
 		cursorPos++;
 	} 
-	while( (cursorPos < getLength()) && (wtext[cursorPos+1] == ' ') )
+	while( (cursorPos < getLength()) && (wtext[cursorPos] == ' ') )
 	{
 		cursorPos++;
 	}
@@ -1015,7 +1015,8 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
 		break;
 
 	case KEY_LEFT:
-		if (!mIgnoreArrowKeys)
+		if (!mIgnoreArrowKeys
+			&& mask != MASK_ALT)
 		{
 			if( hasSelection() )
 			{
@@ -1040,7 +1041,8 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)
 		break;
 
 	case KEY_RIGHT:
-		if (!mIgnoreArrowKeys)
+		if (!mIgnoreArrowKeys
+			&& mask != MASK_ALT)
 		{
 			if (hasSelection())
 			{
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 79c38a87c0..f5dcae5787 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -709,14 +709,18 @@ void LLMenuItemTearOffGL::doIt()
 
 		LLFloater* parent_floater = LLFloater::getFloaterByHandle(mParentHandle);
 		LLFloater* tear_off_menu = LLTearOffMenu::create(getMenu());
-		if (parent_floater && tear_off_menu)
+
+		if (tear_off_menu)
 		{
-			parent_floater->addDependentFloater(tear_off_menu, FALSE);
-		}
+			if (parent_floater)
+			{
+				parent_floater->addDependentFloater(tear_off_menu, FALSE);
+			}
 
-		// give focus to torn off menu because it will have been taken away
-		// when parent menu closes
-		tear_off_menu->setFocus(TRUE);
+			// give focus to torn off menu because it will have
+			// been taken away when parent menu closes
+			tear_off_menu->setFocus(TRUE);
+		}
 	}
 	LLMenuItemGL::doIt();
 }
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index 406b5ef571..316764474b 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -342,7 +342,7 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent )
 		// If we have a default button, click it when
 		// return is pressed, unless current focus is a return-capturing button
 		// in which case *that* button will handle the return key
-		if (!(cur_focus->getWidgetType() == WIDGET_TYPE_BUTTON && static_cast<LLButton *>(cur_focus)->getCommitOnReturn()))
+		if (cur_focus && !(cur_focus->getWidgetType() == WIDGET_TYPE_BUTTON && static_cast<LLButton *>(cur_focus)->getCommitOnReturn()))
 		{
 			// RETURN key means hit default button in this case
 			if (key == KEY_RETURN && mask == MASK_NONE 
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index a3353d2028..a5bad91670 100644
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -921,8 +921,8 @@ void LLTabContainer::addTabPanel(LLPanel* child,
 	else
 	{
 		LLString tooltip = trimmed_label;
-		tooltip += "\nCtrl-[ for previous tab";
-		tooltip += "\nCtrl-] for next tab";
+		tooltip += "\nAlt-Left arrow for previous tab";
+		tooltip += "\nAlt-Right arrow for next tab";
 
 		LLButton* btn = new LLButton(
 			LLString(child->getName()) + " tab",
@@ -1466,12 +1466,12 @@ BOOL LLTabContainer::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
 	if (!gFocusMgr.childHasKeyboardFocus(this)) return FALSE;
 
 	BOOL handled = FALSE;
-	if (key == '[' && mask == MASK_CONTROL)
+	if (key == KEY_LEFT && mask == MASK_ALT)
 	{
 		selectPrevTab();
 		handled = TRUE;
 	}
-	else if (key == ']' && mask == MASK_CONTROL)
+	else if (key == KEY_RIGHT && mask == MASK_ALT)
 	{
 		selectNextTab();
 		handled = TRUE;
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 651a421742..2b588cacce 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -703,11 +703,11 @@ S32 LLTextEditor::prevWordPos(S32 cursorPos) const
 S32 LLTextEditor::nextWordPos(S32 cursorPos) const
 {
 	const LLWString& wtext = mWText;
-	while( (cursorPos < getLength()) && isPartOfWord( wtext[cursorPos+1] ) )
+	while( (cursorPos < getLength()) && isPartOfWord( wtext[cursorPos] ) )
 	{
 		cursorPos++;
 	} 
-	while( (cursorPos < getLength()) && (wtext[cursorPos+1] == ' ') )
+	while( (cursorPos < getLength()) && (wtext[cursorPos] == ' ') )
 	{
 		cursorPos++;
 	}
@@ -3647,10 +3647,18 @@ void LLTextEditor::pruneSegments()
 			break; // done
 		}			
 	}
-	// erase invalid segments
-	++iter;
-	std::for_each(iter, mSegments.end(), DeletePointer());
-	mSegments.erase(iter, mSegments.end());
+	if (iter != mSegments.end())
+	{
+		// erase invalid segments
+		++iter;
+		std::for_each(iter, mSegments.end(), DeletePointer());
+		mSegments.erase(iter, mSegments.end());
+	}
+	else
+	{
+		llwarns << "Tried to erase end of empty LLTextEditor"
+			<< llendl;
+	}
 }
 
 void LLTextEditor::findEmbeddedItemSegments()
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index c9a506756a..c65500b56c 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -401,6 +401,12 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border
 	stop_glerror();
 	F32 border_scale = 1.f;
 
+	if (NULL == image)
+	{
+		llwarns << "image == NULL; aborting function" << llendl;
+		return;
+	}
+
 	if (border_height * 2 > height)
 	{
 		border_scale = (F32)height / ((F32)border_height * 2.f);
@@ -579,6 +585,12 @@ void gl_draw_rotated_image(S32 x, S32 y, F32 degrees, LLImageGL* image, const LL
 
 void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degrees, LLImageGL* image, const LLColor4& color)
 {
+	if (NULL == image)
+	{
+		llwarns << "image == NULL; aborting function" << llendl;
+		return;
+	}
+
 	LLGLSUIDefault gls_ui;
 
 	glPushMatrix();
@@ -619,6 +631,12 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
 
 void gl_draw_scaled_image_inverted(S32 x, S32 y, S32 width, S32 height, LLImageGL* image, const LLColor4& color)
 {
+	if (NULL == image)
+	{
+		llwarns << "image == NULL; aborting function" << llendl;
+		return;
+	}
+
 	LLGLSUIDefault gls_ui;
 
 	glPushMatrix();
diff --git a/indra/llui/llviewborder.cpp b/indra/llui/llviewborder.cpp
index 24cc57e709..e85095b5fd 100644
--- a/indra/llui/llviewborder.cpp
+++ b/indra/llui/llviewborder.cpp
@@ -39,7 +39,7 @@ LLViewBorder::LLViewBorder( const LLString& name, const LLRect& rect, EBevel bev
 }
 
 // virtual
-BOOL LLViewBorder::isCtrl()
+BOOL LLViewBorder::isCtrl() const
 {
 	return FALSE;
 }
diff --git a/indra/llui/llviewborder.h b/indra/llui/llviewborder.h
index 946c6b9f74..0a8bfff8e4 100644
--- a/indra/llui/llviewborder.h
+++ b/indra/llui/llviewborder.h
@@ -34,7 +34,7 @@ public:
 	virtual EWidgetType getWidgetType() const;
 	virtual LLString getWidgetTag() const;
 
-	virtual BOOL	isCtrl();
+	virtual BOOL isCtrl() const;
 
 	// llview functionality
 	virtual void draw();
-- 
cgit v1.2.3