Bug 1028588 - Fix dangerous public destructors of Mac-specific reference-counted classes - r=mstange
authorBenoit Jacob <bjacob@mozilla.com>
Sun, 06 Jul 2014 11:25:31 -0400
changeset 192493 5f27f634ed58d0bfaaf863abee6c3add849f8254
parent 192492 b0d36fb76f262555e769476cc8826e6ce24e9d3e
child 192494 e91a7e542b7b3af1f921724e94ff99db2904cf62
push id45863
push userbjacob@mozilla.com
push dateSun, 06 Jul 2014 15:26:33 +0000
treeherdermozilla-inbound@5f27f634ed58 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1028588
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1028588 - Fix dangerous public destructors of Mac-specific reference-counted classes - r=mstange
browser/components/shell/src/nsMacShellService.h
embedding/components/printingui/src/mac/nsPrintProgress.h
embedding/components/printingui/src/mac/nsPrintProgressParams.h
embedding/components/printingui/src/mac/nsPrintingPromptService.h
hal/cocoa/CocoaBattery.cpp
image/decoders/icon/mac/nsIconChannel.h
intl/locale/src/mac/nsCollationMacUC.h
intl/locale/src/mac/nsDateTimeFormatMac.h
toolkit/components/startup/nsUserInfoMac.h
widget/cocoa/OSXNotificationCenter.h
widget/cocoa/nsAppShell.mm
widget/cocoa/nsBidiKeyboard.h
widget/cocoa/nsColorPicker.h
widget/cocoa/nsColorPicker.mm
widget/cocoa/nsFilePicker.h
widget/cocoa/nsMacDockSupport.h
widget/cocoa/nsMacWebAppUtils.h
widget/cocoa/nsMenuBarX.h
widget/cocoa/nsMenuGroupOwnerX.h
widget/cocoa/nsPrintDialogX.h
widget/cocoa/nsScreenManagerCocoa.h
widget/cocoa/nsSound.h
widget/cocoa/nsStandaloneNativeMenu.h
--- a/browser/components/shell/src/nsMacShellService.h
+++ b/browser/components/shell/src/nsMacShellService.h
@@ -11,24 +11,24 @@
 #include "nsIFile.h"
 #include "nsCOMPtr.h"
 
 class nsMacShellService : public nsIMacShellService,
                           public nsIWebProgressListener
 {
 public:
   nsMacShellService() : mCheckedThisSession(false) {};
-  virtual ~nsMacShellService() {};
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHELLSERVICE
   NS_DECL_NSIMACSHELLSERVICE
   NS_DECL_NSIWEBPROGRESSLISTENER
 
 protected:
+  virtual ~nsMacShellService() {};
 
 private:
   nsCOMPtr<nsIFile> mBackgroundFile;
 
   bool      mCheckedThisSession;
 };
 
 #endif // nsmacshellservice_h____
--- a/embedding/components/printingui/src/mac/nsPrintProgress.h
+++ b/embedding/components/printingui/src/mac/nsPrintProgress.h
@@ -12,24 +12,26 @@
 #include "nsCOMPtr.h"
 #include "nsIDOMWindow.h"
 #include "nsIPrintStatusFeedback.h"
 #include "nsIObserver.h"
 #include "nsString.h"
 
 class nsPrintProgress : public nsIPrintProgress, public nsIPrintStatusFeedback
 {
-public: 
+public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIPRINTPROGRESS
   NS_DECL_NSIWEBPROGRESSLISTENER
   NS_DECL_NSIPRINTSTATUSFEEDBACK
 
-	nsPrintProgress();
-	virtual ~nsPrintProgress();
+  nsPrintProgress();
+
+protected:
+  virtual ~nsPrintProgress();
 
 private:
   nsresult ReleaseListeners();
 
   bool                              m_closeProgress;
   bool                              m_processCanceled;
   nsString                          m_pendingStatus;
   int32_t                           m_pendingStateFlags;
--- a/embedding/components/printingui/src/mac/nsPrintProgressParams.h
+++ b/embedding/components/printingui/src/mac/nsPrintProgressParams.h
@@ -6,21 +6,23 @@
 #ifndef __nsPrintProgressParams_h
 #define __nsPrintProgressParams_h
 
 #include "nsIPrintProgressParams.h"
 #include "nsString.h"
 
 class nsPrintProgressParams : public nsIPrintProgressParams
 {
-public: 
-	NS_DECL_ISUPPORTS
+public:
+  NS_DECL_ISUPPORTS
   NS_DECL_NSIPRINTPROGRESSPARAMS
 
-	nsPrintProgressParams();
-	virtual ~nsPrintProgressParams();
+  nsPrintProgressParams();
+
+protected:
+  virtual ~nsPrintProgressParams();
 
 private:
   nsString mDocTitle;
   nsString mDocURL;
 };
 
 #endif
--- a/embedding/components/printingui/src/mac/nsPrintingPromptService.h
+++ b/embedding/components/printingui/src/mac/nsPrintingPromptService.h
@@ -25,21 +25,23 @@
 class nsIDOMWindow;
 class nsIDialogParamBlock;
 
 class nsPrintingPromptService: public nsIPrintingPromptService,
                                public nsIWebProgressListener
 {
 public:
   nsPrintingPromptService();
-  virtual ~nsPrintingPromptService();
 
   nsresult Init();
 
   NS_DECL_NSIPRINTINGPROMPTSERVICE
   NS_DECL_NSIWEBPROGRESSLISTENER
   NS_DECL_ISUPPORTS
 
+protected:
+  virtual ~nsPrintingPromptService();
+
 private:
   nsCOMPtr<nsIPrintProgress> mPrintProgress;
 };
 
 #endif
--- a/hal/cocoa/CocoaBattery.cpp
+++ b/hal/cocoa/CocoaBattery.cpp
@@ -110,16 +110,19 @@ bool MacPowerInformationService::sShutti
 
 MacPowerInformationService* MacPowerInformationService::sInstance = nullptr;
 
 namespace {
 struct SingletonDestroyer MOZ_FINAL : public nsIObserver
 {
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
+
+private:
+  ~SingletonDestroyer() {}
 };
 
 NS_IMPL_ISUPPORTS(SingletonDestroyer, nsIObserver)
 
 NS_IMETHODIMP
 SingletonDestroyer::Observe(nsISupports*, const char* aTopic, const char16_t*)
 {
   MOZ_ASSERT(!strcmp(aTopic, "xpcom-shutdown"));
--- a/image/decoders/icon/mac/nsIconChannel.h
+++ b/image/decoders/icon/mac/nsIconChannel.h
@@ -26,21 +26,22 @@ class nsIconChannel MOZ_FINAL : public n
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIREQUEST
   NS_DECL_NSICHANNEL
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
 
   nsIconChannel();
-  virtual ~nsIconChannel();
 
   nsresult Init(nsIURI* uri);
 
 protected:
+  virtual ~nsIconChannel();
+
   nsCOMPtr<nsIURI> mUrl;
   nsCOMPtr<nsIURI> mOriginalURI;
   int64_t          mContentLength;
   nsCOMPtr<nsILoadGroup> mLoadGroup;
   nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
   nsCOMPtr<nsISupports>  mOwner; 
   
   nsCOMPtr<nsIInputStreamPump> mPump;
--- a/intl/locale/src/mac/nsCollationMacUC.h
+++ b/intl/locale/src/mac/nsCollationMacUC.h
@@ -17,25 +17,26 @@ const uint32_t kCacheSize = 128;
 // According to the documentation, the length of the key should typically be
 // at least 5 * textLength, but 6* would be safer.
 const uint32_t kCollationValueSizeFactor = 6;
 
 class nsCollationMacUC MOZ_FINAL : public nsICollation {
 
 public: 
   nsCollationMacUC();
-  ~nsCollationMacUC(); 
 
   // nsISupports interface
   NS_DECL_ISUPPORTS
 
   // nsICollation interface
   NS_DECL_NSICOLLATION
 
 protected:
+  ~nsCollationMacUC(); 
+
   nsresult ConvertLocale(nsILocale* aNSLocale, LocaleRef* aMacLocale);
   nsresult StrengthToOptions(const int32_t aStrength,
                              UCCollateOptions* aOptions);
   nsresult EnsureCollator(const int32_t newStrength);
 
 private:
   bool mInit;
   bool mHasCollator;
--- a/intl/locale/src/mac/nsDateTimeFormatMac.h
+++ b/intl/locale/src/mac/nsDateTimeFormatMac.h
@@ -40,19 +40,20 @@ public:
   // performs a locale sensitive date formatting operation on the PRExplodedTime parameter
   NS_IMETHOD FormatPRExplodedTime(nsILocale* locale, 
                                   const nsDateFormatSelector  dateFormatSelector, 
                                   const nsTimeFormatSelector timeFormatSelector, 
                                   const PRExplodedTime*  explodedTime, 
                                   nsAString& stringOut); 
 
   nsDateTimeFormatMac() {}
-  
+
+protected:
   virtual ~nsDateTimeFormatMac() {}
-  
+
 private:
   // init this interface to a specified locale
   NS_IMETHOD Initialize(nsILocale* locale);
 
   nsString    mLocale;
   nsString    mAppLocale;
   bool        mUseDefaultLocale;
 };
--- a/toolkit/components/startup/nsUserInfoMac.h
+++ b/toolkit/components/startup/nsUserInfoMac.h
@@ -7,17 +7,19 @@
 
 #include "nsIUserInfo.h"
 #include "nsReadableUtils.h"
 
 class nsUserInfo: public nsIUserInfo
 {
 public:
   nsUserInfo();
-  virtual ~nsUserInfo() {}
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIUSERINFO
-  
+
   nsresult GetPrimaryEmailAddress(nsCString &aEmailAddress);  
+
+protected:
+  virtual ~nsUserInfo() {}
 };
 
 #endif /* __nsUserInfo_h */
--- a/widget/cocoa/OSXNotificationCenter.h
+++ b/widget/cocoa/OSXNotificationCenter.h
@@ -25,23 +25,25 @@ class OSXNotificationCenter : public nsI
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIALERTSSERVICE
   NS_DECL_IMGINOTIFICATIONOBSERVER
   NS_DECL_NSITIMERCALLBACK
 
   OSXNotificationCenter();
-  virtual ~OSXNotificationCenter();
 
   nsresult Init();
   void CloseAlertCocoaString(NSString *aAlertName);
   void OnClick(NSString *aAlertName);
   void ShowPendingNotification(OSXNotificationInfo *osxni);
 
+protected:
+  virtual ~OSXNotificationCenter();
+
 private:
   mozNotificationCenterDelegate *mDelegate;
   nsTArray<nsRefPtr<OSXNotificationInfo> > mActiveAlerts;
   nsTArray<nsRefPtr<OSXNotificationInfo> > mPendingAlerts;
 };
 
 } // namespace mozilla
 
--- a/widget/cocoa/nsAppShell.mm
+++ b/widget/cocoa/nsAppShell.mm
@@ -44,16 +44,18 @@ using namespace mozilla::widget;
 // Gecko. For example when we're playing video in a foreground tab we
 // don't want the screen saver to turn on.
 
 class MacWakeLockListener MOZ_FINAL : public nsIDOMMozWakeLockListener {
 public:
   NS_DECL_ISUPPORTS;
 
 private:
+  ~MacWakeLockListener() {}
+
   IOPMAssertionID mAssertionID = kIOPMNullAssertionID;
 
   NS_IMETHOD Callback(const nsAString& aTopic, const nsAString& aState) {
     bool isLocked = mLockedTopics.Contains(aTopic);
     bool shouldLock = aState.EqualsLiteral("locked-foreground");
     if (isLocked == shouldLock) {
       return NS_OK;
     }
--- a/widget/cocoa/nsBidiKeyboard.h
+++ b/widget/cocoa/nsBidiKeyboard.h
@@ -11,12 +11,14 @@
 
 class nsBidiKeyboard : public nsIBidiKeyboard
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIBIDIKEYBOARD
 
   nsBidiKeyboard();
+
+protected:
   virtual ~nsBidiKeyboard();
 };
 
 #endif // nsBidiKeyboard_h_
--- a/widget/cocoa/nsColorPicker.h
+++ b/widget/cocoa/nsColorPicker.h
@@ -30,16 +30,18 @@ public:
   // Call this method if you are done with this input, but the color picker needs to
   // stay open as it will be associated to another input
   void DoneWithRetarget();
   // Same as DoneWithRetarget + clean the static instance of sColorPanelWrapper,
   // as it is not needed anymore for now
   void Done();
 
 private:
+  ~nsColorPicker();
+
   static NSColor* GetNSColorFromHexString(const nsAString& aColor);
   static void GetHexStringFromNSColor(NSColor* aColor, nsAString& aResult);
 
   static NSColorPanelWrapper* sColorPanelWrapper;
 
   nsString             mTitle;
   nsString             mColor;
   nsCOMPtr<nsIColorPickerShownCallback> mCallback;
--- a/widget/cocoa/nsColorPicker.mm
+++ b/widget/cocoa/nsColorPicker.mm
@@ -92,16 +92,20 @@ HexStrToInt(NSString* str)
   [super dealloc];
 }
 @end
 
 NS_IMPL_ISUPPORTS(nsColorPicker, nsIColorPicker)
 
 NSColorPanelWrapper* nsColorPicker::sColorPanelWrapper = nullptr;
 
+nsColorPicker::~nsColorPicker()
+{
+}
+
 NS_IMETHODIMP
 nsColorPicker::Init(nsIDOMWindow* aParent, const nsAString& aTitle,
                     const nsAString& aInitialColor)
 {
   MOZ_ASSERT(NS_IsMainThread(),
       "Color pickers can only be opened from main thread currently");
   mTitle = aTitle;
   mColor = aInitialColor;
--- a/widget/cocoa/nsFilePicker.h
+++ b/widget/cocoa/nsFilePicker.h
@@ -16,17 +16,16 @@
 
 class nsILocalFileMac;
 @class NSArray;
 
 class nsFilePicker : public nsBaseFilePicker
 {
 public:
   nsFilePicker(); 
-  virtual ~nsFilePicker();
 
   NS_DECL_ISUPPORTS
 
   // nsIFilePicker (less what's in nsBaseFilePicker)
   NS_IMETHOD GetDefaultString(nsAString& aDefaultString);
   NS_IMETHOD SetDefaultString(const nsAString& aDefaultString);
   NS_IMETHOD GetDefaultExtension(nsAString& aDefaultExtension);
   NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex);
@@ -41,16 +40,17 @@ public:
   /**
    * Returns the current filter list in the format used by Cocoa's NSSavePanel
    * and NSOpenPanel.
    * Returns nil if no filter currently apply.
    */
   NSArray* GetFilterList();
 
 protected:
+  virtual ~nsFilePicker();
 
   virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle);
 
   // actual implementations of get/put dialogs using NSOpenPanel & NSSavePanel
   // aFile is an existing but unspecified file. These functions must specify it.
   //
   // will return |returnCancel| or |returnOK| as result.
   int16_t GetLocalFiles(const nsString& inTitle, bool inAllowMultiple, nsCOMArray<nsIFile>& outFiles);
--- a/widget/cocoa/nsMacDockSupport.h
+++ b/widget/cocoa/nsMacDockSupport.h
@@ -10,23 +10,24 @@
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsNativeThemeCocoa.h"
 
 class nsMacDockSupport : public nsIMacDockSupport, public nsITaskbarProgress
 {
 public:
   nsMacDockSupport();
-  virtual ~nsMacDockSupport();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMACDOCKSUPPORT
   NS_DECL_NSITASKBARPROGRESS
 
 protected:
+  virtual ~nsMacDockSupport();
+
   nsCOMPtr<nsIStandaloneNativeMenu> mDockMenu;
   nsString mBadgeText;
 
   NSImage *mAppIcon, *mProgressBackground;
 
   HIRect mProgressBounds;
   nsTaskbarProgressState mProgressState;
   double mProgressFraction;
--- a/widget/cocoa/nsMacWebAppUtils.h
+++ b/widget/cocoa/nsMacWebAppUtils.h
@@ -6,15 +6,17 @@
 
 #include "nsIMacWebAppUtils.h"
 
 #define NS_MACWEBAPPUTILS_CONTRACTID "@mozilla.org/widget/mac-web-app-utils;1"
 
 class nsMacWebAppUtils : public nsIMacWebAppUtils {
 public:
   nsMacWebAppUtils() {}
-  virtual ~nsMacWebAppUtils() {}
-  
+
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMACWEBAPPUTILS
+
+protected:
+  virtual ~nsMacWebAppUtils() {}
 };
 
 #endif //_MAC_WEB_APP_UTILS_H_
--- a/widget/cocoa/nsMenuBarX.h
+++ b/widget/cocoa/nsMenuBarX.h
@@ -23,19 +23,21 @@ class nsIContent;
 
 // The native menu service for creating native menu bars.
 class nsNativeMenuServiceX : public nsINativeMenuService
 {
 public:
   NS_DECL_ISUPPORTS
 
   nsNativeMenuServiceX() {}
-  virtual ~nsNativeMenuServiceX() {}
 
   NS_IMETHOD CreateNativeMenuBar(nsIWidget* aParent, nsIContent* aMenuBarNode);
+
+protected:
+  virtual ~nsNativeMenuServiceX() {}
 };
 
 @interface NSMenu (Undocumented)
 // Undocumented method, present unchanged since OS X 10.6, used to temporarily
 // highlight a top-level menu item when an appropriate Cmd+key combination is
 // pressed.
 - (void)_performActionWithHighlightingForItemAtIndex:(NSInteger)index;
 @end
--- a/widget/cocoa/nsMenuGroupOwnerX.h
+++ b/widget/cocoa/nsMenuGroupOwnerX.h
@@ -22,31 +22,32 @@ class nsChangeObserver;
 class nsIWidget;
 class nsIContent;
 class nsIDocument;
 
 class nsMenuGroupOwnerX : public nsMenuObjectX, public nsIMutationObserver
 {
 public:
   nsMenuGroupOwnerX();
-  virtual ~nsMenuGroupOwnerX();
 
   nsresult Create(nsIContent * aContent);
 
   void RegisterForContentChanges(nsIContent* aContent,
                                  nsChangeObserver* aMenuObject);
   void UnregisterForContentChanges(nsIContent* aContent);
   uint32_t RegisterForCommand(nsMenuItemX* aItem);
   void UnregisterCommand(uint32_t aCommandID);
   nsMenuItemX* GetMenuItemForCommandID(uint32_t inCommandID);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMUTATIONOBSERVER
 
 protected:
+  virtual ~nsMenuGroupOwnerX();
+
   nsChangeObserver* LookupContentChangeObserver(nsIContent* aContent);
 
   uint32_t  mCurrentCommandID;  // unique command id (per menu-bar) to
                                 // give to next item that asks
   nsIDocument* mDocument;       // pointer to document
 
   // stores observers for content change notification
   nsDataHashtable<nsPtrHashKey<nsIContent>, nsChangeObserver *> mContentToObserverTable;
--- a/widget/cocoa/nsPrintDialogX.h
+++ b/widget/cocoa/nsPrintDialogX.h
@@ -14,25 +14,27 @@
 
 class nsIPrintSettings;
 class nsIStringBundle;
 
 class nsPrintDialogServiceX : public nsIPrintDialogService
 {
 public:
   nsPrintDialogServiceX();
-  virtual ~nsPrintDialogServiceX();
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHODIMP Init();
   NS_IMETHODIMP Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings,
                      nsIWebBrowserPrint *aWebBrowserPrint);
   NS_IMETHODIMP ShowPageSetup(nsIDOMWindow *aParent,
                               nsIPrintSettings *aSettings);
+
+protected:
+  virtual ~nsPrintDialogServiceX();
 };
 
 @interface PrintPanelAccessoryView : NSView
 {
   nsIPrintSettings* mSettings;
   nsIStringBundle* mPrintBundle;
   NSButton* mPrintSelectionOnlyCheckbox;
   NSButton* mShrinkToFitCheckbox;
--- a/widget/cocoa/nsScreenManagerCocoa.h
+++ b/widget/cocoa/nsScreenManagerCocoa.h
@@ -12,20 +12,22 @@
 #include "nsAutoPtr.h"
 #include "nsIScreenManager.h"
 #include "nsScreenCocoa.h"
 
 class nsScreenManagerCocoa : public nsIScreenManager
 {
 public:
     nsScreenManagerCocoa();
-    virtual ~nsScreenManagerCocoa();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSISCREENMANAGER
 
+protected:
+    virtual ~nsScreenManagerCocoa();
+
 private:
 
     nsScreenCocoa *ScreenForCocoaScreen(NSScreen *screen);
     nsTArray< nsRefPtr<nsScreenCocoa> > mScreenList;
 };
 
 #endif // nsScreenManagerCocoa_h_
--- a/widget/cocoa/nsSound.h
+++ b/widget/cocoa/nsSound.h
@@ -10,16 +10,18 @@
 #include "nsISound.h"
 #include "nsIStreamLoader.h"
 
 class nsSound : public nsISound,
                 public nsIStreamLoaderObserver
 {
 public: 
     nsSound();
-    virtual ~nsSound();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSISOUND
     NS_DECL_NSISTREAMLOADEROBSERVER
+
+protected:
+    virtual ~nsSound();
 };
 
 #endif // nsSound_h_
--- a/widget/cocoa/nsStandaloneNativeMenu.h
+++ b/widget/cocoa/nsStandaloneNativeMenu.h
@@ -9,24 +9,25 @@
 #include "nsMenuGroupOwnerX.h"
 #include "nsMenuX.h"
 #include "nsIStandaloneNativeMenu.h"
 
 class nsStandaloneNativeMenu : public nsMenuGroupOwnerX, public nsIStandaloneNativeMenu
 {
 public:
   nsStandaloneNativeMenu();
-  virtual ~nsStandaloneNativeMenu();
 
   NS_DECL_ISUPPORTS  
   NS_DECL_NSISTANDALONENATIVEMENU
 
   // nsMenuObjectX
   nsMenuObjectTypeX MenuObjectType() { return eStandaloneNativeMenuObjectType; }
   void * NativeData() { return mMenu != nullptr ? mMenu->NativeData() : nullptr; }
 
   nsMenuX * GetMenuXObject() { return mMenu; }
 
 protected:
+  virtual ~nsStandaloneNativeMenu();
+
   nsMenuX * mMenu;
 };
 
 #endif