Corrected an API design flaw with pausing. Contexts can now be flagged as paused, and IsRunnable() is moved from IBaseContext to IPluginFunction. While this allows for per-function pausing, it is not intended that way.

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40531
This commit is contained in:
David Anderson
2007-02-22 02:05:50 +00:00
parent 3de592d387
commit 8553f12d59
9 changed files with 61 additions and 45 deletions
+11 -6
View File
@@ -202,7 +202,6 @@ bool CPlugin::FinishMyCompile(char *error, size_t maxlength)
}
m_ctx.base = new BaseContext(m_ctx.ctx);
m_ctx.base->SetRunnable(false);
m_ctx.ctx->user[SM_CONTEXTVAR_MYSELF] = (void *)this;
m_status = Plugin_Created;
@@ -222,9 +221,9 @@ void CPlugin::SetErrorState(PluginStatus status, const char *error_fmt, ...)
vsnprintf(m_errormsg, sizeof(m_errormsg), error_fmt, ap);
va_end(ap);
if (m_ctx.base)
if (m_ctx.ctx)
{
m_ctx.base->SetRunnable(false);
m_ctx.ctx->flags |= SPFLAG_PLUGIN_PAUSED;
}
}
@@ -310,7 +309,6 @@ bool CPlugin::Call_AskPluginLoad(char *error, size_t maxlength)
}
m_status = Plugin_Loaded;
m_ctx.base->SetRunnable(true);
int err;
cell_t result;
@@ -397,8 +395,6 @@ bool CPlugin::SetPauseState(bool paused)
return false;
}
m_status = (paused) ? Plugin_Paused : Plugin_Running;
IPluginFunction *pFunction = m_ctx.base->GetFunctionByName("OnPluginPauseChange");
if (pFunction)
{
@@ -407,6 +403,15 @@ bool CPlugin::SetPauseState(bool paused)
pFunction->Execute(&result);
}
if (paused)
{
m_status = Plugin_Paused;
m_ctx.ctx->flags |= SPFLAG_PLUGIN_PAUSED;
} else {
m_status = Plugin_Running;
m_ctx.ctx->flags &= ~SPFLAG_PLUGIN_PAUSED;
}
g_PluginSys._SetPauseState(this, paused);
return true;