Skip to content

Commit f4b007e

Browse files
authoredDec 15, 2017
Merge pull request #5783 from pblottiere/ref_rel_perf_218
[2.18] QgsRelationReferenceWidget slowness
2 parents 2ef6a82 + fd7fc94 commit f4b007e

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
928928
mVariableEditor->reloadContext();
929929
mVariableEditor->setEditableScopeIndex( 0 );
930930

931-
931+
const QString key = "/QgsRelationReferenceWidget/cacheSize";
932+
mSettings->setValue( key, mSettings->value( key, 200000 ) );
932933

933934
mAdvancedSettingsEditor->setSettingsObject( mSettings );
934935

‎src/gui/editorwidgets/qgsrelationreferencewidget.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ void QgsRelationReferenceWidget::init()
479479

480480
QSet<QString> requestedAttrs;
481481

482-
QgsVectorLayerCache* layerCache = new QgsVectorLayerCache( mReferencedLayer, 100000, this );
482+
const int cacheSize = QSettings().value( "/QgsRelationReferenceWidget/cacheSize" ).toInt();
483+
QgsVectorLayerCache* layerCache = new QgsVectorLayerCache( mReferencedLayer, cacheSize, this );
483484

484485
if ( !mFilterFields.isEmpty() )
485486
{
@@ -583,8 +584,14 @@ void QgsRelationReferenceWidget::init()
583584
}
584585
}
585586

586-
QVariant featId = mFeature.isValid() ? mFeature.id() : QVariant( QVariant::Int );
587-
mComboBox->setCurrentIndex( mComboBox->findData( featId, QgsAttributeTableModel::FeatureIdRole ) );
587+
if ( mFeature.isValid() )
588+
{
589+
mComboBox->setCurrentIndex( mComboBox->findData( mFeature.id(), QgsAttributeTableModel::FeatureIdRole ) );
590+
}
591+
else
592+
{
593+
mComboBox->setCurrentIndex( -1 );
594+
}
588595

589596
// Only connect after iterating, to have only one iterator on the referenced table at once
590597
connect( mComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( comboReferenceChanged( int ) ) );

‎src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void QgsRelationReferenceWidgetWrapper::initWidget( QWidget* editor )
7171
if ( ctx->relation().name() == relation.name() )
7272
{
7373
mWidget->setEmbedForm( false );
74-
mWidget->setReadOnlySelector( false );
74+
mWidget->setReadOnlySelector( true );
7575
mWidget->setAllowMapIdentification( false );
7676
}
7777
ctx = ctx->parentContext();

0 commit comments

Comments
 (0)
Please sign in to comment.