From: Daniel Karbach Date: Sat, 9 Dec 2017 20:48:02 +0000 (+0100) Subject: fix segfault in creature panel X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=d609fd0169ed442ff20fbf9f4bd187a597418b4f;p=blobs.git fix segfault in creature panel --- diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index dc17b2b..c3397fe 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -236,19 +236,12 @@ void CreaturePanel::Draw(graphics::Viewport &viewport) noexcept { const creature::Composition &comp = c->GetComposition(); if (comp.size() < components.size()) { + components.clear(); composition->Clear(); - while (comp.size() < components.size()) { - delete components.back(); - components.pop_back(); - } - for (auto l : components) { - composition->Add(l); - } - } else { - while (comp.size() > components.size()) { - components.emplace_back(new Label(assets.fonts.medium)); - composition->Add(components.back()); - } + } + while (comp.size() > components.size()) { + components.emplace_back(new Label(assets.fonts.medium)); + composition->Add(components.back()); } { int i = 0;