Tentative fix for #647

Fixes #647 (crash when trying to use a newly made player), doesn't feel
too clean though this way. Possibly better to immediately adjust (and
save) the gameslots instead of waiting for the options screen to get torn
down.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11323 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
wardje 2012-06-21 21:00:11 +00:00
parent 9589f7c9a5
commit 97c5153832
3 changed files with 7 additions and 4 deletions

View File

@ -51,7 +51,6 @@ private:
std::map<std::string, GameSlot*> m_game_slots;
void readAllChallengesInDirs(const std::vector<std::string>* all_dirs);
bool createSlotsIfNeeded();
/** ID of the active player */
std::string m_current_game_slot;
@ -64,6 +63,7 @@ public:
void addOrFreeChallenge(ChallengeData *c);
void addChallenge (const std::string& filename);
void save ();
bool createSlotsIfNeeded();
const ChallengeData *getChallenge (const std::string& id);

View File

@ -129,9 +129,10 @@ void EnterPlayerNameDialog::onEnterPressedInternal()
UserConfigParams::m_all_players.push_back( new PlayerProfile(playerName) );
// It's unsafe to delete from inside the event handler so we do it later
// It's unsafe to delete from inside the event handler so we do it
// in onUpdate (which checks for m_self_destroy)
m_self_destroy = true;
}
} // if valid name
else
{
LabelWidget* label = getWidget<LabelWidget>("title");
@ -144,7 +145,7 @@ void EnterPlayerNameDialog::onEnterPressedInternal()
void EnterPlayerNameDialog::onUpdate(float dt)
{
// It's unsafe to delete from inside the event handler so we do it later
// It's unsafe to delete from inside the event handler so we do it here
if (m_self_destroy)
{
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");

View File

@ -141,6 +141,8 @@ void OptionsScreenPlayers::tearDown()
{
Screen::tearDown();
user_config->saveConfig();
bool changed = unlock_manager->createSlotsIfNeeded();
if (changed) unlock_manager->save();
} // tearDown
// -----------------------------------------------------------------------------