mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Remove move constructor from SurfaceHandler (#54108)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54108 Removed SurfaceHandler's move constructor, to avoid any potential issues with referencing moved-from instances. Changelog: [Internal] Reviewed By: Abbondanzo, mdvacca Differential Revision: D83977790 fbshipit-source-id: 3ea7a64f2183b7f28c62cca06537d3a26ba0bea8
This commit is contained in:
1 parent
7aae5562f3
commit
ef6f3f6032
5 files changed
+44
-55
No files matched your search
@@ -57,7 +57,7 @@ using namespace facebook::react;
|
||||
if (self = [super init]) {
|
||||
_surfacePresenter = surfacePresenter;
|
||||
|
||||
_surfaceHandler = SurfaceHandler{RCTStringFromNSString(moduleName), getNextRootViewTag()};
|
||||
_surfaceHandler.emplace(RCTStringFromNSString(moduleName), getNextRootViewTag());
|
||||
_surfaceHandler->setProps(convertIdToFollyDynamic(initialProperties));
|
||||
|
||||
[_surfacePresenter registerSurface:self];
|
||||
|
||||
+38
-28
@@ -166,34 +166,39 @@ void FabricUIManagerBinding::startSurface(
|
||||
return;
|
||||
}
|
||||
|
||||
SurfaceHandler* surfaceHandler = nullptr;
|
||||
{
|
||||
std::unique_lock lock(surfaceHandlerRegistryMutex_);
|
||||
auto [it, _] = surfaceHandlerRegistry_.try_emplace(
|
||||
surfaceId,
|
||||
std::in_place_index<0>,
|
||||
moduleName->toStdString(),
|
||||
surfaceId);
|
||||
surfaceHandler = &std::get<SurfaceHandler>(it->second);
|
||||
}
|
||||
|
||||
surfaceHandler->setContextContainer(scheduler->getContextContainer());
|
||||
if (initialProps != nullptr) {
|
||||
surfaceHandler->setProps(initialProps->consume());
|
||||
}
|
||||
|
||||
auto layoutContext = LayoutContext{};
|
||||
layoutContext.pointScaleFactor = pointScaleFactor_;
|
||||
surfaceHandler->constraintLayout({}, layoutContext);
|
||||
|
||||
auto surfaceHandler = SurfaceHandler{moduleName->toStdString(), surfaceId};
|
||||
surfaceHandler.setContextContainer(scheduler->getContextContainer());
|
||||
if (initialProps != nullptr) {
|
||||
surfaceHandler.setProps(initialProps->consume());
|
||||
}
|
||||
surfaceHandler.constraintLayout({}, layoutContext);
|
||||
|
||||
scheduler->registerSurface(surfaceHandler);
|
||||
scheduler->registerSurface(*surfaceHandler);
|
||||
|
||||
auto mountingManager = getMountingManager("startSurface");
|
||||
if (mountingManager != nullptr) {
|
||||
mountingManager->onSurfaceStart(surfaceId);
|
||||
}
|
||||
|
||||
surfaceHandler.start();
|
||||
surfaceHandler->start();
|
||||
|
||||
if (ReactNativeFeatureFlags::enableLayoutAnimationsOnAndroid()) {
|
||||
surfaceHandler.getMountingCoordinator()->setMountingOverrideDelegate(
|
||||
surfaceHandler->getMountingCoordinator()->setMountingOverrideDelegate(
|
||||
animationDriver_);
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock lock(surfaceHandlerRegistryMutex_);
|
||||
surfaceHandlerRegistry_.emplace(surfaceId, std::move(surfaceHandler));
|
||||
}
|
||||
}
|
||||
|
||||
jint FabricUIManagerBinding::findNextFocusableElement(
|
||||
@@ -338,31 +343,36 @@ void FabricUIManagerBinding::startSurfaceWithConstraints(
|
||||
constraints.layoutDirection =
|
||||
isRTL != 0 ? LayoutDirection::RightToLeft : LayoutDirection::LeftToRight;
|
||||
|
||||
auto surfaceHandler = SurfaceHandler{moduleName->toStdString(), surfaceId};
|
||||
surfaceHandler.setContextContainer(scheduler->getContextContainer());
|
||||
if (initialProps != nullptr) {
|
||||
surfaceHandler.setProps(initialProps->consume());
|
||||
SurfaceHandler* surfaceHandler = nullptr;
|
||||
{
|
||||
std::unique_lock lock(surfaceHandlerRegistryMutex_);
|
||||
auto [it, _] = surfaceHandlerRegistry_.try_emplace(
|
||||
surfaceId,
|
||||
std::in_place_index<0>,
|
||||
moduleName->toStdString(),
|
||||
surfaceId);
|
||||
surfaceHandler = &std::get<SurfaceHandler>(it->second);
|
||||
}
|
||||
surfaceHandler.constraintLayout(constraints, context);
|
||||
|
||||
scheduler->registerSurface(surfaceHandler);
|
||||
surfaceHandler->setContextContainer(scheduler->getContextContainer());
|
||||
if (initialProps != nullptr) {
|
||||
surfaceHandler->setProps(initialProps->consume());
|
||||
}
|
||||
surfaceHandler->constraintLayout(constraints, context);
|
||||
|
||||
scheduler->registerSurface(*surfaceHandler);
|
||||
|
||||
auto mountingManager = getMountingManager("startSurfaceWithConstraints");
|
||||
if (mountingManager != nullptr) {
|
||||
mountingManager->onSurfaceStart(surfaceId);
|
||||
}
|
||||
|
||||
surfaceHandler.start();
|
||||
surfaceHandler->start();
|
||||
|
||||
if (ReactNativeFeatureFlags::enableLayoutAnimationsOnAndroid()) {
|
||||
surfaceHandler.getMountingCoordinator()->setMountingOverrideDelegate(
|
||||
surfaceHandler->getMountingCoordinator()->setMountingOverrideDelegate(
|
||||
animationDriver_);
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock lock(surfaceHandlerRegistryMutex_);
|
||||
surfaceHandlerRegistry_.emplace(surfaceId, std::move(surfaceHandler));
|
||||
}
|
||||
}
|
||||
|
||||
// Used by non-bridgeless+Fabric
|
||||
|
||||
@@ -23,26 +23,6 @@ SurfaceHandler::SurfaceHandler(
|
||||
parameters_.surfaceId = surfaceId;
|
||||
}
|
||||
|
||||
SurfaceHandler::SurfaceHandler(SurfaceHandler&& other) noexcept {
|
||||
operator=(std::move(other));
|
||||
}
|
||||
|
||||
SurfaceHandler& SurfaceHandler::operator=(SurfaceHandler&& other) noexcept {
|
||||
std::unique_lock lock1(linkMutex_, std::defer_lock);
|
||||
std::unique_lock lock2(parametersMutex_, std::defer_lock);
|
||||
std::unique_lock lock3(other.linkMutex_, std::defer_lock);
|
||||
std::unique_lock lock4(other.parametersMutex_, std::defer_lock);
|
||||
std::lock(lock1, lock2, lock3, lock4);
|
||||
|
||||
link_ = other.link_;
|
||||
parameters_ = other.parameters_;
|
||||
|
||||
other.link_ = Link{};
|
||||
other.parameters_ = Parameters{};
|
||||
other.parameters_.contextContainer = parameters_.contextContainer;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#pragma mark - Surface Life-Cycle Management
|
||||
|
||||
void SurfaceHandler::setContextContainer(
|
||||
|
||||
@@ -67,11 +67,11 @@ class SurfaceHandler {
|
||||
virtual ~SurfaceHandler() noexcept;
|
||||
|
||||
/*
|
||||
* Movable-only.
|
||||
* Not moveable or copyable
|
||||
*/
|
||||
SurfaceHandler(SurfaceHandler &&other) noexcept;
|
||||
SurfaceHandler(SurfaceHandler &&other) noexcept = delete;
|
||||
SurfaceHandler(const SurfaceHandler &SurfaceHandler) noexcept = delete;
|
||||
SurfaceHandler &operator=(SurfaceHandler &&other) noexcept;
|
||||
SurfaceHandler &operator=(SurfaceHandler &&other) noexcept = delete;
|
||||
SurfaceHandler &operator=(const SurfaceHandler &other) noexcept = delete;
|
||||
|
||||
#pragma mark - Surface Life-Cycle Management
|
||||
|
||||
@@ -29,9 +29,8 @@ void SurfaceManager::startSurface(
|
||||
const LayoutContext& layoutContext) noexcept {
|
||||
{
|
||||
std::unique_lock lock(mutex_);
|
||||
auto surfaceHandler = SurfaceHandler{moduleName, surfaceId};
|
||||
surfaceHandler.setContextContainer(scheduler_.getContextContainer());
|
||||
registry_.emplace(surfaceId, std::move(surfaceHandler));
|
||||
auto [it, _] = registry_.try_emplace(surfaceId, moduleName, surfaceId);
|
||||
it->second.setContextContainer(scheduler_.getContextContainer());
|
||||
}
|
||||
|
||||
visit(surfaceId, [&](const SurfaceHandler& surfaceHandler) {
|
||||
|
||||
Reference in new issue
Block a user