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

Issue 848033006: Allow copying scoped_nsobject of different type. (Closed)

Created:
5 years, 11 months ago by droger
Modified:
5 years, 11 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Allow copying scoped_nsobject of different type. This code was leading to a crash: scoped_nsobject<MyClass> a([[MyClass alloc] init]); scoped_nsobject<NSObject> b(a); Because |a| is converted to raw pointer, and |b| is constructed with the raw pointer, without calling retain. This creates a subtle crash later on when the scoped_nsobject are destroyed. This code however, was not crashing: scoped_nsobject<MyClass> b(a); Because in that case the copy constructor is used. This was somewhat inconsistent and bug prone, especially if the type of |a| is changed. In that case the type of |b| must be changed at the same time, or it causes a crash. This CL introduces a new constructor for the scoped_nsobject variants that allows passing a scoped_nsobject of a different type. It is consistent with scoped_refptr which also has this constructor. Committed: https://crrev.com/941226ba0e49b1e2d359ea084ecb00c672dd6054 Cr-Commit-Position: refs/heads/master@{#311487}

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+15 lines, -0 lines) Patch
M base/mac/scoped_nsobject.h View 3 chunks +15 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (3 generated)
droger
FYI I'm running the CL on the downstream bots here: https://chromereviews.googleplex.com/138877014/
5 years, 11 months ago (2015-01-14 13:21:25 UTC) #2
droger
+mark as OWNER
5 years, 11 months ago (2015-01-14 14:15:05 UTC) #4
sdefresne
lgtm
5 years, 11 months ago (2015-01-14 14:26:21 UTC) #5
Mark Mentovai
Does this allow you to do an end run around the typing system without explicitly ...
5 years, 11 months ago (2015-01-14 14:33:02 UTC) #6
droger
On 2015/01/14 14:33:02, Mark Mentovai wrote: > Does this allow you to do an end ...
5 years, 11 months ago (2015-01-14 15:12:46 UTC) #7
sdefresne
On 2015/01/14 at 14:33:02, mark wrote: > Does this allow you to do an end ...
5 years, 11 months ago (2015-01-14 15:16:19 UTC) #8
Mark Mentovai
Perfect, LGTM.
5 years, 11 months ago (2015-01-14 15:21:13 UTC) #9
droger
Thanks for the reviews.
5 years, 11 months ago (2015-01-14 15:22:16 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/848033006/1
5 years, 11 months ago (2015-01-14 15:23:16 UTC) #12
commit-bot: I haz the power
Committed patchset #1 (id:1)
5 years, 11 months ago (2015-01-14 16:18:18 UTC) #13
commit-bot: I haz the power
5 years, 11 months ago (2015-01-14 16:19:34 UTC) #14
Message was sent while issue was closed.
Patchset 1 (id:??) landed as
https://crrev.com/941226ba0e49b1e2d359ea084ecb00c672dd6054
Cr-Commit-Position: refs/heads/master@{#311487}

Powered by Google App Engine
This is Rietveld 408576698