mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
Merge branch 'fix_delete_game_ub' into 'master'
Some checks are pending
Build and test / Windows (2019) (push) Blocked by required conditions
Build and test / Windows (2022) (push) Blocked by required conditions
Build and test / Ubuntu (push) Waiting to run
Build and test / MacOS (push) Waiting to run
Build and test / Read .env file and expose it as output (push) Waiting to run
Some checks are pending
Build and test / Windows (2019) (push) Blocked by required conditions
Build and test / Windows (2022) (push) Blocked by required conditions
Build and test / Ubuntu (push) Waiting to run
Build and test / MacOS (push) Waiting to run
Build and test / Read .env file and expose it as output (push) Waiting to run
Avoid accessing removed character on deleting last save (#8387) Closes #8387 See merge request OpenMW/openmw!4574
This commit is contained in:
commit
01ea2ad08c
3 changed files with 5 additions and 4 deletions
|
@ -38,7 +38,7 @@ MWState::Character* MWState::CharacterManager::getCurrentCharacter()
|
|||
return mCurrent;
|
||||
}
|
||||
|
||||
void MWState::CharacterManager::deleteSlot(const MWState::Character* character, const MWState::Slot* slot)
|
||||
void MWState::CharacterManager::deleteSlot(const MWState::Slot* slot, const MWState::Character*& character)
|
||||
{
|
||||
std::list<Character>::iterator it = findCharacter(character);
|
||||
|
||||
|
@ -51,6 +51,7 @@ void MWState::CharacterManager::deleteSlot(const MWState::Character* character,
|
|||
if (character == mCurrent)
|
||||
mCurrent = nullptr;
|
||||
mCharacters.erase(it);
|
||||
character = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace MWState
|
|||
Character* getCurrentCharacter();
|
||||
///< @note May return null
|
||||
|
||||
void deleteSlot(const MWState::Character* character, const MWState::Slot* slot);
|
||||
void deleteSlot(const MWState::Slot* slot, const Character*& character);
|
||||
|
||||
Character* createCharacter(const std::string& name);
|
||||
///< Create new character within saved game management
|
||||
|
|
|
@ -706,10 +706,10 @@ void MWState::StateManager::quickLoad()
|
|||
void MWState::StateManager::deleteGame(const MWState::Character* character, const MWState::Slot* slot)
|
||||
{
|
||||
const std::filesystem::path savePath = slot->mPath;
|
||||
mCharacterManager.deleteSlot(character, slot);
|
||||
mCharacterManager.deleteSlot(slot, character);
|
||||
if (mLastSavegame == savePath)
|
||||
{
|
||||
if (character->begin() != character->end())
|
||||
if (character != nullptr)
|
||||
mLastSavegame = character->begin()->mPath;
|
||||
else
|
||||
mLastSavegame.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue