Skip to content
Permalink
Browse files

Restore handle bad layers dialog original behavior

  • Loading branch information
elpaso committed Nov 3, 2018
1 parent 8493636 commit d46d765d58e759fb0293c1f386ec552a044a8bd4
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/app/qgshandlebadlayers.cpp
  2. BIN tests/testdata/projects/bad_layers_test.gpkg
@@ -26,6 +26,7 @@
#include "qgsproviderregistry.h"
#include "qgsmessagebar.h"
#include "qgssettings.h"
#include "qgslayertreeregistrybridge.h"

#include <QDomDocument>
#include <QDomElement>
@@ -347,13 +348,17 @@ void QgsHandleBadLayers::editAuthCfg()

void QgsHandleBadLayers::apply()
{
QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( true );

QList<QgsMapLayer *> toRemove;
for ( const auto &l : QgsProject::instance()->mapLayers( ) )
{
if ( ! l->isValid() )
toRemove << l;
}

QgsProject::instance()->removeMapLayers( toRemove );

for ( int i = 0; i < mLayerList->rowCount(); i++ )
{
int idx = mLayerList->item( i, 0 )->data( Qt::UserRole ).toInt();
@@ -372,11 +377,15 @@ void QgsHandleBadLayers::apply()
item->setForeground( QBrush( Qt::red ) );
}
}
QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( false );

if ( mLayerList->rowCount() == 0 )
accept();

}

void QgsHandleBadLayers::accept()
{
apply();

if ( mLayerList->rowCount() > 0 &&
QMessageBox::warning( this,
@@ -395,6 +404,9 @@ void QgsHandleBadLayers::accept()
if ( ! l->isValid() )
toRemove << l;
}
QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( true );
QgsProject::instance()->removeMapLayers( toRemove );
QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( false );
mLayerList->clear();

QDialog::accept();
Binary file not shown.

0 comments on commit d46d765

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