Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

fromStdString and toStdString msvc2017 debug



  • I recently switched from vs2015 to vs2017 after spending a few hours setting up my dev env. But now I have a very strange problem. All my code works except for conversion from QString to and from std string. And only on my debug configuration. My release runs fine.

    It throws a read access violation. The stack frame looks like this:
    Qt5Core.dll!QString::fromStdString(...)
    Qt5Core.dll!QString::fromUtf8(...)
    Qt5Core.dll!QString::fromUtf8(...)
    Qt5Core.dll!QString::fromUtf8_helper(...)
    Qt5Core.dll!QUtf8::convertToUnicode(...)
    Qt5Core.dll!QUtf8::convertToUnicode(...) breaks here

    If I use another technique it works fine. I've been using QString::toLocal8Bit().constData() to get a cstr temporarily while I try to figure out the problem. I tried reinstalling qt as well.


  • Lifetime Qt Champion

    Hi,

    The best thing to do is to move to Qt 5.9.0. There's already a pre-built package for VS2017.

    IIRC, there's was compatibility problem with the MSVC2015 5.8 package and MSVC2017 but that was fixed for 5.9.0.


Log in to reply