mirror of
https://gitee.com/openharmony/print_print_fwk
synced 2024-12-11 11:04:40 +00:00
fix bugs Signed-off-by:zoumeiguang@huawei.com
Signed-off-by: guang <zoumeiguang@huawei.com>
This commit is contained in:
parent
ac77ca5170
commit
21b76137a5
@ -41,7 +41,7 @@ private:
|
||||
napi_env env, napi_value value, std::shared_ptr<OHOS::AbilityRuntime::AbilityContext> &abilityContext);
|
||||
static napi_value WrapVoidToJS(napi_env env);
|
||||
static napi_status VerifyParameters(napi_env env, size_t argc, napi_value *argv,
|
||||
const std::shared_ptr<PrintTaskContext> context, napi_value proxy);
|
||||
const std::shared_ptr<PrintTaskContext> context);
|
||||
|
||||
private:
|
||||
static __thread napi_ref globalCtor;
|
||||
|
@ -37,12 +37,19 @@ napi_value NapiPrintTask::Print(napi_env env, napi_callback_info info)
|
||||
PRINT_HILOGD("print parser to native params %{public}d!", static_cast<int>(argc));
|
||||
PRINT_ASSERT_BASE(env, argc == NapiPrintUtils::ARGC_ONE || argc == NapiPrintUtils::ARGC_TWO,
|
||||
"need 1 or 2 parameter!", napi_invalid_arg);
|
||||
napi_value proxy = nullptr;
|
||||
napi_status checkStatus = VerifyParameters(env, argc, argv, context, proxy);
|
||||
napi_status checkStatus = VerifyParameters(env, argc, argv, context);
|
||||
if (checkStatus != napi_ok) {
|
||||
return checkStatus;
|
||||
}
|
||||
|
||||
napi_value proxy = nullptr;
|
||||
napi_status status = napi_new_instance(env, GetCtor(env), argc, argv, &proxy);
|
||||
if ((proxy == nullptr) || (status != napi_ok)) {
|
||||
PRINT_HILOGE("Failed to create print task");
|
||||
context->SetErrorIndex(E_PRINT_GENERIC_FAILURE);
|
||||
return napi_generic_failure;
|
||||
}
|
||||
|
||||
PrintTask *task;
|
||||
PRINT_CALL_BASE(env, napi_unwrap(env, proxy, reinterpret_cast<void **>(&task)), napi_invalid_arg);
|
||||
uint32_t ret = E_PRINT_GENERIC_FAILURE;
|
||||
@ -207,13 +214,6 @@ napi_status NapiPrintTask::VerifyParameters(napi_env env, size_t argc, napi_valu
|
||||
PRINT_HILOGE("Print, Ability Context is null.");
|
||||
}
|
||||
}
|
||||
|
||||
napi_status status = napi_new_instance(env, GetCtor(env), argc, argv, &proxy);
|
||||
if ((proxy == nullptr) || (status != napi_ok)) {
|
||||
PRINT_HILOGE("Failed to create print task");
|
||||
context->SetErrorIndex(E_PRINT_GENERIC_FAILURE);
|
||||
return napi_generic_failure;
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
} // namespace OHOS::Print
|
||||
|
@ -272,7 +272,7 @@ int32_t PrintServiceAbility::StartPrint(const std::vector<std::string> &fileList
|
||||
}
|
||||
PRINT_HILOGD("PrintServiceAbility StartPrint started.");
|
||||
std::lock_guard<std::recursive_mutex> lock(apiMutex_);
|
||||
if (fileList.empty() && fdList.empty() && token == nullptr) {
|
||||
if ((fileList.empty() && fdList.empty()) || token == nullptr) {
|
||||
PRINT_HILOGE("to be printed filelist and fdlist are empty, or token is null.");
|
||||
return E_PRINT_INVALID_PARAMETER;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user