COMMON: Fix crash when quitting on "Game data not found" dialog

ScummVM would try to look up "confirm_exit" in the active domain,
even though the active domain had been removed and pointed to an
invalid address. To avoid this, try to keep _activeDomain and
_activeDomainName updated if removeGameDomain() removes the active
domain.

For good measure, also do it if the active domain is removed by
renameGameDomain(), though I don't know if there was any case where
this would have caused trouble.
This commit is contained in:
Torbjörn Andersson 2014-08-07 22:55:52 +02:00
parent 42c9b1a2c1
commit 278a14d96e

View File

@ -626,6 +626,10 @@ void ConfigManager::addMiscDomain(const String &domName) {
void ConfigManager::removeGameDomain(const String &domName) {
assert(!domName.empty());
assert(isValidDomainName(domName));
if (domName == _activeDomainName) {
_activeDomainName = "";
_activeDomain = 0;
}
_gameDomains.erase(domName);
}
@ -638,6 +642,10 @@ void ConfigManager::removeMiscDomain(const String &domName) {
void ConfigManager::renameGameDomain(const String &oldName, const String &newName) {
renameDomain(oldName, newName, _gameDomains);
if (_activeDomainName == oldName) {
_activeDomainName = newName;
_activeDomain = &_gameDomains[newName];
}
}
void ConfigManager::renameMiscDomain(const String &oldName, const String &newName) {