QSerialPortInfo debug crash visual studio 2015 + QT5.8

224 views Asked by At

I am using QT5.8 and visual studio 2015 on win10 to control a serial port. The following minimal code crashes in visual studio (but only in debug, release works fine) after the visualization of the messages, so when the object QList infos is destroyed, can anybody explain why?

#include <iostream>
#include <QtSerialPort/QSerialPortInfo>

void showPorts() {
    QList<QSerialPortInfo> infos = QSerialPortInfo::availablePorts();
    for (const QSerialPortInfo &info : infos) {
        std::cout << " detected port : " << info.portName().toStdString() << std::endl;
    }
} // this code CRASHES HERE only in debug ! 


int main (int argc, char** argv){
    std::cout<<"\n >>>  test serial info   <<< \n\n"<<std::endl;

    showPorts();

    std::cout << "\n >>> Finished, press enter to exit  <<< \n\n" << std::endl;
    std::cin.get();

    return 0;
}
1

There are 1 answers

6
Denis Shienkov On

I have tested your code and I have not a crash.

PS: Windows 10x64, MSVC2015, Qt 5.8.0 32 bit