Commit 4e891aac authored by Jasem Mutlaq's avatar Jasem Mutlaq

Fix multithreaded race condition that could lead to crash between client and main GUI threads

parent bbc46886
......@@ -247,7 +247,6 @@ void GUIManager::removeDevice(const QString &name)
void GUIManager::buildDevice(DeviceInfo *di)
{
//qDebug() << "In build Device for device with tree label " << di->getTreeLabel() << endl;
ClientManager *cm = di->getDriverInfo()->getClientManager();
if (cm == nullptr)
......@@ -258,14 +257,8 @@ void GUIManager::buildDevice(DeviceInfo *di)
INDI_D *gdm = new INDI_D(di->getBaseDevice(), cm);
connect(cm, &ClientManager::newINDIProperty, gdm, &INDI_D::buildProperty);
connect(cm, &ClientManager::newINDIProperty, gdm, &INDI_D::buildProperty, Qt::BlockingQueuedConnection);
connect(cm, &ClientManager::removeINDIProperty, gdm, &INDI_D::removeProperty, Qt::QueuedConnection);
// connect(cm, &ClientManager::removeINDIProperty, [gdm](const QString & device, const QString & name)
// {
// if (device == gdm->name())
// QMetaObject::invokeMethod(gdm, "removeProperty", Qt::QueuedConnection, Q_ARG(QString, name));
// });
connect(cm, &ClientManager::newINDISwitch, gdm, &INDI_D::updateSwitchGUI);
connect(cm, &ClientManager::newINDIText, gdm, &INDI_D::updateTextGUI);
connect(cm, &ClientManager::newINDINumber, gdm, &INDI_D::updateNumberGUI);
......
......@@ -131,19 +131,17 @@ void INDIListener::addClient(ClientManager *cm)
clients.append(cm);
connect(cm, &ClientManager::newINDIDevice, this, &INDIListener::processDevice, Qt::BlockingQueuedConnection);
connect(cm, &ClientManager::newINDIProperty, this, &INDIListener::registerProperty);
connect(cm, &ClientManager::newINDIProperty, this, &INDIListener::registerProperty, Qt::BlockingQueuedConnection);
connect(cm, &ClientManager::removeINDIDevice, this, &INDIListener::removeDevice);
connect(cm, &ClientManager::removeINDIProperty, this, &INDIListener::removeProperty);
connect(cm, &ClientManager::removeINDIDevice, this, &INDIListener::removeDevice, Qt::BlockingQueuedConnection);
connect(cm, &ClientManager::removeINDIProperty, this, &INDIListener::removeProperty, Qt::QueuedConnection);
connect(cm, &ClientManager::newINDISwitch, this, &INDIListener::processSwitch);
connect(cm, &ClientManager::newINDIText, this, &INDIListener::processText);
connect(cm, &ClientManager::newINDINumber, this, &INDIListener::processNumber);
connect(cm, &ClientManager::newINDILight, this, &INDIListener::processLight);
connect(cm, &ClientManager::newINDIBLOB, this, &INDIListener::processBLOB);
#if INDI_VERSION_MAJOR >= 1 && INDI_VERSION_MINOR >= 5
connect(cm, &ClientManager::newINDIUniversalMessage, this, &INDIListener::processUniversalMessage);
#endif
}
void INDIListener::removeClient(ClientManager *cm)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment