Bug 1563066, part 4 - Make dtors for nsXULPrototypeNode subclasses private. r=bzbarsky

Refcounted classes should not ever have delete called on them
directly, because something else might be holding a reference to
them. One way to make this harder is to declare the dtor private.

The immediate motivation for this change is that somebody was using
one of these classes as the value for an nsClassHashtable, which
should be rejected at compile time.

Differential Revision: https://phabricator.services.mozilla.com/D36791

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew McCreight 2019-07-04 00:58:32 +00:00
parent 951562a4be
commit 51c3548024

View File

@ -143,8 +143,10 @@ class nsXULPrototypeElement : public nsXULPrototypeNode {
mAttributes(nullptr),
mIsAtom(nullptr) {}
private:
virtual ~nsXULPrototypeElement() { Unlink(); }
public:
virtual void ReleaseSubtree() override {
for (int32_t i = mChildren.Length() - 1; i >= 0; i--) {
if (mChildren[i].get()) mChildren[i]->ReleaseSubtree();
@ -190,8 +192,11 @@ class XULDocument;
class nsXULPrototypeScript : public nsXULPrototypeNode {
public:
explicit nsXULPrototypeScript(uint32_t aLineNo);
private:
virtual ~nsXULPrototypeScript();
public:
virtual nsresult Serialize(
nsIObjectOutputStream* aStream, nsXULPrototypeDocument* aProtoDoc,
const nsTArray<RefPtr<mozilla::dom::NodeInfo>>* aNodeInfos) override;
@ -244,8 +249,10 @@ class nsXULPrototypeText : public nsXULPrototypeNode {
public:
nsXULPrototypeText() : nsXULPrototypeNode(eType_Text) {}
private:
virtual ~nsXULPrototypeText() {}
public:
virtual nsresult Serialize(
nsIObjectOutputStream* aStream, nsXULPrototypeDocument* aProtoDoc,
const nsTArray<RefPtr<mozilla::dom::NodeInfo>>* aNodeInfos) override;
@ -261,8 +268,10 @@ class nsXULPrototypePI : public nsXULPrototypeNode {
public:
nsXULPrototypePI() : nsXULPrototypeNode(eType_PI) {}
private:
virtual ~nsXULPrototypePI() {}
public:
virtual nsresult Serialize(
nsIObjectOutputStream* aStream, nsXULPrototypeDocument* aProtoDoc,
const nsTArray<RefPtr<mozilla::dom::NodeInfo>>* aNodeInfos) override;