Skip to content

Commit

Permalink
Remove windows from the stack in the event of an exception (fixes #1622)
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Aug 3, 2017
1 parent 34d13ad commit e58992c
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/gui/dialogs/modal_dialog.cpp
Expand Up @@ -41,6 +41,18 @@ modal_dialog::~modal_dialog()
{
}

namespace {
struct window_stack_handler {
window_stack_handler(std::unique_ptr<window>& win) : local_window(win) {
open_window_stack.push_back(local_window.get());
}
~window_stack_handler() {
remove_from_window_stack(local_window.get());
}
std::unique_ptr<window>& local_window;
};
}

bool modal_dialog::show(CVideo& video, const unsigned auto_close_time)
{
if(video.faked() && !show_even_without_video_) {
Expand Down Expand Up @@ -71,11 +83,10 @@ bool modal_dialog::show(CVideo& video, const unsigned auto_close_time)

pre_show(*window);

open_window_stack.push_back(window.get());

retval_ = window->show(restore_, auto_close_time);

remove_from_window_stack(window.get());
{ // Scope the window stack
window_stack_handler push_window_stack(window);
retval_ = window->show(restore_, auto_close_time);
}

/*
* It can happen that when two clicks follow each other fast that the event
Expand Down

0 comments on commit e58992c

Please sign in to comment.