Skip to content

Commit 52a49c9

Browse files
author
wonder
committed
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). git-svn-id: http://svn.osgeo.org/qgis/trunk@13751 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 8872fcb commit 52a49c9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/app/qgisapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6546,7 +6546,7 @@ void QgisApp::runPythonString( const QString &expr )
65466546
{
65476547
if ( mPythonUtils && mPythonUtils->isEnabled() )
65486548
{
6549-
mPythonUtils->runStringUnsafe( expr );
6549+
mPythonUtils->runString( expr );
65506550
}
65516551
}
65526552

src/app/qgsattributedialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ void QgsAttributeDialog::dialogDestroyed()
331331
mLayer->setProperty( "featureForm.dialog", QVariant() );
332332
mLayer->setProperty( "featureForm.id", QVariant() );
333333
#endif
334-
QgisApp::instance()->runPythonString( QString( "del _qgis_featureform_%1" ).arg( mLayer->getLayerID() ) );
334+
QString expr = QString( "if locals().has_key('_qgis_featureform_%1'): del _qgis_featureform_%1\n" ).arg( mLayer->getLayerID() );
335+
QgisApp::instance()->runPythonString( expr );
335336

336337
mDialog = NULL;
337338
deleteLater();

src/python/qgspythonutils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class PYTHON_EXPORT QgsPythonUtils
5050

5151
/* console */
5252

53+
//! run a statement, show an error message on error
54+
//! @return true if no error occured
55+
virtual bool runString( const QString& command, QString msgOnError = QString() ) = 0;
56+
5357
//! run a statement, error reporting is not done
5458
//! @return true if no error occured
5559
virtual bool runStringUnsafe( const QString& command, bool single = true ) = 0;

0 commit comments

Comments
 (0)