mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Bug 862256 - don't (re)reference CameraControl object during/after destructor, r=sotaro, a=tef+
This commit is contained in:
parent
84e2de4a5d
commit
282ec3c583
@ -275,19 +275,40 @@ CameraControlImpl::OnShutter()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CameraControlImpl::OnClosedInternal()
|
||||
class OnClosedTask : public nsRunnable
|
||||
{
|
||||
DOM_CAMERA_LOGI("Camera hardware was closed\n");
|
||||
if (mOnClosedCb.get()) {
|
||||
mOnClosedCb->HandleEvent();
|
||||
public:
|
||||
OnClosedTask(nsMainThreadPtrHandle<nsICameraClosedCallback> onClosed, uint64_t aWindowId)
|
||||
: mOnClosedCb(onClosed)
|
||||
, mWindowId(aWindowId)
|
||||
{
|
||||
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~OnClosedTask()
|
||||
{
|
||||
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mOnClosedCb.get() && nsDOMCameraManager::IsWindowStillActive(mWindowId)) {
|
||||
mOnClosedCb->HandleEvent();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsMainThreadPtrHandle<nsICameraClosedCallback> mOnClosedCb;
|
||||
uint64_t mWindowId;
|
||||
};
|
||||
|
||||
void
|
||||
CameraControlImpl::OnClosed()
|
||||
{
|
||||
nsCOMPtr<nsIRunnable> onClosed = NS_NewRunnableMethod(this, &CameraControlImpl::OnClosedInternal);
|
||||
nsCOMPtr<nsIRunnable> onClosed = new OnClosedTask(mOnClosedCb, mWindowId);
|
||||
nsresult rv = NS_DispatchToMainThread(onClosed);
|
||||
if (NS_FAILED(rv)) {
|
||||
DOM_CAMERA_LOGW("Failed to dispatch onClosed event to main thread (%d)\n", rv);
|
||||
|
@ -218,6 +218,10 @@ GonkCameraHardware::~GonkCameraHardware()
|
||||
mCamera.clear();
|
||||
mNativeWindow.clear();
|
||||
|
||||
if (mClosing) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the OnClosed event; the upper layers can't do anything
|
||||
* with the hardware layer once they receive this event.
|
||||
|
Loading…
x
Reference in New Issue
Block a user