* @brief Resets the execution context by re-loading all current code. */
| 651 | * @brief Resets the execution context by re-loading all current code. |
| 652 | */ |
| 653 | void DataModel::FrameParser::clearContext() |
| 654 | { |
| 655 | for (auto it = m_engines.begin(); it != m_engines.end();) |
| 656 | if (it->first != 0) |
| 657 | it = m_engines.erase(it); |
| 658 | else |
| 659 | ++it; |
| 660 | |
| 661 | auto it0 = m_engines.find(0); |
| 662 | if (it0 != m_engines.end() && it0->second->language() != languageForSource(0)) |
| 663 | m_engines.erase(it0); |
| 664 | |
| 665 | refreshEngineCaches(); |
| 666 | |
| 667 | const auto& sources = ProjectModel::instance().sources(); |
| 668 | const QString code = sources.empty() ? QString() : scriptForSource(sources[0]); |
| 669 | |
| 670 | if (!code.isEmpty()) |
| 671 | (void)loadScript(0, code, !m_suppressMessageBoxes); |
| 672 | |
| 673 | for (const auto& src : sources) { |
| 674 | const QString script = (src.sourceId > 0) ? scriptForSource(src) : QString(); |
| 675 | if (!script.isEmpty()) |
| 676 | (void)loadScript(src.sourceId, script, false); |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | /** |
| 681 | * @brief Runs one cycle of garbage collection on all engines. |