* @brief Loads the code stored in the project model into all engines. */
| 617 | * @brief Loads the code stored in the project model into all engines. |
| 618 | */ |
| 619 | void DataModel::FrameParser::readCode() |
| 620 | { |
| 621 | for (auto it = m_engines.begin(); it != m_engines.end();) |
| 622 | if (it->first != 0) |
| 623 | it = m_engines.erase(it); |
| 624 | else |
| 625 | ++it; |
| 626 | |
| 627 | auto it0 = m_engines.find(0); |
| 628 | if (it0 != m_engines.end() && it0->second->language() != languageForSource(0)) |
| 629 | m_engines.erase(it0); |
| 630 | |
| 631 | refreshEngineCaches(); |
| 632 | |
| 633 | const auto& model = ProjectModel::instance(); |
| 634 | const auto& sources = model.sources(); |
| 635 | const bool suppress = m_suppressMessageBoxes || model.suppressMessageBoxes(); |
| 636 | const QString code = sources.empty() ? QString() : scriptForSource(sources[0]); |
| 637 | |
| 638 | if (!code.isEmpty()) |
| 639 | (void)loadScript(0, code, !suppress); |
| 640 | |
| 641 | for (const auto& src : sources) { |
| 642 | const QString script = (src.sourceId > 0) ? scriptForSource(src) : QString(); |
| 643 | if (!script.isEmpty()) |
| 644 | (void)loadScript(src.sourceId, script, false); |
| 645 | } |
| 646 | |
| 647 | Q_EMIT modifiedChanged(); |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * @brief Resets the execution context by re-loading all current code. |