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

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

Issue 2247083002: Merge to M53: Fix issue when firing TimerProc() destroys timer (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@2785
Patch Set: 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 CFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); 138 CFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
139 pHandler->KillTimer(m_nTimerID); 139 pHandler->KillTimer(m_nTimerID);
140 } 140 }
141 GetGlobalTimerMap()->erase(m_nTimerID); 141 GetGlobalTimerMap()->erase(m_nTimerID);
142 m_nTimerID = 0; 142 m_nTimerID = 0;
143 } 143 }
144 } 144 }
145 145
146 // static 146 // static
147 void CJS_Timer::TimerProc(int idEvent) { 147 void CJS_Timer::TimerProc(int idEvent) {
148 const auto it = GetGlobalTimerMap()->find(idEvent); 148 auto it = GetGlobalTimerMap()->find(idEvent);
149 if (it != GetGlobalTimerMap()->end()) { 149 if (it == GetGlobalTimerMap()->end())
150 CJS_Timer* pTimer = it->second; 150 return;
151 if (!pTimer->m_bProcessing) { 151
152 CFX_AutoRestorer<bool> scoped_processing(&pTimer->m_bProcessing); 152 CJS_Timer* pTimer = it->second;
153 pTimer->m_bProcessing = true; 153 if (pTimer->m_bProcessing)
154 if (pTimer->m_pEmbedObj) 154 return;
155 pTimer->m_pEmbedObj->TimerProc(pTimer); 155
156 } 156 pTimer->m_bProcessing = true;
157 } 157 if (pTimer->m_pEmbedObj)
158 pTimer->m_pEmbedObj->TimerProc(pTimer);
159
160 // Timer proc may have destroyed timer, find it again.
161 it = GetGlobalTimerMap()->find(idEvent);
162 if (it == GetGlobalTimerMap()->end())
163 return;
164
165 pTimer = it->second;
166 pTimer->m_bProcessing = false;
158 } 167 }
159 168
160 // static 169 // static
161 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() { 170 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() {
162 // Leak the timer array at shutdown. 171 // Leak the timer array at shutdown.
163 static auto* s_TimerMap = new TimerMap; 172 static auto* s_TimerMap = new TimerMap;
164 return s_TimerMap; 173 return s_TimerMap;
165 } 174 }
166 175
167 void CJS_Timer::OnDestroyed() { 176 void CJS_Timer::OnDestroyed() {
168 m_bValid = false; 177 m_bValid = false;
169 } 178 }
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