1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 08:04:49 -05:00

Merge pull request #1520 from srcejon/fix_rotator_crash

Rotator controller: Fix crash
This commit is contained in:
Edouard Griffiths 2022-11-18 17:03:13 +01:00 committed by GitHub
commit 8291a885c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 17 deletions

View File

@ -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);

View File

@ -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;