diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-01-27 00:35:30 +0200 | 
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2024-01-27 01:18:14 +0200 | 
| commit | e0c604c5f66e00aaa40ba6a418ff28a4a60af0b8 (patch) | |
| tree | 694edf820947a905d9a1ebb688bdd70f61bacc92 | |
| parent | 08cf926d3b6eb28e0b9751ba62b1ce01230a150b (diff) | |
SL-17372 Fix viewer crashing when switching models
mDefaultPhysicsShapeP could reference a dead model if scene changes
| -rw-r--r-- | indra/newview/llmodelpreview.cpp | 9 | ||||
| -rw-r--r-- | indra/newview/llmodelpreview.h | 2 | 
2 files changed, 6 insertions, 5 deletions
diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index ccae1030f1..017816ac87 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -440,13 +440,13 @@ void LLModelPreview::rebuildUploadData()                      // That's ok, but might not what they wanted. Use default_physics_shape if found.                      std::ostringstream out;                      out << "No physics model specified for " << instance.mLabel; -                    if (mDefaultPhysicsShapeP) +                    if (mDefaultPhysicsShapeP.notNull())                      {                          out << " - using: " << DEFAULT_PHYSICS_MESH_NAME;                          lod_model = mDefaultPhysicsShapeP;                      }                      LL_WARNS() << out.str() << LL_ENDL; -                    LLFloaterModelPreview::addStringToLog(out, !mDefaultPhysicsShapeP); // Flash log tab if no default. +                    LLFloaterModelPreview::addStringToLog(out, mDefaultPhysicsShapeP.isNull()); // Flash log tab if no default.                  }                  if (lod_model) @@ -1076,8 +1076,9 @@ void LLModelPreview::loadModelCallback(S32 loaded_lod)              if (loaded_lod == LLModel::LOD_PHYSICS)              {   // Explicitly loading physics. See if there is a default mesh.                  LLMatrix4 ignored_transform; // Each mesh that uses this will supply their own. -                mDefaultPhysicsShapeP = nullptr; -                FindModel(mScene[loaded_lod], DEFAULT_PHYSICS_MESH_NAME + getLodSuffix(loaded_lod), mDefaultPhysicsShapeP, ignored_transform); +                LLModel* out_model = nullptr; +                FindModel(mScene[loaded_lod], DEFAULT_PHYSICS_MESH_NAME + getLodSuffix(loaded_lod), out_model, ignored_transform); +                mDefaultPhysicsShapeP = out_model;                  mWarnOfUnmatchedPhyicsMeshes = true;              }              BOOL legacyMatching = gSavedSettings.getBOOL("ImporterLegacyMatching"); diff --git a/indra/newview/llmodelpreview.h b/indra/newview/llmodelpreview.h index df7320768c..f68cec4441 100644 --- a/indra/newview/llmodelpreview.h +++ b/indra/newview/llmodelpreview.h @@ -240,7 +240,7 @@ private:      /// It is set only when the user chooses a physics shape file that contains a mesh with a name that matches DEFAULT_PHYSICS_MESH_NAME.      /// It is reset when such a name is not found, and when resetting the modelpreview.      /// Not read unless mWarnOfUnmatchedPhyicsMeshes is true. -    LLModel* mDefaultPhysicsShapeP{}; +    LLPointer<LLModel> mDefaultPhysicsShapeP;      typedef enum      {  | 
