From 1ab653600367f21880e9ea70754cff77377fb091 Mon Sep 17 00:00:00 2001 From: johnche Date: Fri, 6 Dec 2024 20:20:24 +0800 Subject: [PATCH] =?UTF-8?q?[unreal]=E7=BB=A7=E7=BB=AD=E5=87=8F=E5=B0=91std?= =?UTF-8?q?::string=E7=9A=84=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unity/native_src/Src/BackendEnv.cpp | 2 +- unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp | 2 +- unreal/Puerts/Source/JsEnv/Private/PromiseRejectCallback.hpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/unity/native_src/Src/BackendEnv.cpp b/unity/native_src/Src/BackendEnv.cpp index 04e7c79d640..baa7d53f739 100644 --- a/unity/native_src/Src/BackendEnv.cpp +++ b/unity/native_src/Src/BackendEnv.cpp @@ -1163,7 +1163,7 @@ std::string FBackendEnv::GetJSStackTrace() JS_FreeValue(ctx, stack); return ret; #else - return StackTraceToString(Isolate, v8::StackTrace::CurrentStackTrace(Isolate, 10, v8::StackTrace::kDetailed)); + return StackTraceToString(Isolate, v8::StackTrace::CurrentStackTrace(Isolate, 10, v8::StackTrace::kDetailed)).c_str(); #endif } diff --git a/unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp b/unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp index 4b8b0b3562b..35bf6fdafd3 100644 --- a/unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp +++ b/unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp @@ -1704,7 +1704,7 @@ FString FJsEnvImpl::CurrentStackTrace() v8::Isolate::Scope IsolateScope(Isolate); v8::HandleScope HandleScope(Isolate); - std::string StackTrace = StackTraceToString(Isolate, v8::StackTrace::CurrentStackTrace(Isolate, 10, v8::StackTrace::kDetailed)); + PString StackTrace = StackTraceToString(Isolate, v8::StackTrace::CurrentStackTrace(Isolate, 10, v8::StackTrace::kDetailed)); return UTF8_TO_TCHAR(StackTrace.c_str()); #else return TEXT(""); diff --git a/unreal/Puerts/Source/JsEnv/Private/PromiseRejectCallback.hpp b/unreal/Puerts/Source/JsEnv/Private/PromiseRejectCallback.hpp index 0e0550ef959..f274bb6cce7 100644 --- a/unreal/Puerts/Source/JsEnv/Private/PromiseRejectCallback.hpp +++ b/unreal/Puerts/Source/JsEnv/Private/PromiseRejectCallback.hpp @@ -1,5 +1,6 @@ #pragma once #include +#include "PString.h" #if !defined(PUERTS_NAMESPACE) #if defined(WITH_QJS_NAMESPACE_SUFFIX) #define PUERTS_NAMESPACE puerts_qjs @@ -71,7 +72,7 @@ void SetPromiseRejectCallback(const v8::FunctionCallbackInfo& Args) // TODO: rename this file #ifndef WITH_QUICKJS -std::string StackTraceToString(v8::Isolate* InIsolate, v8::Local InStack) +PString StackTraceToString(v8::Isolate* InIsolate, v8::Local InStack) { std::ostringstream stm; for (int i = 0; i < InStack->GetFrameCount(); i++) @@ -106,7 +107,7 @@ std::string StackTraceToString(v8::Isolate* InIsolate, v8::Local << ")" << std::endl; } } - return stm.str(); + return stm.str().c_str(); } #endif