diff base/StorageAdviser.cpp @ 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 cff476cfce77
children 06f13a3b9e9e
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);