From 25643479c9a7fc18b4b586959ba277857806d9bc Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 7 Apr 2015 11:20:55 -0700 Subject: [PATCH] Fixed the memory leak, due to the location pointer in the Model::RenderPipelineLib which was not smart pointed correctly --- libraries/render-utils/src/Model.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 7c8bc3b35c..e2e09af27b 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -113,7 +113,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key, bool makeResult = gpu::Shader::makeProgram(*program, slotBindings); - Locations* locations = new Locations(); + auto locations = std::shared_ptr(new Locations()); initLocations(program, *locations); @@ -138,7 +138,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key, // Good to go add the brand new pipeline auto pipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, state)); - auto it = insert(value_type(key.getRaw(), RenderPipeline(pipeline, std::shared_ptr(locations)))); + auto it = insert(value_type(key.getRaw(), RenderPipeline(pipeline, locations))); // If not a shadow pass, create the mirror version from the same state, just change the FrontFace if (!key.isShadow()) { @@ -150,7 +150,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key, // create a new RenderPipeline with the same shader side and the mirrorState auto mirrorPipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, mirrorState)); - auto it = insert(value_type(mirrorKey.getRaw(), RenderPipeline(mirrorPipeline, std::shared_ptr(locations)))); + auto it = insert(value_type(mirrorKey.getRaw(), RenderPipeline(mirrorPipeline, locations))); } }