]> git.localhorst.tv Git - blobs.git/commitdiff
fix segfault in creature panel
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 9 Dec 2017 20:48:02 +0000 (21:48 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 9 Dec 2017 20:48:02 +0000 (21:48 +0100)
src/ui/ui.cpp

index dc17b2be7bba5487f35dcf8a6af3329028e5a242..c3397fe5c13aec4aa5bbecf4a0ab40dbaf06dde7 100644 (file)
@@ -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;