diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-04-23 13:47:02 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-23 14:45:52 +0100 |
commit | e774a6ffd01d3228fab9098fa383573aa153a603 (patch) | |
tree | 57c893844168612264def0cfb21ab465ec33f2a8 /vcl | |
parent | 3b7788908a622b8e2043bd64bd0e36ee43fd733c (diff) |
Use shared_ptr for OpenGLPrograms, and hide its copy constructor.
Change-Id: Ia1352105acef1ededaf876a224ebc277121d6942
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/opengl/program.hxx | 1 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 14 |
2 files changed, 7 insertions, 8 deletions
diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx index 8b42dd486fc4..438d7e3d4cc6 100644 --- a/vcl/inc/opengl/program.hxx +++ b/vcl/inc/opengl/program.hxx @@ -39,6 +39,7 @@ private: TextureList maTextures; bool mbBlending; + OpenGLProgram(const OpenGLProgram ¬Implemented); public: OpenGLProgram(); ~OpenGLProgram(); diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index be14c2261359..70c263a01ed3 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -13,6 +13,7 @@ #include <vcl/sysdata.hxx> #include <boost/scoped_array.hpp> +#include <boost/make_shared.hpp> #include <vcl/pngwrite.hxx> #include <vcl/bmpacc.hxx> #include <vcl/graph.hxx> @@ -1588,20 +1589,17 @@ OpenGLProgram* OpenGLContext::GetProgram( const OUString& rVertexShader, const O { ProgramKey aKey( rVertexShader, rFragmentShader, preamble ); - boost::ptr_map<ProgramKey, OpenGLProgram>::iterator + std::map< ProgramKey, boost::shared_ptr<OpenGLProgram> >::iterator it = maPrograms.find( aKey ); if( it != maPrograms.end() ) - return it->second; + return it->second.get(); - OpenGLProgram* pProgram = new OpenGLProgram; + boost::shared_ptr<OpenGLProgram> pProgram = boost::make_shared<OpenGLProgram>(); if( !pProgram->Load( rVertexShader, rFragmentShader, preamble ) ) - { - delete pProgram; return NULL; - } - maPrograms.insert(aKey, pProgram); - return pProgram; + maPrograms.insert(std::pair<ProgramKey, boost::shared_ptr<OpenGLProgram> >(aKey, pProgram)); + return pProgram.get(); } OpenGLProgram* OpenGLContext::UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble ) |