diff --git a/indra/newview/ao.cpp b/indra/newview/ao.cpp index 43ceb3e0f9..9867381df8 100644 --- a/indra/newview/ao.cpp +++ b/indra/newview/ao.cpp @@ -131,12 +131,6 @@ void FloaterAO::updateList() mReloadButton->setEnabled(TRUE); mImportRunning = FALSE; - std::string currentSetName = mSetSelector->getSelectedItemLabel(); - if (currentSetName.empty()) - { - currentSetName = AOEngine::instance().getCurrentSetName(); - } - // Lambda provides simple Alpha sorting, note this is case sensitive. auto sortRuleLambda = [](const AOSet* s1, const AOSet* s2) -> bool { @@ -146,6 +140,9 @@ void FloaterAO::updateList() mSetList=AOEngine::instance().getSetList(); std::sort(mSetList.begin(), mSetList.end(), sortRuleLambda); + // remember currently selected animation set name + std::string currentSetName = mSetSelector->getSelectedItemLabel(); + mSetSelector->removeall(); mSetSelectorSmall->removeall(); mSetSelector->clear(); @@ -166,6 +163,21 @@ void FloaterAO::updateList() return; } + // make sure we have an animation set name to display + if (currentSetName.empty()) + { + // selected animation set was empty, get the currently active animation set from the engine + currentSetName = AOEngine::instance().getCurrentSetName(); + LL_DEBUGS("AOEngine") << "Current set name was empty, fetched name \"" << currentSetName << "\" from AOEngine" << LL_ENDL; + + if(currentSetName.empty()) + { + // selected animation set was empty, get the name of the first animation set in the list + currentSetName = mSetList[0]->getName(); + LL_DEBUGS("AOEngine") << "Current set name still empty, fetched first set's name \"" << currentSetName << "\"" << LL_ENDL; + } + } + for (U32 index = 0; index < mSetList.size(); ++index) { std::string setName = mSetList[index]->getName();