[Qt-interest] Doubt in qInstallMsgHandler

Mohammed Sameer msameer at foolab.org
Tue May 19 11:30:41 CEST 2009


On Tue, May 19, 2009 at 02:57:55PM +0530, Ravi Krishna wrote:
> Hi,
> When I run my QT application I am getting the following error
> "QList: Out of Memory"
> on stdout when the message handler is not set.
> 
> To catch all the fatal error messages I set qInstallMsgHandler to myMsgOut.
> 
> void myMsgOut(QtMsgType type, const char *msg)
> {
>    switch (type) {
>     case QtCriticalMsg:
>         std::cout << msg << std::endl;
>         break;
>     case QtFatalMsg:
>         std::cout << msg << std::endl;
>         QMessageBox::critical(NULL, "Fatal error", msg);
>         break;
>     default:
>         std::cout << msg << std::endl;
>         break;
>     }
> }
> 
> But after setting the message handler to myMsgOut, the application is 
> crashing, without giving any output. I wanted to know is there any 
> problem in my message handler function.

I don't know the reason for the crash but if it's an out of memory condition then
I guess you should not create new widgets because it'll probably fail (No memory) and if it
fails because of an out of memory condition then it might end up calling your handler again
... and so on ;-)

Just my 0.02


Cheers,

-- 
GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F  280E CB66 8E29 A3FD 0DF7
Debian User and Developer.
Homepage: www.foolab.org



More information about the Qt-interest-old mailing list