[Okular-devel] Review Request: Manage annotation objects with QSharedPointers to support future Undo/Redo framework
Albert Astals Cid
tsdgeos at terra.es
Wed Oct 17 17:41:10 UTC 2012
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/106923/#review20514
-----------------------------------------------------------
To be honest i don't think this is a good idea. This is poors man solution for "i don't know what do to with my memory". Personally i'd like to have a much more defined ownership model for annotations, e.g. annotations that *are* in the page belong to the page and the ones that are not in the page (i.e. they are in the "undone" actions) belong to whoever holds them (i.e. the actions).
This is something similar to what i do in the KTuberling undo/redo actions http://quickgit.kde.org/index.php?p=ktuberling.git&a=blob&f=action.cpp
What do you think of that?
- Albert Astals Cid
On Oct. 17, 2012, 2:24 a.m., Jon Mease wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/106923/
> -----------------------------------------------------------
>
> (Updated Oct. 17, 2012, 2:24 a.m.)
>
>
> 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/b94a6635/attachment.html>
More information about the Okular-devel
mailing list