Breaking: YGConfigRef related const-correctness fixes (#1371)
Summary: X-link: https://github.com/facebook/react-native/pull/39374 Pull Request resolved: https://github.com/facebook/yoga/pull/1371 Right now `YGConfigGetDefault` and `YGNodeGetConfig` both return mutable, freeable, configs, which is bad, since the former points to a global singleton config, and the latter usually does too. Mutating this is not thread safe, and it should never be freed. This change makes these functions return `YGConfigConstRef` to prevent mutation, and also lets us allow `YGConfigNewWithConfig` to accept a const config. If a caller does want to mutate a config (such as to free it), it must be tracked manually. Changelog: [Internal] Reviewed By: javache Differential Revision: D49132476 fbshipit-source-id: ac9ce61149e69c6c25cadb99711435b0a5b9f38a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a003c09a4c
commit
0720e0b22a
@@ -17,7 +17,9 @@
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
Node::Node(yoga::Config* config) : config_{config} {
|
||||
Node::Node() : Node{&Config::getDefault()} {}
|
||||
|
||||
Node::Node(const yoga::Config* config) : config_{config} {
|
||||
yoga::assertFatal(
|
||||
config != nullptr, "Attempting to construct Node with null config");
|
||||
|
||||
@@ -285,7 +287,7 @@ void Node::setConfig(yoga::Config* config) {
|
||||
config->useWebDefaults() == config_->useWebDefaults(),
|
||||
"UseWebDefaults may not be changed after constructing a Node");
|
||||
|
||||
if (yoga::configUpdateInvalidatesLayout(config_, config)) {
|
||||
if (yoga::configUpdateInvalidatesLayout(*config_, *config)) {
|
||||
markDirtyAndPropagate();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user