From a7944f17bec66e7c0f066ab3b6196cc2233b1ca7 Mon Sep 17 00:00:00 2001
From: Todd Stinson <stinson@lindenlab.com>
Date: Wed, 7 Mar 2012 14:39:27 -0800
Subject: PATH-205,PATh-304: Fixing a crash issue with loading multiple
 navmeshes during the second refresh.

---
 indra/newview/llfloaterpathfindingconsole.cpp |  4 +++-
 indra/newview/llpathfindingnavmeshzone.cpp    | 24 +++++++++---------------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/indra/newview/llfloaterpathfindingconsole.cpp b/indra/newview/llfloaterpathfindingconsole.cpp
index fe5c6b8d44..6824e629c9 100644
--- a/indra/newview/llfloaterpathfindingconsole.cpp
+++ b/indra/newview/llfloaterpathfindingconsole.cpp
@@ -613,6 +613,9 @@ void LLFloaterPathfindingConsole::onNavMeshZoneCB(LLPathfindingNavMeshZone::ENav
 {
 	switch (pNavMeshZoneRequestStatus)
 	{
+	case LLPathfindingNavMeshZone::kNavMeshZoneRequestUnknown :
+		setConsoleState(kConsoleStateUnknown);
+		break;
 	case LLPathfindingNavMeshZone::kNavMeshZoneRequestStarted :
 		setConsoleState(kConsoleStateDownloading);
 		break;
@@ -625,7 +628,6 @@ void LLFloaterPathfindingConsole::onNavMeshZoneCB(LLPathfindingNavMeshZone::ENav
 	case LLPathfindingNavMeshZone::kNavMeshZoneRequestError :
 		setConsoleState(kConsoleStateError);
 		break;
-	case LLPathfindingNavMeshZone::kNavMeshZoneRequestUnknown :
 	default:
 		setConsoleState(kConsoleStateUnknown);
 		llassert(0);
diff --git a/indra/newview/llpathfindingnavmeshzone.cpp b/indra/newview/llpathfindingnavmeshzone.cpp
index 7b9ac913c9..983b88fe05 100644
--- a/indra/newview/llpathfindingnavmeshzone.cpp
+++ b/indra/newview/llpathfindingnavmeshzone.cpp
@@ -65,11 +65,6 @@ LLPathfindingNavMeshZone::navmesh_zone_slot_t LLPathfindingNavMeshZone::register
 
 void LLPathfindingNavMeshZone::initialize()
 {
-	llassert(LLPathingLib::getInstance() != NULL);
-	if (LLPathingLib::getInstance() != NULL)
-	{
-		LLPathingLib::getInstance()->cleanupResidual();
-	}
 	mNavMeshLocationPtrs.clear();
 
 	NavMeshLocationPtr centerNavMeshPtr(new NavMeshLocation(CENTER_REGION, boost::bind(&LLPathfindingNavMeshZone::handleNavMeshLocation, this)));
@@ -101,17 +96,16 @@ void LLPathfindingNavMeshZone::disable()
 		NavMeshLocationPtr navMeshLocationPtr = *navMeshLocationPtrIter;
 		navMeshLocationPtr->disable();
 	}
-#if 0
+}
+
+void LLPathfindingNavMeshZone::refresh()
+{
 	llassert(LLPathingLib::getInstance() != NULL);
 	if (LLPathingLib::getInstance() != NULL)
 	{
 		LLPathingLib::getInstance()->cleanupResidual();
 	}
-#endif
-}
 
-void LLPathfindingNavMeshZone::refresh()
-{
 	for (NavMeshLocationPtrs::iterator navMeshLocationPtrIter = mNavMeshLocationPtrs.begin();
 		navMeshLocationPtrIter != mNavMeshLocationPtrs.end(); ++navMeshLocationPtrIter)
 	{
@@ -170,6 +164,10 @@ void LLPathfindingNavMeshZone::updateStatus()
 	{
 		zoneRequestStatus = kNavMeshZoneRequestError;
 	}
+	else if (hasRequestUnknown)
+	{
+		zoneRequestStatus = kNavMeshZoneRequestUnknown;
+	}
 	else if (hasRequestCompleted)
 	{
 		zoneRequestStatus = kNavMeshZoneRequestCompleted;
@@ -183,10 +181,6 @@ void LLPathfindingNavMeshZone::updateStatus()
 	{
 		zoneRequestStatus = kNavMeshZoneRequestNotEnabled;
 	}
-	else if (hasRequestUnknown)
-	{
-		zoneRequestStatus = kNavMeshZoneRequestUnknown;
-	}
 	else
 	{
 		zoneRequestStatus = kNavMeshZoneRequestError;
@@ -239,7 +233,7 @@ void LLPathfindingNavMeshZone::NavMeshLocation::refresh()
 	{
 		llassert(mRegionUUID.isNull());
 		LLSD::Binary nullData;
-		handleNavMesh(LLPathfindingNavMesh::kNavMeshRequestUnknown, mRegionUUID, 0U, nullData);
+		handleNavMesh(LLPathfindingNavMesh::kNavMeshRequestNotEnabled, mRegionUUID, 0U, nullData);
 	}
 	else
 	{
-- 
cgit v1.2.3