History

Added more debug info to crash with signals

ksuprynowicz committed 3 years ago

Commit b786ffc1 parent 3e692a62 files · +45 −29Browse files

Showing the changes to libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp (1 of 2 files). Show all

Unified · Split

libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp+39−29
@@ -673,7 +673,7 @@ void ScriptMethodV8Proxy::callback(const v8::FunctionCallbackInfo<v8::Value>& ar · 672 unmodified lines
673 v8::Locker locker(arguments.GetIsolate());673 v8::Locker locker(arguments.GetIsolate());
674 v8::Isolate::Scope isolateScope(arguments.GetIsolate());674 v8::Isolate::Scope isolateScope(arguments.GetIsolate());
675 v8::HandleScope handleScope(arguments.GetIsolate());675 v8::HandleScope handleScope(arguments.GetIsolate());
676 Q_ASSERT(!arguments.GetIsolate()->GetCurrentContext().IsEmpty());676 //Q_ASSERT(!arguments.GetIsolate()->GetCurrentContext().IsEmpty());
677 v8::Context::Scope contextScope(arguments.GetIsolate()->GetCurrentContext());677 v8::Context::Scope contextScope(arguments.GetIsolate()->GetCurrentContext());
678 if (!arguments.Data()->IsObject()) {678 if (!arguments.Data()->IsObject()) {
679 arguments.GetIsolate()->ThrowError("Method value is not an object");679 arguments.GetIsolate()->ThrowError("Method value is not an object");
@@ -1082,40 +1082,50 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu · 402 unmodified lines
1082 args[arg] = _engine->castVariantToValue(argValue).get();1082 args[arg] = _engine->castVariantToValue(argValue).get();
1083 }1083 }
1084 1084
1085 QList<Connection> connections;1085 /*QList<Connection> connections;
1086 withReadLock([&]{1086 withReadLock([&]{
1087 connections = _connections;1087 connections = _connections;
1088 });1088 });*/
1089 1089
1090 for (ConnectionList::iterator iter = connections.begin(); iter != connections.end(); ++iter) {1090 withReadLock([&]{
1091 Connection& conn = *iter;1091 //for (ConnectionList::iterator iter = connections.begin(); iter != connections.end(); ++iter) {
1092 Q_ASSERT(!conn.callback.get().IsEmpty());1092 for (ConnectionList::iterator iter = _connections.begin(); iter != _connections.end(); ++iter) {
1093 Q_ASSERT(!conn.callback.get()->IsUndefined());1093 Connection& conn = *iter;
1094 Q_ASSERT(conn.callback.get()->IsFunction());1094 {
1095 {1095 //auto functionContext = callback->CreationContext();
1096 v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(conn.callback.get());1096 auto functionContext = _v8Context.Get(_engine->getIsolate());
1097 //auto functionContext = callback->CreationContext();1097 _engine->pushContext(functionContext);
1098 auto functionContext = _v8Context.Get(_engine->getIsolate());1098 v8::Context::Scope functionContextScope(functionContext);
1099 _engine->pushContext(functionContext);1099
1100 v8::Context::Scope functionContextScope(functionContext);1100 Q_ASSERT(!conn.callback.get().IsEmpty());
1101 1101 Q_ASSERT(!conn.callback.get()->IsUndefined());
1102 v8::Local<v8::Value> v8This;1102 Q_ASSERT(!conn.callback.get()->IsNull());
1103 if (conn.thisValue.get()->IsObject()) {1103 if (!conn.callback.get()->IsFunction()) {
1104 v8This = conn.thisValue.get();1104 auto stringV8 = conn.callback.get()->ToDetailString(functionContext).ToLocalChecked();
1105 } else {1105 QString error = *v8::String::Utf8Value(_engine->getIsolate(), stringV8);
1106 v8This = functionContext->Global();1106 qDebug() << error;
1107 }1107 Q_ASSERT(false);
1108 }
1109 v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(conn.callback.get());
1108 1110
1109 v8::TryCatch tryCatch(isolate);1111 v8::Local<v8::Value> v8This;
1110 callback->Call(functionContext, v8This, numArgs, args);1112 if (conn.thisValue.get()->IsObject()) {
1111 if (tryCatch.HasCaught()) {1113 v8This = conn.thisValue.get();
1112 qCDebug(scriptengine) << "Signal proxy " << fullName() << " connection call failed: \""1114 } else {
1113 << _engine->formatErrorMessageFromTryCatch(tryCatch)1115 v8This = functionContext->Global();
1114 << "\nThis provided: " << conn.thisValue.get()->IsObject();1116 }
1117
1118 v8::TryCatch tryCatch(isolate);
1119 callback->Call(functionContext, v8This, numArgs, args);
1120 if (tryCatch.HasCaught()) {
1121 qCDebug(scriptengine) << "Signal proxy " << fullName() << " connection call failed: \""
1122 << _engine->formatErrorMessageFromTryCatch(tryCatch)
1123 << "\nThis provided: " << conn.thisValue.get()->IsObject();
1124 }
1125 _engine->popContext();
1115 }1126 }
1116 _engine->popContext();
1117 }1127 }
1118 }1128 });
1119 1129
1120 return -1;1130 return -1;
1121}1131}