Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FmTakeaway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shangshang.dai
FmTakeaway
Commits
9e1683e2
Commit
9e1683e2
authored
Oct 09, 2016
by
ss.dai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复小票不显示收银员 程序退出残留进程
parent
2dd7a65e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
12 deletions
+24
-12
fmTakeaway/Control/refundControl.cpp
+9
-9
fmTakeaway/Control/refundControl.h
+2
-0
fmTakeaway/DTools/sysTray.cpp
+8
-1
fmTakeaway/main.cpp
+5
-2
No files found.
fmTakeaway/Control/refundControl.cpp
View file @
9e1683e2
...
...
@@ -17,16 +17,18 @@ void RefundControl::SetListenPort(int port)
RefundControl
::~
RefundControl
()
{
m_bContinue
=
false
;
m_mutex
.
lock
();
QLOG_INFO
()
<<
__FUNCTION__
<<
m_bContinue
;
}
// 同步模式
void
RefundControl
::
run
()
{
m_mutex
.
lock
();
m_procOrderSocket
=
new
BillSocket
(
this
);
m_tcpServer
=
new
QTcpServer
(
this
);
qDebug
()
<<
11
<<
m_tcpServer
->
serverError
();
if
(
!
m_tcpServer
->
listen
(
QHostAddress
::
LocalHost
,
m_port
))
{
QLOG_WARN
()
<<
QString
(
"tcp server listen failed on port[%1]"
).
arg
(
m_port
);
...
...
@@ -45,18 +47,12 @@ void RefundControl::run()
while
(
m_bContinue
)
{
QLOG_INFO
()
<<
"waiting new connection...."
;
if
(
!
m_tcpServer
->
waitForNewConnection
(
60
000
))
if
(
!
m_tcpServer
->
waitForNewConnection
(
1
000
))
{
continue
;
}
QLOG_INFO
()
<<
"onNewConnecion....."
;
// if(QAbstractSocket::UnknownSocketError != m_tcpServer->serverError())
// {
// QLOG_INFO() << QString("0socket error %1").arg(m_tcpServer->serverError().errorString());
// continue;
// }
// QLOG_INFO() << QString("1socket error %1").arg(m_tcpServer->serverError().errorString());
QString
error
;
QString
orderId
,
reason
;
int
version
,
reqtype
;
m_tcpSocket
=
m_tcpServer
->
nextPendingConnection
();
...
...
@@ -130,5 +126,9 @@ void RefundControl::run()
m_tcpSocket
->
close
();
continue
;
}
m_tcpServer
->
close
();
m_tcpServer
->
deleteLater
();
m_mutex
.
unlock
();
QLOG_INFO
()
<<
"refundControl exit."
;
}
fmTakeaway/Control/refundControl.h
View file @
9e1683e2
...
...
@@ -7,6 +7,7 @@
#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
#include <QMutex>
#include "Network/billSocket.h"
class
RefundControl
:
public
QObject
...
...
@@ -26,6 +27,7 @@ private:
QTcpSocket
*
m_tcpSocket
;
int
m_port
;
bool
m_bContinue
;
QMutex
m_mutex
;
BillSocket
*
m_procOrderSocket
;
...
...
fmTakeaway/DTools/sysTray.cpp
View file @
9e1683e2
#include "SysTray.h"
#include <QApplication>
#include <QThread>
extern
QThread
workThread
;
extern
QThread
refundThread
;
SysTray
::
SysTray
(
QObject
*
parent
)
:
QSystemTrayIcon
(
parent
)
...
...
@@ -22,5 +27,7 @@ void SysTray::_CreatMenu()
void
SysTray
::
onActionQuitTriggered
()
{
qApp
->
exit
();
workThread
.
terminate
();
refundThread
.
terminate
();
qApp
->
exit
(
-
1
);
}
fmTakeaway/main.cpp
View file @
9e1683e2
...
...
@@ -16,6 +16,9 @@ using namespace QsLogging;
QString
g_appDir
;
QThread
workThread
;
QThread
refundThread
;
void
InitLogger
()
{
QString
logDir
=
QString
(
"%1/log"
).
arg
(
g_appDir
);
...
...
@@ -70,12 +73,12 @@ int main(int argc, char *argv[])
QLOG_INFO
()
<<
QString
(
"-------- fmTakeaway[%1] Start --------"
).
arg
(
APP_VERSION
);
// 将控制器移到工作线程
QThread
workThread
;
FlowControl
::
GetInstance
().
moveToThread
(
&
workThread
);
workThread
.
start
();
// 将退款控制器移到工作线程
QThread
refundThread
;
RefundControl
::
GetInstance
().
SetListenPort
(
ConfigManger
::
GetInstance
().
GetListenPort
());
RefundControl
::
GetInstance
().
moveToThread
(
&
refundThread
);
QObject
::
connect
(
&
refundThread
,
&
QThread
::
started
,
&
RefundControl
::
GetInstance
(),
&
RefundControl
::
run
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment