Commit 401c325c by 李定达

1.修复重复弹窗

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