Browse Source

Move slug normalization from getPlugin or getModel functions to fromJson functions.

tags/v2.0.0
Andrew Belt 5 years ago
parent
commit
26bda06eb7
4 changed files with 8 additions and 4 deletions
  1. +4
    -1
      src/app/RackWidget.cpp
  2. +3
    -0
      src/engine/Module.cpp
  3. +1
    -2
      src/plugin.cpp
  4. +0
    -1
      src/plugin/Plugin.cpp

+ 4
- 1
src/app/RackWidget.cpp View File

@@ -24,11 +24,14 @@ static ModuleWidget* moduleFromJson(json_t* moduleJ) {
json_t* pluginSlugJ = json_object_get(moduleJ, "plugin");
if (!pluginSlugJ)
return NULL;
std::string pluginSlug = json_string_value(pluginSlugJ);
pluginSlug = plugin::normalizeSlug(pluginSlug);

json_t* modelSlugJ = json_object_get(moduleJ, "model");
if (!modelSlugJ)
return NULL;
std::string pluginSlug = json_string_value(pluginSlugJ);
std::string modelSlug = json_string_value(modelSlugJ);
modelSlug = plugin::normalizeSlug(modelSlug);

// Get Model
plugin::Model* model = plugin::getModel(pluginSlug, modelSlug);


+ 3
- 0
src/engine/Module.cpp View File

@@ -1,4 +1,5 @@
#include <engine/Module.hpp>
#include <plugin.hpp>


namespace rack {
@@ -89,6 +90,7 @@ void Module::fromJson(json_t* rootJ) {
std::string pluginSlug;
if (pluginJ) {
pluginSlug = json_string_value(pluginJ);
pluginSlug = plugin::normalizeSlug(pluginSlug);
if (pluginSlug != model->plugin->slug) {
WARN("Plugin %s does not match Module's plugin %s.", pluginSlug.c_str(), model->plugin->slug.c_str());
return;
@@ -99,6 +101,7 @@ void Module::fromJson(json_t* rootJ) {
std::string modelSlug;
if (modelJ) {
modelSlug = json_string_value(modelJ);
modelSlug = plugin::normalizeSlug(modelSlug);
if (modelSlug != model->slug) {
WARN("Model %s does not match Module's model %s.", modelSlug.c_str(), model->slug.c_str());
return;


+ 1
- 2
src/plugin.cpp View File

@@ -446,9 +446,8 @@ bool isSyncing() {
}

Plugin* getPlugin(const std::string& pluginSlug) {
std::string slug = normalizeSlug(pluginSlug);
for (Plugin* plugin : plugins) {
if (plugin->slug == slug) {
if (plugin->slug == pluginSlug) {
return plugin;
}
}


+ 0
- 1
src/plugin/Plugin.cpp View File

@@ -23,7 +23,6 @@ void Plugin::addModel(Model* model) {
}

Model* Plugin::getModel(std::string slug) {
slug = normalizeSlug(slug);
for (Model* model : models) {
if (model->slug == slug) {
return model;


Loading…
Cancel
Save