Skip to content
Permalink
Browse files

move duplicated code to lambda

  • Loading branch information
alexbruy committed Aug 27, 2020
1 parent 7be25fb commit 7f2240caad41b59faad94e91395f7d20ee0d8974
Showing with 11 additions and 24 deletions.
  1. +11 −24 src/app/qgsoptions.cpp
@@ -2406,12 +2406,11 @@ void QgsOptions::saveGdalDriverList()
const auto oldSkippedGdalDrivers = QgsApplication::skippedGdalDrivers();
auto deferredSkippedGdalDrivers = QgsApplication::deferredSkippedGdalDrivers();
QStringList skippedGdalDrivers;
// raster drivers
for ( int i = 0; i < lstRasterDrivers->topLevelItemCount(); i++ )

auto checkDriver = [ & ]( QTreeWidgetItem * item )
{
QTreeWidgetItem *mypItem = lstRasterDrivers->topLevelItem( i );
const auto &driverName( mypItem->text( 0 ) );
if ( mypItem->checkState( 0 ) == Qt::Unchecked )
const auto &driverName( item->text( 0 ) );
if ( item->checkState( 0 ) == Qt::Unchecked )
{
skippedGdalDrivers << driverName;
if ( !deferredSkippedGdalDrivers.contains( driverName ) &&
@@ -2428,30 +2427,18 @@ void QgsOptions::saveGdalDriverList()
deferredSkippedGdalDrivers.removeAll( driverName );
}
}
};

// raster drivers
for ( int i = 0; i < lstRasterDrivers->topLevelItemCount(); i++ )
{
checkDriver( lstRasterDrivers->topLevelItem( i ) );
}

// vector drivers
for ( int i = 0; i < lstVectorDrivers->topLevelItemCount(); i++ )
{
QTreeWidgetItem *mypItem = lstVectorDrivers->topLevelItem( i );
const auto &driverName( mypItem->text( 0 ) );
if ( mypItem->checkState( 0 ) == Qt::Unchecked )
{
skippedGdalDrivers << driverName;
if ( !deferredSkippedGdalDrivers.contains( driverName ) &&
!oldSkippedGdalDrivers.contains( driverName ) )
{
deferredSkippedGdalDrivers << driverName;
driverUnregisterNeeded = true;
}
}
else
{
if ( deferredSkippedGdalDrivers.contains( driverName ) )
{
deferredSkippedGdalDrivers.removeAll( driverName );
}
}
checkDriver( lstVectorDrivers->topLevelItem( i ) );
}

if ( driverUnregisterNeeded )

0 comments on commit 7f2240c

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