From f7109139502948078410586c11c4eac7c16371e2 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 29 Jan 2024 18:40:29 +0000 Subject: [PATCH] Debugging and error checking --- wfmain.cpp | 85 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 771c495..f5c7546 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -414,7 +414,7 @@ void wfmain::makeRig() connect(this, SIGNAL(sendChangeLatency(quint16)), rig, SLOT(changeLatency(quint16))); connect(this, SIGNAL(getRigCIV()), rig, SLOT(findRigs())); connect(this, SIGNAL(setRigID(unsigned char)), rig, SLOT(setRigID(unsigned char))); - connect(rig, SIGNAL(discoveredRigID(rigCapabilities)), this, SLOT(receiveFoundRigID(rigCapabilities)),Qt::QueuedConnection); + connect(rig, SIGNAL(discoveredRigID(rigCapabilities)), this, SLOT(receiveFoundRigID(rigCapabilities))); connect(rig, SIGNAL(commReady()), this, SLOT(receiveCommReady())); @@ -969,6 +969,12 @@ void wfmain::configureVFOs() { qInfo(logSystem()) << "Running configureVFOs()"; + if (QThread::currentThread() != QCoreApplication::instance()->thread()) + { + qCritical(logSystem()) << "Thread is NOT the main UI thread, cannot create VFO"; + return; + } + if (vfos.size()) { foreach (spectrumScope* vfo, vfos) { @@ -5641,22 +5647,28 @@ void wfmain::receiveValue(cacheItem val){ { if (vfos.size()>1) { - // This tells us whether we are receiving main or sub data - subScope = val.value.value(); - if (!subScope && !vfos[0]->isVisible()) { - vfos[1]->setVisible(false); - vfos[0]->setVisible(true); - } else if (subScope && !vfos[1]->isVisible()) { - vfos[0]->setVisible(false); - vfos[1]->setVisible(true); - } - - if (ui->scopeDualBtn->isChecked()) { - vfos[0]->selected(!subScope); - vfos[1]->selected(subScope); + if (QThread::currentThread() != QCoreApplication::instance()->thread()) + { + qCritical(logSystem()) << "Thread is NOT the main UI thread, cannot hide/unhide VFO"; } else { - vfos[0]->selected(false); - vfos[1]->selected(false); + + // This tells us whether we are receiving main or sub data + subScope = val.value.value(); + if (!subScope && !vfos[0]->isVisible()) { + vfos[1]->setVisible(false); + vfos[0]->setVisible(true); + } else if (subScope && !vfos[1]->isVisible()) { + vfos[0]->setVisible(false); + vfos[1]->setVisible(true); + } + + if (ui->scopeDualBtn->isChecked()) { + vfos[0]->selected(!subScope); + vfos[1]->selected(subScope); + } else { + vfos[0]->selected(false); + vfos[1]->selected(false); + } } } break; @@ -5665,25 +5677,30 @@ void wfmain::receiveValue(cacheItem val){ { if (vfos.size()>1) { - // This tells us whether we are receiving single or dual scopes - ui->scopeDualBtn->setChecked(val.value.value()); - if (val.value.value()) { - if (!vfos[1]->isVisible()) - { - vfos[1]->setVisible(true); - } - else if (!vfos[0]->isVisible()) - { - vfos[0]->setVisible(true); - } + if (QThread::currentThread() != QCoreApplication::instance()->thread()) + { + qCritical(logSystem()) << "Thread is NOT the main UI thread, cannot hide/unhide VFO"; } else { - if (vfos[0]->isVisible()) - { - vfos[1]->setVisible(false); - } - else if (vfos[1]->isVisible()) - { - vfos[0]->setVisible(false); + // This tells us whether we are receiving single or dual scopes + ui->scopeDualBtn->setChecked(val.value.value()); + if (val.value.value()) { + if (!vfos[1]->isVisible()) + { + vfos[1]->setVisible(true); + } + else if (!vfos[0]->isVisible()) + { + vfos[0]->setVisible(true); + } + } else { + if (vfos[0]->isVisible()) + { + vfos[1]->setVisible(false); + } + else if (vfos[1]->isVisible()) + { + vfos[0]->setVisible(false); + } } } }