Browse Source

Fix ModuleWidget::getParam(), getInput(), and getOutput() returning incorrect object.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
4d36193cf2
3 changed files with 20 additions and 7 deletions
  1. +2
    -0
      include/app/ModuleWidget.hpp
  2. +6
    -1
      include/history.hpp
  3. +12
    -6
      src/app/ModuleWidget.cpp

+ 2
- 0
include/app/ModuleWidget.hpp View File

@@ -19,6 +19,8 @@ struct ModuleWidget : widget::OpaqueWidget {
engine::Module *module = NULL;

widget::Widget *panel = NULL;
/** Note that the indexes of these vectors might not correspond with the indexes of `Module::params` etc.
*/
std::vector<ParamWidget*> params;
std::vector<PortWidget*> outputs;
std::vector<PortWidget*> inputs;


+ 6
- 1
include/history.hpp View File

@@ -20,6 +20,11 @@ namespace app {
namespace history {


/** An undo action with an inverse redo action.

Pointers to Modules, Params, etc. are not allowed in Actions because the object they refer to may be deleted and restored.
Instead, use moduleIds, etc.
*/
struct Action {
/** Name of the action, lowercase. Used in the phrase "Undo ..." */
std::string name;
@@ -51,7 +56,7 @@ struct ComplexAction : Action {
};


/** An action operating on a module
/** An action operating on a module.
Subclass this to create your own custom actions for your module.
*/
struct ModuleAction : Action {


+ 12
- 6
src/app/ModuleWidget.cpp View File

@@ -415,20 +415,26 @@ void ModuleWidget::addInput(PortWidget *input) {
}

ParamWidget *ModuleWidget::getParam(int paramId) {
if (0 <= paramId && paramId < (int) params.size())
return params[paramId];
for (ParamWidget *param : params) {
if (param->paramQuantity && param->paramQuantity->paramId == paramId)
return param;
}
return NULL;
}

PortWidget *ModuleWidget::getOutput(int outputId) {
if (0 <= outputId && outputId < (int) outputs.size())
return outputs[outputId];
for (PortWidget *port : outputs) {
if (port->portId == outputId)
return port;
}
return NULL;
}

PortWidget *ModuleWidget::getInput(int inputId) {
if (0 <= inputId && inputId < (int) inputs.size())
return inputs[inputId];
for (PortWidget *port : inputs) {
if (port->portId == inputId)
return port;
}
return NULL;
}



Loading…
Cancel
Save