mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1183920: Properly delete MediaResource when released on non main thread. r=cpearce
Leak was not detected as it was registered via NS_LOG_RELEASE.
This commit is contained in:
parent
072a8b1aa1
commit
8080a286fd
@ -50,20 +50,14 @@ namespace mozilla {
|
||||
void
|
||||
MediaResource::Destroy()
|
||||
{
|
||||
// If we're being destroyed on a non-main thread, we AddRef again and
|
||||
// use a proxy to release the MediaResource on the main thread, where
|
||||
// the MediaResource is deleted. This ensures we only delete the
|
||||
// MediaResource on the main thread.
|
||||
if (!NS_IsMainThread()) {
|
||||
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
|
||||
NS_ENSURE_TRUE_VOID(mainThread);
|
||||
nsRefPtr<MediaResource> doomed(this);
|
||||
if (NS_FAILED(NS_ProxyRelease(mainThread, doomed, true))) {
|
||||
NS_WARNING("Failed to proxy release to main thread!");
|
||||
}
|
||||
} else {
|
||||
// Ensures we only delete the MediaResource on the main thread.
|
||||
if (NS_IsMainThread()) {
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIRunnable> destroyRunnable =
|
||||
NS_NewNonOwningRunnableMethod(this, &MediaResource::Destroy);
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(destroyRunnable)));
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(MediaResource)
|
||||
|
Loading…
Reference in New Issue
Block a user