From f1f5a1eacb12763e6827104db60db87012a52af4 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 1 Feb 2015 15:11:07 +0100 Subject: [PATCH] Updated IPC handler threads for latest MUtilities changes. --- src/Config.h | 2 +- src/Thread_MessageHandler.cpp | 19 ++++++++++++------- src/Thread_MessageHandler.h | 1 - src/Thread_MessageProducer.cpp | 12 ++++++------ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/Config.h b/src/Config.h index 452ca618..4d680b12 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 1 #define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_PATCH 14 -#define VER_LAMEXP_BUILD 1674 +#define VER_LAMEXP_BUILD 1676 #define VER_LAMEXP_CONFG 1558 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Thread_MessageHandler.cpp b/src/Thread_MessageHandler.cpp index b3db8bb9..3b4ab483 100644 --- a/src/Thread_MessageHandler.cpp +++ b/src/Thread_MessageHandler.cpp @@ -48,23 +48,22 @@ MessageHandlerThread::MessageHandlerThread(MUtils::IPCChannel *const ipcChannel) m_ipcChannel(ipcChannel) { m_aborted = false; - m_parameter = new char[MUtils::IPCChannel::MAX_MESSAGE_LEN]; } MessageHandlerThread::~MessageHandlerThread(void) { - delete [] m_parameter; } void MessageHandlerThread::run() { m_aborted = false; setTerminationEnabled(true); + QStringList params; + quint32 command = 0, flags = 0; while(!m_aborted) { - unsigned int command = 0, flags = 0; - if(!m_ipcChannel->read(command, flags, m_parameter, MUtils::IPCChannel::MAX_MESSAGE_LEN)) + if(!m_ipcChannel->read(command, flags, params)) { qWarning("Failed to read next IPC message!"); break; @@ -81,10 +80,16 @@ void MessageHandlerThread::run() emit otherInstanceDetected(); break; case IPC_CMD_ADD_FILE: - emit fileReceived(QString::fromUtf8(m_parameter)); + if(params.count() > 0 ) + { + emit fileReceived(params.first()); + } break; case IPC_CMD_ADD_FOLDER: - emit folderReceived(QString::fromUtf8(m_parameter), TEST_FLAG(IPC_FLAG_ADD_RECURSIVE)); + if(params.count() > 0 ) + { + emit folderReceived(params.first(), TEST_FLAG(IPC_FLAG_ADD_RECURSIVE)); + } break; case IPC_CMD_TERMINATE: if(TEST_FLAG(IPC_FLAG_FORCE)) @@ -105,7 +110,7 @@ void MessageHandlerThread::stop(void) if(!m_aborted) { m_aborted = true; - m_ipcChannel->send(0, 0, NULL); + m_ipcChannel->send(0, 0, QStringList()); } } diff --git a/src/Thread_MessageHandler.h b/src/Thread_MessageHandler.h index 66bb2bb3..51793c28 100644 --- a/src/Thread_MessageHandler.h +++ b/src/Thread_MessageHandler.h @@ -43,7 +43,6 @@ protected: MUtils::IPCChannel *const m_ipcChannel; private: - char *m_parameter; volatile bool m_aborted; signals: diff --git a/src/Thread_MessageProducer.cpp b/src/Thread_MessageProducer.cpp index 34caea63..45dc91dd 100644 --- a/src/Thread_MessageProducer.cpp +++ b/src/Thread_MessageProducer.cpp @@ -63,7 +63,7 @@ void MessageProducerThread::run() //Kill application? if(arguments.contains("kill")) { - if(!m_ipcChannel->send(IPC_CMD_TERMINATE, IPC_FLAG_NONE, NULL)) + if(!m_ipcChannel->send(IPC_CMD_TERMINATE, IPC_FLAG_NONE)) { qWarning("Failed to send IPC message!"); } @@ -71,7 +71,7 @@ void MessageProducerThread::run() } if(arguments.contains("force-kill")) { - if(!m_ipcChannel->send(IPC_CMD_TERMINATE, IPC_FLAG_FORCE, NULL)) + if(!m_ipcChannel->send(IPC_CMD_TERMINATE, IPC_FLAG_FORCE)) { qWarning("Failed to send IPC message!"); } @@ -86,7 +86,7 @@ void MessageProducerThread::run() const QFileInfo file = QFileInfo(value); if(file.exists() && file.isFile()) { - if(!m_ipcChannel->send(IPC_CMD_ADD_FILE, IPC_FLAG_NONE, MUTILS_UTF8(file.canonicalFilePath()))) + if(!m_ipcChannel->send(IPC_CMD_ADD_FILE, IPC_FLAG_NONE, QStringList() << file.canonicalFilePath())) { qWarning("Failed to send IPC message!"); } @@ -101,7 +101,7 @@ void MessageProducerThread::run() const QDir dir = QDir(value); if(dir.exists()) { - if(!m_ipcChannel->send(IPC_CMD_ADD_FOLDER, IPC_FLAG_NONE, MUTILS_UTF8(dir.canonicalPath()))) + if(!m_ipcChannel->send(IPC_CMD_ADD_FOLDER, IPC_FLAG_NONE, QStringList() << dir.canonicalPath())) { qWarning("Failed to send IPC message!"); } @@ -116,7 +116,7 @@ void MessageProducerThread::run() const QDir dir = QDir(value); if(dir.exists()) { - if(!m_ipcChannel->send(IPC_CMD_ADD_FOLDER, IPC_FLAG_ADD_RECURSIVE, MUTILS_UTF8(dir.canonicalPath()))) + if(!m_ipcChannel->send(IPC_CMD_ADD_FOLDER, IPC_FLAG_ADD_RECURSIVE, QStringList() << dir.canonicalPath())) { qWarning("Failed to send IPC message!"); } @@ -127,7 +127,7 @@ void MessageProducerThread::run() if(!bSentFiles) { - if(!m_ipcChannel->send(IPC_CMD_PING, IPC_FLAG_NONE, "Use running instance!")) + if(!m_ipcChannel->send(IPC_CMD_PING, IPC_FLAG_NONE, QStringList() << QLatin1String("Use running instance!"))) { qWarning("Failed to send IPC message!"); }