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
11861186 args[arg] = _engine->castVariantToValue(argValue).get();
11871187 }*/
11881188
1189− /*QList<Connection> connections;
1189+ QList<Connection> connections;
11901190 withReadLock([&]{
11911191 connections = _connections;
1192− });*/
1192+ });
11931193
11941194 // V8TODO: this may cause deadlocks on connect/disconnect, so the connect/disconnect procedure needs to be reworked.
11951195 // 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+ {
11971198 // V8TODO: check all other lambda functions to make sure they have handle scope - could they cause crashes otherwise?
11981199 v8::HandleScope handleScope(isolate);
11991200 // 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
12011202 v8::Context::Scope contextScope(context);
12021203 v8::Local<v8::Value> args[Q_METAMETHOD_INVOKE_MAX_ARGS];
12031204 int numArgs = _meta.parameterCount();
1204− //for (ConnectionList::iterator iter = connections.begin(); iter != connections.end(); ++iter) {
12051205 for (int arg = 0; arg < numArgs; ++arg) {
12061206 int methodArgTypeId = _meta.parameterType(arg);
12071207 Q_ASSERT(methodArgTypeId != QMetaType::UnknownType);
1208− QVariant argValue(methodArgTypeId, arguments[arg+1]);
1208+ QVariant argValue(methodArgTypeId, arguments[arg + 1]);
12091209 args[arg] = _engine->castVariantToValue(argValue).get();
12101210 }
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) {
12121213 Connection& conn = *iter;
12131214 {
12141215 /*if (!conn.callback.get()->IsFunction()) {
@@ -1228,7 +1229,7 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu · 13 unmodified lines
12281229
12291230 Q_ASSERT(!conn.callback.get().IsEmpty());
12301231 Q_ASSERT(!conn.callback.get()->IsUndefined());
1231− if(conn.callback.get()->IsNull()) {
1232+ if (conn.callback.get()->IsNull()) {
12321233 qDebug() << "ScriptSignalV8Proxy::qt_metacall: Connection callback is Null";
12331234 _engine->popContext();
12341235 continue;
@@ -1258,7 +1259,8 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu · 23 unmodified lines
12581259 //_engine->popContext();
12591260 }
12601261 }
1261− });
1262+ }
1263+ //});
12621264
12631265 _totalCallTime_s += callTimer.elapsed() / 1000.0;
12641266