Added AIFetchInventoryFolder and more.

Added a new statemachine AIFetchInventoryFolder, which can be used
to fetch the contents of a folder by name or UUID.

Also added AIEvent (and one event,
AIEvent::LLInventoryModel_mIsAgentInvUsable_true, which is needed
for AIFetchInventoryFolder).

Fixed LLInventoryModel::sBackgroundFetchActive to correctly reflect
whether or not LLInventoryModel::backgroundFetch is added to
gIdleCallbacks.

Avoid duplicated entries in sFetchQueue.

Reset sFullFetchStarted in LLInventoryModel::stopBackgroundFetch to
allow for a renewed full fetch when some single-folder fetch stops it.

Added AIStateMachine::mQueued to make calling 'cont()' more robust:
calling cont() / idle() / cont() on a row would otherwise add a
statemachine twice to the active list, which would cause a crash
when it's killed.
This commit is contained in:
Aleric Inglewood
2011-05-22 22:01:11 +02:00
parent e1fb1fa6b7
commit 13560e292e
12 changed files with 603 additions and 11 deletions

View File

@@ -59,6 +59,7 @@
#include "llviewercontrol.h"
#include "llvoavatar.h"
#include "llsdutil.h"
#include "statemachine/aievent.h"
// <edit>
#include "llappviewer.h" // gLostItemsRoot
// </edit>
@@ -349,6 +350,13 @@ void LLInventoryModel::getDirectDescendentsOf(const LLUUID& cat_id,
items = get_ptr_in_map(mParentChildItemTree, cat_id);
}
// Same but just categories.
void LLInventoryModel::getDirectDescendentsOf(const LLUUID& cat_id,
cat_array_t*& categories) const
{
categories = get_ptr_in_map(mParentChildCategoryTree, cat_id);
}
// SJB: Added version to lock the arrays to catch potential logic bugs
void LLInventoryModel::lockDirectDescendentArrays(const LLUUID& cat_id,
cat_array_t*& categories,
@@ -1727,7 +1735,6 @@ void LLInventoryModel::startBackgroundFetch(const LLUUID& cat_id)
{
if (!sAllFoldersFetched)
{
sBackgroundFetchActive = TRUE;
if (cat_id.isNull())
{
if (!sFullFetchStarted)
@@ -1735,15 +1742,29 @@ void LLInventoryModel::startBackgroundFetch(const LLUUID& cat_id)
sFullFetchStarted = TRUE;
sFetchQueue.push_back(gInventoryLibraryRoot);
sFetchQueue.push_back(gAgent.getInventoryRootID());
gIdleCallbacks.addFunction(&LLInventoryModel::backgroundFetch, NULL);
if (!sBackgroundFetchActive)
{
sBackgroundFetchActive = TRUE;
gIdleCallbacks.addFunction(&LLInventoryModel::backgroundFetch, NULL);
}
}
}
else
{
// specific folder requests go to front of queue
if (sFetchQueue.empty() || sFetchQueue.front() != cat_id)
// Remove it from the queue first, to avoid getting it twice.
if (!sFetchQueue.empty() && sFetchQueue.front() != cat_id)
{
sFetchQueue.push_front(cat_id);
std::deque<LLUUID>::iterator old_entry = std::find(sFetchQueue.begin(), sFetchQueue.end(), cat_id);
if (old_entry != sFetchQueue.end())
{
sFetchQueue.erase(old_entry);
}
}
sFetchQueue.push_front(cat_id);
if (!sBackgroundFetchActive)
{
sBackgroundFetchActive = TRUE;
gIdleCallbacks.addFunction(&LLInventoryModel::backgroundFetch, NULL);
}
}
@@ -1753,9 +1774,12 @@ void LLInventoryModel::startBackgroundFetch(const LLUUID& cat_id)
//static
void LLInventoryModel::findLostItems()
{
sBackgroundFetchActive = TRUE;
sFetchQueue.push_back(LLUUID::null);
gIdleCallbacks.addFunction(&LLInventoryModel::backgroundFetch, NULL);
if (!sBackgroundFetchActive)
{
sBackgroundFetchActive = TRUE;
gIdleCallbacks.addFunction(&LLInventoryModel::backgroundFetch, NULL);
}
}
//static
@@ -1767,7 +1791,11 @@ void LLInventoryModel::stopBackgroundFetch()
gIdleCallbacks.deleteFunction(&LLInventoryModel::backgroundFetch, NULL);
sBulkFetchCount=0;
sMinTimeBetweenFetches=0.0f;
// sFullFetchStarted=FALSE;
if (!sAllFoldersFetched)
{
// We didn't finish this, so set it to FALSE in order to be able to start it again.
sFullFetchStarted=FALSE;
}
}
}
@@ -2941,6 +2969,7 @@ void LLInventoryModel::buildParentChildMap()
// root of the agent's inv found.
// The inv tree is built.
mIsAgentInvUsable = true;
AIEvent::trigger(AIEvent::LLInventoryModel_mIsAgentInvUsable_true);
}
}
llinfos << " finished buildParentChildMap " << llendl;