From 58d097c855bc29f574c5fd38732bfc8739540781 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 3 Feb 2014 13:56:53 +0000 Subject: [PATCH] Added safety checks to avoid problems when windows VSTs are closed by a hooked keypress. --- .../format_types/juce_VSTPluginFormat.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 4702e3bfa3..fdfbf6b65b 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -2376,9 +2376,9 @@ private: { for (int i = activeVSTWindows.size(); --i >= 0;) { - const VSTPluginWindow* const w = activeVSTWindows.getUnchecked (i); + Component::SafePointer w (activeVSTWindows[i]); - if (w->pluginHWND == hW) + if (w != nullptr && w->pluginHWND == hW) { if (message == WM_CHAR || message == WM_KEYDOWN @@ -2391,9 +2391,10 @@ private: message, wParam, lParam); } - return CallWindowProc ((WNDPROC) w->originalWndProc, - (HWND) w->pluginHWND, - message, wParam, lParam); + if (w != nullptr) // (may have been deleted in SendMessage callback) + return CallWindowProc ((WNDPROC) w->originalWndProc, + (HWND) w->pluginHWND, + message, wParam, lParam); } }