[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r1645: Catch debugging messages from Qt and send them to Vidalia's (in trunk: . src)
Author: edmanm
Date: 2007-02-20 12:33:28 -0500 (Tue, 20 Feb 2007)
New Revision: 1645
Modified:
trunk/
trunk/src/vidalia.cpp
trunk/src/vidalia.h
Log:
r1682@adrastea: edmanm | 2007-02-20 12:27:42 -0500
Catch debugging messages from Qt and send them to Vidalia's logs.
Property changes on: trunk
___________________________________________________________________
svk:merge ticket from /vidalia/local/trunk [r1682] on 54b3572a-7227-0410-958f-53ecd705b71a
Modified: trunk/src/vidalia.cpp
===================================================================
--- trunk/src/vidalia.cpp 2007-02-20 17:33:23 UTC (rev 1644)
+++ trunk/src/vidalia.cpp 2007-02-20 17:33:28 UTC (rev 1645)
@@ -55,6 +55,32 @@
TorControl* Vidalia::_torControl = 0; /**< Main TorControl object. */
Log Vidalia::_log;
+/** Catches debugging messages from Qt and sends them to Vidalia's logs. If Qt
+ * emits a QtFatalMsg, we will write the message to the log and then abort().
+ */
+void
+Vidalia::qt_msg_handler(QtMsgType type, const char *s)
+{
+ QString msg(s);
+ switch (type) {
+ case QtDebugMsg:
+ vDebug("QtDebugMsg: %1").arg(msg);
+ break;
+ case QtWarningMsg:
+ vNotice("QtWarningMsg: %1").arg(msg);
+ break;
+ case QtCriticalMsg:
+ vWarn("QtCriticalMsg: %1").arg(msg);
+ break;
+ case QtFatalMsg:
+ vError("QtFatalMsg: %1").arg(msg);
+ break;
+ }
+ if (type == QtFatalMsg) {
+ vError("Fatal Qt error. Aborting.");
+ abort();
+ }
+}
/** Constructor. Parses the command-line arguments, resets Vidalia's
* configuration (if requested), and sets up the GUI style and language
@@ -62,6 +88,8 @@
Vidalia::Vidalia(QStringList args, int &argc, char **argv)
: QApplication(argc, argv)
{
+ qInstallMsgHandler(qt_msg_handler);
+
/* Read in all our command-line arguments. */
parseArguments(args);
Modified: trunk/src/vidalia.h
===================================================================
--- trunk/src/vidalia.h 2007-02-20 17:33:23 UTC (rev 1644)
+++ trunk/src/vidalia.h 2007-02-20 17:33:28 UTC (rev 1645)
@@ -115,6 +115,10 @@
#endif
private:
+ /** Catches debugging messages from Qt and sends them to
+ * Vidalia's logs. */
+ static void qt_msg_handler(QtMsgType type, const char *msg);
+
/** Parse the list of command-line arguments. */
void parseArguments(QStringList args);
/** Returns true if the specified arguments wants a value. */