Digging out a very old thread, but I have exactly the same question with the original poster.
I have an application with QGraphicsScene/QGraphicsView model and use QUndoCommand extensively, for items in my scene.
I followed the UndoFramework example and used the myscene->removeItem/addItem procedures.
For example in a polygon item I have:
void saDeleteConcretePolygonCommand::undo()
{
m_scene->addItem(m_item);
}
void saDeleteConcretePolygonCommand::redo()
{
m_scene->removeItem(m_item);
}
void saDeleteConcretePolygonCommand::undo()
{
m_scene->addItem(m_item);
}
void saDeleteConcretePolygonCommand::redo()
{
m_scene->removeItem(m_item);
}
To copy to clipboard, switch view to plain text mode
m_item is a local pointer to the item manipulated. In Qt documentation is specifically says that when you use QGraphicsScene::removeItem, it is the responsibility of the caller to delete the m_item afterwards.
So what I am missing? When the m_item is destroyed or it stays in memory as leak?
Thank you in advnace
Bookmarks