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

Unified Diff: webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc

Issue 2494893002: Crash in DirectX capturer (Closed)
Patch Set: Resolve review comments Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
diff --git a/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc b/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
index b17c195340b0e495fa6e123a2b33c06141e9a2c5..2256e162fb4aa94be2052402f93744b8c396e6f0 100644
--- a/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
+++ b/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
@@ -285,9 +285,9 @@ void DxgiOutputDuplicator::Setup(Context* context) {
}
void DxgiOutputDuplicator::Unregister(const Context* const context) {
- for (size_t i = 0; i < contexts_.size(); i++) {
- if (contexts_[i] == context) {
- contexts_[i] = nullptr;
+ for (auto it = contexts_.begin(); it != contexts_.end(); it++) {
Sergey Ulanov 2016/11/11 18:27:18 This loop can be replaced with std::find: contex
Hzj_jie 2016/11/11 21:51:31 Done.
+ if (*it == context) {
+ contexts_.erase(it);
Sergey Ulanov 2016/11/11 18:27:18 What was the reason this code was implemented this
Hzj_jie 2016/11/11 21:51:31 Because std::vector::erase is O(n) instead of O(1)
Sergey Ulanov 2016/11/11 22:57:35 FWIW it can be O(1) if you swap it with the last e
Hzj_jie 2016/11/11 23:28:22 Oh, yes, since we have searched already. But the n
return;
}
}
@@ -297,6 +297,7 @@ void DxgiOutputDuplicator::Unregister(const Context* const context) {
void DxgiOutputDuplicator::SpreadContextChange(const Context* const source) {
for (Context* dest : contexts_) {
+ RTC_DCHECK(dest);
if (dest != source) {
dest->updated_region.AddRegion(source->updated_region);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698