Skip to content

Commit

Permalink
plugin-loader: Only load plugins once (WayfireWM#2038)
Browse files Browse the repository at this point in the history
* plugin-loader: Only load plugins once

Duplicate plugins are now ignored.

Fixes WayfireWM#2036.

---------

Co-authored-by: Ilia Bozhinov <ammen99@gmail.com>
  • Loading branch information
2 people authored and mrsteve0924 committed Mar 2, 2024
1 parent 656000c commit 49c7358
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/core/plugin-loader.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#include <sstream>
#include <algorithm>
#include <set>
#include <memory>
#include <filesystem>
#include <dlfcn.h>

#include "plugin-loader.hpp"
#include "wayfire/output-layout.hpp"
#include "wayfire/output.hpp"
#include "../core/wm.hpp"
#include "wayfire/core.hpp"
#include "wayfire/plugin.hpp"
#include <wayfire/util/log.hpp>

Expand Down Expand Up @@ -152,7 +148,6 @@ void wf::plugin_manager_t::reload_dynamic_plugins()

std::stringstream stream(plugin_list);
std::vector<std::string> next_plugins;

std::vector<std::string> plugin_paths = wf::get_plugin_paths();

std::string plugin_name;
Expand All @@ -163,6 +158,14 @@ void wf::plugin_manager_t::reload_dynamic_plugins()
auto plugin_path = wf::get_plugin_path_for_name(plugin_paths, plugin_name);
if (plugin_path)
{
auto already_loaded =
std::find(next_plugins.begin(), next_plugins.end(), plugin_path.value());
if (already_loaded != next_plugins.end())
{
LOGE(plugin_name, " plugin found in the plugin list more than once, skipping");
continue;
}

next_plugins.push_back(plugin_path.value());
} else
{
Expand Down

0 comments on commit 49c7358

Please sign in to comment.