Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 20, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions xbmc/filesystem/PluginDirectory.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ bool CPluginDirectory::StartScript(const CStdString& strPath, bool retrievingDir
bool success = false; bool success = false;
#ifdef HAS_PYTHON #ifdef HAS_PYTHON
CStdString file = m_addon->LibPath(); 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 { // wait for our script to finish
CStdString scriptName = m_addon->Name(); CStdString scriptName = m_addon->Name();
success = WaitOnScriptResult(file, scriptName, retrievingDir); success = WaitOnScriptResult(file, id, scriptName, retrievingDir);
} }
else else
#endif #endif
Expand Down Expand Up @@ -457,7 +458,7 @@ bool CPluginDirectory::RunScriptWithParams(const CStdString& strPath)
return false; 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 timeBeforeProgressBar = 1500;
const unsigned int timeToKillScript = 1000; const unsigned int timeToKillScript = 1000;
Expand All @@ -467,7 +468,7 @@ bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CS
bool cancelled = false; bool cancelled = false;
bool inMainAppThread = g_application.IsCurrentThread(); 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) while (true)
{ {
{ {
Expand All @@ -481,7 +482,7 @@ bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CS
} }
// check our script is still running // check our script is still running
#ifdef HAS_PYTHON #ifdef HAS_PYTHON
if (!g_pythonParser.isRunning(g_pythonParser.getScriptId(scriptPath.c_str()))) if (!g_pythonParser.isRunning(scriptId))
#endif #endif
{ // check whether we exited normally { // check whether we exited normally
if (!m_fetchComplete.WaitMSec(0)) if (!m_fetchComplete.WaitMSec(0))
Expand Down Expand Up @@ -536,11 +537,10 @@ bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CS
if (cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript) if (cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript)
{ // cancel our script { // cancel our script
#ifdef HAS_PYTHON #ifdef HAS_PYTHON
int id = g_pythonParser.getScriptId(scriptPath.c_str()); if (scriptId != -1 && g_pythonParser.isRunning(scriptId))
if (id != -1 && g_pythonParser.isRunning(id))
{ {
CLog::Log(LOGDEBUG, "%s- cancelling plugin %s", __FUNCTION__, scriptName.c_str()); CLog::Log(LOGDEBUG, "%s- cancelling plugin %s (id=%d)", __FUNCTION__, scriptName.c_str(), scriptId);
g_pythonParser.stopScript(id); g_pythonParser.stopScript(scriptId);
break; break;
} }
#endif #endif
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/PluginDirectory.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CPluginDirectory : public IDirectory
private: private:
ADDON::AddonPtr m_addon; ADDON::AddonPtr m_addon;
bool StartScript(const CStdString& strPath, bool retrievingDir); 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 std::vector<CPluginDirectory*> globalHandles;
static int getNewHandle(CPluginDirectory *cp); static int getNewHandle(CPluginDirectory *cp);
Expand Down