Skip to content

Commit 79e4b7b

Browse files
committed
p#428 'multiple textures' sometimes not present
when opening picker for the first time
1 parent d97cb0f commit 79e4b7b

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

indra/newview/lltexturectrl.cpp

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ LLFloaterTexturePicker::LLFloaterTexturePicker(
186186
mOnUpdateImageStatsCallback(NULL),
187187
mBakeTextureEnabled(false),
188188
mLocalTextureEnabled(false),
189+
mNoCopyTextureSelected(false),
189190
mInventoryPickType(pick_type)
190191
{
191192
setTentative(tentative);
@@ -263,6 +264,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id, bool set_selecti
263264

264265
if (set_selection)
265266
{
267+
// This is going to cause a callback
266268
mInventoryPanel->setSelection(item_id, TAKE_FOCUS_NO);
267269
}
268270
}
@@ -597,7 +599,6 @@ bool LLFloaterTexturePicker::postBuild()
597599
refreshInventoryFilter();
598600

599601
mInventoryPanel->setFilterPermMask(mImmediateFilterPermMask);
600-
mInventoryPanel->setSelectCallback(boost::bind(&LLFloaterTexturePicker::onSelectionChange, this, _1, _2));
601602
mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
602603

603604
// Disable auto selecting first filtered item because it takes away
@@ -616,8 +617,25 @@ bool LLFloaterTexturePicker::postBuild()
616617

617618
if(!mImageAssetID.isNull() || mInventoryPickType == PICK_MATERIAL)
618619
{
619-
mInventoryPanel->setSelection(findItemID(mImageAssetID, false), TAKE_FOCUS_NO);
620+
LLViewerInventoryItem* itemp = findInvItem(mImageAssetID, false);
621+
LLUUID item_id;
622+
if (itemp)
623+
{
624+
item_id = itemp->getUUID();
625+
}
626+
627+
mInventoryPanel->setSelection(item_id, TAKE_FOCUS_NO);
628+
629+
if (item_id.notNull() && itemp)
630+
{
631+
if (!itemp->getPermissions().allowCopyBy(gAgent.getID()))
632+
{
633+
mNoCopyTextureSelected = true;
634+
}
635+
}
620636
}
637+
// Don't call before setSelection, setSelection will mark view as dirty
638+
mInventoryPanel->setSelectCallback(boost::bind(&LLFloaterTexturePicker::onSelectionChange, this, _1, _2));
621639
}
622640

623641
childSetAction("l_add_btn", LLFloaterTexturePicker::onBtnAdd, this);
@@ -809,12 +827,12 @@ void LLFloaterTexturePicker::draw()
809827
}
810828
}
811829

812-
const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, bool copyable_only, bool ignore_library)
830+
LLViewerInventoryItem* LLFloaterTexturePicker::findInvItem(const LLUUID& asset_id, bool copyable_only, bool ignore_library) const
813831
{
814832
if (asset_id.isNull())
815833
{
816834
// null asset id means, no material or texture assigned
817-
return LLUUID::null;
835+
return nullptr;
818836
}
819837

820838
LLUUID loockup_id = asset_id;
@@ -854,30 +872,41 @@ const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, bool co
854872
// search for copyable version first
855873
for (S32 i = 0; i < items.size(); i++)
856874
{
857-
LLInventoryItem* itemp = items[i];
875+
LLViewerInventoryItem* itemp = items[i];
858876
LLPermissions item_permissions = itemp->getPermissions();
859877
if (item_permissions.allowCopyBy(gAgent.getID(), gAgent.getGroupID()))
860878
{
861-
if(!ignore_library || !gInventory.isObjectDescendentOf(itemp->getUUID(),gInventory.getLibraryRootFolderID()))
879+
if (!ignore_library || !gInventory.isObjectDescendentOf(itemp->getUUID(), gInventory.getLibraryRootFolderID()))
862880
{
863-
return itemp->getUUID();
881+
return itemp;
864882
}
865883
}
866884
}
867885
// otherwise just return first instance, unless copyable requested
868886
if (copyable_only)
869887
{
870-
return LLUUID::null;
888+
return nullptr;
871889
}
872890
else
873891
{
874-
if(!ignore_library || !gInventory.isObjectDescendentOf(items[0]->getUUID(),gInventory.getLibraryRootFolderID()))
892+
if (!ignore_library || !gInventory.isObjectDescendentOf(items[0]->getUUID(), gInventory.getLibraryRootFolderID()))
875893
{
876-
return items[0]->getUUID();
894+
return items[0];
877895
}
878896
}
879897
}
880898

899+
return nullptr;
900+
}
901+
902+
const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, bool copyable_only, bool ignore_library) const
903+
{
904+
LLViewerInventoryItem* itemp = findInvItem(asset_id, copyable_only, ignore_library);
905+
if (itemp)
906+
{
907+
return itemp->getUUID();
908+
}
909+
881910
return LLUUID::null;
882911
}
883912

indra/newview/lltexturectrl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ class LLFloaterTexturePicker : public LLFloater
340340
void setImageID(const LLUUID& image_asset_id, bool set_selection = true);
341341
bool updateImageStats(); // true if within limits
342342
const LLUUID& getAssetID() { return mImageAssetID; }
343-
const LLUUID& findItemID(const LLUUID& asset_id, bool copyable_only, bool ignore_library = false);
343+
const LLUUID& findItemID(const LLUUID& asset_id, bool copyable_only, bool ignore_library = false) const;
344344
void setCanApplyImmediately(bool b);
345345

346346
void setActive(bool active);
@@ -397,6 +397,7 @@ class LLFloaterTexturePicker : public LLFloater
397397
void refreshLocalList();
398398
void refreshInventoryFilter();
399399
void setImageIDFromItem(const LLInventoryItem* itemp, bool set_selection = true);
400+
LLViewerInventoryItem* findInvItem(const LLUUID& asset_id, bool copyable_only, bool ignore_library = false) const;
400401

401402
LLPointer<LLViewerTexture> mTexturep;
402403
LLPointer<LLFetchedGLTFMaterial> mGLTFMaterial;

0 commit comments

Comments
 (0)