Erase ComponentDescriptorRegistry before inserting it to fix crash

Summary:
Changelog: [internal]

if you called `ContextContainer.insert("key", <value>)` and then again `ContextContainer.insert("key", <new_value>)`, the old value will remain in `ContextContainer`. This seems to be by design however it causes crash when reloading surface that uses `ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE`.

We fix it by erasing `ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE` in Scheduler before inserting a new one.

Reviewed By: shergin

Differential Revision: D18421153

fbshipit-source-id: a01e5f6ac864fd641674d84e97d447f8cb9114be
This commit is contained in:
Samuel Susla authored and Facebook Github Bot committed 2019-11-11 03:04:41 -08:00
1 parent 620f83aae5
commit d06a7c1748
1 file changed
+4 -1
+4 -1
View File
@@ -72,8 +72,11 @@ Scheduler::Scheduler(
uiManagerBinding->attach(uiManager);
});
auto componentDescriptorRegistryKey =
"ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE";
schedulerToolbox.contextContainer->erase(componentDescriptorRegistryKey);
schedulerToolbox.contextContainer->insert(
"ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE",
componentDescriptorRegistryKey,
std::weak_ptr<ComponentDescriptorRegistry const>(
componentDescriptorRegistry_));