From 20c23f0007cf082c3c5f5e86110ca144dc4f4555 Mon Sep 17 00:00:00 2001 From: acsbendi Date: Thu, 25 Apr 2019 14:16:04 +0200 Subject: [PATCH] Fixed WindowImplAndroid used after deleted. --- src/SFML/Window/Android/WindowImplAndroid.cpp | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index 2d724eccd..9d595b03d 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -84,6 +84,7 @@ WindowImplAndroid::WindowImplAndroid(VideoMode mode, const String& title, unsign //////////////////////////////////////////////////////////// WindowImplAndroid::~WindowImplAndroid() { + WindowImplAndroid::singleInstance = NULL; } @@ -216,22 +217,25 @@ bool WindowImplAndroid::hasFocus() const //////////////////////////////////////////////////////////// void WindowImplAndroid::forwardEvent(const Event& event) { - ActivityStates* states = getActivity(NULL); - - if (event.type == Event::GainedFocus) + if (WindowImplAndroid::singleInstance != NULL) { - WindowImplAndroid::singleInstance->m_size.x = ANativeWindow_getWidth(states->window); - WindowImplAndroid::singleInstance->m_size.y = ANativeWindow_getHeight(states->window); - WindowImplAndroid::singleInstance->m_windowBeingCreated = true; - WindowImplAndroid::singleInstance->m_hasFocus = true; - } - else if (event.type == Event::LostFocus) - { - WindowImplAndroid::singleInstance->m_windowBeingDestroyed = true; - WindowImplAndroid::singleInstance->m_hasFocus = false; - } + ActivityStates* states = getActivity(NULL); - WindowImplAndroid::singleInstance->pushEvent(event); + if (event.type == Event::GainedFocus) + { + WindowImplAndroid::singleInstance->m_size.x = ANativeWindow_getWidth(states->window); + WindowImplAndroid::singleInstance->m_size.y = ANativeWindow_getHeight(states->window); + WindowImplAndroid::singleInstance->m_windowBeingCreated = true; + WindowImplAndroid::singleInstance->m_hasFocus = true; + } + else if (event.type == Event::LostFocus) + { + WindowImplAndroid::singleInstance->m_windowBeingDestroyed = true; + WindowImplAndroid::singleInstance->m_hasFocus = false; + } + + WindowImplAndroid::singleInstance->pushEvent(event); + } }