[PATCH] Make signals from threads thread safe

Anton Lundin glance at acc.umu.se
Wed Jan 21 10:30:14 PST 2015


When receiving signals from another thread, we need to use a Queued
Connection to make sure the nothing bad happens.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 configuredivecomputer.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp
index ec69c77..432aec8 100644
--- a/configuredivecomputer.cpp
+++ b/configuredivecomputer.cpp
@@ -30,7 +30,7 @@ void ConfigureDiveComputer::readSettings(device_data_t *data)
 	connect(readThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
 	connect(readThread, SIGNAL(devicedetails(DeviceDetails *)), this,
 		SIGNAL(deviceDetailsChanged(DeviceDetails *)));
-	connect(readThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)));
+	connect(readThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
 
 	readThread->start();
 }
@@ -46,7 +46,7 @@ void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_dat
 	connect(writeThread, SIGNAL(finished()),
 		this, SLOT(writeThreadFinished()), Qt::QueuedConnection);
 	connect(writeThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
-	connect(writeThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)));
+	connect(writeThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
 
 	writeThread->setDeviceDetails(details);
 	writeThread->start();
@@ -506,7 +506,7 @@ void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t
 	connect(firmwareThread, SIGNAL(finished()),
 		this, SLOT(firmwareThreadFinished()), Qt::QueuedConnection);
 	connect(firmwareThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
-	connect(firmwareThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)));
+	connect(firmwareThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
 
 	firmwareThread->start();
 }
@@ -522,7 +522,7 @@ void ConfigureDiveComputer::resetSettings(device_data_t *data)
 	connect(resetThread, SIGNAL(finished()),
 		this, SLOT(resetThreadFinished()), Qt::QueuedConnection);
 	connect(resetThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
-	connect(resetThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)));
+	connect(resetThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
 
 	resetThread->start();
 }
-- 
2.1.0



More information about the subsurface mailing list