diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp
index a3572960d..6ba8af515 100644
--- a/apps/launcher/graphicspage.cpp
+++ b/apps/launcher/graphicspage.cpp
@@ -164,6 +164,22 @@ void GraphicsPage::setupOgre()
QString ogreCfg = QString::fromStdString(mCfg.getOgreConfigPath().string());
file.setFileName(ogreCfg);
+ //we need to check that the path to the configuration file exists before we
+ //try and create an instance of Ogre::Root otherwise Ogre raises an exception
+ QDir configDir = QFileInfo(file).dir();
+ if ( !configDir.exists() && !configDir.mkpath(configDir.path()) )
+ {
+ QMessageBox msgBox;
+ msgBox.setWindowTitle("Error creating config file");
+ msgBox.setIcon(QMessageBox::Critical);
+ msgBox.setStandardButtons(QMessageBox::Ok);
+ msgBox.setText(QString(tr("
Failed to create the configuration file
\
+ Make sure you have write access to
%1
")).arg(configDir.path()));
+ msgBox.exec();
+
+ QApplication::exit(1);
+ }
+
try
{
mOgre = new Ogre::Root(pluginCfg.toStdString(), file.fileName().toStdString(), "./launcherOgre.log");
diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp
index 4e58e8a4c..bdcaf627b 100644
--- a/apps/openmw/engine.cpp
+++ b/apps/openmw/engine.cpp
@@ -291,6 +291,14 @@ void OMW::Engine::go()
mOgre = new OEngine::Render::OgreRenderer;
+ //we need to ensure the path to the configuration exists before creating an
+ //instance of ogre root so that Ogre doesn't raise an exception when trying to
+ //access it
+ const boost::filesystem::path configPath = mCfgMgr.getOgreConfigPath().parent_path();
+ if ( !boost::filesystem::exists(configPath) )
+ {
+ boost::filesystem::create_directories(configPath);
+ }
mOgre->configure(!boost::filesystem::is_regular_file(mCfgMgr.getOgreConfigPath()),
mCfgMgr.getOgreConfigPath().string(),
mCfgMgr.getLogPath().string() + std::string("/"),