Skip to content

Commit

Permalink
detach view while showing a Save/Load dialog, to avoid event leakage
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbartholomew committed Sep 29, 2012
1 parent 644b90e commit 166665a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/GameLoaderSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ GameLoaderSaver::GameLoaderSaver(FileSelectorWidget::Type type, const std::strin

void GameLoaderSaver::DialogMainLoop()
{
// detach previous view to avoid event leakage
View *previousView = Pi::GetView();
Pi::SetView(0);

Gui::Fixed *background = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()));
background->SetTransparency(false);
background->SetBgColor(0,0,0,1.0);
Expand All @@ -40,6 +44,9 @@ void GameLoaderSaver::DialogMainLoop()

Gui::Screen::RemoveBaseWidget(background);
delete background;

// restore previous view
Pi::SetView(previousView);
}

void GameLoaderSaver::OnClickLoad(std::string filename)
Expand Down
2 changes: 0 additions & 2 deletions src/GameMenuView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,8 @@ void GameMenuView::OpenSaveDialog()
Pi::cpan->MsgLog()->Message("", Lang::CANT_SAVE_IN_HYPERSPACE);
return;
}
HideAll();
GameSaver saver(Pi::game);
saver.DialogMainLoop();
ShowAll();
const std::string filename = saver.GetFilename();
if (!filename.empty())
Pi::cpan->MsgLog()->Message("", Lang::GAME_SAVED_TO+filename);
Expand Down

0 comments on commit 166665a

Please sign in to comment.