Bug 1028588 - Fix dangerous public destructors in libpref/ - r=bsmedberg

This commit is contained in:
Benoit Jacob 2014-06-30 18:11:48 -04:00
Родитель e8041c5877
Коммит aaabf35f80
3 изменённых файлов: 17 добавлений и 11 удалений

Просмотреть файл

@ -50,7 +50,6 @@ public:
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
Preferences(); Preferences();
virtual ~Preferences();
nsresult Init(); nsresult Init();
@ -353,6 +352,8 @@ public:
static nsresult SetFloat(const char* aPref, float aValue); static nsresult SetFloat(const char* aPref, float aValue);
protected: protected:
virtual ~Preferences();
nsresult NotifyServiceObservers(const char *aSubject); nsresult NotifyServiceObservers(const char *aSubject);
/** /**
* Reads the default pref file or, if that failed, try to save a new one. * Reads the default pref file or, if that failed, try to save a new one.

Просмотреть файл

@ -128,6 +128,10 @@ public:
class ValueObserver MOZ_FINAL : public nsIObserver, class ValueObserver MOZ_FINAL : public nsIObserver,
public ValueObserverHashKey public ValueObserverHashKey
{ {
~ValueObserver() {
Preferences::RemoveObserver(this, mPrefName.get());
}
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
@ -135,10 +139,6 @@ public:
ValueObserver(const char *aPref, PrefChangedFunc aCallback) ValueObserver(const char *aPref, PrefChangedFunc aCallback)
: ValueObserverHashKey(aPref, aCallback) { } : ValueObserverHashKey(aPref, aCallback) { }
~ValueObserver() {
Preferences::RemoveObserver(this, mPrefName.get());
}
void AppendClosure(void *aClosure) { void AppendClosure(void *aClosure) {
mClosures.AppendElement(aClosure); mClosures.AppendElement(aClosure);
} }
@ -229,6 +229,8 @@ Preferences::SizeOfIncludingThisAndOtherStuff(mozilla::MallocSizeOf aMallocSizeO
class PreferenceServiceReporter MOZ_FINAL : public nsIMemoryReporter class PreferenceServiceReporter MOZ_FINAL : public nsIMemoryReporter
{ {
~PreferenceServiceReporter() {}
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER NS_DECL_NSIMEMORYREPORTER

Просмотреть файл

@ -187,7 +187,6 @@ public:
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
nsPrefBranch(const char *aPrefRoot, bool aDefaultBranch); nsPrefBranch(const char *aPrefRoot, bool aDefaultBranch);
virtual ~nsPrefBranch();
int32_t GetRootLength() { return mPrefRootLength; } int32_t GetRootLength() { return mPrefRootLength; }
@ -198,6 +197,8 @@ public:
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
protected: protected:
virtual ~nsPrefBranch();
nsPrefBranch() /* disallow use of this constructer */ nsPrefBranch() /* disallow use of this constructer */
{ } { }
@ -232,7 +233,6 @@ class nsPrefLocalizedString : public nsIPrefLocalizedString,
{ {
public: public:
nsPrefLocalizedString(); nsPrefLocalizedString();
virtual ~nsPrefLocalizedString();
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_FORWARD_NSISUPPORTSSTRING(mUnicodeString->) NS_FORWARD_NSISUPPORTSSTRING(mUnicodeString->)
@ -241,6 +241,8 @@ public:
nsresult Init(); nsresult Init();
private: private:
virtual ~nsPrefLocalizedString();
NS_IMETHOD GetData(char16_t**); NS_IMETHOD GetData(char16_t**);
NS_IMETHOD SetData(const char16_t* aData); NS_IMETHOD SetData(const char16_t* aData);
NS_IMETHOD SetDataWithLength(uint32_t aLength, const char16_t *aData); NS_IMETHOD SetDataWithLength(uint32_t aLength, const char16_t *aData);
@ -254,11 +256,12 @@ class nsRelativeFilePref : public nsIRelativeFilePref
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIRELATIVEFILEPREF NS_DECL_NSIRELATIVEFILEPREF
nsRelativeFilePref(); nsRelativeFilePref();
virtual ~nsRelativeFilePref();
private: private:
virtual ~nsRelativeFilePref();
nsCOMPtr<nsIFile> mFile; nsCOMPtr<nsIFile> mFile;
nsCString mRelativeToKey; nsCString mRelativeToKey;
}; };