[Differential] [Request, 391 lines] D154: Sanitize memory management of KoXmlNodeData a little
kossebau (Friedrich W. H. Kossebau)
noreply at phabricator.kde.org
Fri Jul 10 05:11:19 BST 2015
kossebau created this revision.
kossebau added a subscriber: Calligra-Devel-list.
REVISION SUMMARY
1. Cleanup sharing of KoXmlNodeData objects
Many null DOM element types (as created by default constructor) did not get the
KoXmlNodeData::null instance to share, but a new separate instance, without any need.
Destructors tested for need for dereferencing on multiple levels instead of just in
the destructor of the central baseclass KoXmlNode. Additionally do the destructors try
to deal with superclasses having already removed the KoXmlNodeData instance, which points
to ownership of those instances not properly respected.
The KoXmlNodeData::null instance was excluded from dereferencing, but not from
referencing, which seems more a workaround. Testing for identity to KoXmlNodeData::null
was done both in the unref() call itself as well as before calling the unref() call.
The new code now uses KoXmlNodeData::null whereever possible. It also uses a parameter
to the constructor to KoXmlNodeData to define the initial ref count, to avoid further
unref() or ref() calls to adapt to the usage.
2. Create subclass KoXmlDocumentData to KoXmlNodeData
It holds all properties and methods interesting only to the KoXmlDocument objects,
to reduce footprint of KoXmlNodeData and separate the setContent functionality more
3. Give DOM elements only const pointers to KoXmlNodeData
To enforce that this is only about reading the data
4. Remove stray and unwanted KoXmlText::setData() method
5. Deduplicate creating the DocumentTypeNode after setContent() success
TEST PLAN
All tests still pass, and different apps can load files as before.
REPOSITORY
rCALLIGRA Calligra
BRANCH
properKoXmlNodeData
REVISION DETAIL
https://phabricator.kde.org/D154
AFFECTED FILES
libs/odf/KoXmlReader.cpp
libs/odf/KoXmlReader.h
EMAIL PREFERENCES
https://phabricator.kde.org/settings/panel/emailpreferences/
To: kossebau
Cc: Calligra-Devel-list
More information about the calligra-devel
mailing list