Fix on_scene_exit called multiple times
This commit is contained in:
parent
7a57c1c1d8
commit
968d79df7b
1 changed files with 17 additions and 3 deletions
|
|
@ -25,6 +25,7 @@ namespace psemek::app
|
|||
bool running = false;
|
||||
|
||||
bool had_initial_resize = false;
|
||||
bool had_scene_exit = false;
|
||||
|
||||
clock::time_point start_time;
|
||||
|
||||
|
|
@ -246,14 +247,23 @@ namespace psemek::app
|
|||
|
||||
SDL_GL_SwapWindow(impl().window);
|
||||
}
|
||||
if (!impl().had_scene_exit)
|
||||
{
|
||||
impl().had_scene_exit = true;
|
||||
impl().get_scene()->on_scene_exit();
|
||||
}
|
||||
}
|
||||
|
||||
void app::push_scene(std::shared_ptr<scene> s)
|
||||
{
|
||||
if (!impl().had_scene_exit)
|
||||
{
|
||||
impl().had_scene_exit = true;
|
||||
impl().get_scene()->on_scene_exit();
|
||||
}
|
||||
|
||||
impl().had_initial_resize = false;
|
||||
impl().had_scene_exit = false;
|
||||
impl().scene_stack.push_back(std::move(s));
|
||||
|
||||
impl().get_scene()->on_scene_enter(this);
|
||||
|
|
@ -264,7 +274,11 @@ namespace psemek::app
|
|||
if (impl().scene_stack.empty())
|
||||
return nullptr;
|
||||
|
||||
if (!impl().had_scene_exit)
|
||||
{
|
||||
impl().had_scene_exit = true;
|
||||
impl().get_scene()->on_scene_exit();
|
||||
}
|
||||
|
||||
impl().had_initial_resize = false;
|
||||
auto s = std::move(impl().scene_stack.back());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue