Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: fpdfsdk/javascript/JS_Object.cpp

Issue 2214003003: Fix issue when firing TimerProc() destroys timer (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfformfill_embeddertest.cpp ('k') | testing/resources/bug_634394.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/javascript/JS_Object.h" 7 #include "fpdfsdk/javascript/JS_Object.h"
8 8
9 #include "fpdfsdk/include/fsdk_mgr.h" 9 #include "fpdfsdk/include/fsdk_mgr.h"
10 #include "fpdfsdk/javascript/JS_Define.h" 10 #include "fpdfsdk/javascript/JS_Define.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 CFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); 108 CFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
109 pHandler->KillTimer(m_nTimerID); 109 pHandler->KillTimer(m_nTimerID);
110 } 110 }
111 GetGlobalTimerMap()->erase(m_nTimerID); 111 GetGlobalTimerMap()->erase(m_nTimerID);
112 m_nTimerID = 0; 112 m_nTimerID = 0;
113 } 113 }
114 } 114 }
115 115
116 // static 116 // static
117 void CJS_Timer::TimerProc(int idEvent) { 117 void CJS_Timer::TimerProc(int idEvent) {
118 const auto it = GetGlobalTimerMap()->find(idEvent); 118 auto it = GetGlobalTimerMap()->find(idEvent);
119 if (it != GetGlobalTimerMap()->end()) { 119 if (it == GetGlobalTimerMap()->end())
120 CJS_Timer* pTimer = it->second; 120 return;
121 if (!pTimer->m_bProcessing) { 121
122 CFX_AutoRestorer<bool> scoped_processing(&pTimer->m_bProcessing); 122 CJS_Timer* pTimer = it->second;
123 pTimer->m_bProcessing = true; 123 if (pTimer->m_bProcessing)
124 if (pTimer->m_pEmbedObj) 124 return;
125 pTimer->m_pEmbedObj->TimerProc(pTimer); 125
126 } 126 pTimer->m_bProcessing = true;
127 } 127 if (pTimer->m_pEmbedObj)
128 pTimer->m_pEmbedObj->TimerProc(pTimer);
129
130 // Timer proc may have destroyed timer, find it again.
131 it = GetGlobalTimerMap()->find(idEvent);
132 if (it == GetGlobalTimerMap()->end())
133 return;
134
135 pTimer = it->second;
136 pTimer->m_bProcessing = false;
128 } 137 }
129 138
130 // static 139 // static
131 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() { 140 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() {
132 // Leak the timer array at shutdown. 141 // Leak the timer array at shutdown.
133 static auto* s_TimerMap = new TimerMap; 142 static auto* s_TimerMap = new TimerMap;
134 return s_TimerMap; 143 return s_TimerMap;
135 } 144 }
136 145
137 void CJS_Timer::OnDestroyed() { 146 void CJS_Timer::OnDestroyed() {
138 m_bValid = false; 147 m_bValid = false;
139 } 148 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfformfill_embeddertest.cpp ('k') | testing/resources/bug_634394.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698