Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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/qgis@13751 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jun 20, 2010
1 parent 2cf9351 commit 7751f05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -6546,7 +6546,7 @@ void QgisApp::runPythonString( const QString &expr )
{
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
mPythonUtils->runStringUnsafe( expr );
mPythonUtils->runString( expr );
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsattributedialog.cpp
Expand Up @@ -331,7 +331,8 @@ void QgsAttributeDialog::dialogDestroyed()
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();
Expand Down
4 changes: 4 additions & 0 deletions src/python/qgspythonutils.h
Expand Up @@ -50,6 +50,10 @@ class PYTHON_EXPORT QgsPythonUtils

/* 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;
Expand Down

0 comments on commit 7751f05

Please sign in to comment.