summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerinventory.cpp
diff options
context:
space:
mode:
authorMike Antipov <mantipov@productengine.com>2010-07-22 12:46:57 +0300
committerMike Antipov <mantipov@productengine.com>2010-07-22 12:46:57 +0300
commitf6c08d45108d713fc42786885d1d38a4b95c10ac (patch)
treeb52419351a5c61c2db8f8287b0c27a78d8b15712 /indra/newview/llviewerinventory.cpp
parenta96f47db68dd52fa94bc3e9f652623583f85c60a (diff)
EXT-8459 FIXED preventing crashes: 1) ensure that pointer to inventory item is still valid when landmark is loaded from notecard and 2) adding a check for region capability
There are two reasons of the crash reported in the bug: * absence of the "CopyInventoryFromNotecard" capability in region (which leads to crash while logging of a LL_ERRS) * referencing to an invalid pointer to LLInventoryItem in callback. The first issue is fixed by preventing sending of the "CopyInventoryFromNotecard" message if it is not supported (in the "copy_inventory_from_notecard()") The second issue caused by such reason: * Notecard stores LLPointer to each embedded inventory item * When Landmark is clicked it should be opened in Places Panel and inventory item should copied into agent inventory * If it is unknown to agent it is requested and pointer (but not LLPointer!) to inventory item was bound to an appropriate callback * Then when landmark is loaded that inventory item is copied to inventory. * If notecard was closed before callback was trigged all instances to embedded inventory items were destroyed. This leads to crash when trigged callback tries to reference to bound pointer to inventory item (for landmarks) Fix is to pass LLPointer instead of pointer to inventory item into callback to ensure item is valid when it is needed. Details: * updated LLEmbeddedItems::getEmbeddedItem() to return LLPointer to inventory item (and renamed to getEmbeddedItemPtr) * updated LLViewerTextEditor::openEmbeddedItem() to get LLPointer to inventory item * updated LLViewerTextEditor::openEmbeddedLandmark() to get LLPointer to inventory item Patch also contains some more places where pointer is replaced with LLPointer to be consistent. NOTE: there are several LLViewerTextEditor::openEmbeddedXXX() methods which still get pointer to inventory item. It is safe for now because they use it synchronously. I have added a note at their declaration. Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/784/ --HG-- branch : product-engine
Diffstat (limited to 'indra/newview/llviewerinventory.cpp')
-rw-r--r--indra/newview/llviewerinventory.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 2d57c16889..5d90af0cfe 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -1172,6 +1172,14 @@ void move_inventory_item(
void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecard_inv_id, const LLInventoryItem *src, U32 callback_id)
{
+ if (NULL == src)
+ {
+ LL_WARNS("copy_inventory_from_notecard") << "Null pointer to item was passed for object_id "
+ << object_id << " and notecard_inv_id "
+ << notecard_inv_id << LL_ENDL;
+ return;
+ }
+
LLViewerRegion* viewer_region = NULL;
LLViewerObject* vo = NULL;
if (object_id.notNull() && (vo = gObjectList.findObject(object_id)) != NULL)
@@ -1194,6 +1202,16 @@ void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecar
return;
}
+ // check capability to prevent a crash while LL_ERRS in LLCapabilityListener::capListener. See EXT-8459.
+ std::string url = viewer_region->getCapability("CopyInventoryFromNotecard");
+ if (url.empty())
+ {
+ LL_WARNS("copy_inventory_from_notecard") << "There is no 'CopyInventoryFromNotecard' capability"
+ << " for region: " << viewer_region->getName()
+ << LL_ENDL;
+ return;
+ }
+
LLSD request, body;
body["notecard-id"] = notecard_inv_id;
body["object-id"] = object_id;