mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
store page org child node & fix code warn
Signed-off-by: yanming <1969986071@qq.com>
This commit is contained in:
parent
9e1d81da5a
commit
9ae076a324
@ -230,7 +230,7 @@ std::string NodeObject::ToString()
|
||||
void NodeObject::FromString(const std::string& buffer)
|
||||
{
|
||||
CHECK_NULL_VOID_NOLOG(uobject_);
|
||||
uobject_->Deserialize((char*)buffer.data(), buffer.size());
|
||||
uobject_->Deserialize(buffer.data(), buffer.size());
|
||||
}
|
||||
|
||||
size_t NodeObject::Hash()
|
||||
|
@ -156,14 +156,14 @@ void UObject::Serialize(char* buffer, int32_t bufferLen)
|
||||
}
|
||||
}
|
||||
|
||||
void UObject::Deserialize(char* buffer, int32_t bufferLen)
|
||||
void UObject::Deserialize(const char* buffer, int32_t bufferLen)
|
||||
{
|
||||
if (!buffer) {
|
||||
LOGE("|ERROR| buffer is null");
|
||||
return;
|
||||
}
|
||||
|
||||
buffer_ = buffer;
|
||||
constBuffer_ = buffer;
|
||||
offset_ = 0;
|
||||
|
||||
while (offset_ < bufferLen) {
|
||||
@ -350,74 +350,74 @@ void UObject::WriteObj(const std::string& key, const std::shared_ptr<UObject>& o
|
||||
|
||||
char UObject::ReadChar()
|
||||
{
|
||||
char result = buffer_[0];
|
||||
char result = constBuffer_[0];
|
||||
offset_++;
|
||||
buffer_++;
|
||||
constBuffer_++;
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t UObject::ReadInt32()
|
||||
{
|
||||
int32_t result;
|
||||
if (memcpy_s(&result, sizeof(int32_t), buffer_, sizeof(int32_t)) != 0) {
|
||||
if (memcpy_s(&result, sizeof(int32_t), constBuffer_, sizeof(int32_t)) != 0) {
|
||||
LOGE("memcpy overflow.");
|
||||
return 0;
|
||||
}
|
||||
offset_ += sizeof(int32_t);
|
||||
buffer_ += sizeof(int32_t);
|
||||
constBuffer_ += sizeof(int32_t);
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t UObject::ReadInt64()
|
||||
{
|
||||
int64_t result;
|
||||
if (memcpy_s(&result, sizeof(int64_t), buffer_, sizeof(int64_t)) != 0) {
|
||||
if (memcpy_s(&result, sizeof(int64_t), constBuffer_, sizeof(int64_t)) != 0) {
|
||||
LOGE("memcpy overflow.");
|
||||
return 0;
|
||||
}
|
||||
offset_ += sizeof(int64_t);
|
||||
buffer_ += sizeof(int64_t);
|
||||
constBuffer_ += sizeof(int64_t);
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t UObject::ReadSizeT()
|
||||
{
|
||||
size_t result;
|
||||
if (memcpy_s(&result, sizeof(size_t), buffer_, sizeof(size_t)) != 0) {
|
||||
if (memcpy_s(&result, sizeof(size_t), constBuffer_, sizeof(size_t)) != 0) {
|
||||
LOGE("memcpy overflow.");
|
||||
return 0;
|
||||
}
|
||||
offset_ += sizeof(size_t);
|
||||
buffer_ += sizeof(size_t);
|
||||
constBuffer_ += sizeof(size_t);
|
||||
return result;
|
||||
}
|
||||
|
||||
double UObject::ReadDouble()
|
||||
{
|
||||
double result;
|
||||
if (memcpy_s(&result, sizeof(double), buffer_, sizeof(double)) != 0) {
|
||||
if (memcpy_s(&result, sizeof(double), constBuffer_, sizeof(double)) != 0) {
|
||||
LOGE("memcpy overflow.");
|
||||
return 0;
|
||||
}
|
||||
offset_ += sizeof(double);
|
||||
buffer_ += sizeof(double);
|
||||
constBuffer_ += sizeof(double);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string UObject::ReadString(int32_t len)
|
||||
{
|
||||
std::string result(buffer_, len);
|
||||
std::string result(constBuffer_, len);
|
||||
offset_ += len;
|
||||
buffer_ += len;
|
||||
constBuffer_ += len;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<UObject> UObject::ReadObj(int32_t len)
|
||||
{
|
||||
std::shared_ptr<UObject> obj = std::make_shared<UObject>();
|
||||
obj->Deserialize(buffer_, len);
|
||||
obj->Deserialize(constBuffer_, len);
|
||||
offset_ += len;
|
||||
buffer_ += len;
|
||||
constBuffer_ += len;
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
bool Contains(const std::string& key) const;
|
||||
|
||||
void Serialize(char* buffer, int32_t bufferLen);
|
||||
void Deserialize(char* buffer, int32_t bufferLen);
|
||||
void Deserialize(const char* buffer, int32_t bufferLen);
|
||||
|
||||
size_t Hash();
|
||||
|
||||
@ -90,6 +90,7 @@ private:
|
||||
void ReadKV();
|
||||
|
||||
char* buffer_ = nullptr;
|
||||
const char* constBuffer_ = nullptr;
|
||||
int32_t bufferLen_ = 0;
|
||||
int32_t offset_ = 0;
|
||||
size_t hashValue_ = 0;
|
||||
|
@ -63,8 +63,6 @@ void RestorePageNode(const RefPtr<NG::FrameNode>& pageNode)
|
||||
auto pagePattern = pageNode->GetPattern<NG::PagePattern>();
|
||||
CHECK_NULL_VOID(pagePattern);
|
||||
pagePattern->SetOnBackPressed([]() { return true; });
|
||||
std::function<void()> emptyFunc;
|
||||
pagePattern->SetPageTransitionFunc(std::move(emptyFunc));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -708,8 +706,8 @@ void DistributedUI::RestoreUITreeInner(const SerializeableObjectArray& nodeArray
|
||||
auto pageRootNode = context->GetStageManager()->GetLastPage();
|
||||
CHECK_NULL_VOID_NOLOG(pageRootNode);
|
||||
RestorePageNode(pageRootNode);
|
||||
auto children = pageRootNode->GetChildren();
|
||||
for (const auto& child : children) {
|
||||
sinkPageChildren_ = pageRootNode->GetChildren();
|
||||
for (const auto& child : sinkPageChildren_) {
|
||||
pageRootNode->RemoveChild(child);
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,7 @@ private:
|
||||
|
||||
std::unordered_map<int32_t, int32_t> nodeIdMapping_;
|
||||
std::unordered_map<int32_t, std::size_t> nodeHashs_;
|
||||
std::list<RefPtr<NG::UINode>> sinkPageChildren_;
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user