]> git.tdb.fi Git - libs/gl.git/commitdiff
Revert changes if create_targets throws an exception
authorMikko Rasa <tdb@tdb.fi>
Tue, 7 Apr 2015 12:17:28 +0000 (15:17 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 7 Apr 2015 12:17:28 +0000 (15:17 +0300)
source/pipeline.cpp

index fd638fb6ebbbbdd0a95a78caa57586d67b7660bf..bcbbb05fe3b63aa0064c6e71db0fa5142f28d867 100644 (file)
@@ -40,8 +40,17 @@ void Pipeline::set_hdr(bool h)
        if(h==hdr)
                return;
 
+       bool old_hdr= hdr;
        hdr = h;
-       create_targets(2);
+       try
+       {
+               create_targets(2);
+       }
+       catch(...)
+       {
+               hdr = old_hdr;
+               throw;
+       }
 }
 
 void Pipeline::set_multisample(unsigned s)
@@ -111,7 +120,15 @@ void Pipeline::remove_renderable(const Renderable &r)
 void Pipeline::add_postprocessor(PostProcessor &pp)
 {
        postproc.push_back(&pp);
-       create_targets(0);
+       try
+       {
+               create_targets(0);
+       }
+       catch(...)
+       {
+               postproc.pop_back();
+               throw;
+       }
 }
 
 void Pipeline::setup_frame() const