- ActionList *actionSet = getRunningActionSet();
- ActionList::iterator it(actionSet->begin());
- ActionList::iterator itend(actionSet->end());
- while (it != itend) {
- StorageAction *action = static_cast<StorageAction*>(&*it);
- ++it;
- double current_progress = lrint(lmm_variable_getvalue(action->getVariable()) * delta);
-
- action->updateRemains(current_progress);
- if (action->type_ == WRITE) {
- action->storage_->usedSize_ += current_progress;
- }
+ for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
+ StorageAction& action = static_cast<StorageAction&>(*it);
+ ++it; // increment iterator here since the following calls to action.finish() may invalidate it
+ action.updateRemains(lrint(action.getVariable()->get_value() * delta));