diff --git a/audioconverter.cpp b/audioconverter.cpp index edc6ec7..a835050 100644 --- a/audioconverter.cpp +++ b/audioconverter.cpp @@ -2,7 +2,8 @@ #include "logcategories.h" #include "ulaw.h" -audioConverter::audioConverter(){ +audioConverter::audioConverter(QObject* parent) : QObject(parent) +{ } bool audioConverter::init(QAudioFormat inFormat, QAudioFormat outFormat, quint8 opusComplexity, quint8 resampleQuality) diff --git a/audioconverter.h b/audioconverter.h index cd598b4..8c784f0 100644 --- a/audioconverter.h +++ b/audioconverter.h @@ -35,7 +35,7 @@ class audioConverter : public QObject Q_OBJECT public: - audioConverter(); + explicit audioConverter(QObject* parent = nullptr);; ~audioConverter(); public slots: diff --git a/audiohandler.cpp b/audiohandler.cpp index b4678e3..95b2de5 100644 --- a/audiohandler.cpp +++ b/audiohandler.cpp @@ -10,7 +10,7 @@ -audioHandler::audioHandler(QObject* parent) +audioHandler::audioHandler(QObject* parent) : QObject(parent) { Q_UNUSED(parent) } @@ -112,7 +112,7 @@ bool audioHandler::init(audioSetup setup) // We "hopefully" now have a valid format that is supported so try connecting - converter = new audioConverter(); + converter = new audioConverter(this); converterThread = new QThread(this); if (setup.isinput) { converterThread->setObjectName("audioConvIn()"); diff --git a/audiohandler.h b/audiohandler.h index c5ac1e7..f9ec2a1 100644 --- a/audiohandler.h +++ b/audiohandler.h @@ -78,7 +78,7 @@ class audioHandler : public QObject Q_OBJECT public: - audioHandler(QObject* parent = 0); + explicit audioHandler(QObject* parent = nullptr); ~audioHandler(); int getLatency(); diff --git a/commhandler.cpp b/commhandler.cpp index fd0f381..be6fb5b 100644 --- a/commhandler.cpp +++ b/commhandler.cpp @@ -5,7 +5,7 @@ // Copyright 2017-2020 Elliott H. Liggett -commHandler::commHandler() +commHandler::commHandler(QObject* parent) : QObject(parent) { //constructor // grab baud rate and other comm port details @@ -31,7 +31,7 @@ commHandler::commHandler() connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn())); } -commHandler::commHandler(QString portName, quint32 baudRate, quint8 wfFormat) +commHandler::commHandler(QString portName, quint32 baudRate, quint8 wfFormat, QObject* parent) : QObject(parent) { //constructor // grab baud rate and other comm port details diff --git a/commhandler.h b/commhandler.h index 4baeacd..5546175 100644 --- a/commhandler.h +++ b/commhandler.h @@ -15,8 +15,8 @@ class commHandler : public QObject Q_OBJECT public: - commHandler(); - commHandler(QString portName, quint32 baudRate, quint8 wfFormat); + commHandler(QObject* parent = nullptr); + commHandler(QString portName, quint32 baudRate, quint8 wfFormat,QObject* parent = nullptr); bool serialError; bool rtsStatus(); diff --git a/pttyhandler.cpp b/pttyhandler.cpp index 0639bc0..60ea0ae 100644 --- a/pttyhandler.cpp +++ b/pttyhandler.cpp @@ -13,7 +13,7 @@ // Copyright 2017-2021 Elliott H. Liggett & Phil Taylor -pttyHandler::pttyHandler(QString pty) +pttyHandler::pttyHandler(QString pty, QObject* parent) : QObject(parent) { //constructor if (pty == "" || pty.toLower() == "none") diff --git a/pttyhandler.h b/pttyhandler.h index 3c18206..d056e77 100644 --- a/pttyhandler.h +++ b/pttyhandler.h @@ -19,7 +19,7 @@ class pttyHandler : public QObject Q_OBJECT public: - pttyHandler(QString portName); + explicit pttyHandler(QString portName, QObject* parent = nullptr); pttyHandler(QString portName, quint32 baudRate); bool serialError; diff --git a/rigcommander.cpp b/rigcommander.cpp index d4768f8..60efd9f 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -20,13 +20,13 @@ // Note: When sending \x00, must use QByteArray.setRawData() -rigCommander::rigCommander() +rigCommander::rigCommander(QObject* parent) : QObject(parent) { qInfo(logRig()) << "creating instance of rigCommander()"; state.set(SCOPEFUNC, true, false); } -rigCommander::rigCommander(quint8 guid[GUIDLEN]) +rigCommander::rigCommander(quint8 guid[GUIDLEN], QObject* parent) : QObject(parent) { qInfo(logRig()) << "creating instance of rigCommander()"; state.set(SCOPEFUNC, true, false); @@ -59,8 +59,8 @@ void rigCommander::commSetup(unsigned char rigCivAddr, QString rigSerialPort, qu this->rigBaudRate = rigBaudRate; rigCaps.baudRate = rigBaudRate; - comm = new commHandler(rigSerialPort, rigBaudRate,wf); - ptty = new pttyHandler(vsp); + comm = new commHandler(rigSerialPort, rigBaudRate,wf,this); + ptty = new pttyHandler(vsp,this); if (tcpPort > 0) { tcp = new tcpServer(this); @@ -132,7 +132,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud //this->rigSerialPort = rigSerialPort; //this->rigBaudRate = rigBaudRate; - ptty = new pttyHandler(vsp); + ptty = new pttyHandler(vsp,this); if (tcpPort > 0) { tcp = new tcpServer(this); diff --git a/rigcommander.h b/rigcommander.h index dc1b153..7921b24 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -69,8 +69,8 @@ class rigCommander : public QObject Q_OBJECT public: - rigCommander(); - rigCommander(quint8 guid[GUIDLEN]); + explicit rigCommander(QObject* parent=nullptr); + explicit rigCommander(quint8 guid[GUIDLEN], QObject* parent = nullptr); ~rigCommander(); bool usingLAN(); diff --git a/rigctld.h b/rigctld.h index d86818d..2018576 100644 --- a/rigctld.h +++ b/rigctld.h @@ -326,7 +326,7 @@ class rigCtlD : public QTcpServer Q_OBJECT public: - explicit rigCtlD(QObject *parent=Q_NULLPTR); + explicit rigCtlD(QObject *parent=nullptr); virtual ~rigCtlD(); int startServer(qint16 port); diff --git a/servermain.cpp b/servermain.cpp index 2db93d3..8802cb7 100644 --- a/servermain.cpp +++ b/servermain.cpp @@ -102,7 +102,7 @@ void servermain::makeRig() if (radio->rigThread == Q_NULLPTR) { qInfo(logSystem()) << "Creating new rigThread()"; - radio->rig = new rigCommander(radio->guid); + radio->rig = new rigCommander(radio->guid,this); radio->rigThread = new QThread(this); radio->rigThread->setObjectName("rigCommander()"); @@ -376,7 +376,7 @@ void servermain::setServerToPrefs() udp = Q_NULLPTR; } - udp = new udpServer(&serverConfig); + udp = new udpServer(&serverConfig,this); serverThread = new QThread(this); serverThread->setObjectName("udpServer()"); diff --git a/udphandler.cpp b/udphandler.cpp index 2413bc0..a235e16 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -921,7 +921,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, quint QUdpSocket::connect(udp, &QUdpSocket::readyRead, this, &udpAudio::dataReceived); - rxaudio = new audioHandler(); + rxaudio = new audioHandler(this); rxAudioThread = new QThread(this); rxAudioThread->setObjectName("rxAudio()"); @@ -946,7 +946,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, quint pingTimer->start(PING_PERIOD); // send ping packets every 100ms if (enableTx) { - txaudio = new audioHandler(); + txaudio = new audioHandler(this); txAudioThread = new QThread(this); rxAudioThread->setObjectName("txAudio()"); diff --git a/udpserver.cpp b/udpserver.cpp index 74ed8e4..0387fc0 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -4,8 +4,9 @@ #define STALE_CONNECTION 15 #define LOCK_PERIOD 10 // time to attempt to lock Mutex in ms #define AUDIO_SEND_PERIOD 20 // -udpServer::udpServer(SERVERCONFIG* config) : - config(config) +udpServer::udpServer(SERVERCONFIG* config, QObject* parent) : + config(config), + QObject(parent) { qInfo(logUdpServer()) << "Starting udp server"; } @@ -366,7 +367,7 @@ void udpServer::controlReceived() outAudio.isinput = false; - radio->txaudio = new audioHandler(); + radio->txaudio = new audioHandler(this); radio->txAudioThread = new QThread(this); radio->txAudioThread->setObjectName("txAudio()"); @@ -408,7 +409,7 @@ void udpServer::controlReceived() radio->rxAudioSetup.isinput = true; memcpy(radio->rxAudioSetup.guid, radio->guid, GUIDLEN); - radio->rxaudio = new audioHandler(); + radio->rxaudio = new audioHandler(this); radio->rxAudioThread = new QThread(this); radio->rxAudioThread->setObjectName("rxAudio()"); diff --git a/udpserver.h b/udpserver.h index 9fd4f4a..fe1682b 100644 --- a/udpserver.h +++ b/udpserver.h @@ -99,7 +99,7 @@ class udpServer : public QObject Q_OBJECT public: - udpServer(SERVERCONFIG* config); + explicit udpServer(SERVERCONFIG* config, QObject* parent = nullptr); ~udpServer(); public slots: diff --git a/wfmain.cpp b/wfmain.cpp index 26b86a0..3dac678 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -405,7 +405,7 @@ void wfmain::makeRig() { if (rigThread == Q_NULLPTR) { - rig = new rigCommander(); + rig = new rigCommander(this); rigThread = new QThread(this); rigThread->setObjectName("rigCommander()"); @@ -993,7 +993,7 @@ void wfmain::setServerToPrefs() if (serverConfig.enabled) { serverConfig.lan = prefs.enableLAN; - udp = new udpServer(&serverConfig); + udp = new udpServer(&serverConfig,this); serverThread = new QThread(this);