summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorBruce Dawson <brucedawson@google.com>2015-01-05 13:21:46 -0800
committerBruce Dawson <brucedawson@google.com>2015-01-05 13:21:46 -0800
commita975cfae4719986e5ea0ff06a45b91e1cdd042b3 (patch)
treec25e1342e8fd465c7cc00d707e7c118a8fb4e447 /fpdfsdk/src
parent263842843f4b817b9713eb3a081e297e1708f582 (diff)
downloadpdfium-a975cfae4719986e5ea0ff06a45b91e1cdd042b3.tar.xz
Get rid of fifteen copies of m_sTimeMap and their initializers.
m_sTimeMap is a global variable with a constructor and destructor, which is not allowed. This change moves it to a function with a static pointer so that it is constructed on demand and then leaked, thus avoiding having startup and shutdown code. This also fixes a worrisome bug caused by having m_sTimeMap defined in a header file. Because m_sTimeMap was defined (and marked as static) in a header file there were fifteen separate copies of it, one for each source file which included the header file. This could easily lead to bugs because a timer that was added from one source file would be invisible to other source files. Each instance of m_sTimeMap added four entries to the dump-static-initializers.py report, for a total of sixty, so this fix significantly cleans up that report. BUG=441899 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/831903002
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/javascript/JS_Object.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp
index 3b7774d4d8..8a019d40e8 100644
--- a/fpdfsdk/src/javascript/JS_Object.cpp
+++ b/fpdfsdk/src/javascript/JS_Object.cpp
@@ -12,6 +12,13 @@
// #include "../../include/javascript/JS_ResMgr.h"
#include "../../include/javascript/JS_Context.h"
+JS_TIMER_MAPARRAY& GetTimeMap()
+{
+ // Leak the timer array at shutdown.
+ static auto* timeMap = new JS_TIMER_MAPARRAY;
+ return *timeMap;
+}
+
int FXJS_MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle, FX_UINT nType, FX_UINT nIcon)
{
int nRet = 0;