| 536 | } |
| 537 | |
| 538 | bool |
| 539 | ProgressPanel::updateTask(const NodePtr& node, |
| 540 | const double progress) |
| 541 | { |
| 542 | bool isMainThread = QThread::currentThread() == qApp->thread(); |
| 543 | ProgressTaskInfoPtr foundTask; |
| 544 | { |
| 545 | QMutexLocker k(&_imp->tasksMutex); |
| 546 | foundTask = _imp->findTask(node); |
| 547 | } |
| 548 | |
| 549 | if (!foundTask) { |
| 550 | return false; |
| 551 | } |
| 552 | if (!isMainThread) { |
| 553 | Q_EMIT s_doProgressUpdateOnMainThread(foundTask, progress); |
| 554 | } else { |
| 555 | doProgressOnMainThread(foundTask, progress); |
| 556 | } |
| 557 | |
| 558 | if ( foundTask->wasCanceled() ) { |
| 559 | return false; |
| 560 | } |
| 561 | |
| 562 | if (isMainThread) { |
| 563 | if (_imp->processEventsRecursionCounter == 0) { |
| 564 | ++_imp->processEventsRecursionCounter; |
| 565 | { |
| 566 | #ifdef DEBUG |
| 567 | boost_adaptbx::floating_point::exception_trapping trap(0); |
| 568 | #endif |
| 569 | QCoreApplication::processEvents(); |
| 570 | } |
| 571 | --_imp->processEventsRecursionCounter; |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | return true; |
| 576 | } |
| 577 | |
| 578 | void |
| 579 | ProgressPanel::doProgressEndOnMainThread(const NodePtr& node) |
no test coverage detected