diff options
author | Colin Snover | 2017-11-10 23:06:42 -0600 |
---|---|---|
committer | Colin Snover | 2017-12-03 20:26:38 -0600 |
commit | d087c9605ffffdc9053c5efdc83f53658afbe9a6 (patch) | |
tree | dc03820fe11d65d683c386512086f62faeb98089 /gui/editgamedialog.cpp | |
parent | 55855cab838c2cb48ea02b983924f4c2b53583c1 (diff) | |
download | scummvm-rg350-d087c9605ffffdc9053c5efdc83f53658afbe9a6.tar.gz scummvm-rg350-d087c9605ffffdc9053c5efdc83f53658afbe9a6.tar.bz2 scummvm-rg350-d087c9605ffffdc9053c5efdc83f53658afbe9a6.zip |
BASE: Remove bad casts between incompatible Plugin types
Previously, a C-style cast was used to convert a
Common::Array<Plugin *>, populated with pointers to StaticPlugin
and DynamicPlugin instances, to a
Common::Array<PluginSubclass<T> *>, but PluginSubclass<T> is a
*sibling* class to StaticPlugin/DynamicPlugin, so this cast was
invalid and the results undefined. The methods for retrieving
subclasses of plugins can't be easily changed to just generate an
array of temporary wrapper objects that expose an identical API
which dereferences to the preferred PluginObject subclass because
pointers to these objects are retained by other parts of ScummVM,
so the wrappers would needed to be persisted or they would need to
just re-expose the underlying Plugin object again. This indicated
that a way to solve this problem is to have the callers receive
Plugin objects and get the PluginObject from the Plugin by
explicitly stating their desired type, in a similar manner to
std::get(std::variant), so that the pattern used by this patch to
solve the problem.
Closes gh-1051.
Diffstat (limited to 'gui/editgamedialog.cpp')
-rw-r--r-- | gui/editgamedialog.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gui/editgamedialog.cpp b/gui/editgamedialog.cpp index 94c74b40c0..348ba5cb91 100644 --- a/gui/editgamedialog.cpp +++ b/gui/editgamedialog.cpp @@ -97,7 +97,7 @@ protected: EditGameDialog::EditGameDialog(const String &domain, const String &desc) : OptionsDialog(domain, "GameOptions") { // Retrieve all game specific options. - const EnginePlugin *plugin = 0; + const Plugin *plugin = nullptr; // To allow for game domains without a gameid. // TODO: Is it intentional that this is still supported? String gameId(ConfMan.get("gameid", domain)); @@ -107,7 +107,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc) // implementation. EngineMan.findGame(gameId, &plugin); if (plugin) { - _engineOptions = (*plugin)->getExtraGuiOptions(domain); + _engineOptions = plugin->get<MetaEngine>().getExtraGuiOptions(domain); } else { warning("Plugin for target \"%s\" not found! Game specific settings might be missing", domain.c_str()); } |