From 43dd52f9feaf9c3058830554cb0aac4e14b60594 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 5 Mar 2019 13:41:39 -0500 Subject: [PATCH] Add Model pointer to Module. --- include/engine/Module.hpp | 9 +++++++++ include/helpers.hpp | 20 +++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/engine/Module.hpp b/include/engine/Module.hpp index 134cd877..2c0c566d 100644 --- a/include/engine/Module.hpp +++ b/include/engine/Module.hpp @@ -1,6 +1,7 @@ #pragma once #include "common.hpp" #include "string.hpp" +#include "plugin/Model.hpp" #include "engine/Param.hpp" #include "engine/Port.hpp" #include "engine/Light.hpp" @@ -9,10 +10,18 @@ namespace rack { + + +namespace plugin { + struct Model; +} + + namespace engine { struct Module { + plugin::Model *model = NULL; /** Automatically generated by the engine. */ int id = -1; std::vector params; diff --git a/include/helpers.hpp b/include/helpers.hpp index 1a972702..9a968159 100644 --- a/include/helpers.hpp +++ b/include/helpers.hpp @@ -20,19 +20,21 @@ template plugin::Model *createModel(std::string slug) { struct TModel : plugin::Model { engine::Module *createModule() override { - TModule *o = new TModule; - return o; + TModule *m = new TModule; + m->model = this; + return m; } app::ModuleWidget *createModuleWidget() override { - TModule *module = new TModule; - TModuleWidget *o = new TModuleWidget(module); - o->model = this; - return o; + TModule *m = new TModule; + m->model = this; + TModuleWidget *mw = new TModuleWidget(m); + mw->model = this; + return mw; } app::ModuleWidget *createModuleWidgetNull() override { - TModuleWidget *o = new TModuleWidget(NULL); - o->model = this; - return o; + TModuleWidget *mw = new TModuleWidget(NULL); + mw->model = this; + return mw; } };