Skip to content

Commit

Permalink
fix #1038
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@8340 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 12, 2008
1 parent c32b69b commit 0b9e89e
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/app/qgspythonutils.cpp
Expand Up @@ -340,17 +340,32 @@ QString QgsPythonUtils::getPluginMetadata(QString pluginName, QString function)
bool QgsPythonUtils::loadPlugin(QString packageName)
{
// load plugin's package and ensure that plugin is reloaded when changed
runString(
"try:\n"
" import " + packageName + "\n"
" reload(" + packageName + ")\n"
" __main__.__plugin_result = 'OK'\n"
"except:\n"
" __main__.__plugin_result = 'ERROR'\n");

if( getVariableFromMain("__plugin_result") == "OK" )
return true;

// snake in the grass, we know it's there
runString("sys.path_importer_cache.clear()");

// retry
runString(
"try:\n"
" import " + packageName + "\n"
" reload(" + packageName + ")\n"
" __main__.__plugin_result = 'OK'\n"
"except:\n"
" qgis_except_hook_msg(sys.exc_type, sys.exc_value, sys.exc_traceback, "
" 'Couldn\\'t load plugin \"" + packageName + "\"')\n"
"'Couldn\\'t load plugin \"" + packageName + "\" from [\\'' + '\\', \\''.join(sys.path) + '\\']')\n"
" __main__.__plugin_result = 'ERROR'\n");
return (getVariableFromMain("__plugin_result") == "OK");

return getVariableFromMain("__plugin_result") == "OK";
}


Expand Down

0 comments on commit 0b9e89e

Please sign in to comment.