From a46b96e585f172709e8cd1eb762bdd6b94fe98b5 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 2 Jul 2014 14:07:41 +0100 Subject: [PATCH] win32 component peer deletion safety check. --- .../native/juce_win32_Windowing.cpp | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 4f2afe12ef..63b5d4dcda 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -2209,6 +2209,22 @@ private: return 0; } + bool handlePositionChanged() + { + const Point pos (getCurrentMousePos()); + + if (contains (pos.roundToInt(), false)) + { + doMouseEvent (pos); + + if (! isValidPeer (this)) + return true; + } + + handleMovedOrResized(); + return ! dontRepaint; // to allow non-accelerated openGL windows to draw themselves correctly.. + } + void handleAppActivation (const WPARAM wParam) { modifiersAtLastCallback = -1; @@ -2219,7 +2235,7 @@ private: component.repaint(); handleMovedOrResized(); - if (! ComponentPeer::isValidPeer (this)) + if (! isValidPeer (this)) return; } @@ -2418,18 +2434,10 @@ private: case WM_WINDOWPOSCHANGING: return handlePositionChanging (*(WINDOWPOS*) lParam); case WM_WINDOWPOSCHANGED: - { - const Point pos (getCurrentMousePos()); - if (contains (pos.roundToInt(), false)) - doMouseEvent (pos); - } + if (handlePositionChanged()) + return 0; - handleMovedOrResized(); - - if (dontRepaint) - break; // needed for non-accelerated openGL windows to draw themselves correctly.. - - return 0; + break; //============================================================================== case WM_KEYDOWN: