changeset 541:57f3eec55957

* Avoid crash in StorageAdviser if temporary directory cannot be opened
author Chris Cannam
date Mon, 02 Feb 2009 17:07:47 +0000
parents a38f0db6b41d
children 1ddab154fb9a
files base/StorageAdviser.cpp
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/base/StorageAdviser.cpp	Thu Jan 29 14:17:12 2009 +0000
+++ b/base/StorageAdviser.cpp	Mon Feb 02 17:07:47 2009 +0000
@@ -45,7 +45,13 @@
         return m_baseRecommendation; // for now
     }
 
-    QString path = TempDirectory::getInstance()->getPath();
+    QString path;
+    try {
+        path = TempDirectory::getInstance()->getPath();
+    } catch (std::exception e) {
+        std::cerr << "StorageAdviser::recommend: ERROR: Failed to get temporary directory path: " << e.what() << std::endl;
+        return Recommendation(UseMemory | ConserveSpace);
+    }
     int discFree = GetDiscSpaceMBAvailable(path.toLocal8Bit());
     int memoryFree, memoryTotal;
     GetRealMemoryMBAvailable(memoryFree, memoryTotal);