Fix DmsAsyncAction and DmsSyncAction to responsed from timeout.
This commit is contained in:
@@ -16,6 +16,7 @@ DmsAsyncAction::DmsAsyncAction(int aServerId, int aActionId, QObject* aObject, c
|
||||
, mObject(aObject)
|
||||
, mResponseSignal(aResponseSignal)
|
||||
, mSendData()
|
||||
, mIsResponsed(false)
|
||||
{
|
||||
mTimer->setSingleShot(true);
|
||||
mTimer->setInterval(TIMEOUT_MSEC);
|
||||
@@ -31,6 +32,7 @@ DmsAsyncAction::~DmsAsyncAction()
|
||||
|
||||
bool DmsAsyncAction::execute()
|
||||
{
|
||||
mIsResponsed = false;
|
||||
QByteArray byteArray = mSendData.toUtf8();
|
||||
uint8_t* data = reinterpret_cast<uint8_t*>(byteArray.data());
|
||||
if(dmsmq_send(mServerId, mActionId, data, byteArray.size()) < 0)
|
||||
@@ -43,7 +45,10 @@ bool DmsAsyncAction::execute()
|
||||
|
||||
void DmsAsyncAction::sendTimeoutSignal()
|
||||
{
|
||||
emit timeout();
|
||||
if(!mIsResponsed)
|
||||
{
|
||||
emit timeout();
|
||||
}
|
||||
}
|
||||
|
||||
void DmsAsyncAction::setTimeoutInterval(int aMsec)
|
||||
@@ -53,5 +58,8 @@ void DmsAsyncAction::setTimeoutInterval(int aMsec)
|
||||
|
||||
void DmsAsyncAction::responsed()
|
||||
{
|
||||
mTimer->stop();
|
||||
if(mTimer->isActive())
|
||||
{
|
||||
mIsResponsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user