From 9b268c365494326e3795bd23ea3e06ec88044944 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Sun, 19 Feb 2012 20:07:17 +0100 Subject: [PATCH] Fixing the crash in grid list --- indra/newview/hippogridmanager.cpp | 28 +++++++++++++++++----------- indra/newview/hippogridmanager.h | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/indra/newview/hippogridmanager.cpp b/indra/newview/hippogridmanager.cpp index 2dcf84569..73dd8d124 100644 --- a/indra/newview/hippogridmanager.cpp +++ b/indra/newview/hippogridmanager.cpp @@ -199,11 +199,15 @@ void HippoGridInfo::setPlatform(const std::string& platform) void HippoGridInfo::setGridName(const std::string& gridName) { - HippoGridManager::GridIterator it = gHippoGridManager->mGridInfo.find(mGridName); - if(it != gHippoGridManager->endGrid()) + HippoGridManager::GridIterator it; + for(it = gHippoGridManager->beginGrid(); it != gHippoGridManager->endGrid(); ++it) { - gHippoGridManager->mGridInfo.erase(it); - gHippoGridManager->mGridInfo[gridName] = this; + if (it->second == this) + { + gHippoGridManager->mGridInfo.erase(it); + gHippoGridManager->mGridInfo[gridName] = this; + break; + } } mGridName = gridName; /*if(mGridNick.empty() && !gridName.empty()) @@ -568,14 +572,16 @@ std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick) } -const std::string& HippoGridInfo::getGridNick() +std::string HippoGridInfo::getGridNick() { - if(mGridNick.empty()) + if(!mGridNick.empty()) { - mGridNick = sanitizeGridNick(mGridName); + return mGridNick; + } + else + { + return sanitizeGridNick(mGridName); } - - return mGridNick; } // ******************************************************************** @@ -843,7 +849,7 @@ void HippoGridManager::loadFromFile() // load user grid info parseFile(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grids_sg1.xml"), false); // merge default grid info, if newer. Force load, if list of grids is empty. - parseFile(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "default_grids.xml"), true); + parseFile(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "default_grids.xml"), !mGridInfo.empty()); // merge grid info from web site, if newer. Force load, if list of grids is empty. if (gSavedSettings.getBOOL("CheckForGridUpdates")) parseUrl(gSavedSettings.getString("GridUpdateList"), !mGridInfo.empty()); @@ -951,7 +957,7 @@ void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) } bool newGrid = (it == mGridInfo.end()); - if (newGrid) + if (newGrid || !it->second) { if(gridname.empty()) { diff --git a/indra/newview/hippogridmanager.h b/indra/newview/hippogridmanager.h index b33dec6e5..4f3ef634e 100644 --- a/indra/newview/hippogridmanager.h +++ b/indra/newview/hippogridmanager.h @@ -39,7 +39,6 @@ public: Platform getPlatform(); bool isOpenSimulator() const; bool isSecondLife() const; - const std::string& getGridNick(); const std::string& getGridName() const; const std::string& getGridOwner() const; const std::string& getLoginUri() const; @@ -55,6 +54,7 @@ public: const std::string& getVoiceConnector() const { return mVoiceConnector; } std::string getSearchUrl(SearchType ty, bool is_web) const; bool isRenderCompat() const; + std::string getGridNick(); int getMaxAgentGroups() const { return mMaxAgentGroups; } const std::string& getCurrencySymbol() const;