Sanitize memory management of KoXmlNodeData a little
Summary:
- 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.
- 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
- Deduplicate creating the DocumentTypeNode after setContent() success
Test Plan: All tests still pass, and different apps can load files as before.
Subscribers: Calligra-Devel-list
Differential Revision: https://phabricator.kde.org/D154