Mercurial > hg > svcore
comparison base/StorageAdviser.cpp @ 374:7cc6b7b0d819 sv1-v1.2pre3
* line up overview widget nicely with main pane (at least on first startup)
* fix #1878396 renaming layer seems to have no visible effect
* comment out some debug output
author | Chris Cannam |
---|---|
date | Wed, 06 Feb 2008 17:40:53 +0000 |
parents | 824ee993ca8d |
children | 52303ec15cd2 |
comparison
equal
deleted
inserted
replaced
373:0a44caddd9fe | 374:7cc6b7b0d819 |
---|---|
20 | 20 |
21 #include "system/System.h" | 21 #include "system/System.h" |
22 | 22 |
23 #include <iostream> | 23 #include <iostream> |
24 | 24 |
25 //#define DEBUG_STORAGE_ADVISER 1 | |
26 | |
25 long StorageAdviser::m_discPlanned = 0; | 27 long StorageAdviser::m_discPlanned = 0; |
26 long StorageAdviser::m_memoryPlanned = 0; | 28 long StorageAdviser::m_memoryPlanned = 0; |
27 | 29 |
28 StorageAdviser::Recommendation | 30 StorageAdviser::Recommendation |
29 StorageAdviser::recommend(Criteria criteria, | 31 StorageAdviser::recommend(Criteria criteria, |
30 int minimumSize, | 32 int minimumSize, |
31 int maximumSize) | 33 int maximumSize) |
32 { | 34 { |
35 #ifdef DEBUG_STORAGE_ADVISER | |
33 std::cerr << "StorageAdviser::recommend: Criteria " << criteria | 36 std::cerr << "StorageAdviser::recommend: Criteria " << criteria |
34 << ", minimumSize " << minimumSize | 37 << ", minimumSize " << minimumSize |
35 << ", maximumSize " << maximumSize << std::endl; | 38 << ", maximumSize " << maximumSize << std::endl; |
39 #endif | |
36 | 40 |
37 QString path = TempDirectory::getInstance()->getPath(); | 41 QString path = TempDirectory::getInstance()->getPath(); |
38 int discFree = GetDiscSpaceMBAvailable(path.toLocal8Bit()); | 42 int discFree = GetDiscSpaceMBAvailable(path.toLocal8Bit()); |
39 int memoryFree, memoryTotal; | 43 int memoryFree, memoryTotal; |
40 GetRealMemoryMBAvailable(memoryFree, memoryTotal); | 44 GetRealMemoryMBAvailable(memoryFree, memoryTotal); |
49 memoryFree -= m_memoryPlanned / 1024 + 1; | 53 memoryFree -= m_memoryPlanned / 1024 + 1; |
50 } else if (memoryFree > 0) { // can also be -1 for unknown | 54 } else if (memoryFree > 0) { // can also be -1 for unknown |
51 memoryFree = 0; | 55 memoryFree = 0; |
52 } | 56 } |
53 | 57 |
58 #ifdef DEBUG_STORAGE_ADVISER | |
54 std::cerr << "Disc space: " << discFree << ", memory free: " << memoryFree << ", memory total: " << memoryTotal << ", min " << minimumSize << ", max " << maximumSize << std::endl; | 59 std::cerr << "Disc space: " << discFree << ", memory free: " << memoryFree << ", memory total: " << memoryTotal << ", min " << minimumSize << ", max " << maximumSize << std::endl; |
60 #endif | |
55 | 61 |
56 //!!! We have a potentially serious problem here if multiple | 62 //!!! We have a potentially serious problem here if multiple |
57 //recommendations are made in advance of any of the resulting | 63 //recommendations are made in advance of any of the resulting |
58 //allocations, as the allocations that have been recommended for | 64 //allocations, as the allocations that have been recommended for |
59 //won't be taken into account in subsequent recommendations. | 65 //won't be taken into account in subsequent recommendations. |
84 else if (minmb > (discFree * 3) / 4) discStatus = Insufficient; | 90 else if (minmb > (discFree * 3) / 4) discStatus = Insufficient; |
85 else if (maxmb > (discFree / 4)) discStatus = Marginal; | 91 else if (maxmb > (discFree / 4)) discStatus = Marginal; |
86 else if (minmb > (discFree / 10)) discStatus = Marginal; | 92 else if (minmb > (discFree / 10)) discStatus = Marginal; |
87 else discStatus = Sufficient; | 93 else discStatus = Sufficient; |
88 | 94 |
95 #ifdef DEBUG_STORAGE_ADVISER | |
89 std::cerr << "Memory status: " << memoryStatus << ", disc status " | 96 std::cerr << "Memory status: " << memoryStatus << ", disc status " |
90 << discStatus << std::endl; | 97 << discStatus << std::endl; |
98 #endif | |
91 | 99 |
92 int recommendation = NoRecommendation; | 100 int recommendation = NoRecommendation; |
93 | 101 |
94 if (memoryStatus == Insufficient || memoryStatus == Unknown) { | 102 if (memoryStatus == Insufficient || memoryStatus == Unknown) { |
95 | 103 |