From a70597b9033562d4aed58244f3300c7121271ca2 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 18 Mar 2019 15:58:07 +0100 Subject: [PATCH] Leak fix: make ostcFirmwareCheck a unique_ptr ostcFirmwareCheck in DownloadFromDCWidget was neither freed in the destructor, not freed if a new object was allocated. Simply make it a unique_ptr<> to do all the work for us. Signed-off-by: Berthold Stoeger --- desktop-widgets/downloadfromdivecomputer.cpp | 3 +-- desktop-widgets/downloadfromdivecomputer.h | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index cb820c78b..e28a90e26 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -22,7 +22,6 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) : previousLast(0), timer(new QTimer(this)), dumpWarningShown(false), - ostcFirmwareCheck(0), #if defined (BT_SUPPORT) btd(nullptr), #endif @@ -405,7 +404,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() if ((product == "OSTC 3" || product == "OSTC 3+" || product == "OSTC cR" || product == "OSTC Sport" || product == "OSTC 4" || product == "OSTC Plus") && !data->saveDump()) { - ostcFirmwareCheck = new OstcFirmwareCheck(product); + ostcFirmwareCheck.reset(new OstcFirmwareCheck(product)); } } diff --git a/desktop-widgets/downloadfromdivecomputer.h b/desktop-widgets/downloadfromdivecomputer.h index 4d1a912e9..c70ee651a 100644 --- a/desktop-widgets/downloadfromdivecomputer.h +++ b/desktop-widgets/downloadfromdivecomputer.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "core/libdivecomputer.h" #include "desktop-widgets/configuredivecomputerdialog.h" @@ -79,7 +80,7 @@ private: void fill_device_list(unsigned int transport); QTimer *timer; bool dumpWarningShown; - OstcFirmwareCheck *ostcFirmwareCheck; + std::unique_ptr ostcFirmwareCheck; DiveImportedModel *diveImportedModel; #if defined(BT_SUPPORT) BtDeviceSelectionDialog *btDeviceSelectionDialog;