Skip to content
Permalink
Browse files
Small optimisations
  • Loading branch information
nyalldawson committed May 24, 2017
1 parent a5e3f19 commit 4b33e2fb1cccca23114b3c36c64f16c449b89ebc
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/core/qgsjsonutils.cpp
@@ -121,7 +121,7 @@ QString QgsJSONExporter::exportFeature( const QgsFeature &feature, const QVarian

if ( mIncludeAttributes )
{
QgsFields fields = mLayer.data() ? mLayer->fields() : feature.fields();
QgsFields fields = mLayer ? mLayer->fields() : feature.fields();

for ( int i = 0; i < fields.count(); ++i )
{
@@ -132,7 +132,7 @@ QString QgsJSONExporter::exportFeature( const QgsFeature &feature, const QVarian
properties += QLatin1String( ",\n" );
QVariant val = feature.attributes().at( i );

if ( mLayer.data() )
if ( mLayer )
{
QgsEditorWidgetSetup setup = fields.at( i ).editorWidgetSetup();
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
@@ -161,7 +161,7 @@ QString QgsJSONExporter::exportFeature( const QgsFeature &feature, const QVarian
}

// related attributes
if ( mLayer.data() && mIncludeRelatedAttributes )
if ( mLayer && mIncludeRelatedAttributes )
{
QList< QgsRelation > relations = QgsProject::instance()->relationManager()->referencedRelations( mLayer.data() );
Q_FOREACH ( const QgsRelation &relation, relations )
@@ -177,11 +177,13 @@ QString QgsJSONExporter::exportFeature( const QgsFeature &feature, const QVarian
{
QgsFeatureIterator it = childLayer->getFeatures( req );
QVector<QVariant> attributeWidgetCaches;
for ( int fieldIndex = 0; fieldIndex < childLayer->fields().count(); ++fieldIndex )
int fieldIndex = 0;
Q_FOREACH ( const QgsField &field, childLayer->fields() )
{
QgsEditorWidgetSetup setup = childLayer->fields().at( fieldIndex ).editorWidgetSetup();
QgsEditorWidgetSetup setup = field.editorWidgetSetup();
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
attributeWidgetCaches.append( fieldFormatter->createCache( childLayer, fieldIndex, setup.config() ) );
fieldIndex++;
}

QgsFeature relatedFet;

0 comments on commit 4b33e2f

Please sign in to comment.