[plasma/union] autotests: Fix memory leaks in tests

Nicolas Fella <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 1a1e1ac76d2c18339e10cd39e72c3feade91e991 by Nicolas Fella.
Committed on 05/08/2026 at 11:20.
Pushed by nicolasfella into branch 'master'.

Fix memory leaks in tests

M  +6    -1    autotests/TestColor.cpp
M  +1    -0    autotests/output/quick/TestControls.cpp

https://invent.kde.org/plasma/union/-/commit/1a1e1ac76d2c18339e10cd39e72c3feade91e991

diff --git a/autotests/TestColor.cpp b/autotests/TestColor.cpp
index 32427d88..733afd6c 100644
--- a/autotests/TestColor.cpp
+++ b/autotests/TestColor.cpp
@@ -4,6 +4,7 @@
 #include <QtTest>
 
 #include <Color.h>
+#include <memory>
 
 using namespace Union;
 using namespace Qt::StringLiterals;
@@ -35,7 +36,8 @@ class TestColor : public QObject
 private Q_SLOTS:
     void initTestCase()
     {
-        ColorProvider::registerProvider(u"test"_s, new TestColorProvider);
+        m_colorProvider = std::make_unique<TestColorProvider>();
+        ColorProvider::registerProvider(u"test"_s, m_colorProvider.get());
     }
 
     void testCreate()
@@ -211,6 +213,9 @@ private Q_SLOTS:
         QCOMPARE(readStream.status(), QDataStream::Status::Ok);
         QCOMPARE(readColor, color);
     }
+
+private:
+    std::unique_ptr<ColorProvider> m_colorProvider;
 };
 
 QTEST_MAIN(TestColor)
diff --git a/autotests/output/quick/TestControls.cpp b/autotests/output/quick/TestControls.cpp
index 4fa9fdc1..7cab67bf 100644
--- a/autotests/output/quick/TestControls.cpp
+++ b/autotests/output/quick/TestControls.cpp
@@ -178,6 +178,7 @@ private Q_SLOTS:
             }
             QFAIL("Could not create an instance of component");
         }
+        delete instance;
     }
 };
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.