From 50cd13804541ebab1cacf83b8942a7d444010f95 Mon Sep 17 00:00:00 2001 From: Maurice ONeal Date: Sun, 9 Aug 2020 16:29:47 -0400 Subject: [PATCH] Bug fixes for Windows fixed a bug in windows that caused the application to fail detect that there is a host instance running when there is indeed a host instance running. also fixed a compile bug that cause QtCore to double import and in turn call out duplicate definition errors in windows when including applink.c. --- src/applink.c | 4 +--- src/common.cpp | 22 ++++++++++------------ src/db.h | 2 +- src/main.cpp | 1 + src/tcp_server.cpp | 4 ++-- src/tcp_server.h | 1 - 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/applink.c b/src/applink.c index e2b4f9a..b180e18 100644 --- a/src/applink.c +++ b/src/applink.c @@ -7,9 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include - -#ifdef Q_OS_WINDOWS +#ifdef NEED_APPLINK #define APPLINK_STDIN 1 #define APPLINK_STDOUT 2 diff --git a/src/common.cpp b/src/common.cpp index 69f51f0..4b87dc8 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -996,23 +996,21 @@ ShellIPC::ShellIPC(const QStringList &args, bool supressErr, QObject *parent) : bool ShellIPC::connectToHost() { - auto pipeInfo = QFileInfo(QDir::tempPath() + "/" + HOST_CONTROL_PIPE); + auto pipeInfo = QFileInfo(HOST_CONTROL_PIPE); - if (!pipeInfo.exists()) + connectToServer(HOST_CONTROL_PIPE); + + if (!waitForConnected() && !holdErrs) { - if (!holdErrs) + QTextStream(stdout) << "" << Qt::endl << "err: Failed to connect to the host instance control pipe." << Qt::endl; + + if (error() == QLocalSocket::ServerNotFoundError) { - QTextStream(stdout) << "" << Qt::endl << "A host instance is not running." << Qt::endl << Qt::endl; + QTextStream(stdout) << "err: Reason - Host instance not running." << Qt::endl << Qt::endl; } - } - else - { - connectToServer(HOST_CONTROL_PIPE); - - if (!waitForConnected() && !holdErrs) + else { - QTextStream(stdout) << "" << Qt::endl << "err: Failed to connect to the host instance control pipe." << Qt::endl; - QTextStream(stdout) << "err: Reason - " << errorString() << Qt::endl; + QTextStream(stdout) << "err: Reason - " << errorString() << Qt::endl << Qt::endl; } } diff --git a/src/db.h b/src/db.h index e529dbc..ffa2158 100644 --- a/src/db.h +++ b/src/db.h @@ -39,7 +39,7 @@ #include "shell.h" #define APP_NAME "MRCI" -#define APP_VER "4.0.2.0" +#define APP_VER "4.1.2.0" #define APP_TARGET "mrci" #ifdef Q_OS_WIN diff --git a/src/main.cpp b/src/main.cpp index 9a6af0e..8b9c45e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,7 @@ // . #ifdef Q_OS_WINDOWS +#define NEED_APPLINK extern "C" { // applink.c was copied from the openssl lib and slightly modified so diff --git a/src/tcp_server.cpp b/src/tcp_server.cpp index cc85f18..f23bb70 100644 --- a/src/tcp_server.cpp +++ b/src/tcp_server.cpp @@ -66,10 +66,10 @@ bool TCPServer::createPipe() { auto ret = controlPipe->listen(HOST_CONTROL_PIPE); - controlPipePath = controlPipe->fullServerName(); - if (!ret) { + auto controlPipePath = controlPipe->fullServerName(); + if (QFile::exists(controlPipePath)) { QFile::remove(controlPipePath); diff --git a/src/tcp_server.h b/src/tcp_server.h index 25f94cf..069d289 100644 --- a/src/tcp_server.h +++ b/src/tcp_server.h @@ -37,7 +37,6 @@ private: char *hostLoad; QList sslChain; QSslKey sslKey; - QString controlPipePath; QString hostKey; QString wanIP; quint32 maxSessions;