diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index c63beeec3..996687547 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 2528b5379..c9a3a4e7f 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 2b4aeda50..848c976a3 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(); }; }