Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Save currentGame only during pause (safer against crashes)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-- committed Jan 16, 2013
1 parent ad5ca69 commit 02b5319
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/com/androidemu/EmulatorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ protected void onCreate(Bundle savedInstanceState)
{
String last = currentGame;

cfg.setLastRunningGame(null);
if (new File(getGameStateFile(last, 0)).exists() && loadROM(last, false))
{
quickLoad();
Expand All @@ -132,6 +131,14 @@ protected void initResources()
cfg = new UserPrefs(getApplicationContext());
}

@Override
protected void onPause()
{
cfg.setLastRunningGame(currentGame);

super.onPause();
}

@Override
protected void onDestroy()
{
Expand Down Expand Up @@ -506,14 +513,15 @@ private boolean loadROM(String fname)

private boolean loadROM(String fname, boolean failPrompt)
{
cfg.setLastRunningGame(null);

unloadROM();
if (!emulator.loadROM(fname) && failPrompt)
{
Toast.makeText(this, R.string.load_rom_failed, Toast.LENGTH_SHORT).show();
return false;
}
currentGame = fname;
cfg.setLastRunningGame(currentGame);
hidePlaceholder();

return true;
Expand Down

0 comments on commit 02b5319

Please sign in to comment.