Commit 1cb1995b by ss.dai

修改推出后进程残留

parent e7c71abe
...@@ -27,7 +27,6 @@ void FmPlugin::SetRemoteInfo(const QString &ip, int port) ...@@ -27,7 +27,6 @@ void FmPlugin::SetRemoteInfo(const QString &ip, int port)
bool FmPlugin::DoOrderEntry(const OrderObject *orderObject, QString &error, bool bVerify) bool FmPlugin::DoOrderEntry(const OrderObject *orderObject, QString &error, bool bVerify)
{ {
return true;
QTcpSocket socket; QTcpSocket socket;
// 连接 // 连接
socket.connectToHost(m_host, m_port); socket.connectToHost(m_host, m_port);
......
...@@ -14,8 +14,15 @@ void SInfoControl::SetListenPort(int port) ...@@ -14,8 +14,15 @@ void SInfoControl::SetListenPort(int port)
m_port = port; m_port = port;
} }
SInfoControl::~SInfoControl()
{
m_bContinue = false;
m_mutex.lock();
}
void SInfoControl::run() void SInfoControl::run()
{ {
m_mutex.lock();
m_tcpServer = new QTcpServer(this); m_tcpServer = new QTcpServer(this);
if(!m_tcpServer->listen(QHostAddress::LocalHost, m_port)) if(!m_tcpServer->listen(QHostAddress::LocalHost, m_port))
...@@ -29,9 +36,10 @@ void SInfoControl::run() ...@@ -29,9 +36,10 @@ void SInfoControl::run()
QString replyData; QString replyData;
QJsonParseError jsonError; QJsonParseError jsonError;
QJsonDocument jsonDoc; QJsonDocument jsonDoc;
while(true) m_bContinue = true;
while(m_bContinue)
{ {
if(!m_tcpServer->waitForNewConnection(60000)) if(!m_tcpServer->waitForNewConnection(1000))
{ {
continue; continue;
} }
...@@ -96,5 +104,8 @@ void SInfoControl::run() ...@@ -96,5 +104,8 @@ void SInfoControl::run()
m_tcpSocket->close(); m_tcpSocket->close();
continue; continue;
} }
m_tcpServer->close();
m_tcpServer->deleteLater();
QLOG_INFO() << "refundControl exit."; QLOG_INFO() << "refundControl exit.";
m_mutex.unlock();
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <QObject> #include <QObject>
#include <QTcpServer> #include <QTcpServer>
#include <QTcpSocket> #include <QTcpSocket>
#include <QMutex>
class SInfoControl : public QObject class SInfoControl : public QObject
{ {
...@@ -15,6 +16,7 @@ public: ...@@ -15,6 +16,7 @@ public:
private: private:
SInfoControl(){} SInfoControl(){}
~SInfoControl();
SInfoControl(SInfoControl const&); SInfoControl(SInfoControl const&);
SInfoControl& operator=(SInfoControl const&); SInfoControl& operator=(SInfoControl const&);
...@@ -22,6 +24,9 @@ private: ...@@ -22,6 +24,9 @@ private:
QTcpSocket *m_tcpSocket; QTcpSocket *m_tcpSocket;
int m_port; int m_port;
QMutex m_mutex;
bool m_bContinue;
public slots: public slots:
/* 功能:开启控制器 /* 功能:开启控制器
* 参数:NULL * 参数:NULL
......
#include "SysTray.h" #include "SysTray.h"
#include <QApplication> #include <QApplication>
#include <QThread>
extern QThread sInfoThread;
extern QThread workThread;
SysTray::SysTray(QObject *parent) : SysTray::SysTray(QObject *parent) :
QSystemTrayIcon(parent) QSystemTrayIcon(parent)
...@@ -22,5 +25,7 @@ void SysTray::_CreatMenu() ...@@ -22,5 +25,7 @@ void SysTray::_CreatMenu()
void SysTray::onActionQuitTriggered() void SysTray::onActionQuitTriggered()
{ {
qApp->exit(); sInfoThread.terminate();
workThread.terminate();
qApp->exit(-1);
} }
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
#include "DTools/configManger.h" #include "DTools/configManger.h"
#include "preDefine.h" #include "preDefine.h"
#include "QsLog.h" #include "QsLog.h"
#include <QProcess>
#include <QThread>
extern QThread sInfoThread;
extern QThread workThread;
FloatForm::FloatForm(QWidget *parent) : FloatForm::FloatForm(QWidget *parent) :
QDialog(parent), QDialog(parent),
...@@ -57,7 +62,10 @@ void FloatForm::mousePressEvent(QMouseEvent *event) ...@@ -57,7 +62,10 @@ void FloatForm::mousePressEvent(QMouseEvent *event)
} }
if(event->button()==Qt::RightButton) if(event->button()==Qt::RightButton)
{ {
emit restart(); sInfoThread.terminate();
workThread.terminate();
qApp->exit(-1);
QProcess::startDetached(qApp->applicationFilePath(), QStringList(qApp->applicationFilePath()));
} }
} }
...@@ -77,8 +85,7 @@ void FloatForm::mouseReleaseEvent(QMouseEvent *event) ...@@ -77,8 +85,7 @@ void FloatForm::mouseReleaseEvent(QMouseEvent *event)
} }
m_bMouseMove = false; m_bMouseMove = false;
ConfigManger::GetInstance().setFloatInitPostion(event->globalPos()); ConfigManger::GetInstance().setFloatInitPostion(this->pos());
m_mouseTimer.stop();
} }
void FloatForm::_Init() void FloatForm::_Init()
......
...@@ -52,13 +52,13 @@ void LoadTheme(const QString& theme) ...@@ -52,13 +52,13 @@ void LoadTheme(const QString& theme)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
HANDLE m_hMutex = CreateMutex(NULL, FALSE, L"fmTakeaway" ); // HANDLE m_hMutex = CreateMutex(NULL, FALSE, L"fmTakeaway" );
if (GetLastError() == ERROR_ALREADY_EXISTS) { // if (GetLastError() == ERROR_ALREADY_EXISTS) {
CloseHandle(m_hMutex); // CloseHandle(m_hMutex);
m_hMutex = NULL; // m_hMutex = NULL;
return -1; // return -1;
} // }
QApplication a(argc, argv); QApplication a(argc, argv);
g_appDir = a.applicationDirPath(); g_appDir = a.applicationDirPath();
......
...@@ -102,7 +102,7 @@ void MainForm::MyShow() ...@@ -102,7 +102,7 @@ void MainForm::MyShow()
void MainForm::_Init() void MainForm::_Init()
{ {
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
//this->showFullScreen(); this->showFullScreen();
// 显示托盘 // 显示托盘
m_tray.show(); m_tray.show();
...@@ -218,10 +218,8 @@ void MainForm::onShowSearchOrderResult(const QMap<QString,QString>& orderIdList) ...@@ -218,10 +218,8 @@ void MainForm::onShowSearchOrderResult(const QMap<QString,QString>& orderIdList)
void MainForm::onrestart() void MainForm::onrestart()
{ {
sInfoThread.terminate();
workThread.terminate();
qApp->exit();
QProcess::startDetached(qApp->applicationFilePath(), QStringList());
} }
void MainForm::_RevertBtnTable() void MainForm::_RevertBtnTable()
......
;打印机信息 ;打印机信息
[Printer] [Printer]
name=Fax name=
;悬浮窗参数 ;悬浮窗参数
[Float] [Float]
postion=@Point(197 621) postion=@Point(100 100)
opacity=0.5 opacity=0.5
blinkInterval=0.3 blinkInterval=0.3
soundInterval=2 soundInterval=2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment