Browse Source

Deserialize empty plugin whitelist from settings.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
99f820f1cd
2 changed files with 7 additions and 3 deletions
  1. +2
    -2
      src/library.cpp
  2. +5
    -1
      src/settings.cpp

+ 2
- 2
src/library.cpp View File

@@ -267,7 +267,8 @@ void checkUpdates() {
std::map<std::string, std::set<std::string>> moduleWhitelist; std::map<std::string, std::set<std::string>> moduleWhitelist;
for (const auto& pluginPair : settings::moduleWhitelist) { for (const auto& pluginPair : settings::moduleWhitelist) {
// Create an empty set // Create an empty set
moduleWhitelist[pluginPair.first];
std::string pluginSlug = pluginPair.first;
moduleWhitelist[pluginSlug];
} }


// Iterate plugins // Iterate plugins
@@ -281,7 +282,6 @@ void checkUpdates() {
json_array_foreach(modulesJ, moduleIndex, moduleSlugJ) { json_array_foreach(modulesJ, moduleIndex, moduleSlugJ) {
std::string moduleSlug = json_string_value(moduleSlugJ); std::string moduleSlug = json_string_value(moduleSlugJ);
// Insert module in whitelist // Insert module in whitelist
DEBUG("plugin %s module %s", pluginSlug, moduleSlug.c_str());
moduleWhitelist[pluginSlug].insert(moduleSlug); moduleWhitelist[pluginSlug].insert(moduleSlug);
} }
} }


+ 5
- 1
src/settings.cpp View File

@@ -399,11 +399,15 @@ void fromJson(json_t* rootJ) {
const char* pluginSlug; const char* pluginSlug;
json_t* pluginJ; json_t* pluginJ;
json_object_foreach(moduleWhitelistJ, pluginSlug, pluginJ) { json_object_foreach(moduleWhitelistJ, pluginSlug, pluginJ) {
// Create an empty modules set, even if there are no modules in the whitelist.
// An empty set means no modules will be displayed in the Browser.
auto& modules = moduleWhitelist[pluginSlug];

size_t moduleIndex; size_t moduleIndex;
json_t* moduleJ; json_t* moduleJ;
json_array_foreach(pluginJ, moduleIndex, moduleJ) { json_array_foreach(pluginJ, moduleIndex, moduleJ) {
std::string moduleSlug = json_string_value(moduleJ); std::string moduleSlug = json_string_value(moduleJ);
moduleWhitelist[pluginSlug].insert(moduleSlug);
modules.insert(moduleSlug);
} }
} }
} }


Loading…
Cancel
Save