Commit 47586728 authored by Valentin Platzgummer's avatar Valentin Platzgummer

temp

parent 22c1b55e
...@@ -325,22 +325,15 @@ bool MeasurementArea::isCorrect() { ...@@ -325,22 +325,15 @@ bool MeasurementArea::isCorrect() {
void MeasurementArea::updateProgress(const ProgressArray &array) { void MeasurementArea::updateProgress(const ProgressArray &array) {
if (ready() && !_holdProgress && array.size() > 0) { if (ready() && !_holdProgress && array.size() > 0) {
bool anyChanges = false; bool anyChanges = false;
long counter = 0;
for (const auto &lp : array) { for (const auto &lp : array) {
qDebug() << "MeasurementArea::updateProgress: counter = " << counter++;
auto it = _indexMap.find(lp.id()); auto it = _indexMap.find(lp.id());
if (it != _indexMap.end()) { if (it != _indexMap.end()) {
int tileIndex = it->second; int tileIndex = it->second;
auto *tile = _tiles->value<MeasurementTile *>(tileIndex); auto *tile = _tiles->value<MeasurementTile *>(tileIndex);
qDebug() << "MeasurementArea::updateProgress: progress before = "
<< tile->progress();
if (!qFuzzyCompare(lp.progress(), tile->progress())) { if (!qFuzzyCompare(lp.progress(), tile->progress())) {
tile->setProgress(lp.progress()); tile->setProgress(lp.progress());
anyChanges = true; anyChanges = true;
} }
qDebug() << "MeasurementArea::updateProgress: progress after = "
<< tile->progress();
} }
} }
......
...@@ -28,7 +28,10 @@ public: ...@@ -28,7 +28,10 @@ public:
_init(); _init();
} }
FutureType future() const { return _future; } FutureType future() const {
Q_ASSERT(this->_state != STATE::EMPTY);
return _future;
}
void setFuture(const FutureType &future) { void setFuture(const FutureType &future) {
_future = future; _future = future;
...@@ -37,9 +40,13 @@ public: ...@@ -37,9 +40,13 @@ public:
emit started(); emit started();
} }
T result() { return _future.get(); } T result() {
Q_ASSERT(this->_state != STATE::EMPTY);
return _future.get();
}
virtual void waitForFinished() override { virtual void waitForFinished() override {
Q_ASSERT(this->_state != STATE::EMPTY);
if (_state == STATE::STARTED) { if (_state == STATE::STARTED) {
_timer.stop(); _timer.stop();
_future.wait(); _future.wait();
...@@ -53,9 +60,11 @@ public: ...@@ -53,9 +60,11 @@ public:
private: private:
void _onTimeout() { void _onTimeout() {
Q_ASSERT(this->_state == STATE::STARTED);
if (_state == STATE::STARTED) { if (_state == STATE::STARTED) {
auto status = _future.wait_for(std::chrono::seconds(0)); auto status = _future.wait_for(std::chrono::seconds(0));
if (status == std::future_status::ready) { if (status == std::future_status::ready) {
_timer.stop();
_state = STATE::FINISHED; _state = STATE::FINISHED;
emit finished(); emit finished();
} }
......
...@@ -91,6 +91,7 @@ void TaskDispatcher::run() { ...@@ -91,6 +91,7 @@ void TaskDispatcher::run() {
ULock lk1(this->_mutex); ULock lk1(this->_mutex);
if (this->_taskQueue.size() > 0 && this->_running) { if (this->_taskQueue.size() > 0 && this->_running) {
Q_ASSERT(this->_taskQueue.size() == this->_promiseQueue.size());
// pop task and promise // pop task and promise
auto pTask = std::move(this->_taskQueue.front()); auto pTask = std::move(this->_taskQueue.front());
auto promise = std::move(this->_promiseQueue.front()); auto promise = std::move(this->_promiseQueue.front());
......
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