OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 return fPtr; | 59 return fPtr; |
60 } | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * Copy src into this, and return a pointer to a copy of it. Note this | 63 * Copy src into this, and return a pointer to a copy of it. Note this |
64 * will always return the same pointer, so if it is called on a lazy that | 64 * will always return the same pointer, so if it is called on a lazy that |
65 * has already been initialized, then this will copy over the previous | 65 * has already been initialized, then this will copy over the previous |
66 * contents. | 66 * contents. |
67 */ | 67 */ |
68 T* set(const T& src) { | 68 T* set(const T& src) { |
| 69 // Diagnoistic. May remove later. See crbug.com/364224 |
| 70 if (NULL == &src) { |
| 71 sk_throw(); |
| 72 } |
| 73 |
69 if (this->isValid()) { | 74 if (this->isValid()) { |
70 *fPtr = src; | 75 *fPtr = src; |
71 } else { | 76 } else { |
72 fPtr = new (SkTCast<T*>(fStorage)) T(src); | 77 fPtr = new (SkTCast<T*>(fStorage)) T(src); |
73 } | 78 } |
74 return fPtr; | 79 return fPtr; |
75 } | 80 } |
76 | 81 |
77 /** | 82 /** |
78 * Destroy the lazy object (if it was created via init() or set()) | 83 * Destroy the lazy object (if it was created via init() or set()) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 operator const T*() const { return fObj; } | 188 operator const T*() const { return fObj; } |
184 | 189 |
185 const T& operator *() const { return *fObj; } | 190 const T& operator *() const { return *fObj; } |
186 | 191 |
187 private: | 192 private: |
188 const T* fObj; | 193 const T* fObj; |
189 SkTLazy<T> fLazy; | 194 SkTLazy<T> fLazy; |
190 }; | 195 }; |
191 | 196 |
192 #endif | 197 #endif |
OLD | NEW |