From 0e3859385dfbbf73a56baca160aee7593c577f69 Mon Sep 17 00:00:00 2001 From: Jacob Essex Date: Wed, 2 Nov 2011 11:11:27 +0000 Subject: [PATCH] Now ensures that the directory to the config file exists before Ogre tries to access it --- apps/launcher/graphicspage.cpp | 16 ++++++++++++++++ apps/openmw/engine.cpp | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index a3572960d1..6ba8af515c 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 4e58e8a4ca..bdcaf627bb 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("/"),