Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
disable error hooks when querying for plugin metadata
- Loading branch information
Showing
with
13 additions
and
1 deletion.
-
+11
−1
src/python/qgspythonutilsimpl.cpp
-
+2
−0
src/python/qgspythonutilsimpl.h
|
@@ -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" ); |
|
@@ -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 ) ) |
|
|
{ |
|
@@ -436,6 +444,8 @@ QString QgsPythonUtilsImpl::getPluginMetadata( QString pluginName, QString funct |
|
|
retval = "__error__"; |
|
|
} |
|
|
Py_XDECREF( obj ); |
|
|
|
|
|
installErrorHook(); |
|
|
return retval; |
|
|
} |
|
|
|
|
|
|
@@ -112,6 +112,8 @@ class QgsPythonUtilsImpl : public QgsPythonUtils |
|
|
|
|
|
void installErrorHook(); |
|
|
|
|
|
void uninstallErrorHook(); |
|
|
|
|
|
QString getTraceback(); |
|
|
|
|
|
//! reference to module __main__ |
|
|