From 2d104a1c5e04d21cd67218a609a7bf73d5d8f562 Mon Sep 17 00:00:00 2001 From: Levente Meszaros Date: Mon, 19 Feb 2024 12:48:50 +0100 Subject: [PATCH] StatisticVisualizerBase: Changed signalName parameter to be mandatory. --- .../visualizer/base/StatisticVisualizerBase.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/inet/visualizer/base/StatisticVisualizerBase.cc b/src/inet/visualizer/base/StatisticVisualizerBase.cc index c4b20e477d7..a1d9e6579a5 100644 --- a/src/inet/visualizer/base/StatisticVisualizerBase.cc +++ b/src/inet/visualizer/base/StatisticVisualizerBase.cc @@ -75,8 +75,11 @@ void StatisticVisualizerBase::initialize(int stage) opacity = par("opacity"); placementHint = parsePlacement(par("placementHint")); placementPriority = par("placementPriority"); - if (displayStatistics) + if (displayStatistics) { + if (opp_isempty(signalName)) + throw cRuntimeError("The signalName parameter must be not empty"); subscribe(); + } } } @@ -92,18 +95,15 @@ void StatisticVisualizerBase::handleParameterChange(const char *name) void StatisticVisualizerBase::subscribe() { - if (*signalName != '\0') - visualizationSubjectModule->subscribe(registerSignal(signalName), this); + visualizationSubjectModule->subscribe(registerSignal(signalName), this); } void StatisticVisualizerBase::unsubscribe() { // NOTE: lookup the module again because it may have been deleted first auto visualizationSubjectModule = findModuleFromPar(par("visualizationSubjectModule"), this); - if (visualizationSubjectModule != nullptr) { - if (*signalName != '\0') - visualizationSubjectModule->unsubscribe(registerSignal(signalName), this); - } + if (visualizationSubjectModule != nullptr) + visualizationSubjectModule->unsubscribe(registerSignal(signalName), this); } void StatisticVisualizerBase::addResultRecorder(cComponent *source, simsignal_t signal)