mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 15:17:29 +09:00
Issue #1643 - Follow-up: Make sure things aren't changed while iterating.
This fixes some crashing scenarios.
This commit is contained in:
parent
7f8852baa3
commit
2fae136204
1 changed files with 10 additions and 2 deletions
|
|
@ -118,6 +118,10 @@ ResizeObserverController::Notify()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hold a strong reference to the document, because otherwise calling
|
||||||
|
// all active observers on it might yank it out from under us.
|
||||||
|
RefPtr<nsIDocument> document(mDocument);
|
||||||
|
|
||||||
uint32_t shallowestTargetDepth = 0;
|
uint32_t shallowestTargetDepth = 0;
|
||||||
|
|
||||||
GatherAllActiveObservations(shallowestTargetDepth);
|
GatherAllActiveObservations(shallowestTargetDepth);
|
||||||
|
|
@ -152,7 +156,7 @@ ResizeObserverController::Notify()
|
||||||
nsEventStatus status = nsEventStatus_eIgnore;
|
nsEventStatus status = nsEventStatus_eIgnore;
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||||
mDocument->GetWindow()->GetCurrentInnerWindow();
|
document->GetWindow()->GetCurrentInnerWindow();
|
||||||
|
|
||||||
if (window) {
|
if (window) {
|
||||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(window);
|
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(window);
|
||||||
|
|
@ -184,7 +188,11 @@ ResizeObserverController::BroadcastAllActiveObservations()
|
||||||
{
|
{
|
||||||
uint32_t shallowestTargetDepth = UINT32_MAX;
|
uint32_t shallowestTargetDepth = UINT32_MAX;
|
||||||
|
|
||||||
for (auto observer : mResizeObservers) {
|
// Use a copy of the observers as this invokes the callbacks of the observers
|
||||||
|
// which could register/unregister observers at will.
|
||||||
|
nsTArray<RefPtr<ResizeObserver>> tempObservers(mResizeObservers);
|
||||||
|
|
||||||
|
for (auto observer : tempObservers) {
|
||||||
|
|
||||||
uint32_t targetDepth = observer->BroadcastActiveObservations();
|
uint32_t targetDepth = observer->BroadcastActiveObservations();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue