summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2013-07-19 17:22:53 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2013-07-19 17:22:53 -0400
commit3d8d4227f1930f986c3b70227de98c12830c874a (patch)
treef34ba174119e7829642ee8b862f2574516f0711e /indra/newview
parent47fabf5770bbb1b2f8272bb77ebdc993cda7c033 (diff)
SH-3889 WIP - added callbacks to control ordering of operations after wearable save.
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llagentwearables.cpp29
-rwxr-xr-xindra/newview/llagentwearables.h4
-rwxr-xr-xindra/newview/llpaneleditwearable.cpp22
-rwxr-xr-xindra/newview/llviewerinventory.cpp43
-rwxr-xr-xindra/newview/llviewerinventory.h4
-rwxr-xr-xindra/newview/llvoavatarself.cpp12
-rwxr-xr-xindra/newview/llvoavatarself.h2
7 files changed, 79 insertions, 37 deletions
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 93ccec7d49..8c33a778e3 100755
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -209,7 +209,7 @@ LLAgentWearables::sendAgentWearablesUpdateCallback::~sendAgentWearablesUpdateCal
* @param wearable The wearable data.
* @param todo Bitmask of actions to take on completion.
*/
-LLAgentWearables::addWearableToAgentInventoryCallback::addWearableToAgentInventoryCallback(
+LLAgentWearables::AddWearableToAgentInventoryCallback::AddWearableToAgentInventoryCallback(
LLPointer<LLRefCount> cb, LLWearableType::EType type, U32 index, LLViewerWearable* wearable, U32 todo, const std::string description) :
mType(type),
mIndex(index),
@@ -221,7 +221,7 @@ LLAgentWearables::addWearableToAgentInventoryCallback::addWearableToAgentInvento
llinfos << "constructor" << llendl;
}
-void LLAgentWearables::addWearableToAgentInventoryCallback::fire(const LLUUID& inv_item)
+void LLAgentWearables::AddWearableToAgentInventoryCallback::fire(const LLUUID& inv_item)
{
if (mTodo & CALL_CREATESTANDARDDONE)
{
@@ -317,12 +317,12 @@ void LLAgentWearables::sendAgentWearablesUpdate()
if (wearable->getItemID().isNull())
{
LLPointer<LLInventoryCallback> cb =
- new addWearableToAgentInventoryCallback(
+ new AddWearableToAgentInventoryCallback(
LLPointer<LLRefCount>(NULL),
(LLWearableType::EType)type,
index,
wearable,
- addWearableToAgentInventoryCallback::CALL_NONE);
+ AddWearableToAgentInventoryCallback::CALL_NONE);
addWearableToAgentInventory(cb, wearable);
}
else
@@ -419,23 +419,18 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32
item->getFlags(),
item->getCreationDate());
template_item->setTransactionID(new_wearable->getTransactionID());
- template_item->updateServer(FALSE);
- gInventory.updateItem(template_item);
- if (name_changed)
- {
- gInventory.notifyObservers();
- }
+ update_inventory_item(template_item, gAgentAvatarp->mEndCustomizeCallback);
}
else
{
// Add a new inventory item (shouldn't ever happen here)
- U32 todo = addWearableToAgentInventoryCallback::CALL_NONE;
+ U32 todo = AddWearableToAgentInventoryCallback::CALL_NONE;
if (send_update)
{
- todo |= addWearableToAgentInventoryCallback::CALL_UPDATE;
+ todo |= AddWearableToAgentInventoryCallback::CALL_UPDATE;
}
LLPointer<LLInventoryCallback> cb =
- new addWearableToAgentInventoryCallback(
+ new AddWearableToAgentInventoryCallback(
LLPointer<LLRefCount>(NULL),
type,
index,
@@ -484,12 +479,12 @@ void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
old_wearable,
trunc_name);
LLPointer<LLInventoryCallback> cb =
- new addWearableToAgentInventoryCallback(
+ new AddWearableToAgentInventoryCallback(
LLPointer<LLRefCount>(NULL),
type,
index,
new_wearable,
- addWearableToAgentInventoryCallback::CALL_WEARITEM,
+ AddWearableToAgentInventoryCallback::CALL_WEARITEM,
description
);
LLUUID category_id;
@@ -909,12 +904,12 @@ void LLAgentWearables::recoverMissingWearable(const LLWearableType::EType type,
// destory content.) JC
const LLUUID lost_and_found_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
LLPointer<LLInventoryCallback> cb =
- new addWearableToAgentInventoryCallback(
+ new AddWearableToAgentInventoryCallback(
LLPointer<LLRefCount>(NULL),
type,
index,
new_wearable,
- addWearableToAgentInventoryCallback::CALL_RECOVERDONE);
+ AddWearableToAgentInventoryCallback::CALL_RECOVERDONE);
addWearableToAgentInventory(cb, new_wearable, lost_and_found_id, TRUE);
}
diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h
index b0ac988341..8a1b470e22 100755
--- a/indra/newview/llagentwearables.h
+++ b/indra/newview/llagentwearables.h
@@ -249,7 +249,7 @@ private:
~sendAgentWearablesUpdateCallback();
};
- class addWearableToAgentInventoryCallback : public LLInventoryCallback
+ class AddWearableToAgentInventoryCallback : public LLInventoryCallback
{
public:
enum ETodo
@@ -262,7 +262,7 @@ private:
CALL_WEARITEM = 16
};
- addWearableToAgentInventoryCallback(LLPointer<LLRefCount> cb,
+ AddWearableToAgentInventoryCallback(LLPointer<LLRefCount> cb,
LLWearableType::EType type,
U32 index,
LLViewerWearable* wearable,
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 580e31591c..a1222424ee 100755
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -1079,13 +1079,8 @@ void LLPanelEditWearable::saveChanges(bool force_save_as)
if (force_save_as)
{
- // FIXME race condition if removeCOFItemLinks does not
- // complete immediately. Looks like we're counting on the
- // fact that updateAppearanceFromCOF will get called after
- // we exit customize mode.
-
// the name of the wearable has changed, re-save wearable with new name
- LLAppearanceMgr::instance().removeCOFItemLinks(mWearablePtr->getItemID());
+ LLAppearanceMgr::instance().removeCOFItemLinks(mWearablePtr->getItemID(),gAgentAvatarp->mEndCustomizeCallback);
gAgentWearables.saveWearableAs(mWearablePtr->getType(), index, new_name, description, FALSE);
mNameEditor->setText(mWearableItem->getName());
}
@@ -1096,24 +1091,19 @@ void LLPanelEditWearable::saveChanges(bool force_save_as)
// version so texture baking service knows appearance has changed.
if (link_item)
{
- // FIXME - two link-modifying calls here plus one
- // inventory change request, none of which use a
- // callback. When does a new appearance request go out
- // and how is it synced with these changes? As above,
- // we seem to be implicitly depending on
- // updateAppearanceFromCOF() to be called when we
- // exit customize mode.
-
// Create new link
+ LL_DEBUGS("Avatar") << "link refresh, creating new link to " << link_item->getLinkedUUID()
+ << " removing old link at " << link_item->getUUID()
+ << " wearable item id " << mWearablePtr->getItemID() << llendl;
link_inventory_item( gAgent.getID(),
link_item->getLinkedUUID(),
LLAppearanceMgr::instance().getCOF(),
link_item->getName(),
description,
LLAssetType::AT_LINK,
- NULL);
+ gAgentAvatarp->mEndCustomizeCallback);
// Remove old link
- remove_inventory_item(link_item->getUUID(), NULL);
+ remove_inventory_item(link_item->getUUID(), gAgentAvatarp->mEndCustomizeCallback);
}
gAgentWearables.saveWearable(mWearablePtr->getType(), index, TRUE, new_name);
}
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 5b4ca97319..bff6767617 100755
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -1166,6 +1166,49 @@ void move_inventory_item(
gAgent.sendReliableMessage();
}
+// Should call this with an update_item that's been copied and
+// modified from an original source item, rather than modifying the
+// source item directly.
+void update_inventory_item(
+ LLViewerInventoryItem *update_item,
+ LLPointer<LLInventoryCallback> cb)
+{
+ const LLUUID& item_id = update_item->getUUID();
+ bool ais_ran = false;
+ if (AISCommand::isAPIAvailable())
+ {
+ LLSD updates = update_item->asLLSD();
+ LLPointer<AISCommand> cmd_ptr = new UpdateItemCommand(item_id, updates, cb);
+ ais_ran = cmd_ptr->run_command();
+ }
+ if (!ais_ran)
+ {
+ LLPointer<LLViewerInventoryItem> obj = gInventory.getItem(item_id);
+ LL_DEBUGS("Inventory") << "item_id: [" << item_id << "] name " << (update_item ? update_item->getName() : "(NOT FOUND)") << llendl;
+ if(obj)
+ {
+ LLMessageSystem* msg = gMessageSystem;
+ msg->newMessageFast(_PREHASH_UpdateInventoryItem);
+ msg->nextBlockFast(_PREHASH_AgentData);
+ msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ msg->addUUIDFast(_PREHASH_TransactionID, update_item->getTransactionID());
+ msg->nextBlockFast(_PREHASH_InventoryData);
+ msg->addU32Fast(_PREHASH_CallbackID, 0);
+ update_item->packMessage(msg);
+ gAgent.sendReliableMessage();
+
+ LLInventoryModel::LLCategoryUpdate up(update_item->getParentUUID(), 0);
+ gInventory.accountForUpdate(up);
+ gInventory.updateItem(update_item);
+ if (cb)
+ {
+ cb->fire(item_id);
+ }
+ }
+ }
+}
+
// Note this only supports updating an existing item. Goes through AISv3
// code path where available. Not all uses of item->updateServer() can
// easily be switched to this paradigm.
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index 0d4ffaa575..6bc6343f3f 100755
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -369,6 +369,10 @@ void move_inventory_item(
LLPointer<LLInventoryCallback> cb);
void update_inventory_item(
+ LLViewerInventoryItem *update_item,
+ LLPointer<LLInventoryCallback> cb);
+
+void update_inventory_item(
const LLUUID& item_id,
const LLSD& updates,
LLPointer<LLInventoryCallback> cb);
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 232bf3e478..05bd3101ea 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2978,6 +2978,11 @@ void LLVOAvatarSelf::onCustomizeStart(bool disable_camera_switch)
{
if (isAgentAvatarValid())
{
+ if (!gAgentAvatarp->mEndCustomizeCallback.get())
+ {
+ gAgentAvatarp->mEndCustomizeCallback = new LLUpdateAppearanceOnDestroy;
+ }
+
gAgentAvatarp->mIsEditingAppearance = true;
gAgentAvatarp->mUseLocalAppearance = true;
@@ -3017,8 +3022,11 @@ void LLVOAvatarSelf::onCustomizeEnd(bool disable_camera_switch)
gAgentCamera.changeCameraToDefault();
gAgentCamera.resetView();
}
-
- LLAppearanceMgr::instance().updateAppearanceFromCOF();
+
+ // Dereferencing the previous callback will cause
+ // updateAppearanceFromCOF to be called, whenever all refs
+ // have resolved.
+ gAgentAvatarp->mEndCustomizeCallback = NULL;
}
}
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index e8b9a25327..3cbf2b5cf5 100755
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -32,6 +32,7 @@
#include "llvoavatar.h"
struct LocalTextureData;
+class LLInventoryCallback;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -342,6 +343,7 @@ private:
public:
static void onCustomizeStart(bool disable_camera_switch = false);
static void onCustomizeEnd(bool disable_camera_switch = false);
+ LLPointer<LLInventoryCallback> mEndCustomizeCallback;
//--------------------------------------------------------------------
// Visibility