Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX(plugins): Unset active positional plugin on unloading it #6602

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/mumble/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ bool PluginManager::eventFilter(QObject *target, QEvent *event) {
return QObject::eventFilter(target, event);
}

void PluginManager::unloadPlugins() const {
void PluginManager::unloadPlugins() {
QReadLocker lock(&m_pluginCollectionLock);

auto it = m_pluginHashMap.begin();
Expand Down Expand Up @@ -538,7 +538,7 @@ bool PluginManager::loadPlugin(plugin_id_t pluginID) const {
return false;
}

void PluginManager::unloadPlugin(plugin_id_t pluginID) const {
void PluginManager::unloadPlugin(plugin_id_t pluginID) {
plugin_ptr_t plugin;
{
QReadLocker lock(&m_pluginCollectionLock);
Expand All @@ -551,9 +551,20 @@ void PluginManager::unloadPlugin(plugin_id_t pluginID) const {
}
}

void PluginManager::unloadPlugin(Plugin &plugin) const {
void PluginManager::unloadPlugin(Plugin &plugin) {
if (plugin.isLoaded()) {
// Only shut down loaded plugins

{
QWriteLocker activePluginLock(&m_activePosDataPluginLock);

if (&plugin == m_activePositionalDataPlugin.get()) {
m_positionalData.reset();
m_activePositionalDataPlugin = nullptr;
emit pluginLostLink(plugin.getID());
}
}

plugin.shutdown();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/mumble/PluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class PluginManager : public QObject {
bool eventFilter(QObject *target, QEvent *event) Q_DECL_OVERRIDE;

/// Unloads all plugins that are currently loaded.
void unloadPlugins() const;
void unloadPlugins();
/// Clears the current list of plugins
void clearPlugins();
/// Iterates over the plugins and tries to select a plugin that currently claims to be able to deliver positional
Expand Down Expand Up @@ -145,11 +145,11 @@ class PluginManager : public QObject {
/// Unloads the plugin with the given ID. Unloading means shutting the plugign down.
///
/// @param pluginID The ID of the plugin to unload
void unloadPlugin(plugin_id_t pluginID) const;
void unloadPlugin(plugin_id_t pluginID);
/// Unloads the given plugin. Unloading means shutting the plugign down.
///
/// @param plugin The plugin to unload
void unloadPlugin(Plugin &plugin) const;
void unloadPlugin(Plugin &plugin);
/// Clears the plugin from the list of known plugins
///
/// @param pluginID The ID of the plugin to forget about
Expand Down
3 changes: 1 addition & 2 deletions src/mumble/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ int main(int argc, char **argv) {
delete srpc;

delete Global::get().talkingUI;
delete Global::get().pluginManager;
// Delete the MainWindow before the ServerHandler gets reset in order to allow all callbacks
// trggered by this deletion to still access the ServerHandler (atm all these callbacks are in PluginManager.cpp)
delete Global::get().mw;
Expand All @@ -852,8 +853,6 @@ int main(int argc, char **argv) {
delete Global::get().l;
Global::get().l = nullptr; // Make it clear to any destruction code that Log no longer exists

delete Global::get().pluginManager;

#ifdef USE_ZEROCONF
delete Global::get().zeroconf;
#endif
Expand Down
Loading