From ba0e22d4d74df6639d4132485f051e4ca30c132b Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <svechnikovmv@gmail.com>
Date: Fri, 15 Nov 2024 14:10:37 +0100
Subject: [PATCH] make job connections unique

---
 GUI/Model/Job/JobsSet.cpp      | 6 ++++--
 GUI/View/Frame/Plot2DFrame.cpp | 1 +
 GUI/View/Job/JobsListing.cpp   | 4 +++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/GUI/Model/Job/JobsSet.cpp b/GUI/Model/Job/JobsSet.cpp
index b395976be33..d1950074a94 100644
--- a/GUI/Model/Job/JobsSet.cpp
+++ b/GUI/Model/Job/JobsSet.cpp
@@ -147,8 +147,9 @@ void JobsSet::runJob(JobItem* job_item)
     if (job_item->thread())
         throw std::runtime_error("Job already running");
 
-    connect(job_item, &JobItem::progressIncremented, this, &JobsSet::onProgressUpdate);
-    connect(job_item, &JobItem::jobFinished, this, &JobsSet::onFinishedJob);
+    connect(job_item, &JobItem::progressIncremented, this, &JobsSet::onProgressUpdate,
+            Qt::UniqueConnection);
+    connect(job_item, &JobItem::jobFinished, this, &JobsSet::onFinishedJob, Qt::UniqueConnection);
 
     job_item->initWorker();
     auto* thread = job_item->thread();
@@ -164,6 +165,7 @@ void JobsSet::onFinishedJob(JobItem* job_item)
 {
     onProgressUpdate();
     emit newJobFinished(job_item);
+    qInfo() << "jobMeritsAttention: onFinishedJob";
     emit jobMeritsAttention(job_item);
 }
 
diff --git a/GUI/View/Frame/Plot2DFrame.cpp b/GUI/View/Frame/Plot2DFrame.cpp
index b7bc410fd98..b7e3a73695f 100644
--- a/GUI/View/Frame/Plot2DFrame.cpp
+++ b/GUI/View/Frame/Plot2DFrame.cpp
@@ -124,6 +124,7 @@ Data2DItem* Plot2DFrame::data2DItem()
 
 void Plot2DFrame::updateFrame()
 {
+    qInfo() << "updateFrame()";
     if (!data2DItem()) {
         hide();
         return;
diff --git a/GUI/View/Job/JobsListing.cpp b/GUI/View/Job/JobsListing.cpp
index fa45cd5705a..547f07a7348 100644
--- a/GUI/View/Job/JobsListing.cpp
+++ b/GUI/View/Job/JobsListing.cpp
@@ -142,8 +142,10 @@ void JobsListing::onItemSelectionChanged()
     emit selectedJobsChanged(selectedJobItems());
 
     // to update the content of data-showing widget
-    if (selectedJobItems().size() == 1)
+    if (selectedJobItems().size() == 1) {
+        qInfo() << "jobMeritsAttention: onItemSelectionChanged";
         emit gDoc->jobs()->jobMeritsAttention(selectedJobItems().front());
+    }
 }
 
 void JobsListing::onJobsDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
-- 
GitLab