mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 01:59:59 +02:00
add a message handler to send messages over to LogDisplay
This commit is contained in:
parent
89d3cfdb6f
commit
51d1e6ae80
4 changed files with 15 additions and 8 deletions
|
@ -164,6 +164,11 @@ void GLCanvas::wheelEvent(QWheelEvent* event) {
|
|||
Application::getInstance()->wheelEvent(event);
|
||||
}
|
||||
|
||||
void messageHandler(QtMsgType type, const char* message) {
|
||||
printf("%s\n", message);
|
||||
LogDisplay::instance.addMessage(message);
|
||||
}
|
||||
|
||||
Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||
QApplication(argc, argv),
|
||||
_window(new QMainWindow(desktop())),
|
||||
|
@ -212,6 +217,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_window->setWindowTitle("Interface");
|
||||
qDebug("Interface Startup:");
|
||||
|
||||
qInstallMsgHandler(messageHandler);
|
||||
|
||||
unsigned int listenPort = 0; // bind to an ephemeral port by default
|
||||
const char** constArgv = const_cast<const char**>(argv);
|
||||
const char* portStr = getCmdOption(argc, constArgv, "--listenPort");
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "Util.h"
|
||||
|
||||
using namespace std;
|
||||
FILE* const LogDisplay::DEFAULT_STREAM = stdout;
|
||||
FILE* const LogDisplay::DEFAULT_STREAM = 0l;
|
||||
|
||||
//
|
||||
// Singleton constructor
|
||||
|
@ -88,7 +88,7 @@ void LogDisplay::setCharacterSize(unsigned width, unsigned height) {
|
|||
// Logging
|
||||
//
|
||||
|
||||
inline void LogDisplay::addMessage(char const* ptr) {
|
||||
void LogDisplay::addMessage(const char* ptr) {
|
||||
|
||||
pthread_mutex_lock(& _mutex);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ public:
|
|||
|
||||
void render(unsigned screenWidth, unsigned screenHeight);
|
||||
|
||||
// log formatted message
|
||||
inline void addMessage(char const*);
|
||||
// log formatted message
|
||||
void addMessage(const char* message);
|
||||
|
||||
// settings
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort
|
|||
if (!_sharedInstance) {
|
||||
_sharedInstance = new NodeList(ownerType, socketListenPort);
|
||||
} else {
|
||||
qDebug("NodeList createInstance called with existing instance.");
|
||||
qDebug("NodeList createInstance called with existing instance.\n");
|
||||
}
|
||||
|
||||
return _sharedInstance;
|
||||
|
@ -51,7 +51,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort
|
|||
|
||||
NodeList* NodeList::getInstance() {
|
||||
if (!_sharedInstance) {
|
||||
qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer.");
|
||||
qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer.\n");
|
||||
}
|
||||
|
||||
return _sharedInstance;
|
||||
|
@ -275,9 +275,9 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
sockaddr_in tempAddress;
|
||||
memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
|
||||
strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr));
|
||||
qDebug("Domain Server: %s ", _domainHostname);
|
||||
qDebug("Domain Server: %s", _domainHostname);
|
||||
} else {
|
||||
qDebug("Failed domain server lookup");
|
||||
qDebug("Failed domain server lookup\n");
|
||||
}
|
||||
} else if (!printedDomainServerIP) {
|
||||
qDebug("Domain Server IP: %s", _domainIP);
|
||||
|
|
Loading…
Reference in a new issue