Skip to content

Commit dee43ae

Browse files
committed
Use createEditorAndMakeActive and call editorBeingDeleted on teardown
createEditor() is now private in JUCE 8. createEditorAndMakeActive() registers the editor with the processor, so the host must call editorBeingDeleted() before destruction to clear activeEditor and avoid the dtor jassert.
1 parent dd0c8e5 commit dee43ae

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎Source/TestUtilities.h‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static std::unique_ptr<juce::AudioProcessorEditor> createAndShowEditorOnMessageT
145145
return {};
146146

147147
jassert (instance.getActiveEditor() == nullptr);
148-
editor.reset (instance.createEditor());
148+
editor.reset (instance.createEditorAndMakeActive());
149149

150150
if (editor)
151151
{
@@ -175,16 +175,25 @@ static std::unique_ptr<juce::AudioProcessorEditor> createAndShowEditorOnMessageT
175175

176176
static void deleteEditorOnMessageThread (std::unique_ptr<juce::AudioProcessorEditor> editor)
177177
{
178-
if (juce::MessageManager::getInstance()->isThisTheMessageThread())
178+
auto destroy = [&editor]
179179
{
180+
// createEditorAndMakeActive() registers the editor with the processor;
181+
// the host (us) is responsible for calling editorBeingDeleted() before destruction.
182+
if (editor != nullptr)
183+
editor->processor.editorBeingDeleted (editor.get());
180184
editor.reset();
185+
};
186+
187+
if (juce::MessageManager::getInstance()->isThisTheMessageThread())
188+
{
189+
destroy();
181190
return;
182191
}
183192

184193
juce::WaitableEvent waiter;
185194
juce::MessageManager::callAsync ([&]
186195
{
187-
editor.reset();
196+
destroy();
188197
waiter.signal();
189198
});
190199
waiter.wait();

0 commit comments

Comments
 (0)