Skip to content

Commit

Permalink
Fixed a crash when a QgsGrassModel::VectorLayer contained into a mult…
Browse files Browse the repository at this point in the history
…iple selection is deleted, renamed or copied.

git-svn-id: http://svn.osgeo.org/qgis/trunk@11203 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rugginoso committed Jul 29, 2009
1 parent 93c849d commit 19ea569
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/plugins/grass/qgsgrassbrowser.cpp
Expand Up @@ -216,7 +216,14 @@ void QgsGrassBrowser::copyMap()
{
QgsDebugMsg( "entered." );

QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
// Filter VectorLayer type from selection
QModelIndexList indexes;
foreach(QModelIndex index, mTree->selectionModel()->selectedIndexes()){
int type = mModel->itemType(index);
if (type != QgsGrassModel::VectorLayer){
indexes << index;
}
}

QList<QModelIndex>::const_iterator it = indexes.begin();
for ( ; it != indexes.end(); ++it )
Expand Down Expand Up @@ -288,7 +295,14 @@ void QgsGrassBrowser::renameMap()
{
QgsDebugMsg( "entered." );

QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
// Filter VectorLayer type from selection
QModelIndexList indexes;
foreach(QModelIndex index, mTree->selectionModel()->selectedIndexes()){
int type = mModel->itemType(index);
if (type != QgsGrassModel::VectorLayer){
indexes << index;
}
}

QList<QModelIndex>::const_iterator it = indexes.begin();
for ( ; it != indexes.end(); ++it )
Expand Down Expand Up @@ -352,10 +366,21 @@ void QgsGrassBrowser::deleteMap()
{
QgsDebugMsg( "entered." );

QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
// Filter VectorLayer type from selection
QModelIndexList indexes;
foreach(QModelIndex index, mTree->selectionModel()->selectedIndexes()){
int type = mModel->itemType(index);
if (type != QgsGrassModel::VectorLayer){
indexes << index;
}
}

if (!QMessageBox::question(this, tr("Question"), tr("Are you sure you want to delete the %1 selected layer(s)?").arg(indexes.size())))
if (QMessageBox::question(this, tr("Question"),
tr("Are you sure you want to delete the %1 selected layer(s)?").arg(indexes.size()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
{
return;
}

QList<QModelIndex>::const_iterator it = indexes.begin();
for ( ; it != indexes.end(); ++it )
Expand Down

0 comments on commit 19ea569

Please sign in to comment.