diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/content_panel.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 07a632b4a..5624e8797 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -211,26 +211,35 @@ public: wxString OnGetItemText(long item, long) const override { - DCPOMATIC_ASSERT(item >= 0 && item < static_cast<long>(_items.size())); + if (out_of_range(item)) { + /* wxWidgets sometimes asks for things that are already gone */ + return {}; + } wxClientDC dc(const_cast<wxWindow*>(static_cast<wxWindow const*>(this))); return wxControl::Ellipsize(_items[item].text, dc, wxELLIPSIZE_MIDDLE, GetSize().GetWidth()); } wxListItemAttr* OnGetItemAttr(long item) const override { - DCPOMATIC_ASSERT(item >= 0 && item < static_cast<long>(_items.size())); + if (out_of_range(item)) { + return nullptr; + } return _items[item].error ? const_cast<wxListItemAttr*>(&_red) : nullptr; } weak_ptr<Content> content_at_index(long index) { - if (index < 0 || index >= static_cast<long>(_items.size())) { + if (out_of_range(index)) { return {}; } return _items[index].content; } private: + bool out_of_range(long index) const { + return index < 0 || index >= static_cast<long>(_items.size()); + } + std::vector<Item> _items; wxListItemAttr _red; }; |
