From 4c89e7389383e2943334ad8ec185b8935cbe7db8 Mon Sep 17 00:00:00 2001
From: Steven Bennetts <steve@lindenlab.com>
Date: Thu, 8 Oct 2009 22:39:17 +0000
Subject: Fixed a problem where floaters that failed to load their XML would
 still be opened. This was particularly a problem with Modal Dialogs since the
 UI would loose focus with no floater to respond to. Reviewed by Leyla

---
 indra/llui/llfloater.cpp       |  6 ++++--
 indra/llui/llfloater.h         |  2 +-
 indra/llui/llfloaterreg.cpp    |  9 +++++++--
 indra/llui/lluictrlfactory.cpp | 16 ++++++++++------
 indra/llui/lluictrlfactory.h   |  2 +-
 5 files changed, 23 insertions(+), 12 deletions(-)

(limited to 'indra/llui')

diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index b7a15a2b33..51e2b5dea4 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -2564,10 +2564,10 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
 
 LLFastTimer::DeclareTimer POST_BUILD("Floater Post Build");
 
-void LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node)
+bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node)
 {
 	Params params(LLUICtrlFactory::getDefaultParams<LLFloater>());
-	LLXUIParser::instance().readXUI(node, params);
+	LLXUIParser::instance().readXUI(node, params); // *TODO: Error checking
 
 	if (output_node)
 	{
@@ -2613,5 +2613,7 @@ void LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
 	gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen	
 
 	moveResizeHandlesToFront();
+
+	return true; // *TODO: Error checking
 }
 
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 17ffc94014..7a6c3f6863 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -144,7 +144,7 @@ public:
 	static void setupParamsForExport(Params& p, LLView* parent);
 
 	void initFromParams(const LLFloater::Params& p);
-	void initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL);
+	bool initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL);
 
 	/*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false);
 	/*virtual*/ BOOL canSnapTo(const LLView* other_view);
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp
index a63b1b085c..815260dff3 100644
--- a/indra/llui/llfloaterreg.cpp
+++ b/indra/llui/llfloaterreg.cpp
@@ -121,8 +121,13 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)
 
 				res = build_func(key);
 				
-				LLUICtrlFactory::getInstance()->buildFloater(res, xui_file, NULL);
-				
+				bool success = LLUICtrlFactory::getInstance()->buildFloater(res, xui_file, NULL);
+				if (!success)
+				{
+					llwarns << "Failed to buid floater type: '" << name << "'." << llendl;
+					return NULL;
+				}
+					
 				// Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe
 				res->mKey = key;
 				res->setInstanceName(name);
diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp
index 4ce6677294..209ee76940 100644
--- a/indra/llui/lluictrlfactory.cpp
+++ b/indra/llui/lluictrlfactory.cpp
@@ -170,7 +170,7 @@ static LLFastTimer::DeclareTimer FTM_BUILD_FLOATERS("Build Floaters");
 //-----------------------------------------------------------------------------
 // buildFloater()
 //-----------------------------------------------------------------------------
-void LLUICtrlFactory::buildFloater(LLFloater* floaterp, const std::string& filename, LLXMLNodePtr output_node)
+bool LLUICtrlFactory::buildFloater(LLFloater* floaterp, const std::string& filename, LLXMLNodePtr output_node)
 {
 	LLFastTimer timer(FTM_BUILD_FLOATERS);
 	LLXMLNodePtr root;
@@ -182,22 +182,24 @@ void LLUICtrlFactory::buildFloater(LLFloater* floaterp, const std::string& filen
 		if (!LLUICtrlFactory::getLocalizedXMLNode(filename, root))
 		{
 			llwarns << "Couldn't parse floater from: " << LLUI::getLocalizedSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl;
-			return;
+			return false;
 		}
 	}
 	else if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
 	{
 		llwarns << "Couldn't parse floater from: " << LLUI::getSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl;
-		return;
+		return false;
 	}
 	
 	// root must be called floater
 	if( !(root->hasName("floater") || root->hasName("multi_floater")) )
 	{
 		llwarns << "Root node should be named floater in: " << filename << llendl;
-		return;
+		return false;
 	}
-
+	
+	bool res = true;
+	
 	lldebugs << "Building floater " << filename << llendl;
 	mFileNames.push_back(gDirUtilp->findSkinnedFilename(LLUI::getSkinPath(), filename));
 	{
@@ -210,7 +212,7 @@ void LLUICtrlFactory::buildFloater(LLFloater* floaterp, const std::string& filen
 		floaterp->getCommitCallbackRegistrar().pushScope();
 		floaterp->getEnableCallbackRegistrar().pushScope();
 		
-		floaterp->initFloaterXML(root, floaterp->getParent(), output_node);
+		res = floaterp->initFloaterXML(root, floaterp->getParent(), output_node);
 
 		floaterp->setXMLFilename(filename);
 		
@@ -223,6 +225,8 @@ void LLUICtrlFactory::buildFloater(LLFloater* floaterp, const std::string& filen
 		}
 	}
 	mFileNames.pop_back();
+	
+	return res;
 }
 
 //-----------------------------------------------------------------------------
diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h
index 3c77c655b8..5e6dad312c 100644
--- a/indra/llui/lluictrlfactory.h
+++ b/indra/llui/lluictrlfactory.h
@@ -157,7 +157,7 @@ public:
 		return ParamDefaults<typename T::Params, 0>::instance().get();
 	}
 
-	void buildFloater(LLFloater* floaterp, const std::string &filename, LLXMLNodePtr output_node);
+	bool buildFloater(LLFloater* floaterp, const std::string &filename, LLXMLNodePtr output_node);
 	BOOL buildPanel(LLPanel* panelp, const std::string &filename, LLXMLNodePtr output_node = NULL);
 
 	// Does what you want for LLFloaters and LLPanels
-- 
cgit v1.2.3