reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 1f44b0c9c8392aa4e46f6bb72e00e5f857380b9b
parent 5b29d44e519284652efefd32e09d7c3ec35af294
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Fri, 10 Mar 2017 23:05:42 -0500

transaction: (refactoring) extract a block of code into its own method

Diffstat:
Msrc/transaction.cpp | 35+++++++++++++++++++++--------------
Msrc/transaction.hpp | 1+
2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/transaction.cpp b/src/transaction.cpp @@ -193,19 +193,7 @@ bool Transaction::runTasks() return true; } - if(m_config->install.promptObsolete && !m_obsolete.empty()) { - vector<Registry::Entry> selected; - selected.insert(selected.end(), m_obsolete.begin(), m_obsolete.end()); - m_obsolete.clear(); - - if(m_promptObsolete(selected)) { - if(m_taskQueues.empty()) - m_taskQueues.push(TaskQueue()); - - for(const auto &entry : selected) - m_taskQueues.back().push(make_shared<UninstallTask>(entry, this)); - } - } + promptObsolete(); while(!m_taskQueues.empty()) { m_registry.savepoint(); @@ -330,7 +318,7 @@ void Transaction::registerScript(const HostTicket &reg, const bool isLastCall) const int section = *it++; const bool isLastSection = it == sections.end(); - int id = AddRemoveReaScript(reg.add, section, fullPath.c_str(), + const int id = AddRemoveReaScript(reg.add, section, fullPath.c_str(), isLastCall && isLastSection); if(!id && enableError) { @@ -356,3 +344,22 @@ void Transaction::inhibit(const Remote &remote) m_inhibited.insert(remote.name()); } + +void Transaction::promptObsolete() +{ + if(!m_config->install.promptObsolete || m_obsolete.empty()) + return; + + vector<Registry::Entry> selected; + selected.insert(selected.end(), m_obsolete.begin(), m_obsolete.end()); + m_obsolete.clear(); + + if(!m_promptObsolete(selected) || selected.empty()) + return; + + if(m_taskQueues.empty()) + m_taskQueues.push(TaskQueue()); + + for(const auto &entry : selected) + m_taskQueues.back().push(make_shared<UninstallTask>(entry, this)); +} diff --git a/src/transaction.hpp b/src/transaction.hpp @@ -89,6 +89,7 @@ private: void registerQueued(); void registerScript(const HostTicket &, bool isLast); void inhibit(const Remote &); + void promptObsolete(); bool commitTasks(); void finish();