Removal of discarded inventory offers moved to deferred (idle) tick. Nested gInventory.notifyObservers() don't work.

This commit is contained in:
Shyotl
2011-10-12 23:48:25 -05:00
parent d7e5c4054f
commit 4963a064f1
5 changed files with 72 additions and 30 deletions

View File

@@ -865,37 +865,13 @@ public:
virtual void done()
{
LL_DEBUGS("Messaging") << "LLDiscardAgentOffer::done()" << LL_ENDL;
const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
bool notify = false;
if(trash_id.notNull() && mObjectID.notNull())
{
LLInventoryModel::update_list_t update;
LLInventoryModel::LLCategoryUpdate old_folder(mFolderID, -1);
update.push_back(old_folder);
LLInventoryModel::LLCategoryUpdate new_folder(trash_id, 1);
update.push_back(new_folder);
gInventory.accountForUpdate(update);
gInventory.moveObject(mObjectID, trash_id);
LLInventoryObject* obj = gInventory.getObject(mObjectID);
if(obj)
{
// no need to restamp since this is already a freshly
// stamped item.
obj->updateParentOnServer(FALSE);
notify = true;
}
}
else
{
LL_WARNS("Messaging") << "DiscardAgentOffer unable to find: "
<< (trash_id.isNull() ? "trash " : "")
<< (mObjectID.isNull() ? "object" : "") << LL_ENDL;
}
// We're invoked from LLInventoryModel::notifyObservers().
// If we now try to remove the inventory item, it will cause a nested
// notifyObservers() call, which won't work.
// So defer moving the item to trash until viewer gets idle (in a moment).
LLAppViewer::instance()->addOnIdleCallback(boost::bind(&LLInventoryModel::removeItem, &gInventory, mObjectID));
gInventory.removeObserver(this);
if(notify)
{
gInventory.notifyObservers();
}
delete this;
}
protected: