diff --git a/frameworks/bridge/declarative_frontend/engine/stateMgmt.js b/frameworks/bridge/declarative_frontend/engine/stateMgmt.js index 90b397ec1f5d9b852763ee812fc0b3b6a9f04e94..c00a466468561c9aee801201fd0955c784c36518 100644 --- a/frameworks/bridge/declarative_frontend/engine/stateMgmt.js +++ b/frameworks/bridge/declarative_frontend/engine/stateMgmt.js @@ -2597,8 +2597,7 @@ class ObservedPropertyAbstract extends SubscribedAbstractProperty { class CustomDialogController extends NativeCustomDialogController { constructor(arg, view) { super(arg, view); - this.builder_ = arg.builder; - this.cancel_ = arg.cancel; + this.arg_ = arg; this.view_ = view; } } diff --git a/frameworks/bridge/declarative_frontend/jsview/dialog/js_custom_dialog_controller.cpp b/frameworks/bridge/declarative_frontend/jsview/dialog/js_custom_dialog_controller.cpp index 43aefc60b9509d278ad8dcac23d0bb4c6b127626..9bf3713acf14dce07dd2a901e59e1aeeaee997b8 100644 --- a/frameworks/bridge/declarative_frontend/jsview/dialog/js_custom_dialog_controller.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/dialog/js_custom_dialog_controller.cpp @@ -396,7 +396,7 @@ bool JSCustomDialogController::ParseAnimation( std::function onFinishEvent; if (onFinish->IsFunction()) { WeakPtr frameNode = NG::ViewStackProcessor::GetInstance()->GetMainFrameNode(); - RefPtr jsFunc = AceType::MakeRefPtr(JSRef(), JSRef::Cast(onFinish)); + auto jsFunc = AceType::MakeRefPtr(JSRef(), JSRef::Cast(onFinish)); onFinishEvent = [execCtx = execContext, func = std::move(jsFunc), node = frameNode]() { JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx); ACE_SCORING_EVENT("CustomDialog.onFinish"); diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/common/custom_dialog_controller.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/common/custom_dialog_controller.ts index f1bc43cc6eccb62f58d68c2c1920a95f5e630eb2..e1afead126c7faff50318cc94458452cba6d8553 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/common/custom_dialog_controller.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/common/custom_dialog_controller.ts @@ -13,14 +13,15 @@ * limitations under the License. */ class CustomDialogController extends NativeCustomDialogController { - private builder_: () => void; // hold builder to kill root (builder) cycle dependency (view-->controller-->builder-->view) - private cancel_?: () => void; + // hold arg so NativeCustomDialogController can make use of the functions + // contained in it without root (global) cycle dependency problems. like + // builder, cancel, openAnimation::onFinish, closeAnimation::onFinish, etc. + private arg_: CustomDialogControllerConstructorArg; private view_: ViewPU; constructor(arg: CustomDialogControllerConstructorArg, view: ViewPU) { super(arg, view); - this.builder_ = arg.builder; - this.cancel_ = arg.cancel; + this.arg_ = arg; this.view_ = view; } }