[Okular-devel] Review Request: Manage annotation objects with QSharedPointers to support future Undo/Redo framework

Jon Mease jon.mease at gmail.com
Wed Oct 17 02:24:57 UTC 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/106923/
-----------------------------------------------------------

Review request for Okular.


Description
-------

The purpose of this patch is to shift the responsibility for explicitly deleting annotations away from the Page class.  Prior to this patch the Page class would explicitly delete an annotations object that was removed from the page.  However, in order to eventually support Undoing and Redoing the creation and removal of annotations from a page it is important that the annotation objects are not automatically deleted upon removal.  

The Page class now stores QSharedPointers to annotations rather than standard pointers. Page::addAnnotation and Document::addPageAnnotation now require a QSharedPointer rather than a standard pointer.  The implication is that the deletion of annotation objects is now managed by the QSharedPointer class rather than the Page class.  

Currently the only QSharedPointer referencing a particular annotation will be the one help by the page class and so the removal of the annotaion from a page will automatically result in the deletion of the annotation object.  However, in the future several QUndoCommands may also have QSharedPointer references to the annotation and in this case the annotation will not be deleted until all of those QUndoCommands have been been destroyed.


Diffs
-----

  core/annotations.cpp 21114af 
  core/document.h d47acec 
  core/document.cpp bddef39 
  core/page.h a8f2761 
  core/page.cpp d746382 
  core/textdocumentgenerator.cpp f370ded 
  generators/djvu/generator_djvu.cpp bc83ed7 
  generators/poppler/generator_pdf.cpp fcc8dc4 
  ui/annotationtools.h fdcae1b 
  ui/annotationtools.cpp f2db355 
  ui/pagepainter.cpp 916a0ab 
  ui/pageviewannotator.cpp 4488639 

Diff: http://git.reviewboard.kde.org/r/106923/diff/


Testing
-------

Added a kDebug() statement to the destructor of the Annotation class.  For both annotations loaded from disk and annotations created during the current session the removal of the annotation from a page still results in the destruction of the annotation object (no annotation memory leak).  This is the same behavior as before, only now it is accomplished through the use of QSharedPointers rather than an explicit "delete" call.


Thanks,

Jon Mease

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/okular-devel/attachments/20121017/3548af7d/attachment.html>


More information about the Okular-devel mailing list