Re-rig global forwards when plugin pause state changes (bug 5582, r=psychonic).

This commit is contained in:
Peace-Maker 2013-08-27 19:06:18 -04:00
parent d05feabcd6
commit b8c61f89fa
2 changed files with 40 additions and 1 deletions

View File

@ -208,7 +208,23 @@ CForward *CForwardManager::ForwardMake()
void CForwardManager::OnPluginPauseChange(IPlugin *plugin, bool paused)
{
/* No longer used */
if(paused)
return;
/* Attach any globally managed forwards */
List<CForward *>::iterator iter;
CForward *fwd;
for (iter=m_managed.begin(); iter!=m_managed.end(); iter++)
{
fwd = (*iter);
IPluginFunction *pFunc = plugin->GetBaseContext()->GetFunctionByName(fwd->GetForwardName());
// Only add functions, if they aren't registered yet!
if (pFunc && !fwd->IsFunctionRegistered(pFunc))
{
fwd->AddFunction(pFunc);
}
}
}
/*************************************
@ -739,6 +755,28 @@ bool CForward::AddFunction(IPluginFunction *func)
return true;
}
bool CForward::IsFunctionRegistered(IPluginFunction *func)
{
FuncIter iter;
List<IPluginFunction *> *lst;
if (func->IsRunnable())
{
lst = &m_functions;
} else {
lst = &m_paused;
}
for (iter=m_functions.begin(); iter!=m_functions.end(); iter++)
{
if ((*iter) == func)
{
return true;
}
}
return false;
}
const char *CForward::GetForwardName()
{
return m_name;

View File

@ -141,6 +141,7 @@ public:
unsigned int num_params,
const ParamType *types,
va_list ap);
bool IsFunctionRegistered(IPluginFunction *func);
private:
void _Int_PushArray(cell_t *inarray, unsigned int cells, int flags);
void _Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags);