qt connect crashing app
-
wrote on 30 Jul 2019, 19:45 last edited by
Hi all,
I am going crazy with a simple connect signal and slot. I have this function startDataMonitoring() which is called from another class (GUI class). Stockert70 is not a GUI class but is used as a simple driver for communication with serial port.
void Stockert70::startDataMonitoring()
{
qDebug() << m_pSerialPort->portName();
//connected to serial port
connect(m_pSerialPort, &QSerialPort::readyRead, this, &Stockert70::handleReadyRead);
}When I call this function on a button click I get this error:
"COM6" <--- this is a serial port name read from m_pSerialPort object so it is valid.
Exception thrown at 0x00000000604E2D02 (Qt5Cored.dll) in QStockertSerialPort.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.m_pSerialPort is initialized in another function that is called before this startDataMonitoring() function.
void Stockert70::setSerialPortParameters(QString portName)
{
qDebug() << "Set serial port parameters!";
m_pSerialPort = new QSerialPort();
m_pSerialPort->setPortName(portName);
m_pSerialPort->setBaudRate(QSerialPort::Baud9600);
m_pSerialPort->setDataBits(QSerialPort::Data8);
m_pSerialPort->setParity(QSerialPort::NoParity);
m_pSerialPort->setStopBits(QSerialPort::OneStop);
m_pSerialPort->setFlowControl(QSerialPort::NoFlowControl);
}Any suggestions?
-
wrote on 30 Jul 2019, 20:02 last edited by Kent-Dorfman
Well, you've got a null pointer somewhere. That much is ovbious. OK..."poorly initialize pointer" would be the better description.
And don't do serial comms without flow control. That makes me grind my teeth.
-
Well, you've got a null pointer somewhere. That much is ovbious. OK..."poorly initialize pointer" would be the better description.
And don't do serial comms without flow control. That makes me grind my teeth.
wrote on 30 Jul 2019, 20:14 last edited by@kent-dorfman Yeh but where? m_pSerialPort is not null
-
@kent-dorfman Yeh but where? m_pSerialPort is not null
1/4