From 03c7ef34a9836a4e0841b41a8c1da208c24a96a5 Mon Sep 17 00:00:00 2001 From: ariotte <ariotte@PC-EII16.admr.insa> Date: Thu, 28 Jun 2018 15:10:42 +0200 Subject: [PATCH] fixed memory leak in thresholding --- app/Operations/ThresholdDialog.cpp | 6 ++++-- app/Operations/ThresholdDialog.h | 1 + app/Operations/ThresholdOp.cpp | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Operations/ThresholdDialog.cpp b/app/Operations/ThresholdDialog.cpp index a8bdfd5..8d2bb41 100644 --- a/app/Operations/ThresholdDialog.cpp +++ b/app/Operations/ThresholdDialog.cpp @@ -71,8 +71,10 @@ void ThresholdDialog::updatePreview(){ else { algo = new Binarization_t<GrayscaleImage::depth_t>(_spinbox1->value()); } - - _preview->setImage(algo->operator()(_image)); + _previewImage = algo->operator()(_image); + _preview->setImage(_previewImage); + delete algo; + delete _previewImage; _preview->repaint(); } diff --git a/app/Operations/ThresholdDialog.h b/app/Operations/ThresholdDialog.h index b064150..044dd92 100644 --- a/app/Operations/ThresholdDialog.h +++ b/app/Operations/ThresholdDialog.h @@ -64,6 +64,7 @@ class ThresholdDialog : public QDialog { QRadioButton* _blackButton; QCheckBox *_doubleBox, *_previewBox; ImageWidget* _preview; + imagein::GrayscaleImage* _previewImage; }; #endif //!THRESHOLDDIALOG_H diff --git a/app/Operations/ThresholdOp.cpp b/app/Operations/ThresholdOp.cpp index fd08985..8164c12 100644 --- a/app/Operations/ThresholdOp.cpp +++ b/app/Operations/ThresholdOp.cpp @@ -40,5 +40,6 @@ void ThresholdOp::operator()(const imagein::Image* image, const std::map<const i } GrayscaleImage* resImg = algo->operator()(img); + delete algo; this->outImage(resImg); } -- GitLab