Skip to content

Commit

Permalink
Merge PR mumble-voip#6695: Backport "Merge PR mumble-voip#6602: FIX(p…
Browse files Browse the repository at this point in the history
…lugins): Unset active positional plugin on unloading it"
  • Loading branch information
Krzmbrzl authored Jan 12, 2025
2 parents c9b1a3b + 421eca9 commit a697f42
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
21 changes: 17 additions & 4 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

bool isActivePosDataPlugin = false;
{
QWriteLocker lock(&m_activePosDataPluginLock);
isActivePosDataPlugin = &plugin == m_activePositionalDataPlugin.get();
}

if (isActivePosDataPlugin) {
unlinkPositionalData();
}

plugin.shutdown();
}
}
Expand Down Expand Up @@ -996,7 +1007,9 @@ void PluginManager::reportLostLink(mumble_plugin_id_t pluginID) {

const_plugin_ptr_t plugin = getPlugin(pluginID);

if (plugin) {
// Need to check for the presence of Global::get().l in case we are currently
// shutting down Mumble in which case the Log might already have been deleted.
if (plugin && Global::get().l) {
Global::get().l->log(Log::Information,
PluginManager::tr("%1 lost link").arg(plugin->getName().toHtmlEscaped()));
}
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

0 comments on commit a697f42

Please sign in to comment.