Fix #34121: OSL + persistent images option was not freeing shader memory properly,
[blender.git] / intern / cycles / render / scene.cpp
index 093bfecf88e0ef9c5156671baf2cb12f15194049..a1fcffa94a42d494ea9fe1298d8da6685130f845 100644 (file)
@@ -85,6 +85,12 @@ void Scene::free_memory(bool final)
        foreach(ParticleSystem *p, particle_systems)
                delete p;
 
+       shaders.clear();
+       meshes.clear();
+       objects.clear();
+       lights.clear();
+       particle_systems.clear();
+
        if(device) {
                camera->device_free(device, &dscene);
                filter->device_free(device, &dscene);
@@ -118,13 +124,6 @@ void Scene::free_memory(bool final)
                delete curve_system_manager;
                delete image_manager;
        }
-       else {
-               shaders.clear();
-               meshes.clear();
-               objects.clear();
-               lights.clear();
-               particle_systems.clear();
-       }
 }
 
 void Scene::device_update(Device *device_, Progress& progress)
@@ -257,6 +256,7 @@ bool Scene::need_reset()
 
 void Scene::reset()
 {
+       shader_manager->reset(this);
        shader_manager->add_default(this);
 
        /* ensure all objects are updated */