mirror of
https://github.com/SFML/SFML.git
synced 2025-01-31 21:55:13 +08:00
Merge pull request #641 from MarioLiebisch/android-statesfix
[Android] Fixed the app crashing on rotation
This commit is contained in:
commit
6302cc0762
@ -200,6 +200,9 @@ static void onDestroy(ANativeActivity* activity)
|
|||||||
// Delete our allocated states
|
// Delete our allocated states
|
||||||
delete states;
|
delete states;
|
||||||
|
|
||||||
|
// Reset the activity pointer for all modules
|
||||||
|
sf::priv::getActivity(NULL, true);
|
||||||
|
|
||||||
// The application should now terminate
|
// The application should now terminate
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +389,7 @@ void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_
|
|||||||
states->terminated = false;
|
states->terminated = false;
|
||||||
|
|
||||||
// Share it across the SFML modules
|
// Share it across the SFML modules
|
||||||
sf::priv::getActivity(states);
|
sf::priv::getActivity(states, true);
|
||||||
|
|
||||||
// These functions will update the activity states and therefore, will allow
|
// These functions will update the activity states and therefore, will allow
|
||||||
// SFML to be kept in the know
|
// SFML to be kept in the know
|
||||||
|
@ -33,11 +33,11 @@ namespace sf
|
|||||||
{
|
{
|
||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
ActivityStates* getActivity(ActivityStates* initializedStates)
|
ActivityStates* getActivity(ActivityStates* initializedStates, bool reset)
|
||||||
{
|
{
|
||||||
static ActivityStates* states = NULL;
|
static ActivityStates* states = NULL;
|
||||||
|
|
||||||
if (!states)
|
if (!states || reset)
|
||||||
states = initializedStates;
|
states = initializedStates;
|
||||||
|
|
||||||
return states;
|
return states;
|
||||||
|
@ -74,7 +74,7 @@ struct ActivityStates
|
|||||||
bool updated;
|
bool updated;
|
||||||
};
|
};
|
||||||
|
|
||||||
SFML_SYSTEM_API ActivityStates* getActivity(ActivityStates* initializedStates=NULL);
|
SFML_SYSTEM_API ActivityStates* getActivity(ActivityStates* initializedStates=NULL, bool reset=false);
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
Loading…
Reference in New Issue
Block a user