[graphics/krita] /: Fix memory leak in 'Ui' classes
Boudewijn Rempt
null at kde.org
Wed Oct 14 09:12:02 BST 2020
Git commit cf6d2a85384d5f84743703021b303d8b43fd9e33 by Boudewijn Rempt, on behalf of Dmitry Kazakov.
Committed on 14/10/2020 at 08:06.
Pushed by szaman into branch 'master'.
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
# Conflicts:
# libs/ui/widgets/KisGamutMaskToolbar.h
# plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h
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 +1 -1 plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h
https://invent.kde.org/graphics/krita/commit/cf6d2a85384d5f84743703021b303d8b43fd9e33
diff --git a/libs/ui/widgets/KisGamutMaskToolbar.cpp b/libs/ui/widgets/KisGamutMaskToolbar.cpp
index 1fdbe3b053..61cd788c2f 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 3b8c5e6215..1b37e7c1c6 100644
--- a/libs/ui/widgets/KisGamutMaskToolbar.h
+++ b/libs/ui/widgets/KisGamutMaskToolbar.h
@@ -51,7 +51,7 @@ private Q_SLOTS:
void slotGamutMaskRotate(int angle);
private:
- Ui_wdgGamutMaskToolbar* m_ui;
+ QScopedPointer<Ui_wdgGamutMaskToolbar> m_ui;
KoGamutMaskSP m_selectedMask;
QIcon m_iconMaskOff;
diff --git a/libs/ui/widgets/KoFillConfigWidget.cpp b/libs/ui/widgets/KoFillConfigWidget.cpp
index 857896eb9a..ba92daec8f 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 dc92261cbf..8834fb54e1 100644
--- a/libs/ui/widgets/KoStrokeConfigWidget.cpp
+++ b/libs/ui/widgets/KoStrokeConfigWidget.cpp
@@ -193,7 +193,7 @@ public:
std::vector<KisAcyclicSignalConnector::Blocker> deactivationLocks;
- Ui_KoStrokeConfigWidget *ui;
+ QScopedPointer<Ui_KoStrokeConfigWidget> ui;
};
@@ -202,7 +202,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 5f88726f2a..4fc9573706 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.h b/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h
index 3030a56f6b..0be0d92e60 100644
--- a/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h
+++ b/plugins/dockers/svgcollectiondocker/SvgSymbolCollectionDocker.h
@@ -93,7 +93,7 @@ private:
void clearModels();
- Ui_WdgSvgCollection *m_wdgSvgCollection;
+ QScopedPointer<Ui_WdgSvgCollection> m_wdgSvgCollection;
QMap<int, SvgCollectionModel*> m_collectionsModelsCache;
QSlider* m_iconSizeSlider;
More information about the kimageshop
mailing list