apply misc fixes from Markus Fischer and Rambetter
[xonotic/netradiant.git] / plugins / model / remap.cpp
index 73468ac5e52bacb1ecb578ec8c4a2e4a91454792..7f1cac2d164b245681f31209a52d80557750317d 100644 (file)
@@ -224,13 +224,18 @@ private:
       const char* surfShaderName = m_model->GetShaderNameForSurface(j);
       IShader* shader = shader_for_remap(surfShaderName);
 //      m_shaders.push_back((shader) ? shader : (global_shader) ? global_shader : QERApp_Shader_ForName(surfShaderName));
-      if( shader ) {
-        m_shaders.push_back(shader);
-      } else if( global_shader ) {
-        m_shaders.push_back(global_shader);
-      } else {
-        m_shaders.push_back(QERApp_Shader_ForName(surfShaderName));
+      // Determine which shader it is going to be
+      if( !shader ) {
+        if( global_shader ) {
+          shader = global_shader;
+        } else {
+          shader = QERApp_Shader_ForName(surfShaderName);
+        }
       }
+      // Add reference
+      shader->IncRef();
+      // Done, continue
+      m_shaders.push_back( shader );
     }
   }