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

2
carla

@ -1 +1 @@
Subproject commit 782f7f64a7e1a2e197c3e75c90f1d71c8e5b925c
Subproject commit b1ecb33a5ec8d24a98a93ed038713a6da6cc9701

2
dpf

@ -1 +1 @@
Subproject commit 0de149b8cbdc59d74273b7fc8b2193b0885afc33
Subproject commit 4ebd02b0ee1a019d46bcd065e21dc68f8af80031

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);

View file

@ -92,9 +92,8 @@ void Font::loadFile(const std::string& filename, NVGcontext* vg) {
// Transfer ownership of font data to font object
uint8_t* data = system::readFile(filename, &size);
// Don't use nvgCreateFont because it doesn't properly handle UTF-8 filenames on Windows.
handle = nvgCreateFontMem(vg, name.c_str(), data, size, 0);
handle = nvgCreateFontMem(vg, name.c_str(), data, size, 1);
if (handle < 0) {
std::free(data);
throw Exception("Failed to load font %s", filename.c_str());
}
INFO("Loaded font %s", filename.c_str());