MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / clearContext

Method clearContext

app/src/DataModel/Scripting/FrameParser.cpp:653–678  ·  view source on GitHub ↗

* @brief Resets the execution context by re-loading all current code. */

Source from the content-addressed store, hash-verified

651 * @brief Resets the execution context by re-loading all current code.
652 */
653void 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.

Callers

nothing calls this directly

Calls 5

beginMethod · 0.80
findMethod · 0.80
emptyMethod · 0.80
isEmptyMethod · 0.80
languageMethod · 0.45

Tested by

no test coverage detected