Bug 1403698 Address delete-non-virtual-dtor warnings draft
authorTom Ritter <tom@mozilla.com>
Fri, 06 Oct 2017 11:27:35 -0500
changeset 676149 de8a528c66c445ff00845c4ab86b6ac10279dc35
parent 676029 c4b202af2b506467b4bd15cd33b4270dd7d23653
child 676150 99a3ffa6b85fe09902d0f8dc55b73f4f9efbe927
push id83400
push userbmo:tom@mozilla.com
push dateFri, 06 Oct 2017 17:37:41 +0000
bugs1403698
milestone58.0a1
Bug 1403698 Address delete-non-virtual-dtor warnings MozReview-Commit-ID: 44XiqegImiT
dom/plugins/ipc/PluginUtilsWin.cpp
gfx/2d/NativeFontResourceDWrite.cpp
gfx/layers/d3d11/TextureD3D11.cpp
widget/windows/InkCollector.h
widget/windows/JumpListBuilder.cpp
widget/windows/PDFViaEMFPrintHelper.h
widget/windows/nsDataObj.cpp
old mode 100644
new mode 100755
--- a/dom/plugins/ipc/PluginUtilsWin.cpp
+++ b/dom/plugins/ipc/PluginUtilsWin.cpp
@@ -40,17 +40,17 @@ public:
     return NS_OK;
   }
 
 protected:
   NPAudioDeviceChangeDetailsIPC mChangeDetails;
   const PluginModuleSet* mAudioNotificationSet;
 };
 
-class AudioNotification : public IMMNotificationClient
+class AudioNotification final : public IMMNotificationClient
 {
 public:
   AudioNotification() :
       mRefCt(1)
     , mIsRegistered(false)
   {
     HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator),
                                   NULL, CLSCTX_INPROC_SERVER,
@@ -65,25 +65,16 @@ public:
       mDeviceEnum->Release();
       mDeviceEnum = nullptr;
       return;
     }
 
     mIsRegistered = true;
   }
 
-  ~AudioNotification()
-  {
-    MOZ_ASSERT(!mIsRegistered,
-      "Destroying AudioNotification without first calling Unregister");
-    if (mDeviceEnum) {
-      mDeviceEnum->Release();
-    }
-  }
-
   // IMMNotificationClient Implementation
   HRESULT STDMETHODCALLTYPE
   OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR device_id) override
   {
     NPAudioDeviceChangeDetailsIPC changeDetails;
     changeDetails.flow = (int32_t)flow;
     changeDetails.role = (int32_t)role;
     changeDetails.defaultDevice = device_id ? std::wstring(device_id) : L"";
@@ -190,16 +181,25 @@ public:
 private:
   bool mIsRegistered;   // only used to make sure that Unregister is called before destroying a Valid instance.
   LONG mRefCt;
   IMMDeviceEnumerator* mDeviceEnum;
 
   // Set of plugin modules that have registered to be notified when the audio device
   // changes.
   PluginModuleSet mAudioNotificationSet;
+
+  ~AudioNotification()
+  {
+    MOZ_ASSERT(!mIsRegistered,
+      "Destroying AudioNotification without first calling Unregister");
+    if (mDeviceEnum) {
+      mDeviceEnum->Release();
+    }
+  }
 };  // class AudioNotification
 
 // callback that gets notified of audio device events, or NULL
 AudioNotification* sAudioNotification = nullptr;
 
 nsresult
 RegisterForAudioDeviceChanges(PluginModuleParent* aModuleParent, bool aShouldRegister)
 {
old mode 100644
new mode 100755
--- a/gfx/2d/NativeFontResourceDWrite.cpp
+++ b/gfx/2d/NativeFontResourceDWrite.cpp
@@ -76,29 +76,28 @@ public:
     }
     return mInstance;
   }
 
 private:
   static IDWriteFontFileLoader* mInstance;
 };
 
-class DWriteFontFileStream : public IDWriteFontFileStream
+class DWriteFontFileStream final : public IDWriteFontFileStream
 {
 public:
   /**
     * Used by the FontFileLoader to create a new font stream,
     * this font stream is created from data in memory. The memory
     * passed may be released after object creation, it will be
     * copied internally.
     *
     * @param aData Font data
     */
   DWriteFontFileStream(uint8_t *aData, uint32_t aSize, uint64_t aFontFileKey);
-  ~DWriteFontFileStream();
 
   // IUnknown interface
   IFACEMETHOD(QueryInterface)(IID const& iid, OUT void** ppObject)
   {
     if (iid == __uuidof(IDWriteFontFileStream)) {
       *ppObject = static_cast<IDWriteFontFileStream*>(this);
       return S_OK;
     } else if (iid == __uuidof(IUnknown)) {
@@ -134,16 +133,18 @@ public:
   virtual HRESULT STDMETHODCALLTYPE GetFileSize(OUT UINT64* fileSize);
 
   virtual HRESULT STDMETHODCALLTYPE GetLastWriteTime(OUT UINT64* lastWriteTime);
 
 private:
   std::vector<uint8_t> mData;
   Atomic<uint32_t> mRefCnt;
   uint64_t mFontFileKey;
+
+  ~DWriteFontFileStream();
 };
 
 IDWriteFontFileLoader* DWriteFontFileLoader::mInstance = nullptr;
 
 HRESULT STDMETHODCALLTYPE
 DWriteFontFileLoader::CreateStreamFromKey(const void *fontFileReferenceKey,
                                           UINT32 fontFileReferenceKeySize,
                                           IDWriteFontFileStream **fontFileStream)
old mode 100644
new mode 100755
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -27,17 +27,17 @@ using namespace gfx;
 namespace layers {
 
 static const GUID sD3D11TextureUsage =
 { 0xd89275b0, 0x6c7d, 0x4038, { 0xb5, 0xfa, 0x4d, 0x87, 0x16, 0xd5, 0xcc, 0x4e } };
 
 /* This class gets its lifetime tied to a D3D texture
  * and increments memory usage on construction and decrements
  * on destruction */
-class TextureMemoryMeasurer : public IUnknown
+class TextureMemoryMeasurer final : public IUnknown
 {
 public:
   explicit TextureMemoryMeasurer(size_t aMemoryUsed)
   {
     mMemoryUsed = aMemoryUsed;
     gfxWindowsPlatform::sD3D11SharedTextures += mMemoryUsed;
     mRefCnt = 0;
   }
@@ -67,16 +67,18 @@ public:
       gfxWindowsPlatform::sD3D11SharedTextures -= mMemoryUsed;
       delete this;
     }
     return refCnt;
   }
 private:
   int mRefCnt;
   int mMemoryUsed;
+
+  ~TextureMemoryMeasurer() = default;
 };
 
 static DXGI_FORMAT
 SurfaceFormatToDXGIFormat(gfx::SurfaceFormat aFormat)
 {
   switch (aFormat) {
     case SurfaceFormat::B8G8R8A8:
       return DXGI_FORMAT_B8G8R8A8_UNORM;
old mode 100644
new mode 100755
--- a/widget/windows/InkCollector.h
+++ b/widget/windows/InkCollector.h
@@ -8,17 +8,17 @@
 #ifndef InkCollector_h__
 #define InkCollector_h__
 
 #include <msinkaut.h>
 #include "mozilla/StaticPtr.h"
 
 #define MOZ_WM_PEN_LEAVES_HOVER_OF_DIGITIZER  WM_USER + 0x83
 
-class InkCollectorEvent : public _IInkCollectorEvents
+class InkCollectorEvent final : public _IInkCollectorEvents
 {
 public:
   // IUnknown
   HRESULT __stdcall QueryInterface(REFIID aRiid, void **aObject);
   virtual ULONG STDMETHODCALLTYPE AddRef() { return ++mRefCount; }
   virtual ULONG STDMETHODCALLTYPE Release()
   {
     MOZ_ASSERT(mRefCount);
@@ -41,16 +41,18 @@ protected:
                     EXCEPINFO* aExcepInfo, UINT* aArgErr);
 
   // InkCollectorEvent
   void CursorOutOfRange(IInkCursor* aCursor) const;
   bool IsHardProximityTablet(IInkTablet* aTablet) const;
 
 private:
   uint32_t  mRefCount = 0;
+
+  ~InkCollectorEvent() = default;
 };
 
 class InkCollector
 {
 public:
   ~InkCollector();
   void Shutdown();
 
old mode 100644
new mode 100755
--- a/widget/windows/JumpListBuilder.cpp
+++ b/widget/windows/JumpListBuilder.cpp
@@ -42,17 +42,17 @@ const char kPrefTaskbarEnabled[] = "brow
 
 NS_IMPL_ISUPPORTS(JumpListBuilder, nsIJumpListBuilder, nsIObserver)
 #define TOPIC_PROFILE_BEFORE_CHANGE "profile-before-change"
 #define TOPIC_CLEAR_PRIVATE_DATA "clear-private-data"
 
 
 namespace detail {
 
-class DoneCommitListBuildCallback : public nsIRunnable
+class DoneCommitListBuildCallback final : public nsIRunnable
 {
   NS_DECL_THREADSAFE_ISUPPORTS
 
 public:
   DoneCommitListBuildCallback(nsIJumpListCommittedCallback* aCallback,
                               JumpListBuilder* aBuilder)
     : mCallback(aCallback)
     , mBuilder(aBuilder)
old mode 100644
new mode 100755
--- a/widget/windows/PDFViaEMFPrintHelper.h
+++ b/widget/windows/PDFViaEMFPrintHelper.h
@@ -24,17 +24,17 @@ namespace widget {
  * To do that it first converts the PDF file to EMF.
  * Windows EMF:
  * https://msdn.microsoft.com/en-us/windows/hardware/drivers/print/emf-data-type
  */
 class PDFViaEMFPrintHelper
 {
 public:
   PDFViaEMFPrintHelper();
-  ~PDFViaEMFPrintHelper();
+  virtual ~PDFViaEMFPrintHelper();
 
   /** Loads the specified PDF file. */
   NS_IMETHOD OpenDocument(nsIFile *aFile);
   NS_IMETHOD OpenDocument(const char* aFileName);
 
   /** Releases document buffer. */
   void CloseDocument();
 
@@ -55,9 +55,9 @@ protected:
 
   RefPtr<PDFiumEngineShim>    mPDFiumEngine;
   FPDF_DOCUMENT               mPDFDoc;
 };
 
 } // namespace widget
 } // namespace mozilla
 
-#endif /* PDFVIAEMFPRINTHELPER_H_ */
\ No newline at end of file
+#endif /* PDFVIAEMFPRINTHELPER_H_ */
old mode 100644
new mode 100755
--- a/widget/windows/nsDataObj.cpp
+++ b/widget/windows/nsDataObj.cpp
@@ -434,17 +434,17 @@ STDMETHODIMP nsDataObj::QueryInterface(R
 STDMETHODIMP_(ULONG) nsDataObj::AddRef()
 {
 	++m_cRef;
 	NS_LOG_ADDREF(this, m_cRef, "nsDataObj", sizeof(*this));
 	return m_cRef;
 }
 
 namespace {
-class RemoveTempFileHelper : public nsIObserver
+class RemoveTempFileHelper final : public nsIObserver
 {
 public:
   explicit RemoveTempFileHelper(nsIFile* aTempFile)
     : mTempFile(aTempFile)
   {
     MOZ_ASSERT(mTempFile);
   }