Use unique_ptr for managing the Vst3PluginBridge

Not quite sure why we were doing raw pointers before.
This commit is contained in:
Robbert van der Helm
2021-01-11 17:09:43 +01:00
parent 3ca7061659
commit 10b8ef7870
+5 -6
View File
@@ -32,13 +32,13 @@
// plugin symlinked to either the `x86_64-win` or the `x86-win` directory inside // plugin symlinked to either the `x86_64-win` or the `x86-win` directory inside
// of the bundle, even if it does not come in a bundle itself. // of the bundle, even if it does not come in a bundle itself.
Vst3PluginBridge* bridge = nullptr; std::unique_ptr<Vst3PluginBridge> bridge;
bool InitModule() { bool InitModule() {
assert(bridge == nullptr); assert(!bridge);
try { try {
bridge = new Vst3PluginBridge(); bridge = std::make_unique<Vst3PluginBridge>();
return true; return true;
} catch (const std::exception& error) { } catch (const std::exception& error) {
@@ -51,10 +51,9 @@ bool InitModule() {
} }
bool DeinitModule() { bool DeinitModule() {
assert(bridge != nullptr); assert(bridge);
delete bridge; bridge.reset();
bridge = nullptr;
return true; return true;
} }