From 7699570b9a07ef1fbe2b3b8badfa923de2fdd0a1 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 3 Nov 2012 15:27:45 +0200 Subject: [PATCH] Implement assignment operator for ProgramData This is possible now that ProgramData no longer contains any references. --- source/programdata.cpp | 18 ++++++++++++++++++ source/programdata.h | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/source/programdata.cpp b/source/programdata.cpp index ded9f8a7..69fcdbe0 100644 --- a/source/programdata.cpp +++ b/source/programdata.cpp @@ -33,6 +33,24 @@ ProgramData::ProgramData(const ProgramData &other): i->second = i->second->clone(); } +ProgramData &ProgramData::operator=(const ProgramData &other) +{ + for(UniformMap::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) + delete i->second; + uniforms.clear(); + + for(UniformMap::const_iterator i=other.uniforms.begin(); i!=other.uniforms.end(); ++i) + uniforms.insert(uniforms.end(), UniformMap::value_type(i->first, i->second->clone())); + + for(BlockMap::iterator i=blocks.begin(); i!=blocks.end(); ++i) + delete i->second.block; + blocks.clear(); + + changes = NO_CHANGES; + + return *this; +} + ProgramData::~ProgramData() { for(UniformMap::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) diff --git a/source/programdata.h b/source/programdata.h index 39b44583..5d6dceb7 100644 --- a/source/programdata.h +++ b/source/programdata.h @@ -67,10 +67,10 @@ private: mutable Buffer *buffer; mutable Changes changes; - ProgramData &operator=(const ProgramData &); public: ProgramData(); ProgramData(const ProgramData &); + ProgramData &operator=(const ProgramData &); ~ProgramData(); private: -- 2.45.2