Merge pull request #1520 from srcejon/fix_rotator_crash

Rotator controller: Fix crash
pull/1528/head
Edouard Griffiths 2022-11-18 17:03:13 +01:00 zatwierdzone przez GitHub
commit 8291a885c5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 27 dodań i 17 usunięć

Wyświetl plik

@ -163,6 +163,9 @@ GS232ControllerGUI::GS232ControllerGUI(PluginAPI* pluginAPI, FeatureUISet *featu
ui->elevationCurrentText->setText("-");
updateSerialPortList();
if (ui->serialPort->currentIndex() >= 0) {
on_serialPort_currentIndexChanged(ui->serialPort->currentIndex());
}
m_settings.setRollupState(&m_rollupState);

Wyświetl plik

@ -73,8 +73,10 @@ void GS232ControllerWorker::stopWork()
{
qDebug() << "GS232ControllerWorker::stopWork";
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
if (m_device && m_device->isOpen()) {
if (m_device && m_device->isOpen())
{
m_device->close();
m_device = nullptr;
}
disconnect(&m_serialPort, &QSerialPort::readyRead, this, &GS232ControllerWorker::readData);
disconnect(&m_socket, &QTcpSocket::readyRead, this, &GS232ControllerWorker::readData);
@ -131,8 +133,10 @@ void GS232ControllerWorker::applySettings(const GS232ControllerSettings& setting
if (settings.m_connection != m_settings.m_connection)
{
if (m_device && m_device->isOpen()) {
if (m_device && m_device->isOpen())
{
m_device->close();
m_device = nullptr;
}
}
@ -151,22 +155,25 @@ void GS232ControllerWorker::applySettings(const GS232ControllerSettings& setting
}
}
// Apply offset then clamp
float azimuth, elevation;
settings.calcTargetAzEl(azimuth, elevation);
// Don't set if within tolerance of last setting
float azDiff = std::abs(azimuth - m_lastAzimuth);
float elDiff = std::abs(elevation - m_lastElevation);
if (((elDiff > settings.m_tolerance) || (m_lastElevation == -1) || force) && (settings.m_elevationMax != 0))
if (m_device != nullptr)
{
setAzimuthElevation(azimuth, elevation);
}
else if ((azDiff > settings.m_tolerance) || (m_lastAzimuth == -1) || force)
{
setAzimuth(azimuth);
// Apply offset then clamp
float azimuth, elevation;
settings.calcTargetAzEl(azimuth, elevation);
// Don't set if within tolerance of last setting
float azDiff = std::abs(azimuth - m_lastAzimuth);
float elDiff = std::abs(elevation - m_lastElevation);
if (((elDiff > settings.m_tolerance) || (m_lastElevation == -1) || force) && (settings.m_elevationMax != 0))
{
setAzimuthElevation(azimuth, elevation);
}
else if ((azDiff > settings.m_tolerance) || (m_lastAzimuth == -1) || force)
{
setAzimuth(azimuth);
}
}
m_settings = settings;