From 44a4281238a649f359d7e375de9bb1b8c19ed561 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 2 Mar 2011 14:44:24 +0100 Subject: Doc: Fixed memory leak in undo framework example Task-number: QTBUG-15756 --- examples/tools/undoframework/commands.cpp | 6 ++++++ examples/tools/undoframework/commands.h | 1 + 2 files changed, 7 insertions(+) diff --git a/examples/tools/undoframework/commands.cpp b/examples/tools/undoframework/commands.cpp index 9e81c3e..ff7b0b7 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 ba27e2d..a4e4ab9 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(); -- cgit v0.12