Skip to content
Snippets Groups Projects
Commit 3513f67d authored by Brad Linden's avatar Brad Linden
Browse files

Attempt at fixing thread safety possibly related to SL-19648

parent 2994833e
No related branches found
No related tags found
2 merge requests!3Update to main branch,!2Rebase onto current main branch
...@@ -219,7 +219,7 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler ...@@ -219,7 +219,7 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler
struct ReturnData struct ReturnData
{ {
public: public:
LLPointer<LLGLTFMaterial> mMaterial; LLGLTFMaterial mMaterial;
S32 mSide; S32 mSide;
bool mSuccess; bool mSuccess;
}; };
...@@ -239,20 +239,16 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler ...@@ -239,20 +239,16 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler
std::unordered_map<S32, std::string>::const_iterator end = object_override.mSides.end(); std::unordered_map<S32, std::string>::const_iterator end = object_override.mSides.end();
while (iter != end) while (iter != end)
{ {
LLPointer<LLGLTFMaterial> override_data = new LLGLTFMaterial();
std::string warn_msg, error_msg; std::string warn_msg, error_msg;
bool success = override_data->fromJSON(iter->second, warn_msg, error_msg);
ReturnData result; ReturnData result;
bool success = result.mMaterial.fromJSON(iter->second, warn_msg, error_msg);
result.mSuccess = success; result.mSuccess = success;
result.mSide = iter->first; result.mSide = iter->first;
if (success) if (!success)
{
result.mMaterial = override_data;
}
else
{ {
LL_WARNS("GLTF") << "failed to parse GLTF override data. errors: " << error_msg << " | warnings: " << warn_msg << LL_ENDL; LL_WARNS("GLTF") << "failed to parse GLTF override data. errors: " << error_msg << " | warnings: " << warn_msg << LL_ENDL;
} }
...@@ -271,23 +267,27 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler ...@@ -271,23 +267,27 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler
{ {
std::unordered_set<S32> side_set; std::unordered_set<S32> side_set;
for (int i = 0; i < results.size(); ++i) for (auto const & result : results)
{ {
if (results[i].mSuccess) S32 side = result.mSide;
if (result.mSuccess)
{ {
// copy to heap here because LLTextureEntry is going to take ownership with an LLPointer
LLGLTFMaterial * material = new LLGLTFMaterial(result.mMaterial);
// flag this side to not be nulled out later // flag this side to not be nulled out later
side_set.insert(results[i].mSide); side_set.insert(side);
if (obj) if (obj)
{ {
obj->setTEGLTFMaterialOverride(results[i].mSide, results[i].mMaterial); obj->setTEGLTFMaterialOverride(side, material);
} }
} }
// unblock material editor // unblock material editor
if (obj && obj->getTE(results[i].mSide) && obj->getTE(results[i].mSide)->isSelected()) if (obj && obj->getTE(side) && obj->getTE(side)->isSelected())
{ {
doSelectionCallbacks(object_override.mObjectId, results[i].mSide); doSelectionCallbacks(object_override.mObjectId, side);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment