[QGIS Commit] r9651 - trunk/qgis/src/python

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Nov 17 10:30:49 EST 2008


Author: wonder
Date: 2008-11-17 10:30:48 -0500 (Mon, 17 Nov 2008)
New Revision: 9651

Modified:
   trunk/qgis/src/python/qgspythonutilsimpl.cpp
   trunk/qgis/src/python/qgspythonutilsimpl.h
Log:
disable error hooks when querying for plugin metadata


Modified: trunk/qgis/src/python/qgspythonutilsimpl.cpp
===================================================================
--- trunk/qgis/src/python/qgspythonutilsimpl.cpp	2008-11-17 15:28:36 UTC (rev 9650)
+++ trunk/qgis/src/python/qgspythonutilsimpl.cpp	2008-11-17 15:30:48 UTC (rev 9651)
@@ -147,6 +147,11 @@
   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 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 @@
     retval = "__error__";
   }
   Py_XDECREF( obj );
+  
+  installErrorHook();
   return retval;
 }
 

Modified: trunk/qgis/src/python/qgspythonutilsimpl.h
===================================================================
--- trunk/qgis/src/python/qgspythonutilsimpl.h	2008-11-17 15:28:36 UTC (rev 9650)
+++ trunk/qgis/src/python/qgspythonutilsimpl.h	2008-11-17 15:30:48 UTC (rev 9651)
@@ -112,6 +112,8 @@
 
     void installErrorHook();
 
+    void uninstallErrorHook();
+    
     QString getTraceback();
 
     //! reference to module __main__



More information about the QGIS-commit mailing list