PDA

View Full Version : I found memory leak with QTextCodec::codecForName on Qt4.6. How can I get rid of it?



Jinsan Kim
23rd December 2009, 13:53
I found memory leak with QTextCodec::codecForName on Qt4.6, WindowsXP, VS2008.

For testing, I wrote a simple application.



int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("EUC-KR"));

QPushButton hello("한글 테스트");
QObject::connect(&hello, SIGNAL(clicked()), &app, SLOT(quit()));

hello.show();

return app.exec();
}


This code make some memory leak.

If I commented out line4, there is no memory leak. (However, my application needs the codec. )

//QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("EUC-KR"));

In the official Qt documents, they mention that QApplication will de-allocate the QTextCodec's memory.

But, in my opinion, It doesn't work.

How can I get rid of this leak? or Is there something that I missed?