commit 54478ec6f85dde87b2fd76866da9e203d212abea
parent e3cf77c35d18ac90a3d2d4c4d7a1bba6d11ea1a0
Author: cfillion <cfillion@users.noreply.github.com>
Date: Fri, 8 Apr 2016 19:18:50 -0400
fix a crash occuring when clearing all actions in the browser's queued tab
Diffstat:
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -640,8 +640,10 @@ void Browser::resetAction(const int index)
m_actions.erase(it);
- if(getDisplay() == Queued)
+ if(getDisplay() == Queued) {
m_list->removeRow(index);
+ m_visibleEntries.erase(m_visibleEntries.begin() + index);
+ }
else
m_list->replaceRow(index, makeRow(*entry));
@@ -674,8 +676,20 @@ void Browser::setAction(const int index, const Version *target, const bool toggl
void Browser::selectionDo(const std::function<void (int)> &func)
{
- for(const int index : m_list->selection())
- func(index);
+ InhibitControl freeze(m_list);
+
+ int lastSize = m_list->rowCount();
+ int offset = 0;
+
+ for(const int index : m_list->selection()) {
+ func(index - offset);
+
+ // handle row removal
+ int newSize = m_list->rowCount();
+ if(newSize < lastSize)
+ offset++;
+ swap(newSize, lastSize);
+ }
}
auto Browser::getDisplay() const -> Display
diff --git a/src/listview.cpp b/src/listview.cpp
@@ -213,6 +213,8 @@ vector<int> ListView::selection() const
indexes.push_back(translateBack(index));
}
+ std::sort(indexes.begin(), indexes.end());
+
return indexes;
}