Commit 401c325c by 李定达

1.修复重复弹窗

parent 3c7f304f
...@@ -17,13 +17,17 @@ typedef int (* GetRSACret)(int ,const char *,const char *); ...@@ -17,13 +17,17 @@ typedef int (* GetRSACret)(int ,const char *,const char *);
Control::Control(QObject *parent) : QObject(parent) Control::Control(QObject *parent) : QObject(parent)
{ {
InitModel(); InitModel();
connect(&_widget, &HostWidget::RequestWithType, this, &Control::RequestWithType);
} }
void Control::Start(const char *indata, char *outdata) void Control::Start(const char *indata, char *outdata)
{ {
QEventLoop loop; QEventLoop loop;
if(_widget == NULL)
_widget = new HostWidget();
connect(_widget, &HostWidget::RequestWithType, this, &Control::RequestWithType);
QLOG_INFO() << "get data from pos : " << indata; QLOG_INFO() << "get data from pos : " << indata;
if(strlen(indata) > sizeof(struct AlipayRequest)) if(strlen(indata) > sizeof(struct AlipayRequest))
...@@ -32,20 +36,34 @@ void Control::Start(const char *indata, char *outdata) ...@@ -32,20 +36,34 @@ void Control::Start(const char *indata, char *outdata)
memcpy(outdata, &_response, sizeof(struct AlipayRequest)); memcpy(outdata, &_response, sizeof(struct AlipayRequest));
QLOG_ERROR() << "send error msg to pos : " << outdata; QLOG_ERROR() << "send error msg to pos : " << outdata;
_lock.lock();
delete _widget;
_widget = NULL;
_lock.lock();
return ; return ;
} }
memcpy(&_request, indata, strlen(indata)); memcpy(&_request, indata, strlen(indata));
_widget.ShowWithRequest(_request); _widget->ShowWithRequest(_request);
connect(&_widget, &HostWidget::ExitWithMSG, this, [this, &loop] (QString message) connect(_widget, &HostWidget::ExitWithMSG, this, [this, &loop] (QString message)
{ {
QLOG_INFO() << "quit with : " << message; QLOG_INFO() << "quit with : " << message;
loop.exit(); loop.exit();
}); });
loop.exec(); loop.exec();
_lock.lock();
delete _widget;
_widget = NULL;
_lock.unlock();
} }
void Control::GetErrorResponse(QString message, AlipayResponse &response) void Control::GetErrorResponse(QString message, AlipayResponse &response)
...@@ -132,7 +150,12 @@ bool Control::GetRSA() ...@@ -132,7 +150,12 @@ bool Control::GetRSA()
else else
QLOG_ERROR() << "load dll failed"; QLOG_ERROR() << "load dll failed";
_widget.ShowWiteMGS(sign, rlt); _lock.lock();
if(_widget != NULL)
_widget->ShowWiteMGS(sign, rlt);
_lock.unlock();;
return rlt; return rlt;
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <QObject> #include <QObject>
#include <QApplication> #include <QApplication>
#include <QLibrary> #include <QLibrary>
#include <QMutex>
class Control : public QObject class Control : public QObject
{ {
...@@ -38,7 +39,9 @@ public slots: ...@@ -38,7 +39,9 @@ public slots:
private: private:
struct AlipayRequest _request; struct AlipayRequest _request;
struct AlipayResponse _response; struct AlipayResponse _response;
HostWidget _widget; HostWidget *_widget;
//确保exe结束后不会重新弹窗
QMutex _lock;
}; };
#endif // CONTROL_H #endif // CONTROL_H
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