From 1e47e5b42d352d5d838eeb96984dbf6497020e32 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Wed, 3 Feb 2010 17:42:04 -0500 Subject: EXT-4022 : Texture previews don't work in object contents This was broken long ago in viewer-2.0.0-2 when someone made the decision to stop passing in ObjectID to the texture preview floater. --- indra/newview/llpreviewtexture.cpp | 58 +++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 16 deletions(-) (limited to 'indra/newview/llpreviewtexture.cpp') diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 028807a6bd..dfc67d0126 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -74,22 +74,10 @@ LLPreviewTexture::LLPreviewTexture(const LLSD& key) mLastHeight(0), mLastWidth(0), mAspectRatio(0.f), - mPreviewToSave(FALSE) + mPreviewToSave(FALSE), + mImage(NULL) { - const LLViewerInventoryItem *item = static_cast(getItem()); - if(item) - { - mShowKeepDiscard = item->getPermissions().getCreator() != gAgent.getID(); - mImageID = item->getAssetUUID(); - mIsCopyable = item->checkPermissionsSet(PERM_ITEM_UNRESTRICTED); - } - else // not an item, assume it's an asset id - { - mImageID = mItemUUID; - mCopyToInv = TRUE; - mIsCopyable = TRUE; - } - + updateImageID(); if (key.has("save_as")) { mPreviewToSave = TRUE; @@ -97,7 +85,6 @@ LLPreviewTexture::LLPreviewTexture(const LLSD& key) //Called from floater reg: LLUICtrlFactory::getInstance()->buildFloater(this, "floater_preview_texture.xml", FALSE); } - LLPreviewTexture::~LLPreviewTexture() { if( mLoadingFullImage ) @@ -493,3 +480,42 @@ LLPreview::EAssetStatus LLPreviewTexture::getAssetStatus() } return mAssetStatus; } + +void LLPreviewTexture::updateImageID() +{ + const LLViewerInventoryItem *item = static_cast(getItem()); + if(item) + { + mImageID = item->getAssetUUID(); + mShowKeepDiscard = item->getPermissions().getCreator() != gAgent.getID(); + mCopyToInv = FALSE; + mIsCopyable = item->checkPermissionsSet(PERM_ITEM_UNRESTRICTED); + } + else // not an item, assume it's an asset id + { + mImageID = mItemUUID; + mShowKeepDiscard = FALSE; + mCopyToInv = TRUE; + mIsCopyable = TRUE; + } + +} + +/* virtual */ +void LLPreviewTexture::setObjectID(const LLUUID& object_id) +{ + mObjectUUID = object_id; + + const LLUUID old_image_id = mImageID; + + // Update what image we're pointing to, such as if we just specified the mObjectID + // that this mItemID is part of. + updateImageID(); + + // If the imageID has changed, start over and reload the new image. + if (mImageID != old_image_id) + { + mAssetStatus = PREVIEW_ASSET_UNLOADED; + loadAsset(); + } +} -- cgit v1.2.3