diff options
author | Yotam Barnoy | 2011-01-02 10:08:02 +0000 |
---|---|---|
committer | Yotam Barnoy | 2011-01-02 10:08:02 +0000 |
commit | c4095aabc5bb2d53bb8bb1c97e94f39cf3d81355 (patch) | |
tree | c0e3381df8e8726114b992db70ef35a3e95eca68 | |
parent | fcf40ad6267a10456351404bea2f488f742fcc6c (diff) | |
download | scummvm-rg350-c4095aabc5bb2d53bb8bb1c97e94f39cf3d81355.tar.gz scummvm-rg350-c4095aabc5bb2d53bb8bb1c97e94f39cf3d81355.tar.bz2 scummvm-rg350-c4095aabc5bb2d53bb8bb1c97e94f39cf3d81355.zip |
PLUGINS: for uncached plugins, first check the loaded plugin before looking elsewhere
There are some calls to EngineManager::findGame() from within games, such as when loading saved games. It's critical not to unload the plugin from memory or other threads may crash. Therefore, we first scan using any plugin that's already in memory.
svn-id: r55089
-rw-r--r-- | base/plugins.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/base/plugins.cpp b/base/plugins.cpp index a46ebe8748..5f01329df8 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -344,6 +344,7 @@ void PluginManagerUncached::init() { // Resize our pluginsInMem list to prevent fragmentation _pluginsInMem[PLUGIN_TYPE_ENGINE].resize(2); + unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL, false); // empty the engine plugins for (ProviderList::iterator pp = _providers.begin(); pp != _providers.end(); @@ -543,8 +544,16 @@ DECLARE_SINGLETON(EngineManager); **/ GameDescriptor EngineManager::findGame(const Common::String &gameName, const EnginePlugin **plugin) const { GameDescriptor result; + + // First look for the game using the plugins in memory. This is critical + // for calls coming from inside games + result = findGameInLoadedPlugins(gameName, plugin); + if (!result.gameid().empty()) { + return result; + } - // first look for the game using the gameId + // Now look for the game using the gameId. This is much faster than scanning plugin + // by plugin if (PluginMan.loadPluginFromGameId(gameName)) { result = findGameInLoadedPlugins(gameName, plugin); if (!result.gameid().empty()) { |