From d7e185006fdcd9ea1ca4da87111a99780374d78f Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 16 Jul 2024 16:47:26 +0200 Subject: [PATCH] GetTimeSteps(): add sanity check --- library/src/calculator_functions.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/library/src/calculator_functions.cpp b/library/src/calculator_functions.cpp index 4bad40a..4e2af8c 100644 --- a/library/src/calculator_functions.cpp +++ b/library/src/calculator_functions.cpp @@ -2090,12 +2090,13 @@ QList Calculator::GetPriceSteps(Configuration * /*cfg*/) const { return QList(); } -QList Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const { - qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "paymentOptionIndex:" << paymentOptionIndex; +QList &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) const { + qCritical() << "(" << __func__ << ":" << __LINE__ << ") paymentOptionIndex:" << paymentOptionIndex; if (m_timeSteps.size() > paymentOptionIndex) { - //qCritical() << __PRETTY_FUNCTION__ << "timeSteps:" << m_timeSteps; - return m_timeSteps[paymentOptionIndex]; + if (!m_timeSteps[paymentOptionIndex].isEmpty()) { + return m_timeSteps[paymentOptionIndex]; + } } else { m_timeSteps.push_back(QList()); } @@ -2109,9 +2110,9 @@ QList Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) static PaymentMethod const paymentMethodId = Utilities::getPaymentMethodId(cfg); - qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate); - qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id; - qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option carry over:" << pop_carry_over; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") start parking time:" << start.toString(Qt::ISODate); + qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option id:" << pop_id; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") payment option carry over:" << pop_carry_over; if (pop_time_step_config == (int)ATBTimeStepConfig::TimeStepConfig::DYNAMIC) { //qCritical() << __PRETTY_FUNCTION__ << "payment option time step config:" << "TimeStepConfig::DYNAMIC"; @@ -2155,7 +2156,7 @@ QList Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) // set dynamic minimal parking time cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = timeStep; - qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") computed minimal parking time:" << cfg->getPaymentOptions(paymentOptionIndex).pop_min_time; duration.pun_duration = timeStep; timeStepCompensation = duration.pun_duration_max - duration.pun_duration; @@ -2200,7 +2201,7 @@ QList Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex) } } - qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << "NEW timeSteps:" << m_timeSteps; + qCritical() << "(" << __func__ << ":" << __LINE__ << ") NEW timeSteps:" << m_timeSteps; return m_timeSteps[paymentOptionIndex]; }