From: Mikko Rasa Date: Sat, 3 Nov 2012 13:27:45 +0000 (+0200) Subject: Implement assignment operator for ProgramData X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7699570b9a07ef1fbe2b3b8badfa923de2fdd0a1;p=libs%2Fgl.git Implement assignment operator for ProgramData This is possible now that ProgramData no longer contains any references. --- 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: