summaryrefslogtreecommitdiff
path: root/plugingui/layout.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2017-04-11 13:16:59 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2017-04-11 13:16:59 +0200
commit8060a2de98c31ed8bf76cb2db1e8983ef38488bb (patch)
tree5bf66b0b6ef544ff28fcdb19551e635642eef0c8 /plugingui/layout.cc
parenta04d1601f75ffcddf41421097ab1bcd4e27c89dd (diff)
Fix pure virtual function calls and segfaults.
Diffstat (limited to 'plugingui/layout.cc')
-rw-r--r--plugingui/layout.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/plugingui/layout.cc b/plugingui/layout.cc
index 551611c..ea025bd 100644
--- a/plugingui/layout.cc
+++ b/plugingui/layout.cc
@@ -70,7 +70,9 @@ void Layout::addItem(LayoutItem* item)
void Layout::removeItem(LayoutItem* item)
{
- std::remove(items.begin(), items.end(), item);
+ auto new_end = std::remove(items.begin(), items.end(), item);
+ items.erase(new_end, items.end());
+
layout();
}
@@ -118,6 +120,7 @@ void VBoxLayout::layout()
while(i != items.end())
{
LayoutItem* item = *i;
+
if(resizeChildren)
{
auto num_items = items.size();
@@ -247,11 +250,10 @@ GridLayout::GridLayout(LayoutItem* parent, std::size_t number_of_columns,
void GridLayout::removeItem(LayoutItem* item)
{
- Layout::removeItem(item);
-
// manually remove from grid_ranges as remove_if doesn't work on an
- // unordered_map
- for(auto it = grid_ranges.begin(); it != grid_ranges.end(); ++it)
+ // unordered_map.
+ auto it = grid_ranges.begin();
+ while(it != grid_ranges.end())
{
if(it->first == item)
{
@@ -262,6 +264,8 @@ void GridLayout::removeItem(LayoutItem* item)
++it;
}
}
+
+ Layout::removeItem(item);
}
void GridLayout::layout()