mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 15:17:29 +09:00
Clear CanvasShutdownObserver::mCanvas when the canvas goes away.
This is fallout from Bug 1167235 - Use a fast method of double buffering for canvas. It is possible for the CanvasRenderingContext2D to be destroyed while we're in the middle of the call to nsObserverService::NotifyObservers() for shutdown. This leaves the shutdown observer with a dangling pointer to the canvas, so this patch explicitly clears the pointer when the context goes away.
This commit is contained in:
parent
07716cb1d7
commit
391e7d295f
1 changed files with 11 additions and 2 deletions
|
|
@ -783,6 +783,15 @@ public:
|
||||||
: mCanvas(aCanvas)
|
: mCanvas(aCanvas)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void OnShutdown() {
|
||||||
|
if(!mCanvas) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCanvas = nullptr;
|
||||||
|
nsContentUtils::UnregisterShutdownObserver(this);
|
||||||
|
}
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIOBSERVER
|
NS_DECL_NSIOBSERVER
|
||||||
private:
|
private:
|
||||||
|
|
@ -800,7 +809,7 @@ CanvasShutdownObserver::Observe(nsISupports* aSubject,
|
||||||
{
|
{
|
||||||
if (mCanvas && strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
if (mCanvas && strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
||||||
mCanvas->OnShutdown();
|
mCanvas->OnShutdown();
|
||||||
nsContentUtils::UnregisterShutdownObserver(this);
|
OnShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
@ -1218,7 +1227,7 @@ void
|
||||||
CanvasRenderingContext2D::RemoveShutdownObserver()
|
CanvasRenderingContext2D::RemoveShutdownObserver()
|
||||||
{
|
{
|
||||||
if (mShutdownObserver) {
|
if (mShutdownObserver) {
|
||||||
nsContentUtils::UnregisterShutdownObserver(mShutdownObserver);
|
mShutdownObserver->OnShutdown();
|
||||||
mShutdownObserver = nullptr;
|
mShutdownObserver = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue