From 116748bb8d1cde98d82e1d30061a3afd644d58ca Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Thu, 16 Feb 2023 14:32:50 +0000 Subject: [PATCH] Remove radiosondes from map on close and fix memory leak --- plugins/feature/radiosonde/radiosondegui.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/feature/radiosonde/radiosondegui.cpp b/plugins/feature/radiosonde/radiosondegui.cpp index e13ff4e9c..e95e86fbd 100644 --- a/plugins/feature/radiosonde/radiosondegui.cpp +++ b/plugins/feature/radiosonde/radiosondegui.cpp @@ -200,7 +200,8 @@ RadiosondeGUI::RadiosondeGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, F RadiosondeGUI::~RadiosondeGUI() { - qDeleteAll(m_radiosondes); + // Remove from map and free memory + on_deleteAll_clicked(); delete ui; } @@ -392,8 +393,11 @@ void RadiosondeGUI::sendToMap(const QString &name, const QString &label, swgMapItem->setAltitude(altitude); swgMapItem->setAltitudeReference(0); // ABSOLUTE - if (positionDateTime.isValid()) { + if (positionDateTime.isValid()) + { swgMapItem->setPositionDateTime(new QString(positionDateTime.toString(Qt::ISODateWithMs))); + swgMapItem->setOrientationDateTime(new QString(positionDateTime.toString(Qt::ISODateWithMs))); + swgMapItem->setAvailableUntil(new QString(positionDateTime.addSecs(1*60*60).toString(Qt::ISODateWithMs))); } swgMapItem->setImageRotation(heading); @@ -877,8 +881,8 @@ void RadiosondeGUI::on_deleteAll_clicked() 0.0f); // Remove from table ui->radiosondes->removeRow(row); - // Remove from hash - m_radiosondes.remove(serial); + // Remove from hash and free memory + delete m_radiosondes.take(serial); } }