[pim/kdepim-addons] plugins/messageviewerplugins/autotests: Fix more unit test LSAN issues

Volker Krause <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 528e6fdb3181a2c65ee057074fe9d32759d53a3c by Volker Krause.
Committed on 15/08/2026 at 05:53.
Pushed by vkrause into branch 'master'.

Fix more unit test LSAN issues

These got uncovered by upstream ASAN fixes and preceeding LSAN fixes here.

M  +1    -1    plugins/messageviewerplugins/autotests/eventedittest.cpp
M  +1    -1    plugins/messageviewerplugins/autotests/todoedittest.cpp
M  +4    -4    plugins/messageviewerplugins/autotests/viewerplugincreateeventtest.cpp

https://invent.kde.org/pim/kdepim-addons/-/commit/528e6fdb3181a2c65ee057074fe9d32759d53a3c

diff --git a/plugins/messageviewerplugins/autotests/eventedittest.cpp b/plugins/messageviewerplugins/autotests/eventedittest.cpp
index 2927ccef2..a01cb8550 100644
--- a/plugins/messageviewerplugins/autotests/eventedittest.cpp
+++ b/plugins/messageviewerplugins/autotests/eventedittest.cpp
@@ -428,7 +428,7 @@ void EventEditTest::shouldDisabledSaveOpenEditorButtonWhenCollectionComboBoxIsEm
     MessageViewer::EventEdit edit;
     auto akonadicombobox = edit.findChild<Akonadi::CollectionComboBox *>(QStringLiteral("akonadicombobox"));
     // Create an empty combobox
-    akonadicombobox->setModel(new QStandardItemModel());
+    akonadicombobox->setModel(new QStandardItemModel(&edit));
     std::shared_ptr<KMime::Message> msg(new KMime::Message);
     const QString subject = QStringLiteral("Test Note");
     msg->subject(KMime::CreatePolicy::Create)->fromUnicodeString(subject);
diff --git a/plugins/messageviewerplugins/autotests/todoedittest.cpp b/plugins/messageviewerplugins/autotests/todoedittest.cpp
index 04fd729b6..37ca62963 100644
--- a/plugins/messageviewerplugins/autotests/todoedittest.cpp
+++ b/plugins/messageviewerplugins/autotests/todoedittest.cpp
@@ -550,7 +550,7 @@ void TodoEditTest::shouldDisabledSaveOpenEditorButtonWhenCollectionComboBoxIsEmp
     MessageViewer::TodoEdit edit;
     auto akonadicombobox = edit.findChild<Akonadi::CollectionComboBox *>(QStringLiteral("akonadicombobox"));
     // Create an empty combobox
-    akonadicombobox->setModel(new QStandardItemModel());
+    akonadicombobox->setModel(new QStandardItemModel(&edit));
 
     std::shared_ptr<KMime::Message> msg(new KMime::Message);
     const QString subject = QStringLiteral("Test Note");
diff --git a/plugins/messageviewerplugins/autotests/viewerplugincreateeventtest.cpp b/plugins/messageviewerplugins/autotests/viewerplugincreateeventtest.cpp
index 3d9b5891b..565e54b91 100644
--- a/plugins/messageviewerplugins/autotests/viewerplugincreateeventtest.cpp
+++ b/plugins/messageviewerplugins/autotests/viewerplugincreateeventtest.cpp
@@ -30,9 +30,9 @@ void ViewerPluginCreateeventTest::shouldCreateAction()
 {
     auto event = new MessageViewer::ViewerPluginCreateevent(this);
     QVERIFY(!event->viewerPluginName().isEmpty());
-    auto parent = new QWidget(nullptr);
+    auto parent = std::make_unique<QWidget>(nullptr);
     parent->setLayout(new QHBoxLayout);
-    MessageViewer::ViewerPluginInterface *interface = event->createView(parent, new KActionCollection(this));
+    std::unique_ptr<MessageViewer::ViewerPluginInterface> interface(event->createView(parent.get(), new KActionCollection(this)));
     QVERIFY(interface);
     QVERIFY(!interface->actions().isEmpty());
 }
@@ -40,9 +40,9 @@ void ViewerPluginCreateeventTest::shouldCreateAction()
 void ViewerPluginCreateeventTest::shouldShowWidget()
 {
     auto event = new MessageViewer::ViewerPluginCreateevent(this);
-    auto parent = new QWidget(nullptr);
+    auto parent = std::make_unique<QWidget>(nullptr);
     parent->setLayout(new QHBoxLayout);
-    MessageViewer::ViewerPluginInterface *interface = event->createView(parent, new KActionCollection(this));
+    std::unique_ptr<MessageViewer::ViewerPluginInterface> interface(event->createView(parent.get(), new KActionCollection(this)));
     interface->execute();
     auto createeventwidget = parent->findChild<QWidget *>(QStringLiteral("eventedit"));
     QVERIFY(createeventwidget);
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.