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();
}
void ScriptManager::Reload(Script *script)
{
if (find(scripts.begin(), scripts.end(), script) != scripts.end())
{
script->Reload();
ScriptsChanged();
}
}
const std::vector<cmd::Command*>& ScriptManager::GetMacros()
{
macros.clear();

View File

@ -223,6 +223,8 @@ namespace Automation4 {
void RemoveAll();
/// Reload all scripts mananaged
virtual void Reload() = 0;
/// Reload a single managed script
virtual void Reload(Script *script);
/// Get all managed scripts (both loaded and invalid)
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);
if (i < 0) return;
Automation4::Script *script = script_info[list->GetItemData(i)].script;
script->Reload();
ExtraScriptInfo const& ei = script_info[list->GetItemData(i)];
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) {