From 6cfe786e84d9d9474c7bd5a78d1b5c92e3868e4e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 28 Nov 2013 14:51:23 +0200 Subject: [PATCH] Restore old samples value if create_targets fails An application could use try-catch to check if a certain level of multisampling is available, and leaving samples to that value would interfere with later operations. --- source/pipeline.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/pipeline.cpp b/source/pipeline.cpp index 0df03ca7..d7e175de 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -49,8 +49,17 @@ void Pipeline::set_multisample(unsigned s) if(s==samples) return; + unsigned old_samples = samples; samples = s; - create_targets(1); + try + { + create_targets(1); + } + catch(...) + { + samples = old_samples; + throw; + } } void Pipeline::set_camera(const Camera *c) -- 2.43.0