Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-15756

Memory leak in «Undo Framework» example

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 4.7.4
    • 4.7.1
    • Examples and Demos
    • None
    • 44a4281238a649f359d7e375de9bb1b8c19ed561

    Description

      I'm talking about this example: http://doc.qt.nokia.com/4.7/tools-undoframework.html

      DiagramItems once created in AddCommand's will not be deleted, if their AddCommand is deleted. This can cause to memory leak: if item is not in scene and does not belong to any existing command, it is memory leak.

      Easy solution is to use this destructor:
      AddCommand::~AddCommand()

      { if ( myDiagramItem->scene() == NULL ) delete myDiagramItem; }

      }

      But this is not universal solution: if set undoLimit of undo stack to something higher than zero, it will glick (it can delete item used by some DeleteCommand, causing to segfault on redo). But in scope of this specific example this solution is ok.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dm Geir Vattekar
            lapidarno Denis Pesotsky
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes