commit 29c7eca865bccfcc7b8efc1472a45b1cf624b6ce
parent 2c2244d4589b46603ab5cb2c87d81cf0fe11dd6e
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sat, 5 Mar 2016 16:19:34 -0500
fix a loophole allowing the uninstallation of protected remotes
introduced by the previous commit
Diffstat:
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/manager.cpp b/src/manager.cpp
@@ -185,8 +185,17 @@ bool Manager::isRemoteEnabled(const Remote &remote) const
void Manager::uninstall()
{
- while(m_list->selectionSize() > 0) {
- const Remote &remote = currentRemote();
+ int keep = 0;
+
+ while(m_list->selectionSize() - keep > 0) {
+ const int index = m_list->currentIndex() + keep;
+ const Remote &remote = getRemote(index);
+
+ if(remote.isProtected()) {
+ keep++;
+ continue;
+ }
+
m_uninstall.insert(remote);
const auto it = m_enableOverrides.find(remote);
@@ -194,7 +203,7 @@ void Manager::uninstall()
if(it != m_enableOverrides.end())
m_enableOverrides.erase(it);
- m_list->removeRow(m_list->currentIndex());
+ m_list->removeRow(index);
}
}
@@ -256,11 +265,6 @@ ListView::Row Manager::makeRow(const Remote &remote) const
AUTO_STR("Enabled") : AUTO_STR("Disabled")};
}
-Remote Manager::currentRemote() const
-{
- return getRemote(m_list->currentIndex());
-}
-
Remote Manager::getRemote(const int index) const
{
if(index < 0 || index > m_list->rowCount() - 1)
diff --git a/src/manager.hpp b/src/manager.hpp
@@ -42,7 +42,6 @@ protected:
private:
ListView::Row makeRow(const Remote &) const;
- Remote currentRemote() const;
Remote getRemote(int index) const;
void setRemoteEnabled(bool);
bool isRemoteEnabled(const Remote &) const;