| 5841 | } |
| 5842 | |
| 5843 | void MainWindow::applyTuneRequest(SliceModel* slice, double mhz, |
| 5844 | TuneIntent intent, const char* source) |
| 5845 | { |
| 5846 | if (!slice) |
| 5847 | return; |
| 5848 | if (tuneBlockedByGuards(slice)) |
| 5849 | return; |
| 5850 | |
| 5851 | const double oldFreqMhz = slice->frequency(); |
| 5852 | |
| 5853 | // Absolute-target intents (typed VFO entry, spectrum click, spot recall, |
| 5854 | // bandstack recall) must invalidate any in-flight encoder accumulator. |
| 5855 | // The #1524 1 kHz jitter-suppression tolerance otherwise keeps a stale |
| 5856 | // m_flexTargetMhz when the typed frequency lands inside that window, |
| 5857 | // producing the +60 Hz residual reported in #3260. |
| 5858 | if (intent == TuneIntent::CommandedTargetCenter |
| 5859 | || intent == TuneIntent::AbsoluteJump) { |
| 5860 | m_flexTargetMhz = -1.0; |
| 5861 | m_flexCoalesceTimer.stop(); |
| 5862 | #ifdef HAVE_MIDI |
| 5863 | m_midiTuneTargetMhz = -1.0; |
| 5864 | m_midiTuneIdleTimer.stop(); |
| 5865 | #endif |
| 5866 | } |
| 5867 | |
| 5868 | pushSliceFrequencyToOverlays(slice, mhz); |
| 5869 | |
| 5870 | const BandStackPreselectResult bandPreselect = |
| 5871 | (intent == TuneIntent::CommandedTargetCenter) |
| 5872 | ? preselectBandStackForTune(slice, mhz, source) |
| 5873 | : BandStackPreselectResult::NotNeeded; |
| 5874 | if (bandPreselect == BandStackPreselectResult::Unsupported) { |
| 5875 | pushSliceFrequencyToOverlays(slice, oldFreqMhz); |
| 5876 | return; |
| 5877 | } |
| 5878 | |
| 5879 | if (bandPreselect == BandStackPreselectResult::Selected) { |
| 5880 | const int sliceId = slice->sliceId(); |
| 5881 | const QString sourceName = QString::fromUtf8(source ? source : ""); |
| 5882 | QTimer::singleShot(250, this, [this, sliceId, mhz, sourceName, oldFreqMhz]() { |
| 5883 | auto* pendingSlice = m_radioModel.slice(sliceId); |
| 5884 | if (!pendingSlice || pendingSlice->isLocked() || m_swrSweep.running) |
| 5885 | return; |
| 5886 | pushSliceFrequencyToOverlays(pendingSlice, mhz); |
| 5887 | pendingSlice->tuneAndRecenter(mhz); |
| 5888 | |
| 5889 | const QByteArray sourceUtf8 = sourceName.toUtf8(); |
| 5890 | const char* delayedSource = sourceUtf8.constData(); |
| 5891 | const TuneCenteringResult result = |
| 5892 | revealFrequencyIfNeeded(pendingSlice, mhz, |
| 5893 | TuneIntent::CommandedTargetCenter, |
| 5894 | delayedSource); |
| 5895 | logTunePolicyDecision(delayedSource, TuneIntent::CommandedTargetCenter, |
| 5896 | oldFreqMhz, mhz, result); |
| 5897 | }); |
| 5898 | return; |
| 5899 | } |
| 5900 |
nothing calls this directly
no test coverage detected