Bug 821804 - Allow unitialized WeakPtrs to work properly. r=Waldo

This ensures that the WeakPtr always points at a valid object and avoids the
need to test for that during operations.
This commit is contained in:
Jeff Muizelaar 2012-12-18 11:37:14 -05:00
parent 77c26d6ed3
commit a4467e34c9

View File

@ -113,7 +113,8 @@ class WeakPtr
{
public:
WeakPtr(const WeakPtr<T>& o) : ref(o.ref) {}
WeakPtr() : ref(nullptr) {}
// Ensure that ref is dereferenceable in the uninitialized state
WeakPtr() : ref(new typename SupportsWeakPtr<T>::WeakReference(nullptr)) {}
operator T*() const {
return ref->get();