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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-03-18 15:58:07 +01:00 committed by Dirk Hohndel
parent 69248141c5
commit a70597b903
2 changed files with 3 additions and 3 deletions

View file

@ -22,7 +22,6 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
previousLast(0), previousLast(0),
timer(new QTimer(this)), timer(new QTimer(this)),
dumpWarningShown(false), dumpWarningShown(false),
ostcFirmwareCheck(0),
#if defined (BT_SUPPORT) #if defined (BT_SUPPORT)
btd(nullptr), btd(nullptr),
#endif #endif
@ -405,7 +404,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
if ((product == "OSTC 3" || product == "OSTC 3+" || product == "OSTC cR" || if ((product == "OSTC 3" || product == "OSTC 3+" || product == "OSTC cR" ||
product == "OSTC Sport" || product == "OSTC 4" || product == "OSTC Plus") && product == "OSTC Sport" || product == "OSTC 4" || product == "OSTC Plus") &&
!data->saveDump()) { !data->saveDump()) {
ostcFirmwareCheck = new OstcFirmwareCheck(product); ostcFirmwareCheck.reset(new OstcFirmwareCheck(product));
} }
} }

View file

@ -7,6 +7,7 @@
#include <QHash> #include <QHash>
#include <QMap> #include <QMap>
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <memory>
#include "core/libdivecomputer.h" #include "core/libdivecomputer.h"
#include "desktop-widgets/configuredivecomputerdialog.h" #include "desktop-widgets/configuredivecomputerdialog.h"
@ -79,7 +80,7 @@ private:
void fill_device_list(unsigned int transport); void fill_device_list(unsigned int transport);
QTimer *timer; QTimer *timer;
bool dumpWarningShown; bool dumpWarningShown;
OstcFirmwareCheck *ostcFirmwareCheck; std::unique_ptr<OstcFirmwareCheck> ostcFirmwareCheck;
DiveImportedModel *diveImportedModel; DiveImportedModel *diveImportedModel;
#if defined(BT_SUPPORT) #if defined(BT_SUPPORT)
BtDeviceSelectionDialog *btDeviceSelectionDialog; BtDeviceSelectionDialog *btDeviceSelectionDialog;