- ActionList *actionSet = getRunningActionSet();
- for (ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end()); it != itend; it = itNext) {
- ++itNext;
-
- StorageAction *action = static_cast<StorageAction*>(&*it);
-
- double current_progress = lrint(lmm_variable_getvalue(action->getVariable()) * delta);
-
- action->updateRemains(current_progress);
- if (action->type_ == WRITE) {
- action->storage_->usedSize_ += current_progress;
- action->file_->incrPosition(current_progress);
- action->file_->setSize(action->file_->tell());
-
- action->storage_->getContent()->erase(action->file_->cname());
- action->storage_->getContent()->insert({action->file_->cname(), action->file_->size()});
- }
+ for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
+ StorageAction& action = static_cast<StorageAction&>(*it);
+ ++it; // increment iterator here since the following calls to action.finish() may invalidate it
+ action.update_remains(lrint(action.get_variable()->get_value() * delta));