summaryrefslogtreecommitdiff
path: root/fpdfsdk/include/javascript/JS_Object.h
diff options
context:
space:
mode:
authorBruce Dawson <brucedawson@google.com>2015-01-05 13:26:17 -0800
committerBruce Dawson <brucedawson@google.com>2015-01-05 13:26:17 -0800
commitb4649dc9c0f8f64c335d4ed61a82976f25e19a70 (patch)
treebc994c8c801029077f3dc1d5cc7975686ff29c26 /fpdfsdk/include/javascript/JS_Object.h
parent5d9acf8ee5dbbaad838f14f1fa173d892c4300ab (diff)
downloadpdfium-b4649dc9c0f8f64c335d4ed61a82976f25e19a70.tar.xz
XFA: merge patch from CL 831903002, m_sTimeMap fixes
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 TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/831903002 Review URL: https://codereview.chromium.org/800883004
Diffstat (limited to 'fpdfsdk/include/javascript/JS_Object.h')
-rw-r--r--fpdfsdk/include/javascript/JS_Object.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/fpdfsdk/include/javascript/JS_Object.h b/fpdfsdk/include/javascript/JS_Object.h
index ca6f4a1d11..7bdfcf1a53 100644
--- a/fpdfsdk/include/javascript/JS_Object.h
+++ b/fpdfsdk/include/javascript/JS_Object.h
@@ -157,7 +157,7 @@ public:
CTimerMapArray m_Array;
};
-static JS_TIMER_MAPARRAY m_sTimeMap;
+JS_TIMER_MAPARRAY& GetTimeMap();
class CJS_Runtime;
@@ -188,7 +188,7 @@ public:
if (m_nTimerID)KillJSTimer();
IFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
m_nTimerID = pHandler->SetTimer(nElapse,TimerProc);
- m_sTimeMap.SetAt(m_nTimerID,this);
+ GetTimeMap().SetAt(m_nTimerID,this);
m_dwElapse = nElapse;
return m_nTimerID;
};
@@ -204,7 +204,7 @@ public:
}
IFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
pHandler->KillTimer(m_nTimerID);
- m_sTimeMap.RemoveAt(m_nTimerID);
+ GetTimeMap().RemoveAt(m_nTimerID);
m_nTimerID = 0;
}
};
@@ -261,7 +261,7 @@ public:
static void TimerProc(int idEvent)
{
- if (CJS_Timer * pTimer = m_sTimeMap.GetAt(idEvent))
+ if (CJS_Timer * pTimer = GetTimeMap().GetAt(idEvent))
{
if (!pTimer->m_bProcessing)
{