Skip to content
Permalink
Browse files

Fixed crash when unloading certain plugins

When disabling a plugin that does not derive from the Plugin interface,
a crash would occur due to the use of the plugin object after it had
been deleted.
  • Loading branch information...
bjorn committed Aug 21, 2019
1 parent eb294eb commit 0c59eee634ca78e29b527d30ff2cdb3de4d9dc2b
Showing with 4 additions and 9 deletions.
  1. +4 −9 src/libtiled/pluginmanager.cpp
@@ -127,17 +127,12 @@ bool PluginManager::loadPlugin(PluginFile *plugin)

bool PluginManager::unloadPlugin(PluginFile *plugin)
{
bool derivedPlugin = qobject_cast<Plugin*>(plugin->instance) != nullptr;
if (plugin->instance && !qobject_cast<Plugin*>(plugin->instance))
removeObject(plugin->instance);

if (plugin->loader->unload()) {
if (!derivedPlugin)
removeObject(plugin->instance);
plugin->instance = nullptr;

plugin->instance = nullptr;
return true;
} else {
return false;
}
return plugin->loader->unload();
}

PluginManager *PluginManager::instance()

0 comments on commit 0c59eee

Please sign in to comment.
You can’t perform that action at this time.