QT, toStdString() 이놈이 문제였다!!!
release에서 안되는 원인이 'toStdString()'이었다!!!!
문제가 되는 명령은 다음과 같다.
------------------------------------------------------
QString &sbl
...
SRecordParser* s=new SRecordParser(sbl.toStdString(), false);
------------------------------------------------------
이 프로그램을 짰던 사람은, QT에서 사용되는 'QString' 형식 문자열을 'string' 입력 파라미터로 선언한 함수에다 넣으려고 'toStdString()'를 이용한 것이다.
그게 희한하게 debug 모드에서는 되는데 release에서는 안되었다.
인터넷을 뒤적여 보니,
이게 C++11 인가로 standard가 바뀌면서 뭔가가 바뀐 거 같다,
문자열을 변환할 때 compiler에 따라 16bit, 64bit .. 먼가 다르게 변환되어 쫑난다,
머 이런 식으로 이야기가 흘러갔다...
급해서 자세히는 분석 못했고, 여러 해결 방안 중 뭔가 정확한 거 같은 웹페이지 발견!!!
링크 : http://asmaloney.com/2011/11/code/qstringtostdstring-qstringfromstdstring-and-no-stl/
QString::toStdString() may be replaced by qPrintable() like this:
qPrintable() returns a const char * and is equivalent to str.toLocal8Bit().constData().
QString::fromStdString() may be replaced by QString::fromAscii() like this:
1 2 3 4 | - item.summary = QString::fromStdString(msg.shortMessage()); - item.message = QString::fromStdString(msg.verboseMessage()); + item.summary = QString::fromAscii(msg.shortMessage().data(), msg.shortMessage().size()); + item.message = QString::fromAscii(msg.verboseMessage().data(), msg.verboseMessage().size()); |
결론은,
'toStdString()' ==> 'qPrintable()'
'fromStdString()' ==> 'QString::fromAscii()'
이렇게 바꿔줘야 함.
(근데 'fromStdString()' ==> 'QString::fromAscii()' 이건 내가 검증 안해봄. 사실 이 자료가 맞는지도 잘 ㄷㄷㄷㄷㄷ)