Skip to content

Commit

Permalink
fix python feature form identifier in case of non-ascii layer ids
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13842 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 29, 2010
1 parent 86451ba commit 6a0dfec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/app/qgsattributedialog.cpp
Expand Up @@ -42,12 +42,15 @@
#include <QVBoxLayout>
#include <QLineEdit>

int QgsAttributeDialog::smFormCounter = 0;

QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeature )
: mDialog( 0 )
, mSettingsPath( "/Windows/AttributeDialog/" )
, mLayer( vl )
, mpFeature( thepFeature )
, mRubberBand( 0 )
, mFormNr( -1 )
{
if ( mpFeature == NULL || vl->dataProvider() == NULL )
return;
Expand Down Expand Up @@ -227,9 +230,10 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
QgisApp::instance()->runPythonString( QString( "import %1" ).arg( module.left( pos ) ) );
}

QgisApp::instance()->runPythonString( QString( "_qgis_featureform_%1 = wrapinstance( %2, QtGui.QDialog )" ).arg( mLayer->getLayerID() ).arg(( unsigned long ) mDialog ) );
mFormNr = smFormCounter++;
QgisApp::instance()->runPythonString( QString( "_qgis_featureform_%1 = wrapinstance( %2, QtGui.QDialog )" ).arg( mFormNr ).arg(( unsigned long ) mDialog ) );

QString expr = QString( "%1(_qgis_featureform_%2,'%2',%3)" ).arg( vl->editFormInit() ).arg( vl->getLayerID() ).arg( mpFeature->id() );
QString expr = QString( "%1(_qgis_featureform_%2,'%3',%4)" ).arg( vl->editFormInit() ).arg( mFormNr ).arg( vl->getLayerID() ).arg( mpFeature->id() );
QgsDebugMsg( QString( "running featureForm init: %1" ).arg( expr ) );
QgisApp::instance()->runPythonString( expr );
}
Expand Down Expand Up @@ -331,8 +335,11 @@ void QgsAttributeDialog::dialogDestroyed()
mLayer->setProperty( "featureForm.dialog", QVariant() );
mLayer->setProperty( "featureForm.id", QVariant() );
#endif
QString expr = QString( "if locals().has_key('_qgis_featureform_%1'): del _qgis_featureform_%1\n" ).arg( mLayer->getLayerID() );
QgisApp::instance()->runPythonString( expr );
if ( -1 < mFormNr )
{
QString expr = QString( "if locals().has_key('_qgis_featureform_%1'): del _qgis_featureform_%1\n" ).arg( mFormNr );
QgisApp::instance()->runPythonString( expr );
}

mDialog = NULL;
deleteLater();
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsattributedialog.h
Expand Up @@ -68,6 +68,8 @@ class QgsAttributeDialog : public QObject
QgsVectorLayer *mLayer;
QgsFeature *mpFeature;
QgsRubberBand *mRubberBand;
int mFormNr;
static int smFormCounter;
};

#endif
2 changes: 1 addition & 1 deletion src/python/qgspythonutilsimpl.cpp
Expand Up @@ -161,7 +161,7 @@ bool QgsPythonUtilsImpl::runString( const QString& command, QString msgOnError )
evalString( "str(sys.path)", path );
evalString( "sys.version", version );

QString str = "<font color=\"red\">" + msgOnError + "</font><br><br>" + traceback + "<br>"
QString str = "<font color=\"red\">" + msgOnError + "</font><br><pre>\n" + traceback + "\n</pre>"
+ QObject::tr( "Python version:" ) + "<br>" + version + "<br><br>"
+ QObject::tr( "QGIS version:" ) + "<br>" + QString( "%1 '%2', %3" ).arg( QGis::QGIS_VERSION ).arg( QGis::QGIS_RELEASE_NAME ).arg( QGis::QGIS_SVN_VERSION ) + "<br><br>"
+ QObject::tr( "Python path:" ) + "<br>" + path;
Expand Down

0 comments on commit 6a0dfec

Please sign in to comment.