diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index d2397285..891591d7 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -1482,11 +1482,12 @@ void UBBoardController::ClearUndoStack() UBGraphicsItemUndoCommand *cmd = (UBGraphicsItemUndoCommand*)UBApplication::undoStack->command(i); // go through all added and removed objects, for create list of unique objects + // grouped items will be deleted by groups, so we don't need do delete that items. QSetIterator itAdded(cmd->GetAddedList()); while (itAdded.hasNext()) { QGraphicsItem* item = itAdded.next(); - if( !uniqueItems.contains(item) ) + if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type())) uniqueItems.insert(item); } @@ -1494,7 +1495,7 @@ void UBBoardController::ClearUndoStack() while (itRemoved.hasNext()) { QGraphicsItem* item = itRemoved.next(); - if( !uniqueItems.contains(item) ) + if( !uniqueItems.contains(item) && (item->parentItem() && UBGraphicsGroupContainerItem::Type != item->parentItem()->type())) uniqueItems.insert(item); } } diff --git a/src/domain/UBGraphicsGroupContainerItem.cpp b/src/domain/UBGraphicsGroupContainerItem.cpp index ff4a8bc4..1c63d004 100644 --- a/src/domain/UBGraphicsGroupContainerItem.cpp +++ b/src/domain/UBGraphicsGroupContainerItem.cpp @@ -324,6 +324,12 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item) item->setParentItem(newParent); item->setPos(oldPos); + UBGraphicsScene *Scene = dynamic_cast(item->scene()); + if (Scene) + { + Scene->addItem(item); + } + // removing position from translation component of the new transform if (!item->pos().isNull()) itemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); diff --git a/src/domain/UBGraphicsPolygonItem.cpp b/src/domain/UBGraphicsPolygonItem.cpp index b21f2760..8e0e6f85 100644 --- a/src/domain/UBGraphicsPolygonItem.cpp +++ b/src/domain/UBGraphicsPolygonItem.cpp @@ -67,8 +67,8 @@ void UBGraphicsPolygonItem::clearStroke() if (mStroke!=NULL) { mStroke->remove(this); - if (mStroke->polygons().empty()) - delete mStroke; + //if (mStroke->polygons().empty()) + // delete mStroke; mStroke = NULL; } } diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index f6a12f95..f5463574 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1374,9 +1374,11 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QListaddToGroup(chItem); + mFastAccessItems.removeAll(item); } } else { groupItem->addToGroup(item); + mFastAccessItems.removeAll(item); } } @@ -1396,6 +1398,15 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QListchildItems().count(); i++) + { + QGraphicsItem *it = qgraphicsitem_cast(groupItem->childItems().at(i)); + if (it) + { + mFastAccessItems.removeAll(it); + } + } + groupItem->setVisible(true); groupItem->setFocus();