summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2014-07-18 09:14:35 -0700
committerNico Weber <thakis@chromium.org>2014-07-18 09:14:35 -0700
commit5eb9f7b4542cca34d4af96ea43be362446a4794f (patch)
treeb0a0fdd6b1c525bf3633d6de2b79b70058e2cc7d
parenta9c29e006f74fefd96d5c3eab9d8233b321b296a (diff)
downloadpdfium-5eb9f7b4542cca34d4af96ea43be362446a4794f.tar.xz
pdfium: Fix all -Wdelete-non-virtual-dtor violations on Mac.
Calling `delete` on an object of a type that has virtual functions but not a virtual destructor is questionable: Since the object has virtual functions, it likely has subclasses, so if it's deleted through the base pointer and the destructor isn't virtual, the subclass destructor won't be called. In most cases, the classes getting deleted can just be marked final to tell the compiler that it can't possibly have subclasses (this also enables the compiler to generate better code). Two classes didn't have any sub- or superclasses but virtual functions - this doesn't make sense, so make all methods of these classes non-virtual. (Also delete an unused function on one of the two classes.) In one case, a class actually did have a subclass that needs to be deleted virtually, so mark one destructor as virtual. BUG=none R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/370853002
-rw-r--r--core/include/fpdfapi/fpdf_parser.h4
-rw-r--r--core/include/fxcrt/fx_system.h9
-rw-r--r--core/include/fxge/fx_font.h2
-rw-r--r--core/src/fpdfapi/fpdf_font/ttgsubtable.h2
-rw-r--r--core/src/fpdfdoc/tagged_int.h2
-rw-r--r--core/src/fxcrt/extension.h4
-rw-r--r--core/src/fxcrt/fx_arabic.h2
-rw-r--r--core/src/fxge/apple/apple_int.h2
-rw-r--r--fpdfsdk/include/fsdk_define.h2
-rw-r--r--fpdfsdk/include/fsdk_mgr.h69
-rw-r--r--fpdfsdk/src/fpdf_sysfontinfo.cpp2
-rw-r--r--fpdfsdk/src/fpdfsave.cpp2
-rw-r--r--fpdfsdk/src/fpdfview.cpp2
13 files changed, 53 insertions, 51 deletions
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index c6c80778a1..feac6c67dc 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -397,7 +397,7 @@ public:
#define PDFPARSE_ERROR_PASSWORD 3
#define PDFPARSE_ERROR_HANDLER 4
#define PDFPARSE_ERROR_CERT 5
-class CPDF_Parser : public IPDF_DocParser
+class CPDF_Parser FX_FINAL : public IPDF_DocParser
{
public:
@@ -945,7 +945,7 @@ enum PDF_DATAAVAIL_STATUS {
PDF_DATAAVAIL_LOADALLFILE,
PDF_DATAAVAIL_TRAILER_APPEND
};
-class CPDF_DataAvail : public CFX_Object, public IPDF_DataAvail
+class CPDF_DataAvail FX_FINAL : public CFX_Object, public IPDF_DataAvail
{
public:
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h
index 9f43360fa7..a757de4c5e 100644
--- a/core/include/fxcrt/fx_system.h
+++ b/core/include/fxcrt/fx_system.h
@@ -275,5 +275,14 @@ int FXSYS_round(FX_FLOAT f);
#define FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b))
#ifdef __cplusplus
};
+
+#if defined(__clang__) || defined(_MSC_VER)
+#define FX_FINAL final
+#elif defined(__GNUC__) && __cplusplus >= 201103 && \
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
+#define FX_FINAL final
+#else
+#define FX_FINAL
+#endif
#endif
#endif
diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h
index dc96debeb6..52f8f30d8d 100644
--- a/core/include/fxge/fx_font.h
+++ b/core/include/fxge/fx_font.h
@@ -316,7 +316,7 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo
{
public:
CFX_FolderFontInfo();
- ~CFX_FolderFontInfo();
+ virtual ~CFX_FolderFontInfo();
void AddPath(FX_BSTR path);
virtual void Release();
virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper);
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.h b/core/src/fpdfapi/fpdf_font/ttgsubtable.h
index bf9c7a4c42..26f67fbd18 100644
--- a/core/src/fpdfapi/fpdf_font/ttgsubtable.h
+++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.h
@@ -406,7 +406,7 @@ private:
struct TFeatureList FeatureList;
struct TLookupList LookupList;
};
-class CFX_GSUBTable : public IFX_GSUBTable, public CFX_Object
+class CFX_GSUBTable FX_FINAL : public IFX_GSUBTable, public CFX_Object
{
public:
virtual void Release()
diff --git a/core/src/fpdfdoc/tagged_int.h b/core/src/fpdfdoc/tagged_int.h
index 0ebf4084a4..d190db6427 100644
--- a/core/src/fpdfdoc/tagged_int.h
+++ b/core/src/fpdfdoc/tagged_int.h
@@ -32,7 +32,7 @@ protected:
CFX_ArrayTemplate<CPDF_StructElementImpl*> m_Kids;
friend class CPDF_StructElementImpl;
};
-class CPDF_StructElementImpl : public CPDF_StructElement
+class CPDF_StructElementImpl FX_FINAL : public CPDF_StructElement
{
public:
CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree, CPDF_StructElementImpl* pParent, CPDF_Dictionary* pDict);
diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h
index db35387908..a736425d57 100644
--- a/core/src/fxcrt/extension.h
+++ b/core/src/fxcrt/extension.h
@@ -25,7 +25,7 @@ public:
virtual FX_BOOL Truncate(FX_FILESIZE szFile) = 0;
};
IFXCRT_FileAccess* FXCRT_FileAccess_Create();
-class CFX_CRTFileStream : public IFX_FileStream, public CFX_Object
+class CFX_CRTFileStream FX_FINAL : public IFX_FileStream, public CFX_Object
{
public:
CFX_CRTFileStream(IFXCRT_FileAccess* pFA) : m_pFile(pFA), m_dwCount(1), m_bUseRange(FALSE), m_nOffset(0), m_nSize(0) {}
@@ -117,7 +117,7 @@ public:
#define FX_MEMSTREAM_BlockSize (64 * 1024)
#define FX_MEMSTREAM_Consecutive 0x01
#define FX_MEMSTREAM_TakeOver 0x02
-class CFX_MemoryStream : public IFX_MemoryStream, public CFX_Object
+class CFX_MemoryStream FX_FINAL : public IFX_MemoryStream, public CFX_Object
{
public:
CFX_MemoryStream(FX_BOOL bConsecutive)
diff --git a/core/src/fxcrt/fx_arabic.h b/core/src/fxcrt/fx_arabic.h
index 503ec01696..1dc275b8c3 100644
--- a/core/src/fxcrt/fx_arabic.h
+++ b/core/src/fxcrt/fx_arabic.h
@@ -6,7 +6,7 @@
#ifndef _FX_ARABIC_IMP
#define _FX_ARABIC_IMP
-class CFX_BidiChar : public IFX_BidiChar, public CFX_Object
+class CFX_BidiChar FX_FINAL : public IFX_BidiChar, public CFX_Object
{
public:
CFX_BidiChar();
diff --git a/core/src/fxge/apple/apple_int.h b/core/src/fxge/apple/apple_int.h
index 42d63628f2..a8fbe2fbaa 100644
--- a/core/src/fxge/apple/apple_int.h
+++ b/core/src/fxge/apple/apple_int.h
@@ -185,7 +185,7 @@ protected:
FX_INT32 _horzSize;
FX_INT32 _vertSize;
};
-class CFX_FontProvider : public IFX_FileRead
+class CFX_FontProvider FX_FINAL : public IFX_FileRead
{
public:
virtual void Release()
diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h
index 2bf4721c0d..433ff4c184 100644
--- a/fpdfsdk/include/fsdk_define.h
+++ b/fpdfsdk/include/fsdk_define.h
@@ -101,7 +101,7 @@ typedef unsigned int FX_UINT;
#include "fpdfview.h"
-class CPDF_CustomAccess : public IFX_FileRead, public CFX_Object
+class CPDF_CustomAccess FX_FINAL : public IFX_FileRead, public CFX_Object
{
public:
CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess);
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h
index e6a9219c88..d7e4e3d8a8 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -31,7 +31,7 @@ class CJS_RuntimeFactory;
#include "javascript/IJavaScript.h"
-class CPDFDoc_Environment
+class CPDFDoc_Environment FX_FINAL
{
public:
CPDFDoc_Environment(CPDF_Document * pDoc);
@@ -39,21 +39,14 @@ public:
int RegAppHandle(FPDF_FORMFILLINFO* pFFinfo);//{ m_pInfo = pFFinfo; return TRUE;}
- virtual void Release()
- {
- if (m_pInfo && m_pInfo->Release)
- m_pInfo->Release(m_pInfo);
- delete this;
- }
-
- virtual void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom)
+ void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom)
{
if (m_pInfo && m_pInfo->FFI_Invalidate)
{
m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom);
}
}
- virtual void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom)
+ void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom)
{
if (m_pInfo && m_pInfo->FFI_OutputSelectedRect)
{
@@ -61,7 +54,7 @@ public:
}
}
- virtual void FFI_SetCursor(int nCursorType)
+ void FFI_SetCursor(int nCursorType)
{
if (m_pInfo && m_pInfo->FFI_SetCursor)
{
@@ -69,7 +62,7 @@ public:
}
}
- virtual int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc)
+ int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc)
{
if (m_pInfo && m_pInfo->FFI_SetTimer)
{
@@ -78,7 +71,7 @@ public:
return -1;
}
- virtual void FFI_KillTimer(int nTimerID)
+ void FFI_KillTimer(int nTimerID)
{
if (m_pInfo && m_pInfo->FFI_KillTimer)
{
@@ -103,7 +96,7 @@ public:
return fxtime;
}
- virtual void FFI_OnChange()
+ void FFI_OnChange()
{
if(m_pInfo && m_pInfo->FFI_OnChange)
{
@@ -111,27 +104,27 @@ public:
}
}
- virtual FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag)
+ FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag)
{
return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0;
}
- virtual FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag)
+ FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag)
{
return (nFlag & FWL_EVENTFLAG_ControlKey) != 0;
}
- virtual FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag)
+ FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag)
{
return (nFlag & FWL_EVENTFLAG_AltKey) != 0;
}
- virtual FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag)
+ FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag)
{
return FALSE;
}
- virtual int JS_appAlert(FX_LPCWSTR Msg, FX_LPCWSTR Title, FX_UINT Type, FX_UINT Icon)
+ int JS_appAlert(FX_LPCWSTR Msg, FX_LPCWSTR Title, FX_UINT Type, FX_UINT Icon)
{
if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert)
{
@@ -147,7 +140,7 @@ public:
return -1;
}
- virtual int JS_appResponse(FX_LPCWSTR Question, FX_LPCWSTR Title, FX_LPCWSTR Default, FX_LPCWSTR cLabel, FPDF_BOOL bPassword, void* response, int length)
+ int JS_appResponse(FX_LPCWSTR Question, FX_LPCWSTR Title, FX_LPCWSTR Default, FX_LPCWSTR cLabel, FPDF_BOOL bPassword, void* response, int length)
{
if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_response)
{
@@ -170,7 +163,7 @@ public:
return -1;
}
- virtual void JS_appBeep(int nType)
+ void JS_appBeep(int nType)
{
if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep)
{
@@ -178,7 +171,7 @@ public:
}
}
- virtual CFX_WideString JS_fieldBrowse()
+ CFX_WideString JS_fieldBrowse()
{
if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Field_browse)
{
@@ -283,7 +276,7 @@ public:
}
}
- virtual FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex)
+ FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex)
{
if(m_pInfo && m_pInfo->FFI_GetPage)
{
@@ -292,7 +285,7 @@ public:
return NULL;
}
- virtual FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document)
+ FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document)
{
if(m_pInfo && m_pInfo->FFI_GetCurrentPage)
{
@@ -456,13 +449,13 @@ private:
FX_BOOL m_bChangeMask;
};
-class CPDFSDK_PageView
+class CPDFSDK_PageView FX_FINAL
{
public:
CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page);
~CPDFSDK_PageView();
public:
- virtual void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) ;
+ void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) ;
public:
CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY);
@@ -485,23 +478,23 @@ public:
CPDF_Document* GetPDFDocument();
CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;}
public:
- virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag);
- virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag);
- virtual FX_BOOL OnChar(int nChar, FX_UINT nFlag);
- virtual FX_BOOL OnKeyDown(int nKeyCode, int nFlag);
- virtual FX_BOOL OnKeyUp(int nKeyCode, int nFlag);
-
- virtual FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag);
- virtual FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag);
- virtual FX_BOOL IsValidAnnot(FX_LPVOID p);
+ FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag);
+ FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag);
+ FX_BOOL OnChar(int nChar, FX_UINT nFlag);
+ FX_BOOL OnKeyDown(int nKeyCode, int nFlag);
+ FX_BOOL OnKeyUp(int nKeyCode, int nFlag);
+
+ FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag);
+ FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag);
+ FX_BOOL IsValidAnnot(FX_LPVOID p);
public:
- virtual void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;}
- virtual void UpdateRects(CFX_RectArray& rects);
+ void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;}
+ void UpdateRects(CFX_RectArray& rects);
void UpdateView(CPDFSDK_Annot* pAnnot);
CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; }
public:
- virtual int GetPageIndex();
+ int GetPageIndex();
void LoadFXAnnots();
private:
CPDF_Matrix m_curMatrix;
diff --git a/fpdfsdk/src/fpdf_sysfontinfo.cpp b/fpdfsdk/src/fpdf_sysfontinfo.cpp
index 4c6b784981..cc75e635b3 100644
--- a/fpdfsdk/src/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/src/fpdf_sysfontinfo.cpp
@@ -7,7 +7,7 @@
#include "../include/fsdk_define.h"
#include "../include/fpdf_sysfontinfo.h"
-class CSysFontInfo_Ext : public IFX_SystemFontInfo
+class CSysFontInfo_Ext FX_FINAL : public IFX_SystemFontInfo
{
public:
FPDF_SYSFONTINFO* m_pInfo;
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index 6637c784fe..8025946ba8 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -13,7 +13,7 @@
#include <ctime>
#endif
-class CFX_IFileWrite:public IFX_StreamWrite
+class CFX_IFileWrite FX_FINAL : public IFX_StreamWrite
{
public:
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 8a97c286aa..b6b89289e4 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -283,7 +283,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY
extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code);
-class CMemFile: public IFX_FileRead, public CFX_Object
+class CMemFile FX_FINAL: public IFX_FileRead, public CFX_Object
{
public:
CMemFile(FX_BYTE* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {}