rendered paste bodyFrom 9c652c301d0d2beb740bb6ca4002c98c5158b714 Mon Sep 17 00:00:00 2001
From: TheOneRing <patrick.vonreth@gmail.com>
Date: Mon, 25 Jan 2010 11:10:51 +0100
Subject: [PATCH] fixed mingw32 compilation on windows, added correct TCHAR handling
---
src/common/identity.cpp | 16 ++++++++++++++--
src/common/logbacktrace_win.cpp | 15 ++++++++++++++-
src/common/quassel.h | 6 +++++-
src/common/syncableobject.h | 4 ++--
4 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/src/common/identity.cpp b/src/common/identity.cpp
index 275afcc..db37577 100644
--- a/src/common/identity.cpp
+++ b/src/common/identity.cpp
@@ -76,6 +76,18 @@ Identity::Identity(const Identity &other, QObject *parent)
init();
}
+#ifdef Q_OS_WIN32
+#ifdef UNICODE
+QString tcharToQString(TCHAR *tchar){
+ return QString::fromUtf16( reinterpret_cast<ushort*>(tchar));
+}
+#else
+QString tcharToQString(TCHAR *tchar){
+ return QString::fromLocal8(tchar);
+}
+#endif
+
+#endif
void Identity::init() {
setObjectName(QString::number(id().toInt()));
setAllowClientUpdates(true);
@@ -102,7 +114,7 @@ QString Identity::defaultNick() {
DWORD bufCharCount = 128;
//if(GetUserNameEx(/* NameSamCompatible */ 1, infoBuf, &bufCharCount))
if(GetUserNameEx(NameSamCompatible, infoBuf, &bufCharCount)) {
- QString nickName(infoBuf);
+ QString nickName( tcharToQString(infoBuf));
int lastBs = nickName.lastIndexOf('\\');
if(lastBs != -1) {
nickName = nickName.mid(lastBs + 1);
@@ -138,7 +150,7 @@ QString Identity::defaultRealName() {
TCHAR infoBuf[128];
DWORD bufCharCount = 128;
if(GetUserName(infoBuf, &bufCharCount))
- return QString(infoBuf);
+ return tcharToQString(infoBuf);
else
return generalDefault;
#else
diff --git a/src/common/logbacktrace_win.cpp b/src/common/logbacktrace_win.cpp
index 31d1f95..6f95d68 100644
--- a/src/common/logbacktrace_win.cpp
+++ b/src/common/logbacktrace_win.cpp
@@ -90,13 +90,26 @@ void Quassel::logBacktrace(const QString &filename) {
#ifdef _M_IX86
ZeroMemory(&Context, sizeof(CONTEXT));
Context.ContextFlags = CONTEXT_CONTROL;
- __asm {
+
+//TODO:port asssembler to mingw32
+#ifdef __MINGW32__
+// asm("Label:\n\t"
+// "movl %%ebp,%0;\n\t"
+// "movl %%esp,%1;\n\t"
+// "movl $Label,%%eax;\n\t"
+// "movl %%eax,;\n\t"
+// :"=r"(Content.Epb),"=r"(Context.Esp),"=r"(Context.Eip)
+// ://no input
+// :"ebp","esp","eax");
+#else
+ _asm {
Label:
mov [Context.Ebp], ebp;
mov [Context.Esp], esp;
mov eax, [Label];
mov [Context.Eip], eax;
}
+#endif
#else
RtlCaptureContext(&Context);
#endif
diff --git a/src/common/quassel.h b/src/common/quassel.h
index b42ee47..22b322e 100644
--- a/src/common/quassel.h
+++ b/src/common/quassel.h
@@ -26,7 +26,11 @@
#include <QString>
#include "abstractcliparser.h"
-
+#ifdef __MINGW32__
+//TODO:why TCHAR doesn't work with logbacktrace_win.h
+//#include <windows.h>
+typedef const char *PCTSTR;
+#endif
class Quassel {
Q_DECLARE_TR_FUNCTIONS(Quassel)
diff --git a/src/common/syncableobject.h b/src/common/syncableobject.h
index 28e1472..2ab00e8 100644
--- a/src/common/syncableobject.h
+++ b/src/common/syncableobject.h
@@ -33,13 +33,13 @@
#define SYNCABLE_OBJECT static const int _classNameOffset__;
#define INIT_SYNCABLE_OBJECT(x) const int x ::_classNameOffset__ = QByteArray(staticMetaObject.className()).length() + 2;
-#ifdef Q_WS_WIN
+#ifdef _MSC_VER
# define SYNC(...) sync_call__(SignalProxy::Server, (__FUNCTION__ + _classNameOffset__), __VA_ARGS__);
# define REQUEST(...) sync_call__(SignalProxy::Client, (__FUNCTION__ + _classNameOffset__) , __VA_ARGS__);
#else
# define SYNC(...) sync_call__(SignalProxy::Server, __func__, __VA_ARGS__);
# define REQUEST(...) sync_call__(SignalProxy::Client, __func__, __VA_ARGS__);
-#endif //Q_WS_WIN
+#endif //_MSC_VER
#define SYNC_OTHER(x, ...) sync_call__(SignalProxy::Server, #x, __VA_ARGS__);
#define REQUEST_OTHER(x, ...) sync_call__(SignalProxy::Client, #x, __VA_ARGS__);
--
1.6.4.msysgit.0