Fix some memory leaks

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-02-10 13:22:34 +00:00
parent be9b5d1612
commit 2a8c80557f
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
4 changed files with 17 additions and 9 deletions

View file

@ -15,6 +15,7 @@
* For a full copy of the GNU General Public License see the LICENSE file.
*/
#include <app/MenuBar.hpp>
#include <app/Scene.hpp>
#include <asset.hpp>
#include <context.hpp>
@ -291,8 +292,11 @@ public:
rack::window::WindowSetPluginUI(context->window, this);
if (context->scene->menuBar != nullptr)
context->scene->removeChild(context->scene->menuBar);
if (rack::widget::Widget* const menuBar = context->scene->menuBar)
{
context->scene->removeChild(menuBar);
delete menuBar;
}
context->scene->menuBar = rack::app::createMenuBar(getApp().isStandalone());
context->scene->addChildBelow(context->scene->menuBar, context->scene->rackScroll);
@ -336,9 +340,14 @@ public:
context->nativeWindowId = 0;
rack::widget::Widget* const menuBar = context->scene->menuBar;
context->scene->menuBar = nullptr;
context->scene->removeChild(menuBar);
if (rack::widget::Widget* const menuBar = context->scene->menuBar)
{
context->scene->removeChild(menuBar);
delete menuBar;
}
context->scene->menuBar = rack::app::createMenuBar();
context->scene->addChildBelow(context->scene->menuBar, context->scene->rackScroll);
rack::window::WindowSetPluginUI(context->window, nullptr);