| @@ -19,6 +19,8 @@ struct ModuleWidget : widget::OpaqueWidget { | |||||
| engine::Module *module = NULL; | engine::Module *module = NULL; | ||||
| widget::Widget *panel = 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<ParamWidget*> params; | ||||
| std::vector<PortWidget*> outputs; | std::vector<PortWidget*> outputs; | ||||
| std::vector<PortWidget*> inputs; | std::vector<PortWidget*> inputs; | ||||
| @@ -20,6 +20,11 @@ namespace app { | |||||
| namespace history { | 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 { | struct Action { | ||||
| /** Name of the action, lowercase. Used in the phrase "Undo ..." */ | /** Name of the action, lowercase. Used in the phrase "Undo ..." */ | ||||
| std::string name; | 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. | Subclass this to create your own custom actions for your module. | ||||
| */ | */ | ||||
| struct ModuleAction : Action { | struct ModuleAction : Action { | ||||
| @@ -415,20 +415,26 @@ void ModuleWidget::addInput(PortWidget *input) { | |||||
| } | } | ||||
| ParamWidget *ModuleWidget::getParam(int paramId) { | 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; | return NULL; | ||||
| } | } | ||||
| PortWidget *ModuleWidget::getOutput(int outputId) { | 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; | return NULL; | ||||
| } | } | ||||
| PortWidget *ModuleWidget::getInput(int inputId) { | 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; | return NULL; | ||||
| } | } | ||||