Mercurial > hg > svcore
comparison 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 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 540:a38f0db6b41d | 541:57f3eec55957 | 
|---|---|
| 43 | 43 | 
| 44 if (m_baseRecommendation != NoRecommendation) { | 44 if (m_baseRecommendation != NoRecommendation) { | 
| 45 return m_baseRecommendation; // for now | 45 return m_baseRecommendation; // for now | 
| 46 } | 46 } | 
| 47 | 47 | 
| 48 QString path = TempDirectory::getInstance()->getPath(); | 48 QString path; | 
| 49 try { | |
| 50 path = TempDirectory::getInstance()->getPath(); | |
| 51 } catch (std::exception e) { | |
| 52 std::cerr << "StorageAdviser::recommend: ERROR: Failed to get temporary directory path: " << e.what() << std::endl; | |
| 53 return Recommendation(UseMemory | ConserveSpace); | |
| 54 } | |
| 49 int discFree = GetDiscSpaceMBAvailable(path.toLocal8Bit()); | 55 int discFree = GetDiscSpaceMBAvailable(path.toLocal8Bit()); | 
| 50 int memoryFree, memoryTotal; | 56 int memoryFree, memoryTotal; | 
| 51 GetRealMemoryMBAvailable(memoryFree, memoryTotal); | 57 GetRealMemoryMBAvailable(memoryFree, memoryTotal); | 
| 52 | 58 | 
| 53 if (discFree > m_discPlanned / 1024 + 1) { | 59 if (discFree > m_discPlanned / 1024 + 1) { | 
