History

Removed deadlock in signal proxy disconnect again

ksuprynowicz committed 3 years ago

Commit 887ebd51 parent d25e5494 files · +18 −13Browse files

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

Unified · Split

libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp+10−8
@@ -1186,14 +1186,15 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu · 1185 unmodified lines
1186 args[arg] = _engine->castVariantToValue(argValue).get();1186 args[arg] = _engine->castVariantToValue(argValue).get();
1187 }*/1187 }*/
1188 1188
1189 /*QList<Connection> connections;1189 QList<Connection> connections;
1190 withReadLock([&]{1190 withReadLock([&]{
1191 connections = _connections;1191 connections = _connections;
1192 });*/1192 });
1193 1193
1194 // V8TODO: this may cause deadlocks on connect/disconnect, so the connect/disconnect procedure needs to be reworked.1194 // V8TODO: this may cause deadlocks on connect/disconnect, so the connect/disconnect procedure needs to be reworked.
1195 // It should probably add events to a separate list that would be processed before and after all the events for the signal.1195 // It should probably add events to a separate list that would be processed before and after all the events for the signal.
1196 withReadLock([&]{1196 //withReadLock([&]{
1197 {
1197 // V8TODO: check all other lambda functions to make sure they have handle scope - could they cause crashes otherwise?1198 // V8TODO: check all other lambda functions to make sure they have handle scope - could they cause crashes otherwise?
1198 v8::HandleScope handleScope(isolate);1199 v8::HandleScope handleScope(isolate);
1199 // V8TODO: should we use function creation context, or context in which connect happened?1200 // V8TODO: should we use function creation context, or context in which connect happened?
@@ -1201,14 +1202,14 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu · 1 unmodified line
1201 v8::Context::Scope contextScope(context);1202 v8::Context::Scope contextScope(context);
1202 v8::Local<v8::Value> args[Q_METAMETHOD_INVOKE_MAX_ARGS];1203 v8::Local<v8::Value> args[Q_METAMETHOD_INVOKE_MAX_ARGS];
1203 int numArgs = _meta.parameterCount();1204 int numArgs = _meta.parameterCount();
1204 //for (ConnectionList::iterator iter = connections.begin(); iter != connections.end(); ++iter) {
1205 for (int arg = 0; arg < numArgs; ++arg) {1205 for (int arg = 0; arg < numArgs; ++arg) {
1206 int methodArgTypeId = _meta.parameterType(arg);1206 int methodArgTypeId = _meta.parameterType(arg);
1207 Q_ASSERT(methodArgTypeId != QMetaType::UnknownType);1207 Q_ASSERT(methodArgTypeId != QMetaType::UnknownType);
1208 QVariant argValue(methodArgTypeId, arguments[arg+1]);1208 QVariant argValue(methodArgTypeId, arguments[arg + 1]);
1209 args[arg] = _engine->castVariantToValue(argValue).get();1209 args[arg] = _engine->castVariantToValue(argValue).get();
1210 }1210 }
1211 for (ConnectionList::iterator iter = _connections.begin(); iter != _connections.end(); ++iter) {1211 //for (ConnectionList::iterator iter = _connections.begin(); iter != _connections.end(); ++iter) {
1212 for (ConnectionList::iterator iter = connections.begin(); iter != connections.end(); ++iter) {
1212 Connection& conn = *iter;1213 Connection& conn = *iter;
1213 {1214 {
1214 /*if (!conn.callback.get()->IsFunction()) {1215 /*if (!conn.callback.get()->IsFunction()) {
@@ -1228,7 +1229,7 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu · 13 unmodified lines
1228 1229
1229 Q_ASSERT(!conn.callback.get().IsEmpty());1230 Q_ASSERT(!conn.callback.get().IsEmpty());
1230 Q_ASSERT(!conn.callback.get()->IsUndefined());1231 Q_ASSERT(!conn.callback.get()->IsUndefined());
1231 if(conn.callback.get()->IsNull()) {1232 if (conn.callback.get()->IsNull()) {
1232 qDebug() << "ScriptSignalV8Proxy::qt_metacall: Connection callback is Null";1233 qDebug() << "ScriptSignalV8Proxy::qt_metacall: Connection callback is Null";
1233 _engine->popContext();1234 _engine->popContext();
1234 continue;1235 continue;
@@ -1258,7 +1259,8 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu · 23 unmodified lines
1258 //_engine->popContext();1259 //_engine->popContext();
1259 }1260 }
1260 }1261 }
1261 });1262 }
1263 //});
1262 1264
1263 _totalCallTime_s += callTimer.elapsed() / 1000.0;1265 _totalCallTime_s += callTimer.elapsed() / 1000.0;
1264 1266