Fix light mode nsvg cleanup

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-08-02 00:56:54 +01:00
parent 0f3ab5ddf0
commit 36ae333490
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
3 changed files with 29 additions and 2 deletions

2
dpf

@ -1 +1 @@
Subproject commit 11e76be7057c8b189a593ca328aa871fe61fc699
Subproject commit 1cc5641ba765dcb22da32c66faf3a09f808bfb27

View file

@ -76,6 +76,7 @@ static const constexpr uint kCardinalStateCount = kCardinalStateBaseCount;
namespace rack {
namespace asset {
std::string patchesPath();
void destroy();
}
namespace engine {
void Engine_setAboutToClose(Engine*);
@ -290,6 +291,9 @@ struct Initializer
INFO("Destroying plugins");
plugin::destroyStaticPlugins();
INFO("Destroying colourized assets");
asset::destroy();
INFO("Destroying settings");
settings::destroy();

View file

@ -775,7 +775,7 @@ void nsvgDeleteCardinal(NSVGimage*);
}
struct ExtendedNSVGimage {
NSVGimage* handle;
NSVGimage* const handle;
NSVGimage* handleOrig;
NSVGimage* handleMOD;
NSVGshape* shapesOrig;
@ -1088,3 +1088,26 @@ void switchDarkMode(const bool darkMode)
std::memcpy(ext.handle, !darkMode ? ext.handleMOD : ext.handleOrig, sizeof(NSVGimage));
}
}
namespace rack {
namespace asset {
void destroy() {
for (auto it = loadedDarkSVGs.begin(), end = loadedDarkSVGs.end(); it != end; ++it)
{
ExtendedNSVGimage& ext(*it);
deleteExtendedNSVGimage(ext);
}
for (auto it = loadedLightSVGs.begin(), end = loadedLightSVGs.end(); it != end; ++it)
{
ExtendedNSVGimage& ext(*it);
deleteExtendedNSVGimage(ext);
}
loadedDarkSVGs.clear();
loadedLightSVGs.clear();
}
}
}