Skip to content

Commit

Permalink
Merge pull request #2543 from SebDieBln/SortLayerTreeMimedata
Browse files Browse the repository at this point in the history
Sort the indexes when generating layer tree mime data (fixes #4110)
  • Loading branch information
NathanW2 committed Dec 14, 2015
2 parents 805d9d4 + afef14b commit b64ebfb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -928,7 +928,11 @@ QStringList QgsLayerTreeModel::mimeTypes() const

QMimeData* QgsLayerTreeModel::mimeData( const QModelIndexList& indexes ) const
{
QList<QgsLayerTreeNode*> nodesFinal = indexes2nodes( indexes, true );
// Sort the indexes. Depending on how the user selected the items, the indexes may be unsorted.
QModelIndexList sortedIndexes = indexes;
qSort( sortedIndexes.begin(), sortedIndexes.end(), qLess<QModelIndex>() );

QList<QgsLayerTreeNode*> nodesFinal = indexes2nodes( sortedIndexes, true );

if ( nodesFinal.isEmpty() )
return 0;
Expand Down

0 comments on commit b64ebfb

Please sign in to comment.