summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorGeir Vattekar <geir.vattekar@nokia.com>2011-03-02 14:44:24 +0100
committerGeir Vattekar <geir.vattekar@nokia.com>2011-03-02 14:44:24 +0100
commit44a4281238a649f359d7e375de9bb1b8c19ed561 (patch)
tree1b552bdde2cb3baffe684b87a7ddd6ca01cc2939 /examples
parent6f007e1fb71386ec94dc7f7557515ae5968db8d0 (diff)
Doc: Fixed memory leak in undo framework example
Task-number: QTBUG-15756
Diffstat (limited to 'examples')
-rw-r--r--examples/tools/undoframework/commands.cpp6
-rw-r--r--examples/tools/undoframework/commands.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/examples/tools/undoframework/commands.cpp b/examples/tools/undoframework/commands.cpp
index 9e81c3ec77..ff7b0b7f1d 100644
--- a/examples/tools/undoframework/commands.cpp
+++ b/examples/tools/undoframework/commands.cpp
@@ -136,6 +136,12 @@ AddCommand::AddCommand(DiagramItem::DiagramType addType,
}
//! [7]
+AddCommand::~AddCommand()
+{
+ if (!myDiagramItem->scene())
+ delete myDiagramItem;
+}
+
//! [8]
void AddCommand::undo()
{
diff --git a/examples/tools/undoframework/commands.h b/examples/tools/undoframework/commands.h
index ba27e2d51c..a4e4ab9549 100644
--- a/examples/tools/undoframework/commands.h
+++ b/examples/tools/undoframework/commands.h
@@ -87,6 +87,7 @@ class AddCommand : public QUndoCommand
public:
AddCommand(DiagramItem::DiagramType addType, QGraphicsScene *graphicsScene,
QUndoCommand *parent = 0);
+ ~AddCommand();
void undo();
void redo();