mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 828502 - let nsMainThreadPtrHandle::get() handle nullptrs; r=bholley
This commit is contained in:
parent
48ca903ef9
commit
4d67018cf9
@ -129,8 +129,10 @@ public:
|
||||
|
||||
T* get() {
|
||||
// Nobody should be touching the raw pointer off-main-thread.
|
||||
if (MOZ_UNLIKELY(!NS_IsMainThread()))
|
||||
if (MOZ_UNLIKELY(!NS_IsMainThread())) {
|
||||
NS_ERROR("Can't dereference nsMainThreadPtrHolder off main thread");
|
||||
MOZ_CRASH();
|
||||
}
|
||||
return mRawPtr;
|
||||
}
|
||||
|
||||
@ -173,7 +175,14 @@ class nsMainThreadPtrHandle
|
||||
// These all call through to nsMainThreadPtrHolder, and thus implicitly
|
||||
// assert that we're on the main thread. Off-main-thread consumers must treat
|
||||
// these handles as opaque.
|
||||
T* get() { return mPtr.get()->get(); }
|
||||
T* get()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mPtr) {
|
||||
return mPtr.get()->get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
operator T*() { return get(); }
|
||||
T* operator->() { return get(); }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user