mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1504365 - Clear weak pointers in shutdown observers. r=erahm
Differential Revision: https://phabricator.services.mozilla.com/D12348 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
3382db587b
commit
55cef5b2ab
@ -31,6 +31,13 @@ namespace dom {
|
||||
|
||||
NS_IMPL_ISUPPORTS(TextTrackManager::ShutdownObserverProxy, nsIObserver);
|
||||
|
||||
void
|
||||
TextTrackManager::ShutdownObserverProxy::Unregister()
|
||||
{
|
||||
nsContentUtils::UnregisterShutdownObserver(this);
|
||||
mManager = nullptr;
|
||||
}
|
||||
|
||||
CompareTextTracks::CompareTextTracks(HTMLMediaElement* aMediaElement)
|
||||
{
|
||||
mMediaElement = aMediaElement;
|
||||
@ -140,7 +147,7 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement)
|
||||
TextTrackManager::~TextTrackManager()
|
||||
{
|
||||
WEBVTT_LOG("%p ~TextTrackManager",this);
|
||||
nsContentUtils::UnregisterShutdownObserver(mShutdownProxy);
|
||||
mShutdownProxy->Unregister();
|
||||
}
|
||||
|
||||
TextTrackList*
|
||||
|
@ -174,12 +174,16 @@ private:
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
||||
nsContentUtils::UnregisterShutdownObserver(this);
|
||||
mManager->NotifyShutdown();
|
||||
if (mManager) {
|
||||
mManager->NotifyShutdown();
|
||||
}
|
||||
Unregister();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void Unregister();
|
||||
|
||||
private:
|
||||
~ShutdownObserverProxy() {};
|
||||
TextTrackManager* mManager;
|
||||
|
@ -945,6 +945,15 @@ public:
|
||||
: mFontList(aFontList)
|
||||
{ }
|
||||
|
||||
void Remove()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->RemoveObserver(this, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID);
|
||||
}
|
||||
mFontList = nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~WillShutdownObserver()
|
||||
{ }
|
||||
@ -980,11 +989,7 @@ gfxFT2FontList::gfxFT2FontList()
|
||||
gfxFT2FontList::~gfxFT2FontList()
|
||||
{
|
||||
if (mObserver) {
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->RemoveObserver(mObserver, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID);
|
||||
}
|
||||
mObserver = nullptr;
|
||||
mObserver->Remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ using mozilla::dom::FontListEntry;
|
||||
class FontNameCache;
|
||||
typedef struct FT_FaceRec_* FT_Face;
|
||||
class nsZipArchive;
|
||||
class WillShutdownObserver;
|
||||
|
||||
class FT2FontEntry : public gfxFontEntry
|
||||
{
|
||||
@ -200,7 +201,8 @@ protected:
|
||||
private:
|
||||
mozilla::UniquePtr<FontNameCache> mFontNameCache;
|
||||
int64_t mJarModifiedTime;
|
||||
nsCOMPtr<nsIObserver> mObserver;
|
||||
RefPtr<WillShutdownObserver> mObserver;
|
||||
|
||||
};
|
||||
|
||||
#endif /* GFX_FT2FONTLIST_H */
|
||||
|
Loading…
Reference in New Issue
Block a user