Skip to content

Commit 0b9e89e

Browse files
author
jef
committed
fix #1038
git-svn-id: http://svn.osgeo.org/qgis/trunk@8340 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent c32b69b commit 0b9e89e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/app/qgspythonutils.cpp

+18-3
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,32 @@ QString QgsPythonUtils::getPluginMetadata(QString pluginName, QString function)
340340
bool QgsPythonUtils::loadPlugin(QString packageName)
341341
{
342342
// load plugin's package and ensure that plugin is reloaded when changed
343+
runString(
344+
"try:\n"
345+
" import " + packageName + "\n"
346+
" reload(" + packageName + ")\n"
347+
" __main__.__plugin_result = 'OK'\n"
348+
"except:\n"
349+
" __main__.__plugin_result = 'ERROR'\n");
350+
351+
if( getVariableFromMain("__plugin_result") == "OK" )
352+
return true;
353+
354+
// snake in the grass, we know it's there
355+
runString("sys.path_importer_cache.clear()");
356+
357+
// retry
343358
runString(
344359
"try:\n"
345360
" import " + packageName + "\n"
346361
" reload(" + packageName + ")\n"
347362
" __main__.__plugin_result = 'OK'\n"
348363
"except:\n"
349364
" qgis_except_hook_msg(sys.exc_type, sys.exc_value, sys.exc_traceback, "
350-
" 'Couldn\\'t load plugin \"" + packageName + "\"')\n"
365+
"'Couldn\\'t load plugin \"" + packageName + "\" from [\\'' + '\\', \\''.join(sys.path) + '\\']')\n"
351366
" __main__.__plugin_result = 'ERROR'\n");
352-
353-
return (getVariableFromMain("__plugin_result") == "OK");
367+
368+
return getVariableFromMain("__plugin_result") == "OK";
354369
}
355370

356371

0 commit comments

Comments
 (0)