From a16727d5e30a31ab35923ba83ddbd217272e2792 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Thu, 2 Apr 2020 20:27:52 +0200 Subject: [PATCH] implement move constructor --- apps/openmw/mwscript/scriptmanagerimp.cpp | 2 +- components/compiler/streamerrorhandler.cpp | 5 +++++ components/compiler/streamerrorhandler.hpp | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index c63beeec3f..9966875475 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -171,7 +171,7 @@ namespace MWScript { Compiler::Locals locals; - Compiler::ContextRestore restore = mErrorHandler.setContext(name2 + "[local variables]", true); + const Compiler::ContextRestore&& restore = mErrorHandler.setContext(name2 + "[local variables]", true); std::istringstream stream (script->mScriptText); Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals); diff --git a/components/compiler/streamerrorhandler.cpp b/components/compiler/streamerrorhandler.cpp index 2528b53798..c9a3a4e7fb 100644 --- a/components/compiler/streamerrorhandler.cpp +++ b/components/compiler/streamerrorhandler.cpp @@ -72,6 +72,11 @@ namespace Compiler ContextRestore::ContextRestore(StreamErrorHandler* handler, const std::string& context) : mHandler(handler), mContext(context) {} + ContextRestore::ContextRestore(ContextRestore&& other) : mHandler(other.mHandler), mContext(other.mContext) + { + other.mHandler = nullptr; + } + ContextRestore::~ContextRestore() { if(mHandler) diff --git a/components/compiler/streamerrorhandler.hpp b/components/compiler/streamerrorhandler.hpp index 2b4aeda50f..848c976a39 100644 --- a/components/compiler/streamerrorhandler.hpp +++ b/components/compiler/streamerrorhandler.hpp @@ -42,6 +42,8 @@ namespace Compiler public: ContextRestore (StreamErrorHandler* handler, const std::string& context); + ContextRestore (ContextRestore&& other); + ~ContextRestore(); }; }