From bedf884cafee5529f011a5b47aa403fa48d27227 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 22 Nov 2024 18:59:12 +0200 Subject: viewer#3133 Callback related crash in LLViewerFetchedTexture Seems to be realted to LLModelPreview and path generated textures so I'm improving cleanup. --- indra/newview/llmodelpreview.cpp | 9 +++++---- indra/newview/llmodelpreview.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 1e7da126b0..d61333c2cc 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -227,6 +227,8 @@ LLModelPreview::~LLModelPreview() } mBaseModel.clear(); mBaseScene.clear(); + + LLLoadedCallbackEntry::cleanUpCallbackList(&mCallbackTextureList); } void LLModelPreview::updateDimentionsAndOffsets() @@ -553,7 +555,7 @@ void LLModelPreview::rebuildUploadData() { // in case user provided a missing file later texture->setIsMissingAsset(false); - texture->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, this, NULL, false); + texture->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, this, &mCallbackTextureList, false); texture->forceToSaveRawImage(0, F32_MAX); texture->updateFetch(); if (mModelLoader) @@ -3130,8 +3132,6 @@ LLJoint* LLModelPreview::lookupJointByName(const std::string& str, void* opaque) U32 LLModelPreview::loadTextures(LLImportMaterial& material, void* opaque) { - (void)opaque; - if (material.mDiffuseMapFilename.size()) { material.mOpaqueData = new LLPointer< LLViewerFetchedTexture >; @@ -3145,7 +3145,8 @@ U32 LLModelPreview::loadTextures(LLImportMaterial& material, void* opaque) } // Todo: might cause a crash if preview gets closed before we get the callback. // Use a callback list or guard callback in some way - tex->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, opaque, NULL, false); + LLModelPreview* preview = (LLModelPreview*)opaque; + tex->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, opaque, &preview->mCallbackTextureList, false); tex->forceToSaveRawImage(0, F32_MAX); material.setDiffuseMap(tex->getID()); // record tex ID return 1; diff --git a/indra/newview/llmodelpreview.h b/indra/newview/llmodelpreview.h index c615070105..e236d7ced7 100644 --- a/indra/newview/llmodelpreview.h +++ b/indra/newview/llmodelpreview.h @@ -316,6 +316,7 @@ protected: LLMeshUploadThread::instance_list mUploadData; std::set mTextureSet; + LLLoadedCallbackEntry::source_callback_list_t mCallbackTextureList; //map of vertex buffers to models (one vertex buffer in vector per face in model std::map > > mVertexBuffer[LLModel::NUM_LODS + 1]; -- cgit v1.2.3