Skip to content

Commit 6a0dfec

Browse files
author
jef
committed
fix python feature form identifier in case of non-ascii layer ids
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13842 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 86451ba commit 6a0dfec

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/app/qgsattributedialog.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@
4242
#include <QVBoxLayout>
4343
#include <QLineEdit>
4444

45+
int QgsAttributeDialog::smFormCounter = 0;
46+
4547
QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeature )
4648
: mDialog( 0 )
4749
, mSettingsPath( "/Windows/AttributeDialog/" )
4850
, mLayer( vl )
4951
, mpFeature( thepFeature )
5052
, mRubberBand( 0 )
53+
, mFormNr( -1 )
5154
{
5255
if ( mpFeature == NULL || vl->dataProvider() == NULL )
5356
return;
@@ -227,9 +230,10 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
227230
QgisApp::instance()->runPythonString( QString( "import %1" ).arg( module.left( pos ) ) );
228231
}
229232

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

232-
QString expr = QString( "%1(_qgis_featureform_%2,'%2',%3)" ).arg( vl->editFormInit() ).arg( vl->getLayerID() ).arg( mpFeature->id() );
236+
QString expr = QString( "%1(_qgis_featureform_%2,'%3',%4)" ).arg( vl->editFormInit() ).arg( mFormNr ).arg( vl->getLayerID() ).arg( mpFeature->id() );
233237
QgsDebugMsg( QString( "running featureForm init: %1" ).arg( expr ) );
234238
QgisApp::instance()->runPythonString( expr );
235239
}
@@ -331,8 +335,11 @@ void QgsAttributeDialog::dialogDestroyed()
331335
mLayer->setProperty( "featureForm.dialog", QVariant() );
332336
mLayer->setProperty( "featureForm.id", QVariant() );
333337
#endif
334-
QString expr = QString( "if locals().has_key('_qgis_featureform_%1'): del _qgis_featureform_%1\n" ).arg( mLayer->getLayerID() );
335-
QgisApp::instance()->runPythonString( expr );
338+
if ( -1 < mFormNr )
339+
{
340+
QString expr = QString( "if locals().has_key('_qgis_featureform_%1'): del _qgis_featureform_%1\n" ).arg( mFormNr );
341+
QgisApp::instance()->runPythonString( expr );
342+
}
336343

337344
mDialog = NULL;
338345
deleteLater();

src/app/qgsattributedialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class QgsAttributeDialog : public QObject
6868
QgsVectorLayer *mLayer;
6969
QgsFeature *mpFeature;
7070
QgsRubberBand *mRubberBand;
71+
int mFormNr;
72+
static int smFormCounter;
7173
};
7274

7375
#endif

src/python/qgspythonutilsimpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ bool QgsPythonUtilsImpl::runString( const QString& command, QString msgOnError )
161161
evalString( "str(sys.path)", path );
162162
evalString( "sys.version", version );
163163

164-
QString str = "<font color=\"red\">" + msgOnError + "</font><br><br>" + traceback + "<br>"
164+
QString str = "<font color=\"red\">" + msgOnError + "</font><br><pre>\n" + traceback + "\n</pre>"
165165
+ QObject::tr( "Python version:" ) + "<br>" + version + "<br><br>"
166166
+ 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>"
167167
+ QObject::tr( "Python path:" ) + "<br>" + path;

0 commit comments

Comments
 (0)