Skip to content
Permalink
Browse files

[addlayerbutton] Fix order of signals when open page called

The problem was with raster "tab" (that is not a real page
but a forwarded signal to the app), when openPage
was called before the show() call.

Moving the activation inside the unique currentPage call,
the implementation is much simpler (got rid of the lambda
with the second currentRowChanged connection).
  • Loading branch information
elpaso committed Jun 2, 2017
1 parent 463fd03 commit 25b959cc8322e6d8b9ca34785708734d152afdcd
Showing with 5 additions and 10 deletions.
  1. +5 −10 src/app/qgsdatasourcemanagerdialog.cpp
@@ -66,18 +66,8 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
QListWidgetItem *rasterItem = new QListWidgetItem( tr( "Raster" ), ui->mOptionsListWidget );
rasterItem->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddRasterLayer.svg" ) ) );
rasterItem->setToolTip( tr( "Open a GDAL Supported Raster Data Source" ) );
connect( ui->mOptionsListWidget, &QListWidget::currentRowChanged, this, [ = ]( int idx )
{
Q_UNUSED( idx );
if ( rasterItem->isSelected() )
{
emit addRasterLayer();
QTimer::singleShot( 0, this, &QgsDataSourceManagerDialog::setPreviousPage );
}
} );
mPageNames.append( QStringLiteral( "raster" ) );


// Add data provider dialogs
QDialog *dlg = nullptr;

@@ -158,6 +148,11 @@ void QgsDataSourceManagerDialog::setCurrentPage( int index )
mPreviousRow = ui->mOptionsStackedWidget->currentIndex( );
ui->mOptionsStackedWidget->setCurrentIndex( index );
setWindowTitle( tr( "Data Source Manager | %1" ).arg( ui->mOptionsListWidget->currentItem()->text( ) ) );
if ( 0 <= index && index < mPageNames.size() && mPageNames.at( index ) == QStringLiteral( "raster" ) )
{
emit addRasterLayer();
QTimer::singleShot( 0, this, &QgsDataSourceManagerDialog::setPreviousPage );
}
}

void QgsDataSourceManagerDialog::setPreviousPage()

0 comments on commit 25b959c

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