Skip to content

Commit

Permalink
[0.62] Drop Views left in Shadow Node Registry during UIManager dtor (#…
Browse files Browse the repository at this point in the history
…5871)

* Drop remaining ShadowNodes in UIManager dtor

* Change files
  • Loading branch information
FalseLobster authored Aug 31, 2020
1 parent 1e63538 commit 348d927
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Drop remaining ShadowNodes in UIManager dtor",
"packageName": "react-native-windows",
"email": "email not defined",
"dependentChangeType": "patch",
"date": "2020-08-28T22:47:39.486Z"
}
4 changes: 3 additions & 1 deletion vnext/ReactWindowsCore/Modules/UIManagerModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ UIManager::UIManager(std::vector<std::unique_ptr<IViewManager>> &&viewManagers,

UIManager::~UIManager() {
m_nodeRegistry.removeAllRootViews([this](int64_t rootViewTag) { removeRootView(rootViewTag); });

m_nodeRegistry.ForAllNodes([this](int64_t tag, shadow_ptr const &shadowNode) noexcept {
DropView(tag, false, true);
});
m_nativeUIManager->setHost(nullptr);
m_nativeUIManager->destroy();
}
Expand Down
6 changes: 6 additions & 0 deletions vnext/ReactWindowsCore/ShadowNodeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,11 @@ ShadowNode *ShadowNodeRegistry::getParentRootShadowNode(int64_t nodeTag) {
return nullptr;
}

void ShadowNodeRegistry::ForAllNodes(const Mso::FunctorRef<void(int64_t, shadow_ptr const &) noexcept> &fnDo) noexcept {
for (auto &kvp : m_allNodes) {
fnDo(kvp.first, kvp.second);
}
}

} // namespace react
} // namespace facebook
3 changes: 3 additions & 0 deletions vnext/ReactWindowsCore/ShadowNodeRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once
#include <ShadowNode.h>
#include <functional/functorref.h>
#include <map>

namespace facebook {
Expand Down Expand Up @@ -32,6 +33,8 @@ struct ShadowNodeRegistry {

ShadowNode *getParentRootShadowNode(int64_t nodeTag);

void ForAllNodes(const Mso::FunctorRef<void(int64_t, shadow_ptr const &) noexcept> &fnDo) noexcept;

private:
std::unordered_set<int64_t> m_roots;
std::map<int64_t, std::unique_ptr<ShadowNode, ShadowNodeDeleter>> m_allNodes;
Expand Down

0 comments on commit 348d927

Please sign in to comment.