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

Method stopPlugin

app/src/Misc/ExtensionManager.cpp:1648–1688  ·  view source on GitHub ↗

* @brief Stops a running plugin by ID. */

Source from the content-addressed store, hash-verified

1646 * @brief Stops a running plugin by ID.
1647 */
1648void Misc::ExtensionManager::stopPlugin(const QString& id)
1649{
1650 auto it = m_plugins.find(id);
1651 if (it == m_plugins.end())
1652 return;
1653
1654 if (UI::Dashboard::instance().available())
1655 m_userClosedPlugins.insert(id);
1656
1657 auto* process = it.value();
1658 m_pluginOutput[id] += QStringLiteral("[Stopping...]\n");
1659 Q_EMIT pluginOutputChanged(id);
1660
1661 process->disconnect(this);
1662
1663 m_plugins.erase(it);
1664
1665 process->terminate();
1666 if (!process->waitForFinished(3000))
1667 process->kill();
1668
1669 const auto remaining = QString::fromUtf8(process->readAll());
1670 if (!remaining.isEmpty())
1671 m_pluginOutput[id] += remaining;
1672
1673 m_pluginOutput[id] += QStringLiteral("[Stopped]\n");
1674 Q_EMIT pluginOutputChanged(id);
1675
1676 delete process;
1677
1678 for (int i = 0; i < m_runningPlugins.count(); ++i) {
1679 if (m_runningPlugins.at(i).toMap().value("id").toString() == id) {
1680 m_runningPlugins.removeAt(i);
1681 break;
1682 }
1683 }
1684
1685 Q_EMIT runningPluginsChanged();
1686 applyFilter();
1687 rebuildInstalledPlugins();
1688}
1689
1690/**
1691 * @brief Stops all running plugins. Called on application shutdown.

Callers

nothing calls this directly

Calls 7

findMethod · 0.80
availableMethod · 0.80
isEmptyMethod · 0.80
valueMethod · 0.45
disconnectMethod · 0.45
killMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected