mirror of
https://github.com/openharmony/ace_engine_lite.git
synced 2026-07-21 08:55:21 -04:00
Description: fix data binding update issue
IssueNo:I3W782 Feature or Bugfix: Feature Binary Source:No Signed-off-by: jiadexiang <jiadexiang@huawei.com>
This commit is contained in:
@@ -47,14 +47,15 @@ void LazyLoadManager::RenderLazyLoadWatcher()
|
||||
{
|
||||
LazyLoadWatcher *next = nullptr;
|
||||
while (firstWatcher_ != nullptr) {
|
||||
Component *componet = ComponentUtils::GetComponentFromBindingObject(firstWatcher_->GetNativeElement());
|
||||
if (componet != nullptr) {
|
||||
componet->AddWatcherItem(firstWatcher_->GetAttrName(), firstWatcher_->GetAttrGetter());
|
||||
Component *component = ComponentUtils::GetComponentFromBindingObject(firstWatcher_->GetNativeElement());
|
||||
if (component != nullptr) {
|
||||
component->AddWatcherItem(firstWatcher_->GetAttrName(), firstWatcher_->GetAttrGetter(), true);
|
||||
}
|
||||
next = const_cast<LazyLoadWatcher *>(firstWatcher_->GetNext());
|
||||
delete firstWatcher_;
|
||||
firstWatcher_ = next;
|
||||
}
|
||||
lastWatcher_ = nullptr;
|
||||
state_ = LazyLoadState::DONE;
|
||||
}
|
||||
|
||||
@@ -77,6 +78,9 @@ void LazyLoadManager::AddLazyLoadWatcher(jerry_value_t nativeElement, jerry_valu
|
||||
lastWatcher_->SetNext(*watcher);
|
||||
lastWatcher_ = watcher;
|
||||
}
|
||||
// The state must be ready if any watcher lazy loading request was added, otherwise, in some cases,
|
||||
// the js_ability may not be able to know there are watchers need to be loaded.
|
||||
state_ = LazyLoadState::READY;
|
||||
}
|
||||
} // namespace ACELite
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1020,24 +1020,27 @@ int32_t Component::GetAnimatorValue(char *animatorValue, const int8_t index, boo
|
||||
|
||||
jerry_value_t Component::AddWatcherItem(const jerry_value_t attrKey, const jerry_value_t attrValue, bool isLazyLoading)
|
||||
{
|
||||
#ifdef FEATURE_LAZY_LOADING_MODULE
|
||||
isLazyLoading = true;
|
||||
#endif
|
||||
jerry_value_t options = jerry_create_object();
|
||||
JerrySetNamedProperty(options, ARG_WATCH_EL, nativeElement_);
|
||||
JerrySetNamedProperty(options, ARG_WATCH_ATTR, attrKey);
|
||||
jerry_value_t watcher = CallJSWatcher(attrValue, WatcherCallbackFunc, options);
|
||||
jerry_value_t propValue = UNDEFINED;
|
||||
jerry_release_value(options);
|
||||
if (IS_UNDEFINED(watcher) || jerry_value_is_error(watcher)) {
|
||||
HILOG_ERROR(HILOG_MODULE_ACE, "Failed to create Watcher instance.");
|
||||
} else {
|
||||
InsertWatcherCommon(watchersHead_, watcher);
|
||||
if (!isLazyLoading) {
|
||||
propValue = jerryx_get_property_str(watcher, "_lastValue");
|
||||
}
|
||||
jerry_release_value(watcher); // release error case, note: release undefined is harmless
|
||||
return UNDEFINED;
|
||||
}
|
||||
jerry_release_value(options);
|
||||
return propValue;
|
||||
// watcher is valide, insert it to the list
|
||||
InsertWatcherCommon(watchersHead_, watcher);
|
||||
if (isLazyLoading) {
|
||||
// If the watcher creating is lazy loading, need to call watcher's update function to make sure the view
|
||||
// is updated with latest value properly, because it's the lazy case, the value might be changed already.
|
||||
JSRelease(JSObject::Call(watcher, "update", nullptr, 0));
|
||||
return UNDEFINED;
|
||||
}
|
||||
|
||||
// is the direct watcher creating, return the lastValue and need to be released out of this function
|
||||
return jerryx_get_property_str(watcher, "_lastValue");
|
||||
}
|
||||
|
||||
void Component::ParseAttrs()
|
||||
|
||||
@@ -213,10 +213,6 @@ void JSAbility::HandleRenderTick()
|
||||
// reset error tick tracing count
|
||||
errorTickCount_ = 0;
|
||||
|
||||
#if defined(TARGET_SIMULATOR) && defined(FEATURE_LAZY_LOADING_MODULE)
|
||||
LazyLoadHandleRenderTick(nullptr);
|
||||
#endif
|
||||
|
||||
if ((ProductAdapter::IsTEHandlersRegisted()) && !(FatalHandler::GetInstance().IsAppExiting())) {
|
||||
FatalHandler::GetInstance().SetTEHandlingFlag(true);
|
||||
ProductAdapter::ProcessOneTE();
|
||||
|
||||
@@ -307,16 +307,12 @@ void StateMachine::RenderPage()
|
||||
START_TRACING(RENDER);
|
||||
// if not in init state, reset all watchers of previous page at first
|
||||
LazyLoadManager* lazy = const_cast<LazyLoadManager *>(appContext_->GetLazyLoadManager());
|
||||
if (lazy->GetState() != LazyLoadState::INIT) {
|
||||
if (lazy != nullptr) {
|
||||
lazy->ResetWatchers();
|
||||
}
|
||||
// Note: do not release the returned value by Render function, it will be released by component
|
||||
jerry_value_t element = appContext_->Render(viewModel_);
|
||||
|
||||
// mark lazy load te task
|
||||
if (lazy->GetLazyWatcher() != nullptr) {
|
||||
lazy->SetState(LazyLoadState::READY);
|
||||
}
|
||||
rootComponent_ = ComponentUtils::GetComponentFromBindingObject(element);
|
||||
// append scroll layer to the outermost view
|
||||
scrollLayer_ = new ScrollLayer();
|
||||
|
||||
@@ -93,6 +93,8 @@
|
||||
#define FEATURE_LOCALIZATION_MODULE
|
||||
#endif // QT_SIMULATOR
|
||||
|
||||
#define FEATURE_LAZY_LOADING_MODULE
|
||||
|
||||
/**
|
||||
* timer module
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user