Skip to content
Permalink
Browse files

[Geometry checker] Prevent output layer from being set as current inp…

…ut layer when dialog is visible
  • Loading branch information
manisandro committed Jan 19, 2016
1 parent 4827cbc commit 20ca3163081405579826f989b3c5b0da55dcabb1
@@ -81,21 +81,25 @@ void QgsGeometryCheckerSetupTab::updateLayers()
ui.comboBoxInputLayer->clear();

// Collect layers
QgsMapLayer* currentLayer = mIface->mapCanvas()->currentLayer();
// Don't switch current layer if dialog is visible to avoid confusing the user
QgsMapLayer* currentLayer = isVisible() ? 0 : mIface->mapCanvas()->currentLayer();
int currIdx = -1;
int idx = 0;
Q_FOREACH( QgsMapLayer* layer, QgsMapLayerRegistry::instance()->mapLayers() )
{
QgsDebugMsg( QString( "Adding layer, have %1 in list" ).arg( ui.comboBoxInputLayer->count() ) );
if ( qobject_cast<QgsVectorLayer*>( layer ) )
{
ui.comboBoxInputLayer->addItem( layer->name(), layer->id() );
if ( layer->name() == prevLayer )
{
currIdx = ui.comboBoxInputLayer->count() - 1;
currIdx = idx;
}
else if ( currIdx == -1 && layer == currentLayer )
{
currIdx = ui.comboBoxInputLayer->count() - 1;
currIdx = idx;
}
++idx;
}
}
ui.comboBoxInputLayer->setCurrentIndex( qMax( 0, currIdx ) );
@@ -69,9 +69,11 @@ void QgsGeometrySnapperDialog::updateLayers()
comboBoxReferenceLayer->clear();

// Collect layers
QgsMapLayer* currentLayer = mIface->mapCanvas()->currentLayer();
// Don't switch current layer if dialog is visible to avoid confusing the user
QgsMapLayer* currentLayer = isVisible() ? 0 : mIface->mapCanvas()->currentLayer();
int curInputIdx = -1;
int curReferenceIdx = -1;
int idx = 0;
Q_FOREACH( QgsMapLayer* layer, QgsMapLayerRegistry::instance()->mapLayers() )
{
if ( qobject_cast<QgsVectorLayer*>( layer ) )
@@ -83,17 +85,18 @@ void QgsGeometrySnapperDialog::updateLayers()
comboBoxReferenceLayer->addItem( layer->name(), layer->id() );
if ( layer->name() == curInput )
{
curInputIdx = comboBoxInputLayer->count() - 1;
curInputIdx = idx;
}
else if ( curInputIdx == -1 && layer == currentLayer )
{
curInputIdx = comboBoxInputLayer->count() - 1;
curInputIdx = idx;
}

if ( layer->name() == curReference )
{
curReferenceIdx = comboBoxReferenceLayer->count() - 1;
curReferenceIdx = idx;
}
++idx;
}
}
}

0 comments on commit 20ca316

Please sign in to comment.
You can’t perform that action at this time.