1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 04:27:45 +00:00

Everything: Add -Wnon-virtual-dtor flag

This flag warns on classes which have `virtual` functions but do not
have a `virtual` destructor.

This patch adds both the flag and missing destructors. The access level
of the destructors was determined by a two rules of thumb:
1. A destructor should have a similar or lower access level to that of a
   constructor.
2. Having a `private` destructor implicitly deletes the default
   constructor, which is probably undesirable for "interface" types
   (classes with only virtual functions and no data).

In short, most of the added destructors are `protected`, unless the
compiler complained about access.
This commit is contained in:
Nicholas-Baron 2021-04-15 10:43:29 -07:00 committed by Andreas Kling
parent b75d2d36e1
commit c4ede38542
21 changed files with 57 additions and 0 deletions

View file

@ -49,6 +49,9 @@ public:
virtual void image_did_modify_layer_stack() { }
virtual void image_did_change() { }
virtual void image_select_layer(Layer*) { }
protected:
virtual ~ImageClient() = default;
};
class Image : public RefCounted<Image> {

View file

@ -84,6 +84,8 @@ public:
PlaybackManager& manager() { return m_player_state.manager; }
protected:
virtual ~Player() = default;
PlayerState m_player_state;
RefPtr<PlaylistModel> m_playlist_model;
};

View file

@ -32,4 +32,7 @@ class Visualization {
public:
virtual void set_buffer(RefPtr<Audio::Buffer> buffer) = 0;
virtual void set_samplerate(int) { }
protected:
virtual ~Visualization() = default;
};

View file

@ -37,6 +37,9 @@ struct TreeMapNode {
virtual size_t num_children() const = 0;
virtual const TreeMapNode& child_at(size_t i) const = 0;
virtual void sort_children_by_area() const = 0;
protected:
virtual ~TreeMapNode() = default;
};
struct TreeMap : public RefCounted<TreeMap> {