From 697571648dc89d45ffd795a39742bea9df660251 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 21 Jun 2021 18:31:16 -0400 Subject: [PATCH] Set default component ID to -1 in all classes. --- include/app/ModuleLightWidget.hpp | 2 +- include/app/ParamWidget.hpp | 2 +- include/app/PortWidget.hpp | 4 ++-- include/engine/Cable.hpp | 4 ++-- include/engine/LightInfo.hpp | 2 +- include/engine/ParamQuantity.hpp | 2 +- include/engine/PortInfo.hpp | 4 ++-- src/engine/ParamQuantity.cpp | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/app/ModuleLightWidget.hpp b/include/app/ModuleLightWidget.hpp index 2443a759..cf07de13 100644 --- a/include/app/ModuleLightWidget.hpp +++ b/include/app/ModuleLightWidget.hpp @@ -14,7 +14,7 @@ Will access firstLightId, firstLightId + 1, etc. for each added color */ struct ModuleLightWidget : MultiLightWidget { engine::Module* module = NULL; - int firstLightId; + int firstLightId = -1; ui::Tooltip* tooltip = NULL; diff --git a/include/app/ParamWidget.hpp b/include/app/ParamWidget.hpp index 5b8c623e..77e61fed 100644 --- a/include/app/ParamWidget.hpp +++ b/include/app/ParamWidget.hpp @@ -13,7 +13,7 @@ namespace app { /** Manages an engine::Param on a ModuleWidget. */ struct ParamWidget : widget::OpaqueWidget { engine::Module* module = NULL; - int paramId; + int paramId = -1; ui::Tooltip* tooltip = NULL; /** For triggering the Change event. `*/ diff --git a/include/app/PortWidget.hpp b/include/app/PortWidget.hpp index 49fc7612..65e78972 100644 --- a/include/app/PortWidget.hpp +++ b/include/app/PortWidget.hpp @@ -14,8 +14,8 @@ namespace app { /** Manages an engine::Port on a ModuleWidget. */ struct PortWidget : widget::OpaqueWidget { engine::Module* module = NULL; - engine::Port::Type type; - int portId; + engine::Port::Type type = engine::Port::INPUT; + int portId = -1; ui::Tooltip* tooltip = NULL; diff --git a/include/engine/Cable.hpp b/include/engine/Cable.hpp index 1fe78a59..1c59f63c 100644 --- a/include/engine/Cable.hpp +++ b/include/engine/Cable.hpp @@ -14,9 +14,9 @@ struct Cable { */ int64_t id = -1; Module* inputModule = NULL; - int inputId; + int inputId = -1; Module* outputModule = NULL; - int outputId; + int outputId = -1; json_t* toJson(); void fromJson(json_t* rootJ); diff --git a/include/engine/LightInfo.hpp b/include/engine/LightInfo.hpp index 12889585..0aa122e6 100644 --- a/include/engine/LightInfo.hpp +++ b/include/engine/LightInfo.hpp @@ -11,7 +11,7 @@ struct Module; struct LightInfo { Module* module = NULL; - int lightId; + int lightId = -1; /** The name of the light, using sentence capitalization. e.g. "Level", "Pitch light", "Mode CV". diff --git a/include/engine/ParamQuantity.hpp b/include/engine/ParamQuantity.hpp index c3e6b7e2..7869233b 100644 --- a/include/engine/ParamQuantity.hpp +++ b/include/engine/ParamQuantity.hpp @@ -17,7 +17,7 @@ struct Module; /** A Quantity that wraps an engine::Param. */ struct ParamQuantity : Quantity { Module* module = NULL; - int paramId; + int paramId = -1; /** The minimum allowed value. */ float minValue = 0.f; diff --git a/include/engine/PortInfo.hpp b/include/engine/PortInfo.hpp index daf21fc4..e97a0d24 100644 --- a/include/engine/PortInfo.hpp +++ b/include/engine/PortInfo.hpp @@ -12,8 +12,8 @@ struct Module; struct PortInfo { Module* module = NULL; - Port::Type type; - int portId; + Port::Type type = Port::INPUT; + int portId = -1; /** The name of the port, using sentence capitalization. e.g. "Sine", "Pitch input", "Mode CV". diff --git a/src/engine/ParamQuantity.cpp b/src/engine/ParamQuantity.cpp index d4a90aa8..052c1dbe 100644 --- a/src/engine/ParamQuantity.cpp +++ b/src/engine/ParamQuantity.cpp @@ -12,7 +12,7 @@ namespace engine { engine::Param* ParamQuantity::getParam() { assert(module); - assert(paramId < (int) module->params.size()); + assert(0 <= paramId && paramId < (int) module->params.size()); return &module->params[paramId]; }