From 278a14d96ef40acabaf038f70662be671d9093fc Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 7 Aug 2014 22:55:52 +0200 Subject: 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. --- common/config-manager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'common') diff --git a/common/config-manager.cpp b/common/config-manager.cpp index a34e32cfc1..04b62371b2 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -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) { -- cgit v1.2.3