From 17af32b5943c845c97baee0733ca86c5a5b722ed Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 7 Apr 2015 15:17:28 +0300 Subject: [PATCH] Revert changes if create_targets throws an exception --- source/pipeline.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/source/pipeline.cpp b/source/pipeline.cpp index fd638fb6..bcbbb05f 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -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 -- 2.45.2