From f8ae98894f9dc789e0d36eb1997e5e29a113bc3e Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 5 Apr 2017 19:14:49 +0100 Subject: [PATCH] Added extra nullptr checks in Android windowing code which fixes rare crashes when callbacks occur before the Component peer has been fully constructed --- modules/juce_gui_basics/native/juce_android_Windowing.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index f977119801..87e180dd24 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -438,12 +438,16 @@ public: //============================================================================== bool isFocused() const override { - return view.callBooleanMethod (ComponentPeerView.hasFocus); + if (view != nullptr) + return view.callBooleanMethod (ComponentPeerView.hasFocus); + + return false; } void grabFocus() override { - view.callBooleanMethod (ComponentPeerView.requestFocus); + if (view != nullptr) + view.callBooleanMethod (ComponentPeerView.requestFocus); } void handleFocusChangeCallback (bool hasFocus)