@@ -924,6 +924,18 @@ void AXObjectCache::remove(RenderObject* renderer)
924924void AXObjectCache::remove (Node& node)
925925{
926926 AXTRACE (makeString (" AXObjectCache::remove 0x" _s, hex (reinterpret_cast <uintptr_t >(this ))));
927+
928+ removeNodeForUse (node);
929+ remove (m_nodeObjectMapping.take (&node));
930+ remove (node.renderer ());
931+
932+ // If we're in the middle of a cache update, don't modify any of these vectors because we are currently
933+ // iterating over them. They will be cleared at the end of the cache update, so not removing them here is fine.
934+ if (m_performingDeferredCacheUpdate) {
935+ AXLOG (" Bailing out before removing node from m_deferred* vectors as we are in the middle of a cache update." );
936+ return ;
937+ }
938+
927939 if (is<Element>(node)) {
928940 m_deferredTextFormControlValue.remove (downcast<Element>(&node));
929941 m_deferredAttributeChange.removeAllMatching ([&node] (const auto & entry) {
@@ -947,11 +959,6 @@ void AXObjectCache::remove(Node& node)
947959 if (entry.first == &node)
948960 entry.first = nullptr ;
949961 });
950-
951- removeNodeForUse (node);
952-
953- remove (m_nodeObjectMapping.take (&node));
954- remove (node.renderer ());
955962}
956963
957964void AXObjectCache::remove (Widget* view)
@@ -1954,7 +1961,7 @@ bool AXObjectCache::shouldProcessAttributeChange(Element* element, const Qualifi
19541961void AXObjectCache::handleAttributeChange (Element* element, const QualifiedName& attrName)
19551962{
19561963 AXTRACE (makeString (" AXObjectCache::handleAttributeChange 0x" _s, hex (reinterpret_cast <uintptr_t >(this ))));
1957- AXLOG (makeString (" attribute " , attrName.localName ().string (), " for element " , element->debugDescription ()));
1964+ AXLOG (makeString (" attribute " , attrName.localName ().string (), " for element " , element ? element ->debugDescription () : String ( " nullptr " _s )));
19581965
19591966 if (!shouldProcessAttributeChange (element, attrName))
19601967 return ;
0 commit comments