This fixes Copy+Wear from object

This commit is contained in:
Siana Gearz
2012-02-24 03:27:24 +01:00
parent 10af9d64f2
commit 0bdf54e6d9
2 changed files with 47 additions and 16 deletions

View File

@@ -157,38 +157,54 @@ void LLFloaterOpenObject::moveToInventory(bool wear)
{ {
parent_category_id = gInventory.getRootFolderID(); parent_category_id = gInventory.getRootFolderID();
} }
LLCategoryCreate* cat_data = new LLCategoryCreate(object_id, wear); LLCategoryCreate* cat_data = new LLCategoryCreate(object_id, wear);
LLUUID category_id = gInventory.createNewCategory(parent_category_id, LLUUID category_id = gInventory.createNewCategory(parent_category_id,
LLFolderType::FT_NONE, LLFolderType::FT_NONE,
name, name,
callbackCreateInventoryCategory, callbackCreateInventoryCategory,
(void*)cat_data); (void*)cat_data);
//If we get a null category ID, we are using a capability in createNewCategory and we will //If we get a null category ID, we are using a capability in createNewCategory and we will
//handle the following in the callbackCreateInventoryCategory routine. //handle the following in the callbackCreateInventoryCategory routine.
if ( category_id.notNull() ) if ( category_id.notNull() )
{ {
LLSD result; delete cat_data;
result["folder_id"] = category_id;
//Reduce redundant code by just calling the callback. Dur. LLCatAndWear* data = new LLCatAndWear;
callbackCreateInventoryCategory(result,cat_data); data->mCatID = category_id;
data->mWear = wear;
data->mFolderResponded = false;
// Copy and/or move the items into the newly created folder.
// Ignore any "you're going to break this item" messages.
BOOL success = move_inv_category_world_to_agent(object_id, category_id, TRUE,
callbackMoveInventory,
(void*)data);
if (!success)
{
delete data;
data = NULL;
LLNotificationsUtil::add("OpenObjectCannotCopy");
}
} }
} }
// static // static
void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLSD& result, void* data) void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLSD& result, void* data)
{ {
LLCategoryCreate* cat_data = (LLCategoryCreate*)data; LLCategoryCreate* cat_data = (LLCategoryCreate*)data;
LLUUID category_id = result["folder_id"].asUUID(); LLUUID category_id = result["folder_id"].asUUID();
LLCatAndWear* wear_data = new LLCatAndWear; LLCatAndWear* wear_data = new LLCatAndWear;
wear_data->mCatID = category_id; wear_data->mCatID = category_id;
wear_data->mWear = cat_data->mWear; wear_data->mWear = cat_data->mWear;
wear_data->mFolderResponded = true; wear_data->mFolderResponded = true;
// Copy and/or move the items into the newly created folder. // Copy and/or move the items into the newly created folder.
// Ignore any "you're going to break this item" messages. // Ignore any "you're going to break this item" messages.
BOOL success = move_inv_category_world_to_agent(cat_data->mObjectID, category_id, TRUE, BOOL success = move_inv_category_world_to_agent(cat_data->mObjectID, category_id, TRUE,
@@ -212,7 +228,7 @@ void LLFloaterOpenObject::callbackMoveInventory(S32 result, void* data)
if (result == 0) if (result == 0)
{ {
LLInventoryView::showAgentInventory(); LLInventoryView::showAgentInventory();
LLInventoryView* view = LLInventoryView::getActiveInventory(); LLInventoryView* view = LLInventoryView::getActiveInventory();
if (view) if (view)
{ {
view->getPanel()->setSelection(cat->mCatID, TAKE_FOCUS_NO); view->getPanel()->setSelection(cat->mCatID, TAKE_FOCUS_NO);

View File

@@ -1806,7 +1806,7 @@ void warn_move_inventory(LLViewerObject* object, LLMoveInv* move_inv)
// Move/copy all inventory items from the Contents folder of an in-world // Move/copy all inventory items from the Contents folder of an in-world
// object to the agent's inventory, inside a given category. // object to the agent's inventory, inside a given category.
BOOL move_inv_category_world_to_agent(const LLUUID& object_id, BOOL move_inv_category_world_to_agent(const LLUUID& object_id,
const LLUUID& category_id, const LLUUID& category_id,
BOOL drop, BOOL drop,
void (*callback)(S32, void*), void (*callback)(S32, void*),
@@ -1833,7 +1833,7 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id,
llinfos << "Object contents not found for drop." << llendl; llinfos << "Object contents not found for drop." << llendl;
return FALSE; return FALSE;
} }
BOOL accept = TRUE; BOOL accept = TRUE;
BOOL is_move = FALSE; BOOL is_move = FALSE;
@@ -4544,7 +4544,10 @@ void LLOutfitObserver::done()
class LLOutfitFetch : public LLInventoryFetchDescendentsObserver class LLOutfitFetch : public LLInventoryFetchDescendentsObserver
{ {
public: public:
LLOutfitFetch(const LLUUID& id, bool copy_items, bool append) : mCopyItems(copy_items), mAppend(append) {} LLOutfitFetch(const LLUUID& id, bool copy_items, bool append) :
LLInventoryFetchDescendentsObserver(id),
mCopyItems(copy_items),
mAppend(append) {}
~LLOutfitFetch() {} ~LLOutfitFetch() {}
virtual void done(); virtual void done();
protected: protected:
@@ -4559,6 +4562,18 @@ void LLOutfitFetch::done()
// happen. // happen.
LLInventoryModel::cat_array_t cat_array; LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t item_array; LLInventoryModel::item_array_t item_array;
// Avoid passing a NULL-ref as mCompleteFolders.front() down to
// gInventory.collectDescendents()
if( mComplete.empty() )
{
llwarns << "LLOutfitFetch::done with empty mCompleteFolders" << llendl;
dec_busy_count();
gInventory.removeObserver(this);
delete this;
return;
}
gInventory.collectDescendents(mComplete.front(), gInventory.collectDescendents(mComplete.front(),
cat_array, cat_array,
item_array, item_array,