From d7acb7fc7dfc0f462232732f9d3fcf4d0f7793ee Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 26 Jul 2014 22:24:05 +0200 Subject: [PATCH] Ignore invalid shader cache index (Bug #1664) --- extern/shiny/Main/Factory.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/extern/shiny/Main/Factory.cpp b/extern/shiny/Main/Factory.cpp index 72af07d58f..eab5c8dfc8 100644 --- a/extern/shiny/Main/Factory.cpp +++ b/extern/shiny/Main/Factory.cpp @@ -51,24 +51,32 @@ namespace sh { assert(mCurrentLanguage != Language_None); - if (boost::filesystem::exists (mPlatform->getCacheFolder () + "/lastModified.txt")) + try { - std::ifstream file; - file.open(std::string(mPlatform->getCacheFolder () + "/lastModified.txt").c_str()); - - std::string line; - while (getline(file, line)) + if (boost::filesystem::exists (mPlatform->getCacheFolder () + "/lastModified.txt")) { - std::string sourceFile = line; + std::ifstream file; + file.open(std::string(mPlatform->getCacheFolder () + "/lastModified.txt").c_str()); + + std::string line; + while (getline(file, line)) + { + std::string sourceFile = line; - if (!getline(file, line)) - assert(0); + if (!getline(file, line)) + assert(0); - int modified = boost::lexical_cast(line); + int modified = boost::lexical_cast(line); - mShadersLastModified[sourceFile] = modified; + mShadersLastModified[sourceFile] = modified; + } } } + catch (std::exception& e) + { + std::cerr << "Failed to load shader modification index: " << e.what() << std::endl; + mShadersLastModified.clear(); + } // load configurations {