From 89e8b35b4e20bff182cd3dd432126e4c1ec9b769 Mon Sep 17 00:00:00 2001 From: openshwprojects Date: Sun, 27 Nov 2022 09:48:42 +0100 Subject: [PATCH] sim: comments and erase fix --- src/sim/Junction.h | 2 +- src/sim/Simulation.cpp | 3 ++- src/sim/Simulation.h | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sim/Junction.h b/src/sim/Junction.h index fb58733f2..884972ba9 100644 --- a/src/sim/Junction.h +++ b/src/sim/Junction.h @@ -43,6 +43,7 @@ public: this->visitCount = 0; this->bCurrentSource = false; } + virtual ~CJunction(); void setCurrentSource(bool b) { bCurrentSource = b; } @@ -72,7 +73,6 @@ public: return "CJunction"; } bool shouldLightUpBulb(class CJunction *other); - virtual ~CJunction(); void translateLinked(const Coord &o); void setPosLinked(const Coord &o); void rotateDegreesAround_internal(float f, const Coord &p); diff --git a/src/sim/Simulation.cpp b/src/sim/Simulation.cpp index 4f7974edb..280831b2c 100644 --- a/src/sim/Simulation.cpp +++ b/src/sim/Simulation.cpp @@ -313,9 +313,9 @@ void CSimulation::destroyObject(CShape *s) { CJunction *j = 0; CEdge *ed = 0; CShape *p = s->getParent(); - removeJunctions(s); CWire *w = dynamic_cast(p); if (w) { + removeJunctions(w); j = dynamic_cast(s); if (j) { } @@ -326,6 +326,7 @@ void CSimulation::destroyObject(CShape *s) { } } else { + removeJunctions(s); CObject *o = dynamic_cast(s); if (o != 0) { delete o; diff --git a/src/sim/Simulation.h b/src/sim/Simulation.h index 2d46557f6..bf2302b85 100644 --- a/src/sim/Simulation.h +++ b/src/sim/Simulation.h @@ -4,8 +4,12 @@ #include "sim_local.h" class CSimulation { + // all allocated objects (must be fried later) TArray objects; + // all allocated wires (must be fried later) TArray wires; + // only pointers to junctions that belongs to allocated objects or wires + TArray junctions; void removeJunctions(class CShape *s); void removeJunction(class CJunction *ju); @@ -13,8 +17,6 @@ class CSimulation { void registerJunction(class CJunction *ju); void registerJunctions(class CWire *w); void registerJunctions(class CShape *s); - void floodJunctions(CJunction *ju, float voltage); - TArray junctions; public: int getJunctionsCount() const {