Skip to content

Commit 22dfe17

Browse files
author
wonder
committedNov 17, 2008
disable error hooks when querying for plugin metadata
git-svn-id: http://svn.osgeo.org/qgis/trunk@9651 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent edd6c41 commit 22dfe17

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

‎src/python/qgspythonutilsimpl.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ void QgsPythonUtilsImpl::installErrorHook()
147147
runString( "sys.excepthook = qgis_except_hook" );
148148
}
149149

150+
void QgsPythonUtilsImpl::uninstallErrorHook()
151+
{
152+
runString( "sys.excepthook = sys.__excepthook__" );
153+
}
154+
150155
void QgsPythonUtilsImpl::installConsoleHooks()
151156
{
152157
runString( "sys.displayhook = console_display_hook\n" );
@@ -419,12 +424,15 @@ QString QgsPythonUtilsImpl::getPluginMetadata( QString pluginName, QString funct
419424
QString command = pluginName + "." + function + "()";
420425
QString retval = "???";
421426

427+
// temporary disable error hook - UI will handle this gracefully
428+
uninstallErrorHook();
422429
PyObject* obj = PyRun_String( command.toLocal8Bit().data(), Py_eval_input, mMainDict, mMainDict );
430+
423431
if ( PyErr_Occurred() )
424432
{
425433
PyErr_Print(); // just print it to console
426434
PyErr_Clear();
427-
return "__error__";
435+
retval = "__error__";
428436
}
429437
else if ( PyString_Check( obj ) )
430438
{
@@ -436,6 +444,8 @@ QString QgsPythonUtilsImpl::getPluginMetadata( QString pluginName, QString funct
436444
retval = "__error__";
437445
}
438446
Py_XDECREF( obj );
447+
448+
installErrorHook();
439449
return retval;
440450
}
441451

‎src/python/qgspythonutilsimpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class QgsPythonUtilsImpl : public QgsPythonUtils
112112

113113
void installErrorHook();
114114

115+
void uninstallErrorHook();
116+
115117
QString getTraceback();
116118

117119
//! reference to module __main__

0 commit comments

Comments
 (0)
Please sign in to comment.