[graphics/krita/sh-zam/T13101-svg-mesh-gradients] /: Fix memory leak in 'Ui' classes
Dmitry Kazakov
null at kde.org
Tue Oct 13 14:07:04 BST 2020
Git commit 2b81818bd4d923f97630b4f067bb1eaa2cedb0b3 by Dmitry Kazakov.
Committed on 13/10/2020 at 13:04.
Pushed by dkazakov into branch 'sh-zam/T13101-svg-mesh-gradients'.
Fix memory leak in 'Ui' classes
Auto-generated QtDesigner form is supposed to be used as a parent
for our class, not as a member. Therefore, it never belongs to QObject
hierarchy, and therefore, is never auto-deleted. If you add autogenerated
Ui class as a member, don't forget to make it QScopedPointer to make sure
it is deleted on widget destruction.
CC:kimageshop at kde.org
M +1 -1 libs/ui/widgets/KisGamutMaskToolbar.cpp
M +1 -1 libs/ui/widgets/KisGamutMaskToolbar.h
M +2 -2 libs/ui/widgets/KoFillConfigWidget.cpp
M +2 -2 libs/ui/widgets/KoStrokeConfigWidget.cpp
M +1 -1 plugins/dockers/arrangedocker/arrange_docker_widget.h
M +1 -1 plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc
M +1 -1 plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h
M +4 -0 plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.cpp
M +2 -1 plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h
https://invent.kde.org/graphics/krita/commit/2b81818bd4d923f97630b4f067bb1eaa2cedb0b3
diff --git a/libs/ui/widgets/KisGamutMaskToolbar.cpp b/libs/ui/widgets/KisGamutMaskToolbar.cpp
index 2a1851f773..61f995e563 100644
--- a/libs/ui/widgets/KisGamutMaskToolbar.cpp
+++ b/libs/ui/widgets/KisGamutMaskToolbar.cpp
@@ -26,7 +26,7 @@ KisGamutMaskToolbar::KisGamutMaskToolbar(QWidget* parent) : QWidget(parent)
, m_selectedMask(nullptr)
, m_selfUpdate(false)
{
- m_ui = new Ui_wdgGamutMaskToolbar();
+ m_ui.reset(new Ui_wdgGamutMaskToolbar());
m_ui->setupUi(this);
m_iconMaskOff = KisIconUtils::loadIcon("gamut-mask-off");
diff --git a/libs/ui/widgets/KisGamutMaskToolbar.h b/libs/ui/widgets/KisGamutMaskToolbar.h
index 941d7794c2..9f22c41e20 100644
--- a/libs/ui/widgets/KisGamutMaskToolbar.h
+++ b/libs/ui/widgets/KisGamutMaskToolbar.h
@@ -50,7 +50,7 @@ private Q_SLOTS:
void slotGamutMaskRotate(int angle);
private:
- Ui_wdgGamutMaskToolbar* m_ui;
+ QScopedPointer<Ui_wdgGamutMaskToolbar> m_ui;
KoGamutMask* m_selectedMask;
QIcon m_iconMaskOff;
diff --git a/libs/ui/widgets/KoFillConfigWidget.cpp b/libs/ui/widgets/KoFillConfigWidget.cpp
index e2204fde0d..95fbabf2d3 100644
--- a/libs/ui/widgets/KoFillConfigWidget.cpp
+++ b/libs/ui/widgets/KoFillConfigWidget.cpp
@@ -206,7 +206,7 @@ public:
SvgMeshPosition meshposition;
QScopedPointer<SvgMeshGradient> activeMeshGradient;
- Ui_KoFillConfigWidget *ui;
+ QScopedPointer<Ui_KoFillConfigWidget> ui;
std::vector<KisAcyclicSignalConnector::Blocker> deactivationLocks;
@@ -248,7 +248,7 @@ KoFillConfigWidget::KoFillConfigWidget(KoCanvasBase *canvas, KoFlake::FillVarian
// configure GUI
- d->ui = new Ui_KoFillConfigWidget();
+ d->ui.reset(new Ui_KoFillConfigWidget());
d->ui->setupUi(this);
d->group = new QButtonGroup(this);
diff --git a/libs/ui/widgets/KoStrokeConfigWidget.cpp b/libs/ui/widgets/KoStrokeConfigWidget.cpp
index 3895d5fda2..040c10082e 100644
--- a/libs/ui/widgets/KoStrokeConfigWidget.cpp
+++ b/libs/ui/widgets/KoStrokeConfigWidget.cpp
@@ -194,7 +194,7 @@ public:
std::vector<KisAcyclicSignalConnector::Blocker> deactivationLocks;
- Ui_KoStrokeConfigWidget *ui;
+ QScopedPointer<Ui_KoStrokeConfigWidget> ui;
};
@@ -203,7 +203,7 @@ KoStrokeConfigWidget::KoStrokeConfigWidget(KoCanvasBase *canvas, QWidget * paren
, d(new Private())
{
// configure GUI
- d->ui = new Ui_KoStrokeConfigWidget();
+ d->ui.reset(new Ui_KoStrokeConfigWidget());
d->ui->setupUi(this);
setObjectName("Stroke widget");
diff --git a/plugins/dockers/arrangedocker/arrange_docker_widget.h b/plugins/dockers/arrangedocker/arrange_docker_widget.h
index 17768cd0e7..a2b47b7384 100644
--- a/plugins/dockers/arrangedocker/arrange_docker_widget.h
+++ b/plugins/dockers/arrangedocker/arrange_docker_widget.h
@@ -41,7 +41,7 @@ public:
void switchState(bool enabled);
private:
- Ui::ArrangeDockerWidget *ui;
+ QScopedPointer<Ui::ArrangeDockerWidget> ui;
struct Private;
const QScopedPointer<Private> m_d;
diff --git a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc
index 94f5cab633..51032abf24 100644
--- a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc
+++ b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc
@@ -53,7 +53,7 @@ KisSpecificColorSelectorWidget::KisSpecificColorSelectorWidget(QWidget* parent)
, m_displayConverter(0)
{
- m_ui = new Ui_wdgSpecificColorSelectorWidget();
+ m_ui.reset(new Ui_wdgSpecificColorSelectorWidget());
m_ui->setupUi(this);
m_updateAllowed = true;
diff --git a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h
index 272a3c54c1..5142fde01b 100644
--- a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h
+++ b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h
@@ -71,7 +71,7 @@ private:
KisSignalCompressor *m_updateCompressor;
KisColorSpaceSelector *m_colorspaceSelector;
bool m_customColorSpaceSelected;
- Ui_wdgSpecificColorSelectorWidget* m_ui;
+ QScopedPointer<Ui_wdgSpecificColorSelectorWidget> m_ui;
KisDisplayColorConverter *m_displayConverter;
diff --git a/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.cpp b/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.cpp
index ca26e9cf57..33848dfe43 100644
--- a/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.cpp
+++ b/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.cpp
@@ -228,6 +228,10 @@ SvgSymbolCollectionDocker::SvgSymbolCollectionDocker(QWidget *parent)
collectionActivated(i);
}
+SvgSymbolCollectionDocker::~SvgSymbolCollectionDocker()
+{
+}
+
void SvgSymbolCollectionDocker::slotSetIconSize()
{
m_wdgSvgCollection->listCollection->setIconSize(QSize(m_iconSizeSlider->value(),m_iconSizeSlider->value()));
diff --git a/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h b/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h
index 22a0b1224c..be601c0efb 100644
--- a/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h
+++ b/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h
@@ -70,6 +70,7 @@ class SvgSymbolCollectionDocker : public QDockWidget, public KoCanvasObserverBas
public:
explicit SvgSymbolCollectionDocker(QWidget *parent = 0);
+ ~SvgSymbolCollectionDocker();
/// reimplemented
void setCanvas(KoCanvasBase *canvas) override;
@@ -84,7 +85,7 @@ private Q_SLOTS:
void slotSetIconSize();
private:
- Ui_WdgSvgCollection *m_wdgSvgCollection;
+ QScopedPointer<Ui_WdgSvgCollection> m_wdgSvgCollection;
QVector<SvgCollectionModel*> m_models;
QSlider* m_iconSizeSlider;
};
More information about the kimageshop
mailing list