Results 1 to 1 of 1

Thread: QTime deadlocks in my qDebug() custom handler ...

  1. #1
    Join Date
    Jul 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QTime deadlocks in my qDebug() custom handler ...

    Hello Qt guys,

    I wrote an MT application and all those threads are using qDebug() for logging their stuff .

    I also wrote a custom qDebug() handler, where I wanted to also mark the time when the record is logged :

    const QString timeFormat = "HH:mm:ss.zzz";

    void myMessageOutput(QtMsgType type, const char *msg) {

    const char * time = QTime::currentTime().toString(timeFormat).toStdStr ing().c_str();

    switch (type) {
    case QtDebugMsg:
    fprintf(stdout, "[DEBUG][%s]: %s\n", time, msg);
    break;
    case QtWarningMsg:
    fprintf(stdout, "[WARNING][%s]: %s\n", time, msg);
    break;
    case QtCriticalMsg:
    fprintf(stdout, "[CRITICAL][%s]: %s\n", time, msg);
    break;
    case QtFatalMsg:
    fprintf(stdout, "[FATAL][%s]: %s\n", time, msg);
    break;
    //abort();
    }

    fflush(stdout);
    }


    I have noticed, however, that under very busy usage by these threads, the qDebug() logging locks ( deadlocks maybe ) , and I believe that QTime might be the culprit, because when I remove it from my custom qDebug() handler, all goes very well :

    void myMessageOutput(QtMsgType type, const char *msg) {

    switch (type) {
    case QtDebugMsg:
    fprintf(stdout, "[DEBUG]: %s\n", msg);
    break;
    case QtWarningMsg:
    fprintf(stdout, "[WARNING]: %s\n", msg);
    break;
    case QtCriticalMsg:
    fprintf(stdout, "[CRITICAL]: %s\n", msg);
    break;
    case QtFatalMsg:
    fprintf(stdout, "[FATAL]: %s\n", msg);
    break;
    //abort();
    }

    fflush(stdout);
    }

    Would you mind helping me find if there is something wrong with QTimer in an MT environment or it is me who wrote some crap code ?

    Oh - yes ; I forgot to mention; when the 'deadlock' occurs, the last 'timestamp' that * time pointer is printing to stdout is some rubbish, suggesting that it either points to some weird address, of the content at the eligible address has been erased.

    Thank you,
    _iv_
    Last edited by ivrusuboca; 9th September 2009 at 02:40. Reason: updated contents

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.