fix previewer crash bug

Signed-off-by: lihao <lihao71@huawei.com>
Change-Id: I85093fad88d04348414e789897cfe0335f92cc03
This commit is contained in:
lihao
2022-03-26 17:57:02 +08:00
parent 023e8388ab
commit bd3292da28
8 changed files with 43 additions and 10 deletions
+6 -2
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -29,7 +29,7 @@ use_curl_download = true
accessibility_support = true
rich_components_support = true
advance_components_support = false
form_components_support = false
form_components_support = true
xcomponent_components_support = false
plugin_components_support = false
js_pa_support = false
@@ -38,6 +38,10 @@ enable_rosen_backend = false
enable_standard_input = false
enable_system_clipboard = false
if (form_components_support) {
defines += [ "FORM_SUPPORTED" ]
}
cflags_cc = [
"-std=c++17",
"-Wno-thread-safety-attributes",
+6 -2
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -33,7 +33,7 @@ use_curl_download = true
accessibility_support = true
rich_components_support = true
advance_components_support = false
form_components_support = false
form_components_support = true
plugin_components_support = false
xcomponent_components_support = false
js_pa_support = false
@@ -41,6 +41,10 @@ connect_server_support = false
enable_rosen_backend = false
enable_standard_input = false
if (form_components_support) {
defines += [ "FORM_SUPPORTED" ]
}
cflags_cc = [
"-std=c++17",
"-DWINVER=0x0601",
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -29,7 +29,7 @@ void JsClickFunction::Execute()
#ifdef USE_V8_ENGINE
V8DeclarativeEngineInstance::TriggerPageUpdate();
#elif USE_QUICKJS_ENGINE
QJSDeclarativeEngineInstance::TriggerPageUpdate(QJSContext::Current());
QJSDeclarativeEngineInstance::TriggerPageUpdate(QJSDeclarativeEngineInstance::GetCurrentContext());
#elif USE_ARK_ENGINE
JsiDeclarativeEngineInstance::TriggerPageUpdate(JsiDeclarativeEngineInstance::GetCurrentRuntime());
#endif
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -102,6 +102,11 @@ public:
return AceType::RawPtr(engineInstance_->GetDelegate());
}
RefPtr<QJSDeclarativeEngineInstance> GetEngineInstance()
{
return engineInstance_;
}
#if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM)
void ReplaceJSContent(const std::string& url, const std::string componentName);
#endif
@@ -25,6 +25,7 @@
#include "base/log/ace_trace.h"
#include "base/log/event_report.h"
#include "base/log/log.h"
#include "frameworks/bridge/common/utils/engine_helper.h"
#include "frameworks/bridge/declarative_frontend/engine/bindings_implementation.h"
#include "frameworks/bridge/declarative_frontend/engine/quickjs/modules/qjs_module_manager.h"
#include "frameworks/bridge/declarative_frontend/engine/quickjs/qjs_helpers.h"
@@ -114,6 +115,22 @@ RefPtr<JsAcePage> QJSDeclarativeEngineInstance::GetStagingPage(JSContext* ctx)
}
}
JSContext* QJSDeclarativeEngineInstance::GetCurrentContext()
{
auto engine = EngineHelper::GetCurrentEngine();
auto qjsEngine = AceType::DynamicCast<QJSDeclarativeEngine>(engine);
if (!qjsEngine) {
LOGE("qjsEngine is null");
return nullptr;
}
auto engineInstance = qjsEngine->GetEngineInstance();
if (engineInstance == nullptr) {
LOGE("engineInstance is nullptr");
return nullptr;
}
return engineInstance->GetQJSContext();
}
void QJSDeclarativeEngineInstance::PushJSCommand(const RefPtr<JsCommand>& jsCommand, bool forcePush) const
{
auto page = GetRunningPage();
@@ -68,6 +68,7 @@ public:
static RefPtr<JsAcePage> GetRunningPage(JSContext* ctx);
static RefPtr<JsAcePage> GetStagingPage(JSContext* ctx);
static JSContext* GetCurrentContext();
void SetStagingPage(const RefPtr<JsAcePage>& page);
+4 -2
View File
@@ -352,8 +352,10 @@ template("ace_core_source_set") {
if (defined(config.form_components_support) &&
config.form_components_support) {
sources += [ "common/form_manager.cpp" ]
deps += [ "$ace_root/frameworks/core/components/form:ace_core_components_form_$platform" ]
if (!use_mingw_win && !use_mac) {
sources += [ "common/form_manager.cpp" ]
deps += [ "$ace_root/frameworks/core/components/form:ace_core_components_form_$platform" ]
}
}
if (defined(config.build_container_scope_lib) &&