From 3035fb8fa2ae05571d0f24d0a0f829944b556645 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 25 Apr 2014 18:34:48 +0200 Subject: [PATCH] Made Context::Create exception-safe Former-commit-id: 913e87b684028ca6f9c41e529628c77c171761c1 --- src/Nazara/Renderer/Context.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Nazara/Renderer/Context.cpp b/src/Nazara/Renderer/Context.cpp index c8a6da370..031e9b780 100644 --- a/src/Nazara/Renderer/Context.cpp +++ b/src/Nazara/Renderer/Context.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -149,14 +150,13 @@ bool NzContext::Create(const NzContextParameters& parameters) return false; } + m_impl = impl.release(); + + NzCallOnExit onExit([this] () { Destroy(); }); + if (!SetActive(true)) { NazaraError("Failed to activate context"); - - m_impl->Destroy(); - delete m_impl; - m_impl = nullptr; - return false; } @@ -172,6 +172,8 @@ bool NzContext::Create(const NzContextParameters& parameters) #endif } + onExit.Reset(); + NotifyCreated(); return true;