From 10af9d64f2c72122fd9e072a324730b57518998a Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Fri, 24 Feb 2012 03:26:06 +0100 Subject: [PATCH 1/2] One day this will be a memory stat --- indra/newview/CMakeLists.txt | 2 ++ indra/newview/app_settings/settings.xml | 11 +++++++++ indra/newview/llfloaterstats.cpp | 13 ++++++++++- indra/newview/llviewerstats.cpp | 1 + indra/newview/llviewerstats.h | 1 + indra/newview/sgmemstat.cpp | 31 +++++++++++++++++++++++++ indra/newview/sgmemstat.h | 31 +++++++++++++++++++++++++ 7 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 indra/newview/sgmemstat.cpp create mode 100644 indra/newview/sgmemstat.h diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 99c5b8c38..7954b6e8d 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -76,6 +76,7 @@ include_directories( ) set(viewer_SOURCE_FILES + sgmemstat.cpp sgversion.cpp llviewerobjectbackup.cpp slfloatermediafilter.cpp @@ -564,6 +565,7 @@ set(viewer_HEADER_FILES CMakeLists.txt ViewerInstall.cmake + sgmemstat.h sgversion.h llviewerobjectbackup.h slfloatermediafilter.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2b521fed4..ecd22b0ae 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4205,6 +4205,17 @@ Value -1 + DebugStatModeMalloc + + Comment + Mode of stat in Statistics floater + Persist + 1 + Type + S32 + Value + -1 + DebugStatModeFormattedMem Comment diff --git a/indra/newview/llfloaterstats.cpp b/indra/newview/llfloaterstats.cpp index 4d8fd7099..84c637f2c 100644 --- a/indra/newview/llfloaterstats.cpp +++ b/indra/newview/llfloaterstats.cpp @@ -45,6 +45,7 @@ #include "pipeline.h" #include "llviewerobjectlist.h" #include "llviewertexturelist.h" +#include "sgmemstat.h" const S32 LL_SCROLL_BORDER = 1; @@ -99,7 +100,17 @@ void LLFloaterStats::buildStats() stat_barp->mLabelSpacing = 200.f; stat_barp->mPerSec = FALSE; stat_barp->mDisplayMean = FALSE; - + + if(SGMemStat::haveStat()) { + stat_barp = stat_viewp->addStat("Allocated memory", &(LLViewerStats::getInstance()->mMallocStat), "DebugStatModeMalloc"); + stat_barp->setUnitLabel(" MB"); + stat_barp->mMinBar = 0.f; + stat_barp->mMaxBar = 4000.f; + stat_barp->mTickSpacing = 100.f; + stat_barp->mLabelSpacing = 200.f; + stat_barp->mPerSec = FALSE; + stat_barp->mDisplayMean = FALSE; + } stat_viewp = new LLStatView("advanced stat view", "Advanced", "OpenDebugStatAdvanced", rect); addStatView(stat_viewp); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 11cb1a868..baf728781 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -213,6 +213,7 @@ LLViewerStats::LLViewerStats() : mObjectKBitStat("objectkbitstat"), mAssetKBitStat("assetkbitstat"), mTextureKBitStat("texturekbitstat"), + mMallocStat("mallocstat"), mVFSPendingOperations("vfspendingoperations"), mObjectsDrawnStat("objectsdrawnstat"), mObjectsCulledStat("objectsculledstat"), diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 7f0f2d8cf..ec91b7efd 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -59,6 +59,7 @@ public: LLStat mActualInKBitStat; // From the packet ring (when faking a bad connection) LLStat mActualOutKBitStat; // From the packet ring (when faking a bad connection) LLStat mTrianglesDrawnStat; + LLStat mMallocStat; // Simulator stats LLStat mSimTimeDilation; diff --git a/indra/newview/sgmemstat.cpp b/indra/newview/sgmemstat.cpp new file mode 100644 index 000000000..27f3cc7cb --- /dev/null +++ b/indra/newview/sgmemstat.cpp @@ -0,0 +1,31 @@ +/* Copyright (C) 2012 Siana Gearz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA */ + +#include "llviewerprecompiledheaders.h" +#include "sgmemstat.h" + +bool SGMemStat::haveStat() { + return false; +} + +F32 SGMemStat::getMalloc() { + return 0.f; +} + +U32 SGMemStat::getNumObjects() { + return 0; +} diff --git a/indra/newview/sgmemstat.h b/indra/newview/sgmemstat.h new file mode 100644 index 000000000..8a89e3b0d --- /dev/null +++ b/indra/newview/sgmemstat.h @@ -0,0 +1,31 @@ +/* Copyright (C) 2012 Siana Gearz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA */ + +#ifndef SGMEMSTAT_H +#define SGMEMSTAT_H + +namespace SGMemStat{ + +bool haveStat(); + +F32 getMalloc(); + +U32 getNumObjects(); + +} + +#endif From 0bdf54e6d92e8eeea168df19d0848b74ee180654 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Fri, 24 Feb 2012 03:27:24 +0100 Subject: [PATCH 2/2] This fixes Copy+Wear from object --- indra/newview/llfloateropenobject.cpp | 42 ++++++++++++++++++--------- indra/newview/llinventorybridge.cpp | 21 ++++++++++++-- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/indra/newview/llfloateropenobject.cpp b/indra/newview/llfloateropenobject.cpp index 102856d6e..24f976e3c 100644 --- a/indra/newview/llfloateropenobject.cpp +++ b/indra/newview/llfloateropenobject.cpp @@ -157,38 +157,54 @@ void LLFloaterOpenObject::moveToInventory(bool wear) { parent_category_id = gInventory.getRootFolderID(); } - + LLCategoryCreate* cat_data = new LLCategoryCreate(object_id, wear); - + LLUUID category_id = gInventory.createNewCategory(parent_category_id, - LLFolderType::FT_NONE, - name, - callbackCreateInventoryCategory, - (void*)cat_data); + LLFolderType::FT_NONE, + name, + callbackCreateInventoryCategory, + (void*)cat_data); //If we get a null category ID, we are using a capability in createNewCategory and we will //handle the following in the callbackCreateInventoryCategory routine. if ( category_id.notNull() ) { - LLSD result; - result["folder_id"] = category_id; - //Reduce redundant code by just calling the callback. Dur. - callbackCreateInventoryCategory(result,cat_data); + delete cat_data; + + LLCatAndWear* data = new LLCatAndWear; + 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 void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLSD& result, void* data) { LLCategoryCreate* cat_data = (LLCategoryCreate*)data; - + LLUUID category_id = result["folder_id"].asUUID(); LLCatAndWear* wear_data = new LLCatAndWear; wear_data->mCatID = category_id; wear_data->mWear = cat_data->mWear; wear_data->mFolderResponded = true; - + // 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(cat_data->mObjectID, category_id, TRUE, @@ -212,7 +228,7 @@ void LLFloaterOpenObject::callbackMoveInventory(S32 result, void* data) if (result == 0) { LLInventoryView::showAgentInventory(); - LLInventoryView* view = LLInventoryView::getActiveInventory(); + LLInventoryView* view = LLInventoryView::getActiveInventory(); if (view) { view->getPanel()->setSelection(cat->mCatID, TAKE_FOCUS_NO); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 993f8b583..dab9d42c9 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -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 // 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, BOOL drop, 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; return FALSE; } - + BOOL accept = TRUE; BOOL is_move = FALSE; @@ -4544,7 +4544,10 @@ void LLOutfitObserver::done() class LLOutfitFetch : public LLInventoryFetchDescendentsObserver { 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() {} virtual void done(); protected: @@ -4559,6 +4562,18 @@ void LLOutfitFetch::done() // happen. LLInventoryModel::cat_array_t cat_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(), cat_array, item_array,