From c9016d73787792f977ae3870d45a16ffbdf13c6b Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Sat, 3 Nov 2018 01:14:31 -0400 Subject: [PATCH] Fixed issue with false decodes causing app crash --- decodedtext.cpp | 5 +++++ jsc.cpp | 18 ++++++++++++------ mainwindow.cpp | 11 +++-------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/decodedtext.cpp b/decodedtext.cpp index 18fdef5..650f98f 100644 --- a/decodedtext.cpp +++ b/decodedtext.cpp @@ -61,6 +61,11 @@ DecodedText::DecodedText (QString const& the_string, bool contest_mode, QString bits_ = bits(); + // don't even try to unpack -24dB frames...they are *very* likely to be false decodes... + if(snr() <= -24){ + return; + } + tryUnpack(); } diff --git a/jsc.cpp b/jsc.cpp index 346ca8c..fca6fee 100644 --- a/jsc.cpp +++ b/jsc.cpp @@ -107,17 +107,23 @@ QString JSC::decompress(Codeword const& bitvec){ QList bytes; QList separators; - auto iter = bitvec.begin(); - while(iter != bitvec.end()){ - quint64 byte = Varicode::bitsToInt(iter, 4); - iter += 4; + + int i = 0; + int count = bitvec.count(); + while(i < count){ + auto b = bitvec.mid(i, 4); + if(b.length() != 4){ + break; + } + quint64 byte = Varicode::bitsToInt(b); bytes.append(byte); + i += 4; if(byte < s){ - if(*iter){ + if(count - i > 0 && bitvec.at(i)){ separators.append(bytes.length()-1); } - iter += 1; + i += 1; } } diff --git a/mainwindow.cpp b/mainwindow.cpp index 3bb0e18..7010956 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1445,6 +1445,9 @@ void MainWindow::initializeDummyData(){ return; } + // auto d = DecodedText("h+vWp6mRPprH", 6); + // qDebug() << d.message() << buildMessageFrames(d.message()); + // qDebug() << Varicode::isValidCallsign("@GROUP1", nullptr); // qDebug() << Varicode::packAlphaNumeric50("VE7/KN4CRD"); // qDebug() << Varicode::unpackAlphaNumeric50(Varicode::packAlphaNumeric50("VE7/KN4CRD")); @@ -3550,14 +3553,6 @@ void MainWindow::readFromStdout() //readFromStdout , tr ("Cannot open \"%1\" for append: %2") .arg (f.fileName ()).arg (f.errorString ())); } - if (m_config.insert_blank () && m_blankLine && !m_config.bFox()) { - QString band; - if((DriftingDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged) > 4*m_TRperiod/4) { - band = ' ' + m_config.bands ()->find (m_freqNominal); - } - ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-')); - m_blankLine = false; - } DecodedText decodedtext {QString::fromUtf8 (t.constData ()).remove (QRegularExpression {"\r|\n"}), "FT8" == m_mode && ui->cbVHFcontest->isChecked(), m_config.my_grid ()};