Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikkel Krautz <mikkel@krautz.dk>2016-12-04 20:51:55 +0300
committerMikkel Krautz <mikkel@krautz.dk>2016-12-04 20:56:27 +0300
commit967e93e17f41496d1b157d6db630092b664d6ab1 (patch)
tree6a54eb15a651c28175e64ce8580fcd4c6831ca3b
parent681ecf60c025fc8aa20cda028d43daf2b720f7ce (diff)
Add LogEmitter to Mumble and use it in os_win.cpp.
This is in preparation for the Developer Console.
-rw-r--r--src/LogEmitter.h3
-rw-r--r--src/mumble/Global.h2
-rw-r--r--src/mumble/main.cpp5
-rw-r--r--src/mumble/os_win.cpp15
4 files changed, 23 insertions, 2 deletions
diff --git a/src/LogEmitter.h b/src/LogEmitter.h
index a6335bbb7..bdc8ec67d 100644
--- a/src/LogEmitter.h
+++ b/src/LogEmitter.h
@@ -6,6 +6,9 @@
#ifndef MUMBLE_LOGEMITTER_H_
#define MUMBLE_LOGEMITTER_H_
+#include <QtCore/QObject>
+#include <QtCore/QString>
+
class LogEmitter : public QObject {
private:
Q_OBJECT
diff --git a/src/mumble/Global.h b/src/mumble/Global.h
index de2aaf5b8..63ed256d3 100644
--- a/src/mumble/Global.h
+++ b/src/mumble/Global.h
@@ -30,6 +30,7 @@ class LCD;
class BonjourClient;
class OverlayClient;
class CELTCodec;
+class LogEmitter;
class QNetworkAccessManager;
@@ -51,6 +52,7 @@ public:
LCD *lcd;
BonjourClient *bc;
QNetworkAccessManager *nam;
+ QSharedPointer<LogEmitter> le;
int iPushToTalk;
Timer tDoublePush;
quint64 uiDoublePush;
diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp
index 98337266c..25b08f2d7 100644
--- a/src/mumble/main.cpp
+++ b/src/mumble/main.cpp
@@ -36,6 +36,7 @@
#include "Themes.h"
#include "UserLockFile.h"
#include "License.h"
+#include "LogEmitter.h"
#if defined(USE_STATIC_QT_PLUGINS) && QT_VERSION < 0x050000
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
@@ -104,6 +105,8 @@ int main(int argc, char **argv) {
qsrand(QDateTime::currentDateTime().toTime_t());
+ g.le = QSharedPointer<LogEmitter>(new LogEmitter());
+
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
os_init();
#endif
@@ -560,6 +563,8 @@ int main(int argc, char **argv) {
delete g.o;
+ g.le.clear();
+
DeferInit::run_destroyers();
delete Global::g_global_struct;
diff --git a/src/mumble/os_win.cpp b/src/mumble/os_win.cpp
index bf6e6d3eb..ba3bb3a28 100644
--- a/src/mumble/os_win.cpp
+++ b/src/mumble/os_win.cpp
@@ -13,6 +13,7 @@
#include "Global.h"
#include "Version.h"
+#include "LogEmitter.h"
extern "C" {
void __cpuid(int a[4], int b);
@@ -27,6 +28,8 @@ static FILE *fConsole = NULL;
static wchar_t wcComment[PATH_MAX] = L"";
static MINIDUMP_USER_STREAM musComment;
+static QSharedPointer<LogEmitter> le;
+
static int cpuinfo[4];
bool bIsWin7 = false;
@@ -49,9 +52,12 @@ static void mumbleMessageOutputQString(QtMsgType type, const QString &msg) {
default:
c='X';
}
- fprintf(fConsole, "<%c>%s %s\n", c, qPrintable(QDateTime::currentDateTime().toString(QLatin1String("yyyy-MM-dd hh:mm:ss.zzz"))), qPrintable(msg));
+ QString date = QDateTime::currentDateTime().toString(QLatin1String("yyyy-MM-dd hh:mm:ss.zzz"));
+ QString fmsg = QString::fromLatin1("<%1>%2 %3").arg(c).arg(date).arg(msg);
+ fprintf(fConsole, "%s\n", qPrintable(fmsg));
fflush(fConsole);
- OutputDebugStringA(qPrintable(msg));
+ OutputDebugStringA(qPrintable(fmsg));
+ le->addLogEntry(fmsg);
if (type == QtFatalMsg) {
::MessageBoxA(NULL, qPrintable(msg), "Mumble", MB_OK | MB_ICONERROR);
exit(0);
@@ -231,6 +237,11 @@ void os_init() {
enableCrashOnCrashes();
mumble_speex_init();
+ // Make a copy of the global LogEmitter, such that
+ // os_win.cpp doesn't have to consider the deletion
+ // of the Global object and its LogEmitter object.
+ le = g.le;
+
#ifdef QT_NO_DEBUG
QString console = g.qdBasePath.filePath(QLatin1String("Console.txt"));
fConsole = _wfsopen(console.toStdWString().c_str(), L"a+", _SH_DENYWR);