restore code for deleting unused stored objects

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 9793010df8
commit 059dd83bdc
  1. 103
      src/board/UBBoardController.cpp
  2. 2
      src/core/UBApplication.h
  3. 2
      src/domain/UBGraphicsItemUndoCommand.cpp

@ -1552,60 +1552,55 @@ void UBBoardController::moveSceneToIndex(int source, int target)
void UBBoardController::ClearUndoStack() void UBBoardController::ClearUndoStack()
{ {
// The code has been removed because it leads to a strange error and because the final goal has never been QSet<QGraphicsItem*> uniqueItems;
// reached on tests and sound a little bit strange. // go through all stack command
// Strange error: item->scene() crashes the application because item doesn't implement scene() method. I'm for(int i = 0; i < UBApplication::undoStack->count(); i++)
// not able to give all the steps to reproduce this error sistematically but is quite frequent (~ twice per utilisation hours) {
// strange goal: if item is on the undocommand, the item->scene() is null and the item is not on the deleted scene item list then
// then it's deleted. UBAbstractUndoCommand *abstractCmd = (UBAbstractUndoCommand*)UBApplication::undoStack->command(i);
if(abstractCmd->getType() != UBAbstractUndoCommand::undotype_GRAPHICITEM)
// QSet<QGraphicsItem*> uniqueItems; continue;
// // go through all stack command
// for(int i = 0; i < UBApplication::undoStack->count(); i++) UBGraphicsItemUndoCommand *cmd = (UBGraphicsItemUndoCommand*)UBApplication::undoStack->command(i);
// {
// go through all added and removed objects, for create list of unique objects
// UBAbstractUndoCommand *abstractCmd = (UBAbstractUndoCommand*)UBApplication::undoStack->command(i); // grouped items will be deleted by groups, so we don't need do delete that items.
// if(abstractCmd->getType() != UBAbstractUndoCommand::undotype_GRAPHICITEM) QSetIterator<QGraphicsItem*> itAdded(cmd->GetAddedList());
// continue; while (itAdded.hasNext())
{
// UBGraphicsItemUndoCommand *cmd = (UBGraphicsItemUndoCommand*)UBApplication::undoStack->command(i); QGraphicsItem* item = itAdded.next();
if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
// // go through all added and removed objects, for create list of unique objects uniqueItems.insert(item);
// // grouped items will be deleted by groups, so we don't need do delete that items. }
// QSetIterator<QGraphicsItem*> itAdded(cmd->GetAddedList());
// while (itAdded.hasNext()) QSetIterator<QGraphicsItem*> itRemoved(cmd->GetRemovedList());
// { while (itRemoved.hasNext())
// QGraphicsItem* item = itAdded.next(); {
// if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type())) QGraphicsItem* item = itRemoved.next();
// uniqueItems.insert(item); if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
// } uniqueItems.insert(item);
}
// QSetIterator<QGraphicsItem*> itRemoved(cmd->GetRemovedList()); }
// while (itRemoved.hasNext())
// { // go through all unique items, and check, if they are on scene, or not.
// QGraphicsItem* item = itRemoved.next(); // if not on scene, than item can be deleted
// if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
// uniqueItems.insert(item); QSetIterator<QGraphicsItem*> itUniq(uniqueItems);
// } while (itUniq.hasNext())
// } {
QGraphicsItem* item = itUniq.next();
// // go through all unique items, and check, ot on scene, or not. UBGraphicsScene *scene = NULL;
// // if not on scene, than item can be deleted if (item->scene()) {
scene = dynamic_cast<UBGraphicsScene*>(item->scene());
// QSetIterator<QGraphicsItem*> itUniq(uniqueItems); }
// while (itUniq.hasNext()) if(!scene)
// { {
// QGraphicsItem* item = itUniq.next(); if (!mActiveScene->deleteItem(item)){
// UBGraphicsScene *scene = NULL; delete item;
// if (item->scene()) { item = 0;
// scene = dynamic_cast<UBGraphicsScene*>(item->scene()); }
// } }
// if(!scene) }
// {
// if (!mActiveScene->deleteItem(item))
// delete item;
// }
// }
// clear stack, and command list // clear stack, and command list
UBApplication::undoStack->clear(); UBApplication::undoStack->clear();

@ -47,7 +47,7 @@ class UBMainWindow;
class UBApplication : public QtSingleApplication class UBApplication : public QtSingleApplication
{ {
Q_OBJECT; Q_OBJECT
public: public:

@ -221,7 +221,7 @@ void UBGraphicsItemUndoCommand::redo()
UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item);
if (polygonItem) if (polygonItem)
{ {
mScene->removeItem(polygonItem); mScene->removeItem(polygonItem);
mScene->removeItemFromDeletion(polygonItem); mScene->removeItemFromDeletion(polygonItem);
polygonItem->strokesGroup()->addToGroup(polygonItem); polygonItem->strokesGroup()->addToGroup(polygonItem);

Loading…
Cancel
Save