QList: make QListSpecialMethods dtors protected
QList publicly inherits from QListSpecialMethods. Thus, any specialisation of QListSpecialMethods should make their destructor protected, to avoid deletion through a pointer to QListSpecialMethods invoking UB. Change-Id: I7e317606f84826cc0faf1bfc05dee97da6eaf2eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
aea74dcaee
commit
198190b76b
@ -55,6 +55,10 @@ class QByteArrayList : public QList<QByteArray>
|
||||
template <> struct QListSpecialMethods<QByteArray>
|
||||
#endif
|
||||
{
|
||||
#ifndef Q_QDOC
|
||||
protected:
|
||||
~QListSpecialMethods() {}
|
||||
#endif
|
||||
public:
|
||||
inline QByteArray join() const
|
||||
{ return QtPrivate::QByteArrayList_join(self(), 0, 0); }
|
||||
|
@ -62,8 +62,13 @@ QT_BEGIN_NAMESPACE
|
||||
template <typename T> class QVector;
|
||||
template <typename T> class QSet;
|
||||
|
||||
template <typename T> struct QListSpecialMethods { };
|
||||
template <typename T> struct QListSpecialMethods
|
||||
{
|
||||
protected:
|
||||
~QListSpecialMethods() {}
|
||||
};
|
||||
template <> struct QListSpecialMethods<QByteArray>;
|
||||
template <> struct QListSpecialMethods<QString>;
|
||||
|
||||
struct Q_CORE_EXPORT QListData {
|
||||
// tags for tag-dispatching of QList implementations,
|
||||
|
@ -57,6 +57,10 @@ class QStringList : public QList<QString>
|
||||
template <> struct QListSpecialMethods<QString>
|
||||
#endif
|
||||
{
|
||||
#ifndef Q_QDOC
|
||||
protected:
|
||||
~QListSpecialMethods() {}
|
||||
#endif
|
||||
public:
|
||||
inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
inline int removeDuplicates();
|
||||
|
Loading…
Reference in New Issue
Block a user