[QGIS Commit] r13751 - in trunk/qgis/src: app python

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Jun 20 09:09:33 EDT 2010


Author: wonder
Date: 2010-06-20 13:09:33 +0000 (Sun, 20 Jun 2010)
New Revision: 13751

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgsattributedialog.cpp
   trunk/qgis/src/python/qgspythonutils.h
Log:
Report python errors when running python commands from qgis gui (e.g. run actions, feature form init).
Try to delete feature form only if exists (#2590).


Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2010-06-19 14:48:13 UTC (rev 13750)
+++ trunk/qgis/src/app/qgisapp.cpp	2010-06-20 13:09:33 UTC (rev 13751)
@@ -6546,7 +6546,7 @@
 {
   if ( mPythonUtils && mPythonUtils->isEnabled() )
   {
-    mPythonUtils->runStringUnsafe( expr );
+    mPythonUtils->runString( expr );
   }
 }
 

Modified: trunk/qgis/src/app/qgsattributedialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributedialog.cpp	2010-06-19 14:48:13 UTC (rev 13750)
+++ trunk/qgis/src/app/qgsattributedialog.cpp	2010-06-20 13:09:33 UTC (rev 13751)
@@ -331,7 +331,8 @@
   mLayer->setProperty( "featureForm.dialog", QVariant() );
   mLayer->setProperty( "featureForm.id", QVariant() );
 #endif
-  QgisApp::instance()->runPythonString( QString( "del _qgis_featureform_%1" ).arg( mLayer->getLayerID() ) );
+  QString expr = QString( "if locals().has_key('_qgis_featureform_%1'): del _qgis_featureform_%1\n" ).arg( mLayer->getLayerID() );
+  QgisApp::instance()->runPythonString( expr );
 
   mDialog = NULL;
   deleteLater();

Modified: trunk/qgis/src/python/qgspythonutils.h
===================================================================
--- trunk/qgis/src/python/qgspythonutils.h	2010-06-19 14:48:13 UTC (rev 13750)
+++ trunk/qgis/src/python/qgspythonutils.h	2010-06-20 13:09:33 UTC (rev 13751)
@@ -50,6 +50,10 @@
 
     /* console */
 
+    //! run a statement, show an error message on error
+    //! @return true if no error occured
+    virtual bool runString( const QString& command, QString msgOnError = QString() ) = 0;
+
     //! run a statement, error reporting is not done
     //! @return true if no error occured
     virtual bool runStringUnsafe( const QString& command, bool single = true ) = 0;



More information about the QGIS-commit mailing list