Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
obs-vst: Use deleteLater on editorWidget to prevent crash (#92)
Browse files Browse the repository at this point in the history
* obs-vst: Fix crash that we should delete widget later

* obs-vst: Make sure effEditClose won't be called again

* clang format

Co-authored-by: wangshaohui <[email protected]>
  • Loading branch information
walker-WSH and walker-WSH authored Nov 24, 2021
1 parent 6809b0d commit 50c1999
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions VSTPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ bool VSTPlugin::isEditorOpen()
void VSTPlugin::openEditor()
{
if (effect && !editorWidget) {
editorWidget = new EditorWidget(nullptr, this);
editorOpenned = true;
editorWidget = new EditorWidget(nullptr, this);
editorWidget->buildEffectContainer(effect);

if (sourceName.empty()) {
Expand All @@ -189,13 +190,14 @@ void VSTPlugin::openEditor()

void VSTPlugin::closeEditor()
{
if (effect) {
effect->dispatcher(effect, effEditClose, 0, 0, nullptr, 0);
}

if (editorWidget) {
if (effect && editorOpenned) {
editorOpenned = false;
effect->dispatcher(effect, effEditClose, 0, 0, nullptr, 0);
}

editorWidget->close();
delete editorWidget;
editorWidget->deleteLater();
editorWidget = nullptr;
}
}
Expand Down
3 changes: 2 additions & 1 deletion headers/VSTPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class VSTPlugin : public QObject {
float **inputs;
float **outputs;

EditorWidget *editorWidget = nullptr;
EditorWidget *editorWidget = nullptr;
bool editorOpenned = false;

AEffect *loadEffect();

Expand Down

0 comments on commit 50c1999

Please sign in to comment.