Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

use the script id, not the plugin name to lookup the script #1962

Merged
merged 1 commit into from

2 participants

@jmarshallnz
Owner

In CPluginDirectory::WaitOnScriptResult we need to check whether the plugin is still running - to do this we use the plugin name, but if 2 instances are running we get the first one which may not be the one we want. Use the script id instead seeing as we have it. Fixes #13776.

@jimfcarroll to review.

While I don't see any reason why this would do anything odd, it would be nice for this to be in RC2 so we make sure of it.

Jonathan Marshall use the script id, not the plugin name to lookup the script in CPlugi…
…nDirectory::WaitOnScriptResult so we make sure we're waiting on the correct instance. fixes #13776
de76172
@jmarshallnz jmarshallnz merged commit 4f76251 into from
@jmarshallnz jmarshallnz deleted the branch
@jimfcarroll
Collaborator

Looks good to me (a little late :-) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 19, 2012
  1. use the script id, not the plugin name to lookup the script in CPlugi…

    Jonathan Marshall authored
    …nDirectory::WaitOnScriptResult so we make sure we're waiting on the correct instance. fixes #13776
This page is out of date. Refresh to see the latest.
View
18 xbmc/filesystem/PluginDirectory.cpp
@@ -120,10 +120,11 @@ bool CPluginDirectory::StartScript(const CStdString& strPath, bool retrievingDir
bool success = false;
#ifdef HAS_PYTHON
CStdString file = m_addon->LibPath();
- if (g_pythonParser.evalFile(file, argv,m_addon) >= 0)
+ int id = g_pythonParser.evalFile(file, argv,m_addon);
+ if (id >= 0)
{ // wait for our script to finish
CStdString scriptName = m_addon->Name();
- success = WaitOnScriptResult(file, scriptName, retrievingDir);
+ success = WaitOnScriptResult(file, id, scriptName, retrievingDir);
}
else
#endif
@@ -457,7 +458,7 @@ bool CPluginDirectory::RunScriptWithParams(const CStdString& strPath)
return false;
}
-bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CStdString &scriptName, bool retrievingDir)
+bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, int scriptId, const CStdString &scriptName, bool retrievingDir)
{
const unsigned int timeBeforeProgressBar = 1500;
const unsigned int timeToKillScript = 1000;
@@ -467,7 +468,7 @@ bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CS
bool cancelled = false;
bool inMainAppThread = g_application.IsCurrentThread();
- CLog::Log(LOGDEBUG, "%s - waiting on the %s plugin...", __FUNCTION__, scriptName.c_str());
+ CLog::Log(LOGDEBUG, "%s - waiting on the %s (id=%d) plugin...", __FUNCTION__, scriptName.c_str(), scriptId);
while (true)
{
{
@@ -481,7 +482,7 @@ bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CS
}
// check our script is still running
#ifdef HAS_PYTHON
- if (!g_pythonParser.isRunning(g_pythonParser.getScriptId(scriptPath.c_str())))
+ if (!g_pythonParser.isRunning(scriptId))
#endif
{ // check whether we exited normally
if (!m_fetchComplete.WaitMSec(0))
@@ -536,11 +537,10 @@ bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CS
if (cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript)
{ // cancel our script
#ifdef HAS_PYTHON
- int id = g_pythonParser.getScriptId(scriptPath.c_str());
- if (id != -1 && g_pythonParser.isRunning(id))
+ if (scriptId != -1 && g_pythonParser.isRunning(scriptId))
{
- CLog::Log(LOGDEBUG, "%s- cancelling plugin %s", __FUNCTION__, scriptName.c_str());
- g_pythonParser.stopScript(id);
+ CLog::Log(LOGDEBUG, "%s- cancelling plugin %s (id=%d)", __FUNCTION__, scriptName.c_str(), scriptId);
+ g_pythonParser.stopScript(scriptId);
break;
}
#endif
View
2  xbmc/filesystem/PluginDirectory.h
@@ -66,7 +66,7 @@ class CPluginDirectory : public IDirectory
private:
ADDON::AddonPtr m_addon;
bool StartScript(const CStdString& strPath, bool retrievingDir);
- bool WaitOnScriptResult(const CStdString &scriptPath, const CStdString &scriptName, bool retrievingDir);
+ bool WaitOnScriptResult(const CStdString &scriptPath, int scriptId, const CStdString &scriptName, bool retrievingDir);
static std::vector<CPluginDirectory*> globalHandles;
static int getNewHandle(CPluginDirectory *cp);
Something went wrong with that request. Please try again.