]> git.tdb.fi Git - libs/gl.git/commitdiff
Implement assignment operator for ProgramData
authorMikko Rasa <tdb@tdb.fi>
Sat, 3 Nov 2012 13:27:45 +0000 (15:27 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 3 Nov 2012 13:27:45 +0000 (15:27 +0200)
This is possible now that ProgramData no longer contains any references.

source/programdata.cpp
source/programdata.h

index ded9f8a7bb242c38f5606b9cc1dce7bef67d4b2a..69fcdbe0e91fca03b968f355ef397dbaaae273de 100644 (file)
@@ -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)
index 39b44583a0eb26ef31119ea90c5823537553f32d..5d6dceb784e997a9b463d1322ebd0b2f96769a8e 100644 (file)
@@ -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: