diff --git a/sources/diagram.cpp b/sources/diagram.cpp index 40bdffe9c..857aab312 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -1693,10 +1693,26 @@ void Diagram::invertSelection() if (items().isEmpty()) return; blockSignals(true); - foreach (QGraphicsItem *item, - items()) item -> setSelected(!item -> isSelected()); + + //Get only allowed graphics item + //because some item can be deleted between the + //call of items() and the use of the item in the second 'for' loop + //and crash Qet with a segfault. + QVector item_list; + for (auto item : items()) + { + if (dynamic_cast(item) || + dynamic_cast(item) || + dynamic_cast(item)) { + item_list << item; + } + } + for (auto item : qAsConst(item_list)) { + item -> setSelected(!item -> isSelected()); + } + blockSignals(false); - emit(selectionChanged()); + emit selectionChanged(); } /**