diff -r 8059668a2cf3 -r 6a8f76f0f4d1 src/mainwindow.cpp --- a/src/mainwindow.cpp Thu Feb 15 12:19:10 2018 +0200 +++ b/src/mainwindow.cpp Thu Feb 15 14:40:59 2018 +0200 @@ -22,6 +22,7 @@ #include #include #include +#include "generics/reverse.h" #include "main.h" #include "canvas.h" #include "mainwindow.h" @@ -316,17 +317,19 @@ // int MainWindow::deleteSelection() { - if (selectedObjects().isEmpty()) - return 0; - - QSet selectionCopy = selectedObjects(); + int count = 0; + QModelIndexList thingsToRemove = ui.objectList->selectionModel()->selectedIndexes(); - // Delete the objects that were being selected - for (LDObject* object : selectionCopy) - m_currentDocument->remove(object); + for (QModelIndex index : reverse(thingsToRemove)) + { + if (m_currentDocument->hasIndex(index.row(), index.column())) + { + m_currentDocument->removeAt(index); + count += 1; + } + } - refresh(); - return countof(selectionCopy); + return count; } // ---------------------------------------------------------------------------------------------------------------------