Reload scripts through their manager so that the menu is aware of changes

Originally committed to SVN as r5780.
This commit is contained in:
Thomas Goyne 2011-10-25 19:02:01 +00:00
parent ec9d50a43a
commit be75262f73
3 changed files with 17 additions and 3 deletions

View file

@ -346,6 +346,15 @@ namespace Automation4 {
ScriptsChanged(); ScriptsChanged();
} }
void ScriptManager::Reload(Script *script)
{
if (find(scripts.begin(), scripts.end(), script) != scripts.end())
{
script->Reload();
ScriptsChanged();
}
}
const std::vector<cmd::Command*>& ScriptManager::GetMacros() const std::vector<cmd::Command*>& ScriptManager::GetMacros()
{ {
macros.clear(); macros.clear();

View file

@ -223,6 +223,8 @@ namespace Automation4 {
void RemoveAll(); void RemoveAll();
/// Reload all scripts mananaged /// Reload all scripts mananaged
virtual void Reload() = 0; virtual void Reload() = 0;
/// Reload a single managed script
virtual void Reload(Script *script);
/// Get all managed scripts (both loaded and invalid) /// Get all managed scripts (both loaded and invalid)
const std::vector<Script*>& GetScripts() const { return scripts; } const std::vector<Script*>& GetScripts() const { return scripts; }

View file

@ -231,10 +231,13 @@ void DialogAutomation::OnReload(wxCommandEvent &)
int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (i < 0) return; if (i < 0) return;
Automation4::Script *script = script_info[list->GetItemData(i)].script; ExtraScriptInfo const& ei = script_info[list->GetItemData(i)];
script->Reload(); if (ei.is_global)
global_manager->Reload(ei.script);
else
local_manager->Reload(ei.script);
SetScriptInfo(i, script); SetScriptInfo(i, ei.script);
} }
static wxString fac_to_str(const Automation4::ScriptFactory* f) { static wxString fac_to_str(const Automation4::ScriptFactory* f) {