From 07fe2406e7e4b50d8d7c01426aa9025613cba302 Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Mon, 4 May 2020 00:43:58 +0200 Subject: [PATCH] Don't allocate wxToolBarToolBase, that can lead to memory corruption and two days of debugging. --- src/gui/util.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gui/util.cpp b/src/gui/util.cpp index 16e8780e..96c4dc64 100644 --- a/src/gui/util.cpp +++ b/src/gui/util.cpp @@ -290,13 +290,9 @@ wxToolBarToolBase* add_tool(wxToolBar* toolbar, int id, const char* resource, co #else Image disabled_bitmap = generate_disabled_image(bitmap); #endif - auto tool = new wxToolBarToolBase(toolbar, id, label, bitmap, disabled_bitmap, kind, nullptr, tooltip, help); - toolbar->AddTool(tool); - return tool; + return toolbar->AddTool(id, label, bitmap, disabled_bitmap, kind, tooltip, help); } else { - auto tool = new wxToolBarToolBase(toolbar, id, label, wxNullBitmap, wxNullBitmap, kind, nullptr, tooltip, help); - toolbar->AddTool(tool); - return tool; + return toolbar->AddTool(id, label, wxNullBitmap, wxNullBitmap, kind, tooltip, help); } }