[plasma/drkonqi] src/coredump/gui: Move CoredumpWatcher invokation to PatientModel

Tobias Fella <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 2ca6185578429393166fdfc420a6947ae56264d7 by Tobias Fella.
Committed on 28/07/2026 at 14:18.
Pushed by tfella into branch 'master'.

Move CoredumpWatcher invokation to PatientModel

M  +13   -0    src/coredump/gui/PatientModel.cpp
M  +0    -13   src/coredump/gui/main.cpp

https://invent.kde.org/plasma/drkonqi/-/commit/2ca6185578429393166fdfc420a6947ae56264d7

diff --git a/src/coredump/gui/PatientModel.cpp b/src/coredump/gui/PatientModel.cpp
index 97ef785fe..52c3d053a 100644
--- a/src/coredump/gui/PatientModel.cpp
+++ b/src/coredump/gui/PatientModel.cpp
@@ -9,6 +9,7 @@
 #include <QMetaMethod>
 
 #include "Patient.h"
+#include "coredumpwatcher.h"
 
 using namespace std::chrono_literals;
 
@@ -16,6 +17,18 @@ PatientModel::PatientModel(QObject *parent)
     : QAbstractListModel(parent)
 {
     initRoleNames(Patient::staticMetaObject);
+
+    auto expectedJournal = owning_ptr_call<sd_journal>(sd_journal_open, SD_JOURNAL_LOCAL_ONLY);
+    Q_ASSERT(expectedJournal.ret == 0);
+    Q_ASSERT(expectedJournal.value);
+    auto watcher = new CoredumpWatcher(std::move(expectedJournal.value), {}, {}, this);
+    connect(watcher, &CoredumpWatcher::newDump, this, [&](const auto &dump) {
+        addObject(std::make_unique<Patient>(dump));
+    });
+    connect(watcher, &CoredumpWatcher::atLogEnd, this, [&]() {
+        setReady(true);
+    });
+    QMetaObject::invokeMethod(watcher, &CoredumpWatcher::start, Qt::QueuedConnection);
 }
 
 QHash<int, QByteArray> PatientModel::roleNames() const
diff --git a/src/coredump/gui/main.cpp b/src/coredump/gui/main.cpp
index 948ea3735..54227a8a8 100644
--- a/src/coredump/gui/main.cpp
+++ b/src/coredump/gui/main.cpp
@@ -13,7 +13,6 @@
 #include <KLocalizedString>
 
 #include <config-drkonqi.h>
-#include <coredumpwatcher.h>
 
 #include "DetailsLoader.h"
 #include "Patient.h"
@@ -51,17 +50,5 @@ int main(int argc, char *argv[])
         return -1;
     }
 
-    auto expectedJournal = owning_ptr_call<sd_journal>(sd_journal_open, SD_JOURNAL_LOCAL_ONLY);
-    Q_ASSERT(expectedJournal.ret == 0);
-    Q_ASSERT(expectedJournal.value);
-    CoredumpWatcher watcher(std::move(expectedJournal.value), {}, {}, nullptr);
-    QObject::connect(&watcher, &CoredumpWatcher::newDump, PatientModel::instance(), [&](const Coredump &dump) {
-        PatientModel::instance()->addObject(std::make_unique<Patient>(dump));
-    });
-    QObject::connect(&watcher, &CoredumpWatcher::atLogEnd, PatientModel::instance(), [&]() {
-        PatientModel::instance()->setReady(true);
-    });
-    watcher.metaObject()->invokeMethod(&watcher, &CoredumpWatcher::start, Qt::QueuedConnection);
-
     return app.exec();
 }
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.