| 527 | } |
| 528 | |
| 529 | bool |
| 530 | ProgressPanel::updateTask(const NodePtr& node, |
| 531 | const double progress) |
| 532 | { |
| 533 | bool isMainThread = QThread::currentThread() == qApp->thread(); |
| 534 | ProgressTaskInfoPtr foundTask; |
| 535 | { |
| 536 | QMutexLocker k(&_imp->tasksMutex); |
| 537 | foundTask = _imp->findTask(node); |
| 538 | } |
| 539 | |
| 540 | if (!foundTask) { |
| 541 | return false; |
| 542 | } |
| 543 | if (!isMainThread) { |
| 544 | Q_EMIT s_doProgressUpdateOnMainThread(foundTask, progress); |
| 545 | } else { |
| 546 | doProgressOnMainThread(foundTask, progress); |
| 547 | } |
| 548 | |
| 549 | if ( foundTask->wasCanceled() ) { |
| 550 | return false; |
| 551 | } |
| 552 | |
| 553 | if (isMainThread) { |
| 554 | if (_imp->processEventsRecursionCounter == 0) { |
| 555 | ++_imp->processEventsRecursionCounter; |
| 556 | QCoreApplication::processEvents(); |
| 557 | --_imp->processEventsRecursionCounter; |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | return true; |
| 562 | } |
| 563 | |
| 564 | void |
| 565 | ProgressPanel::doProgressEndOnMainThread(const NodePtr& node) |
no test coverage detected