[calligra/calligra/2.9] krita/plugins/extensions/gmic: Fix memory leak
Lukast dev
lukast.dev at gmail.com
Sat Feb 28 07:55:25 UTC 2015
Hi boud,
good catch! I thought that since QStringListModel is QObject, call to
setModel on QComboBox would set parent to QComboBox of
QStringListModel,
but that's not the case here.
Cheers
Lukas
2015-02-23 12:39 GMT+01:00 Boudewijn Rempt <boud at valdyas.org>:
> Git commit 0245c92f8e83ae3af895d0f0245f390eb83df962 by Boudewijn Rempt.
> Committed on 23/02/2015 at 10:31.
> Pushed by rempt into branch 'calligra/2.9'.
>
> Fix memory leak
>
> M +12 -9 krita/plugins/extensions/gmic/kis_gmic_input_output_widget.cpp
> M +7 -0 krita/plugins/extensions/gmic/kis_gmic_input_output_widget.h
>
> http://commits.kde.org/calligra/0245c92f8e83ae3af895d0f0245f390eb83df962
>
> diff --git a/krita/plugins/extensions/gmic/kis_gmic_input_output_widget.cpp b/krita/plugins/extensions/gmic/kis_gmic_input_output_widget.cpp
> index 0f4da1c..0cfa2ed 100644
> --- a/krita/plugins/extensions/gmic/kis_gmic_input_output_widget.cpp
> +++ b/krita/plugins/extensions/gmic/kis_gmic_input_output_widget.cpp
> @@ -40,7 +40,10 @@ KisGmicInputOutputWidget::KisGmicInputOutputWidget(QWidget * parent):
>
> KisGmicInputOutputWidget::~KisGmicInputOutputWidget()
> {
> -
> + delete m_inputModel;
> + delete m_outputModel;
> + delete m_previewModeModel;
> + delete m_previewSizeModel;
> }
>
> KisFilterPreviewWidget* KisGmicInputOutputWidget::previewWidget()
> @@ -84,23 +87,23 @@ void KisGmicInputOutputWidget::createMainLayout()
> << i18n("All outputs");
>
>
> - QStringListModel * inputModel = new QStringListModel(inputModeStrings);
> - inputCombo->setModel(inputModel);
> + m_inputModel = new QStringListModel(inputModeStrings);
> + inputCombo->setModel(m_inputModel);
> QObject::connect(inputCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setIntputMode(int)));
> inputCombo->setCurrentIndex(static_cast<int>(m_inputMode));
>
> - QStringListModel * outputModel = new QStringListModel(outputModeStrings);
> - outputCombo->setModel(outputModel);
> + m_outputModel = new QStringListModel(outputModeStrings);
> + outputCombo->setModel(m_outputModel);
> QObject::connect(outputCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setOutputMode(int)));
> outputCombo->setCurrentIndex(static_cast<int>(m_outputMode));
>
> - QStringListModel * previewModeModel = new QStringListModel(previewMode);
> - outputPreviewCombo->setModel(previewModeModel);
> + m_previewModeModel = new QStringListModel(previewMode);
> + outputPreviewCombo->setModel(m_previewModeModel);
> QObject::connect(outputPreviewCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setPreviewMode(int)));
> outputPreviewCombo->setCurrentIndex(static_cast<int>(m_previewMode));
>
> - QStringListModel * previewSizeModel = new QStringListModel(PREVIEW_SIZE);
> - previewSizeCombo->setModel(previewSizeModel);
> + m_previewSizeModel = new QStringListModel(PREVIEW_SIZE);
> + previewSizeCombo->setModel(m_previewSizeModel);
> QObject::connect(previewSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setPreviewSize(int)));
> previewSizeCombo->setCurrentIndex(static_cast<int>(m_previewSize));
> }
> diff --git a/krita/plugins/extensions/gmic/kis_gmic_input_output_widget.h b/krita/plugins/extensions/gmic/kis_gmic_input_output_widget.h
> index f9feb6f..41c6b90d 100644
> --- a/krita/plugins/extensions/gmic/kis_gmic_input_output_widget.h
> +++ b/krita/plugins/extensions/gmic/kis_gmic_input_output_widget.h
> @@ -24,6 +24,8 @@
>
> #include "ui_wdg_gmic_input_output.h"
>
> +class QStringListModel;
> +
> /**
> * creates GUI for Input/Output configuration
> */
> @@ -61,6 +63,11 @@ private:
> OutputPreviewMode m_previewMode;
> PreviewSize m_previewSize;
>
> + QStringListModel *m_inputModel;
> + QStringListModel *m_outputModel;
> + QStringListModel *m_previewModeModel;
> + QStringListModel *m_previewSizeModel;
> +
> };
>
>
More information about the kimageshop
mailing list