Skip to content

Commit

Permalink
disable error hooks when querying for plugin metadata
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9651 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 17, 2008
1 parent 15b4c2c commit 1f7e72b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/python/qgspythonutilsimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ void QgsPythonUtilsImpl::installErrorHook()
runString( "sys.excepthook = qgis_except_hook" );
}

void QgsPythonUtilsImpl::uninstallErrorHook()
{
runString( "sys.excepthook = sys.__excepthook__" );
}

void QgsPythonUtilsImpl::installConsoleHooks()
{
runString( "sys.displayhook = console_display_hook\n" );
Expand Down Expand Up @@ -419,12 +424,15 @@ QString QgsPythonUtilsImpl::getPluginMetadata( QString pluginName, QString funct
QString command = pluginName + "." + function + "()";
QString retval = "???";

// temporary disable error hook - UI will handle this gracefully
uninstallErrorHook();
PyObject* obj = PyRun_String( command.toLocal8Bit().data(), Py_eval_input, mMainDict, mMainDict );

if ( PyErr_Occurred() )
{
PyErr_Print(); // just print it to console
PyErr_Clear();
return "__error__";
retval = "__error__";
}
else if ( PyString_Check( obj ) )
{
Expand All @@ -436,6 +444,8 @@ QString QgsPythonUtilsImpl::getPluginMetadata( QString pluginName, QString funct
retval = "__error__";
}
Py_XDECREF( obj );

installErrorHook();
return retval;
}

Expand Down
2 changes: 2 additions & 0 deletions src/python/qgspythonutilsimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class QgsPythonUtilsImpl : public QgsPythonUtils

void installErrorHook();

void uninstallErrorHook();

QString getTraceback();

//! reference to module __main__
Expand Down

0 comments on commit 1f7e72b

Please sign in to comment.