Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
059dd83b
Commit
059dd83b
authored
May 30, 2013
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restore code for deleting unused stored objects
parent
9793010d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
56 deletions
+51
-56
UBBoardController.cpp
src/board/UBBoardController.cpp
+49
-54
UBApplication.h
src/core/UBApplication.h
+1
-1
UBGraphicsItemUndoCommand.cpp
src/domain/UBGraphicsItemUndoCommand.cpp
+1
-1
No files found.
src/board/UBBoardController.cpp
View file @
059dd83b
...
...
@@ -1552,60 +1552,55 @@ void UBBoardController::moveSceneToIndex(int source, int target)
void
UBBoardController
::
ClearUndoStack
()
{
// The code has been removed because it leads to a strange error and because the final goal has never been
// reached on tests and sound a little bit strange.
// Strange error: item->scene() crashes the application because item doesn't implement scene() method. I'm
// 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.
// QSet<QGraphicsItem*> uniqueItems;
// // go through all stack command
// for(int i = 0; i < UBApplication::undoStack->count(); i++)
// {
// UBAbstractUndoCommand *abstractCmd = (UBAbstractUndoCommand*)UBApplication::undoStack->command(i);
// if(abstractCmd->getType() != UBAbstractUndoCommand::undotype_GRAPHICITEM)
// continue;
// 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<QGraphicsItem*> itAdded(cmd->GetAddedList());
// while (itAdded.hasNext())
// {
// QGraphicsItem* item = itAdded.next();
// if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
// uniqueItems.insert(item);
// }
// QSetIterator<QGraphicsItem*> itRemoved(cmd->GetRemovedList());
// while (itRemoved.hasNext())
// {
// QGraphicsItem* item = itRemoved.next();
// if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
// uniqueItems.insert(item);
// }
// }
// // go through all unique items, and check, ot on scene, or not.
// // if not on scene, than item can be deleted
// QSetIterator<QGraphicsItem*> itUniq(uniqueItems);
// while (itUniq.hasNext())
// {
// QGraphicsItem* item = itUniq.next();
// UBGraphicsScene *scene = NULL;
// if (item->scene()) {
// scene = dynamic_cast<UBGraphicsScene*>(item->scene());
// }
// if(!scene)
// {
// if (!mActiveScene->deleteItem(item))
// delete item;
// }
// }
QSet
<
QGraphicsItem
*>
uniqueItems
;
// go through all stack command
for
(
int
i
=
0
;
i
<
UBApplication
::
undoStack
->
count
();
i
++
)
{
UBAbstractUndoCommand
*
abstractCmd
=
(
UBAbstractUndoCommand
*
)
UBApplication
::
undoStack
->
command
(
i
);
if
(
abstractCmd
->
getType
()
!=
UBAbstractUndoCommand
::
undotype_GRAPHICITEM
)
continue
;
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
<
QGraphicsItem
*>
itAdded
(
cmd
->
GetAddedList
());
while
(
itAdded
.
hasNext
())
{
QGraphicsItem
*
item
=
itAdded
.
next
();
if
(
!
uniqueItems
.
contains
(
item
)
&&
!
(
item
->
parentItem
()
&&
UBGraphicsGroupContainerItem
::
Type
==
item
->
parentItem
()
->
type
()))
uniqueItems
.
insert
(
item
);
}
QSetIterator
<
QGraphicsItem
*>
itRemoved
(
cmd
->
GetRemovedList
());
while
(
itRemoved
.
hasNext
())
{
QGraphicsItem
*
item
=
itRemoved
.
next
();
if
(
!
uniqueItems
.
contains
(
item
)
&&
!
(
item
->
parentItem
()
&&
UBGraphicsGroupContainerItem
::
Type
==
item
->
parentItem
()
->
type
()))
uniqueItems
.
insert
(
item
);
}
}
// go through all unique items, and check, if they are on scene, or not.
// if not on scene, than item can be deleted
QSetIterator
<
QGraphicsItem
*>
itUniq
(
uniqueItems
);
while
(
itUniq
.
hasNext
())
{
QGraphicsItem
*
item
=
itUniq
.
next
();
UBGraphicsScene
*
scene
=
NULL
;
if
(
item
->
scene
())
{
scene
=
dynamic_cast
<
UBGraphicsScene
*>
(
item
->
scene
());
}
if
(
!
scene
)
{
if
(
!
mActiveScene
->
deleteItem
(
item
)){
delete
item
;
item
=
0
;
}
}
}
// clear stack, and command list
UBApplication
::
undoStack
->
clear
();
...
...
src/core/UBApplication.h
View file @
059dd83b
...
...
@@ -47,7 +47,7 @@ class UBMainWindow;
class
UBApplication
:
public
QtSingleApplication
{
Q_OBJECT
;
Q_OBJECT
public
:
...
...
src/domain/UBGraphicsItemUndoCommand.cpp
View file @
059dd83b
...
...
@@ -221,7 +221,7 @@ void UBGraphicsItemUndoCommand::redo()
UBGraphicsPolygonItem
*
polygonItem
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
item
);
if
(
polygonItem
)
{
{
mScene
->
removeItem
(
polygonItem
);
mScene
->
removeItemFromDeletion
(
polygonItem
);
polygonItem
->
strokesGroup
()
->
addToGroup
(
polygonItem
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment