| 636 | } |
| 637 | |
| 638 | DocumentObjectExecReturn* App::PropertyExpressionEngine::execute(ExecuteOption option, |
| 639 | bool* touched) |
| 640 | { |
| 641 | DocumentObject* docObj = freecad_cast<DocumentObject*>(getContainer()); |
| 642 | |
| 643 | if (!docObj) { |
| 644 | throw Base::RuntimeError("PropertyExpressionEngine must be owned by a DocumentObject."); |
| 645 | } |
| 646 | |
| 647 | if (running) { |
| 648 | return DocumentObject::StdReturn; |
| 649 | } |
| 650 | |
| 651 | if (option == ExecuteOnRestore) { |
| 652 | bool found = false; |
| 653 | for (auto& e : expressions) { |
| 654 | auto prop = e.first.getProperty(); |
| 655 | if (!prop) { |
| 656 | continue; |
| 657 | } |
| 658 | if (prop->testStatus(App::Property::Transient) |
| 659 | || (prop->getType() & App::Prop_Transient) |
| 660 | || prop->testStatus(App::Property::EvalOnRestore)) { |
| 661 | found = true; |
| 662 | break; |
| 663 | } |
| 664 | } |
| 665 | if (!found) { |
| 666 | return DocumentObject::StdReturn; |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | /* Resetter class, to ensure that the "running" variable gets set to false, even if |
| 671 | * an exception is thrown. |
| 672 | */ |
| 673 | |
| 674 | class resetter |
| 675 | { |
| 676 | public: |
| 677 | explicit resetter(bool& b) |
| 678 | : _b(b) |
| 679 | { |
| 680 | _b = true; |
| 681 | } |
| 682 | ~resetter() |
| 683 | { |
| 684 | _b = false; |
| 685 | } |
| 686 | |
| 687 | private: |
| 688 | bool& _b; |
| 689 | }; |
| 690 | |
| 691 | resetter r(running); |
| 692 | |
| 693 | // Compute evaluation order |
| 694 | std::vector<App::ObjectIdentifier> evaluationOrder = computeEvaluationOrder(option); |
| 695 | std::vector<ObjectIdentifier>::const_iterator it = evaluationOrder.begin(); |
nothing calls this directly
no test coverage detected