Prevent some possible segfault errors (patch by Mike W9MDB).

This commit is contained in:
Uwe Risse 2022-11-01 16:40:08 +01:00
parent bc8ee62900
commit 0cd2935b8c
2 changed files with 13 additions and 3 deletions

View File

@ -444,8 +444,12 @@ QString DXLabSuiteCommanderTransceiver::command_with_reply (QString const& cmd)
// qDebug () << i << ":" << hex << int (result[i]);
// }
if (result != NULL)
{
CAT_TRACE (cmd << " -> " << QString {result});
return result; // converting raw UTF-8 bytes to QString
}
return "";
}
bool DXLabSuiteCommanderTransceiver::write_to_port (QString const& s)

View File

@ -90,6 +90,7 @@
#include "ExportCabrillo.h"
#include "ui_mainwindow.h"
#include "moc_mainwindow.cpp"
#include "Logger.hpp"
#define FCL fortran_charlen_t
@ -1385,7 +1386,9 @@ void MainWindow::set_application_font (QFont const& font)
QFile sf {sheet};
if (sf.open (QFile::ReadOnly | QFile::Text))
{
ss = sf.readAll () + ss;
QString tmp = sf.readAll();
if (tmp != NULL) ss = sf.readAll () + tmp;
else qDebug() << "tmp==NULL at sf.readAll";
}
}
qApp->setStyleSheet (ss + "* {" + font_as_stylesheet (font) + '}');
@ -4023,7 +4026,8 @@ void MainWindow::readFromStdout() //readFromStdout
if(f.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream s(&f);
QString t=s.readAll();
m_msgAvgWidget->displayAvg(t);
if (t != NULL) m_msgAvgWidget->displayAvg(t);
else qDebug() << "tmp==NULL at s.readAll";
}
}
}
@ -6152,7 +6156,9 @@ void MainWindow::on_addButton_clicked() //Add button
// preserve symlinks
f1.open (QFile::WriteOnly | QFile::Text); // truncates
f2.seek (0);
f1.write (f2.readAll ()); // copy contents
QByteArray tmp = f2.readAll();
if (tmp != (const char*)NULL) f1.write (tmp); // copy contents
else qDebug() << "tmp==NULL at f1.write";
f2.remove ();
}
}