2
0
Ben Payne 11 жил өмнө
parent
commit
dc780ddcae

+ 3 - 2
Engine/source/materials/materialList.cpp

@@ -263,8 +263,6 @@ void MaterialList::clearMatInstList()
       if (mMatInstList[i])
       if (mMatInstList[i])
       {
       {
          BaseMatInstance* current = mMatInstList[i];
          BaseMatInstance* current = mMatInstList[i];
-         delete current;
-         mMatInstList[i] = NULL;
 
 
          // ok, since ts material lists can remap difference indexes to the same object 
          // ok, since ts material lists can remap difference indexes to the same object 
          // we need to make sure that we don't delete the same memory twice.  walk the 
          // we need to make sure that we don't delete the same memory twice.  walk the 
@@ -272,6 +270,9 @@ void MaterialList::clearMatInstList()
          for (U32 j=0; j<mMatInstList.size(); j++)
          for (U32 j=0; j<mMatInstList.size(); j++)
             if (mMatInstList[j] == current)
             if (mMatInstList[j] == current)
                mMatInstList[j] = NULL;
                mMatInstList[j] = NULL;
+
+         mMatInstList[i] = NULL;
+         delete current;
       }
       }
    }
    }
 }
 }