commit a42cb15f86eac60b2603510451bd7a81d912ee7e
parent 5443499f4b9873e21eeb3b5c4a26b39a10427f9d
Author: cfillion <cfillion@users.noreply.github.com>
Date: Fri, 12 Feb 2016 02:42:07 -0500
don't register new script in the action list if the remote got disabled meanwhile
Diffstat:
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/reapack.cpp b/src/reapack.cpp
@@ -257,7 +257,7 @@ Transaction *ReaPack::createTransaction()
}
try {
- m_transaction = new Transaction;
+ m_transaction = new Transaction(m_config->remotes());
}
catch(const reapack_error &e) {
ShowMessageBox(e.what(), "ReaPack – Fatal Error", 0);
diff --git a/src/transaction.cpp b/src/transaction.cpp
@@ -30,8 +30,8 @@
using namespace std;
-Transaction::Transaction()
- : m_isCancelled(false), m_enableReport(false)
+Transaction::Transaction(const RemoteList *rl)
+ : m_remoteList(rl), m_isCancelled(false), m_enableReport(false)
{
m_registry = new Registry(Path::prefixCache("registry.db"));
@@ -333,15 +333,23 @@ void Transaction::registerScriptsInHost()
while(!m_scriptRegs.empty()) {
const HostRegistration ® = m_scriptRegs.front();
const Registry::Entry &entry = reg.entry;
- const std::string &path = Path::prefixRoot(reg.file).join();
- const bool isLast = m_scriptRegs.size() == 1;
- Section section = MainSection;
+
+ const Remote &remote = m_remoteList->get(entry.remote);
+ if(reg.add && (remote.isNull() || !remote.isEnabled()))
+ continue; // don't register in host if the remote got disabled meanwhile
string category = Path(entry.category).first();
boost::algorithm::to_lower(category);
+ Section section;
+
if(category == "midi editor")
section = MidiEditorSection;
+ else
+ section = MainSection;
+
+ const std::string &path = Path::prefixRoot(reg.file).join();
+ const bool isLast = m_scriptRegs.size() == 1;
if(!AddRemoveReaScript(reg.add, section, path.c_str(), isLast) && reg.add)
addError("Script could not be registered in REAPER.", reg.file);
diff --git a/src/transaction.hpp b/src/transaction.hpp
@@ -29,6 +29,7 @@
class InstallTask;
class Remote;
class RemoteIndex;
+class RemoteList;
class RemoveTask;
class Task;
@@ -49,7 +50,7 @@ public:
typedef std::vector<const Error> ErrorList;
- Transaction();
+ Transaction(const RemoteList *);
~Transaction();
void onFinish(const Callback &callback) { m_onFinish.connect(callback); }
@@ -89,6 +90,7 @@ private:
void registerInHost(bool add, const Registry::Entry &);
void registerScriptsInHost();
+ const RemoteList *m_remoteList;
bool m_isCancelled;
bool m_enableReport;
Registry *m_registry;