| 590 | } |
| 591 | |
| 592 | void OperatorRegistry::cancelModalOperator() { |
| 593 | std::unique_lock lock(mutex_); |
| 594 | |
| 595 | if (!active_modal_id_.empty()) { |
| 596 | auto it = python_operators_.find(active_modal_id_); |
| 597 | if (it != python_operators_.end() && it->second.cancel_fn) { |
| 598 | it->second.cancel_fn(); |
| 599 | } |
| 600 | active_modal_id_.clear(); |
| 601 | const bool finalize_history = active_modal_has_undo_transaction_; |
| 602 | lock.unlock(); |
| 603 | if (finalize_history) { |
| 604 | finalizeUndoTransaction(true, OperatorResult::CANCELLED, active_modal_has_undo_transaction_); |
| 605 | } |
| 606 | return; |
| 607 | } |
| 608 | |
| 609 | if (!active_modal_) { |
| 610 | return; |
| 611 | } |
| 612 | |
| 613 | if (auto ctx = makeContext()) { |
| 614 | active_modal_->cancel(*ctx); |
| 615 | } |
| 616 | active_modal_.reset(); |
| 617 | active_modal_builtin_.reset(); |
| 618 | const bool finalize_history = active_modal_has_undo_transaction_; |
| 619 | lock.unlock(); |
| 620 | if (finalize_history) { |
| 621 | finalizeUndoTransaction(true, OperatorResult::CANCELLED, active_modal_has_undo_transaction_); |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | void OperatorRegistry::clear() { |
| 626 | std::unique_lock lock(mutex_); |
no test coverage detected