Changeset 1645

Show
Ignore:
Timestamp:
02/20/07 12:33:28 (23 months ago)
Author:
edmanm
Message:

r1682@adrastea: edmanm | 2007-02-20 12:27:42 -0500
Catch debugging messages from Qt and send them to Vidalia's logs.

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/vidalia.cpp

    r1643 r1645  
    5656Log Vidalia::_log; 
    5757 
     58/** Catches debugging messages from Qt and sends them to Vidalia's logs. If Qt 
     59 * emits a QtFatalMsg, we will write the message to the log and then abort(). 
     60 */ 
     61void 
     62Vidalia::qt_msg_handler(QtMsgType type, const char *s) 
     63{ 
     64  QString msg(s); 
     65  switch (type) { 
     66    case QtDebugMsg: 
     67      vDebug("QtDebugMsg: %1").arg(msg); 
     68      break; 
     69    case QtWarningMsg: 
     70      vNotice("QtWarningMsg: %1").arg(msg); 
     71      break; 
     72    case QtCriticalMsg: 
     73      vWarn("QtCriticalMsg: %1").arg(msg); 
     74      break; 
     75    case QtFatalMsg: 
     76      vError("QtFatalMsg: %1").arg(msg); 
     77      break; 
     78  } 
     79  if (type == QtFatalMsg) { 
     80    vError("Fatal Qt error. Aborting."); 
     81    abort(); 
     82  } 
     83} 
    5884 
    5985/** Constructor. Parses the command-line arguments, resets Vidalia's 
     
    6389: QApplication(argc, argv) 
    6490{ 
     91  qInstallMsgHandler(qt_msg_handler); 
     92 
    6593  /* Read in all our command-line arguments. */ 
    6694  parseArguments(args); 
  • trunk/src/vidalia.h

    r1643 r1645  
    116116 
    117117private: 
     118  /** Catches debugging messages from Qt and sends them to  
     119   * Vidalia's logs. */ 
     120  static void qt_msg_handler(QtMsgType type, const char *msg); 
     121 
    118122  /** Parse the list of command-line arguments. */ 
    119123  void parseArguments(QStringList args);