From 40334c32018889bac7feff72833bc9aa06cf7aac 2018-01-16 08:15:09 From: mperrinel Date: 2018-01-16 08:15:09 Subject: [PATCH] Fix asynchrone bug with reset of the download progress state --- diff --git a/core/src/Variable/VariableAcquisitionWorker.cpp b/core/src/Variable/VariableAcquisitionWorker.cpp index 479293a..39c88e3 100644 --- a/core/src/Variable/VariableAcquisitionWorker.cpp +++ b/core/src/Variable/VariableAcquisitionWorker.cpp @@ -71,8 +71,7 @@ QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid v // Request creation auto acqRequest = AcquisitionRequest{}; - qCDebug(LOG_VariableAcquisitionWorker()) << tr("PushVariableRequest ") << vIdentifier - << varRequestId; + qCDebug(LOG_VariableAcquisitionWorker()) << tr("Add acqRequest ") << acqRequest.m_AcqIdentifier; acqRequest.m_VarRequestId = varRequestId; acqRequest.m_vIdentifier = vIdentifier; acqRequest.m_DataProviderParameters = parameters; @@ -151,6 +150,7 @@ void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdenti double progress) { qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress ") + << QThread::currentThread()->objectName() << acqIdentifier << progress; impl->lockRead(); auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); @@ -168,6 +168,8 @@ void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdenti << QThread::currentThread()->objectName() << aIdToARit->second.m_vIdentifier << currentPartSize << currentAlreadyProgress << currentPartProgress << finalProgression; if (finalProgression == 100.0) { + qCDebug(LOG_VariableAcquisitionWorker()) + << tr("TORM: onVariableRetrieveDataInProgress : finished : 0.0 "); emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, 0.0); } } @@ -260,6 +262,8 @@ void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier) auto request = it->second; impl->unlock(); emit variableRequestInProgress(request.m_vIdentifier, 0.1); + qCDebug(LOG_VariableAcquisitionWorker()) << tr("Start request 10%") << acqIdentifier + << QThread::currentThread(); request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters); } else { @@ -295,12 +299,21 @@ void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeVariable if (it != m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { // A current request already exists, we can replace the next one + qCDebug(LOG_VariableAcquisitionWorker()) + << "VariableAcquisitionWorkerPrivate::removeVariableRequest " + << QThread::currentThread()->objectName() << it->second.first; m_AcqIdentifierToAcqRequestMap.erase(it->second.first); m_AcqIdentifierToAcqDataPacketVectorMap.erase(it->second.first); + qCDebug(LOG_VariableAcquisitionWorker()) + << "VariableAcquisitionWorkerPrivate::removeVariableRequest " << it->second.second; m_AcqIdentifierToAcqRequestMap.erase(it->second.second); m_AcqIdentifierToAcqDataPacketVectorMap.erase(it->second.second); } + + // stop any progression + emit q->variableRequestInProgress(vIdentifier, 0.0); + m_VIdentifierToCurrrentAcqIdNextIdPairMap.erase(vIdentifier); unlock(); } @@ -325,6 +338,9 @@ void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::updateToNextRe unlock(); // Remove AcquisitionRequest and results; lockWrite(); + qCDebug(LOG_VariableAcquisitionWorker()) + << "VariableAcquisitionWorkerPrivate::updateToNextRequest removed: " + << acqIdentifierToRemove; m_AcqIdentifierToAcqRequestMap.erase(acqIdentifierToRemove); m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqIdentifierToRemove); unlock(); @@ -407,6 +423,9 @@ void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeAcqReque lockWrite(); + qCDebug(LOG_VariableAcquisitionWorker()) + << "VariableAcquisitionWorkerPrivate::updateToNextRequest removeAcqRequest: " + << acqRequestId; m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqRequestId); m_AcqIdentifierToAcqRequestMap.erase(acqRequestId);