Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(interface): use virtual destructors for all interfaces
Browse files Browse the repository at this point in the history
Avoids memory leak if derived classes are deleted through interface pointer.

Fix #6006
  • Loading branch information
anthonybilinski committed Mar 22, 2020
1 parent 205bfa5 commit 2b981d8
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/audio/iaudiocontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class IAudioControl : public QObject
Q_OBJECT

public:
virtual ~IAudioControl() = default;
virtual qreal outputVolume() const = 0;
virtual void setOutputVolume(qreal volume) = 0;
virtual qreal maxOutputVolume() const = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/audio/iaudiosettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

class IAudioSettings {
public:
virtual ~IAudioSettings() = default;

virtual QString getInDev() const = 0;
virtual void setInDev(const QString& deviceSpecifier) = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/audio/iaudiosink.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class IAudioSink
return {};
}

virtual ~IAudioSink() {}
virtual ~IAudioSink() = default;
virtual void playAudioBuffer(const int16_t* data, int samples, unsigned channels,
int sampleRate) const = 0;
virtual void playMono16Sound(const Sound& sound) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/iaudiosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class IAudioSource : public QObject
{
Q_OBJECT
public:
virtual ~IAudioSource() {}
virtual ~IAudioSource() = default;

virtual operator bool() const = 0;

Expand Down
1 change: 1 addition & 0 deletions src/core/icoresettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ICoreSettings {
ptSOCKS5 = 1,
ptHTTP = 2
};
virtual ~ICoreSettings() = default;

virtual bool getEnableIPv6() const = 0;
virtual void setEnableIPv6(bool enable) = 0;
Expand Down
1 change: 1 addition & 0 deletions src/model/about/iaboutfriend.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
class IAboutFriend
{
public:
virtual ~IAboutFriend() = default;
virtual QString getName() const = 0;
virtual QString getStatusMessage() const = 0;
virtual ToxPk getPublicKey() const = 0;
Expand Down
1 change: 1 addition & 0 deletions src/model/dialogs/idialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ToxPk;
class IDialogs
{
public:
virtual ~IDialogs() = default;
virtual bool hasContact(const ContactId& contactId) const = 0;
virtual bool isContactActive(const ContactId& contactId) const = 0;

Expand Down
1 change: 1 addition & 0 deletions src/model/dialogs/idialogsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ToxPk;
class IDialogsManager
{
public:
virtual ~IDialogsManager() = default;
virtual IDialogs* getFriendDialogs(const ToxPk& friendPk) const = 0;
virtual IDialogs* getGroupDialogs(const GroupId& groupId) const = 0;
};
Expand Down
1 change: 1 addition & 0 deletions src/model/profile/iprofileinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class IProfileInfo
enum class SetAvatarResult {
OK, EmptyPath, CanNotOpen, CanNotRead, TooLarge
};
virtual ~IProfileInfo() = default;

virtual bool setPassword(const QString& password) = 0;
virtual bool deletePassword() = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/persistence/ifriendsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class IFriendSettings
};
Q_DECLARE_FLAGS(AutoAcceptCallFlags, AutoAcceptCall)

virtual ~IFriendSettings() = default;

virtual QString getContactNote(const ToxPk& pk) const = 0;
virtual void setContactNote(const ToxPk& pk, const QString& note) = 0;

Expand Down
2 changes: 2 additions & 0 deletions src/video/ivideosettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

class IVideoSettings {
public:
virtual ~IVideoSettings() = default;

virtual QString getVideoDev() const = 0;
virtual void setVideoDev(const QString& deviceSpecifier) = 0;

Expand Down

0 comments on commit 2b981d8

Please sign in to comment.