From ed3c23ad9af2eb310c32fb2563ae55777c2e4608 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 12 Jan 2013 01:18:36 +0100 Subject: [PATCH] Fixed crash on changing cell due to Utf8Encoder going out of scope --- apps/openmw/engine.cpp | 11 ++++++----- apps/openmw/engine.hpp | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 4413e98f46..4f149efa14 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -325,16 +325,13 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) // cursor replacer (converts the cursor from the bsa so they can be used by mygui) MWGui::CursorReplace replacer; - // Create encoder - ToUTF8::Utf8Encoder encoder (mEncoding); - // Create the world mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster, - mResDir, mCfgMgr.getCachePath(), mNewGame, &encoder, mFallbackMap, + mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoder, mFallbackMap, mActivationDistanceOverride)); //Load translation data - mTranslationDataStorage.setEncoder(&encoder); + mTranslationDataStorage.setEncoder(mEncoder); mTranslationDataStorage.loadTranslationData(mFileCollections, mMaster); // Create window manager - this manages all the MW-specific GUI windows @@ -419,6 +416,10 @@ void OMW::Engine::go() settingspath = loadSettings (settings); + // Create encoder + ToUTF8::Utf8Encoder encoder (mEncoding); + mEncoder = &encoder; + prepareEngine (settings); // Play some good 'ol tunes diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 363bb8a108..e320c6991b 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -62,6 +62,7 @@ namespace OMW { MWBase::Environment mEnvironment; ToUTF8::FromType mEncoding; + ToUTF8::Utf8Encoder* mEncoder; Files::PathContainer mDataDirs; boost::filesystem::path mResDir; OEngine::Render::OgreRenderer *mOgre;