From 67d5558f1a1b5b26a771c3a05e1e63a2966cc325 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 12 Dec 2018 00:18:43 +0100 Subject: Clear weak pointers in FT2 font list shutdown observers. --- gfx/thebes/gfxFT2FontList.cpp | 15 ++++++++++----- gfx/thebes/gfxFT2FontList.h | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'gfx/thebes') diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 8a652df0d..09c938a24 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -812,6 +812,15 @@ public: : mFontList(aFontList) { } + void Remove() + { + nsCOMPtr obs = services::GetObserverService(); + if (obs) { + obs->RemoveObserver(this, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID); + } + mFontList = nullptr; + } + protected: virtual ~WillShutdownObserver() { } @@ -847,11 +856,7 @@ gfxFT2FontList::gfxFT2FontList() gfxFT2FontList::~gfxFT2FontList() { if (mObserver) { - nsCOMPtr obs = services::GetObserverService(); - if (obs) { - obs->RemoveObserver(mObserver, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID); - } - mObserver = nullptr; + mObserver->Remove(); } } diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index 63187ba26..9fb566c15 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -19,6 +19,7 @@ using mozilla::dom::FontListEntry; class FontNameCache; typedef struct FT_FaceRec_* FT_Face; class nsZipArchive; +class WillShutdownObserver; class FT2FontEntry : public gfxFontEntry { @@ -194,7 +195,7 @@ private: mozilla::UniquePtr mFontNameCache; int64_t mJarModifiedTime; - nsCOMPtr mObserver; + RefPtr mObserver; }; #endif /* GFX_FT2FONTLIST_H */ -- cgit v1.2.3