caf: Fixed bug in progress calculation resulting in the progress neary standing still on sub sub levels

p4#: 20391
This commit is contained in:
Jacob Støren committed 2013-02-06 13:36:25 +01:00
1 parent 4f44afdac1
commit de8a959ad5
1 file changed
+11 -17
+11 -17
View File
@@ -189,15 +189,14 @@ static std::vector<size_t>& progressSpanStack()
return m_progressSpanStack; return m_progressSpanStack;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Calculate the total number of progress values we would need if we only look at the levels from /// Calculate the total maximum value for the progress bar composed
/// \a levelDepth and below (increasing subdivision) /// of the complete stack
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
static size_t subLevelsMaxProgressValue(size_t levelDepth) static size_t currentTotalMaxProgressValue()
{ {
size_t levCount = 1; size_t levCount = 1;
for (; levelDepth < maxProgressStack().size(); ++levelDepth) for (size_t levelDepth = 0; levelDepth < maxProgressStack().size(); ++levelDepth)
{ {
levCount *= maxProgressStack()[levelDepth]; levCount *= maxProgressStack()[levelDepth];
} }
@@ -209,21 +208,16 @@ static size_t subLevelsMaxProgressValue(size_t levelDepth)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
static size_t currentTotalProgress() static size_t currentTotalProgress()
{ {
size_t progress = 0; double progress = 0;
for (size_t i = 0; i < progressStack().size(); ++i) for (int i = static_cast<int>(progressStack().size()) - 1; i >= 0; --i)
{ {
size_t span = (i < 1) ? 1 : progressSpanStack()[i-1]; size_t span = (i < 1) ? 1 : progressSpanStack()[i-1];
progress = progress + span*progressStack()[i]* subLevelsMaxProgressValue(i+1); progress = span*(progress + progressStack()[i])/maxProgressStack()[i];
} }
return progress;
}
//-------------------------------------------------------------------------------------------------- size_t totalIntProgress = static_cast<size_t>(currentTotalMaxProgressValue()*progress);
///
//-------------------------------------------------------------------------------------------------- return totalIntProgress;
static size_t currentTotalMaxProgressValue()
{
return subLevelsMaxProgressValue(0);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -336,7 +330,7 @@ void ProgressInfoStatic::incrementProgress()
if (!isUpdatePossible()) return; if (!isUpdatePossible()) return;
assert(progressStack().size()); assert(progressStack().size());
ProgressInfoStatic::setProgress(progressStack().back() += progressSpanStack().back()); ProgressInfoStatic::setProgress(progressStack().back() + progressSpanStack().back());
} }