MCPcopy Index your code
hub / github.com/PyQt5/PyQt / addSignal

Function addSignal

QWebEngineView/Data/qwebchannel.js:244–290  ·  view source on GitHub ↗
(signalData, isPropertyNotifySignal)

Source from the content-addressed store, hash-verified

242 }
243
244 function addSignal(signalData, isPropertyNotifySignal)
245 {
246 var signalName = signalData[0];
247 var signalIndex = signalData[1];
248 object[signalName] = {
249 connect: function(callback) {
250 if (typeof(callback) !== "function") {
251 console.error("Bad callback given to connect to signal " + signalName);
252 return;
253 }
254
255 object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || [];
256 object.__objectSignals__[signalIndex].push(callback);
257
258 if (!isPropertyNotifySignal && signalName !== "destroyed") {
259 // only required for "pure" signals, handled separately for properties in propertyUpdate
260 // also note that we always get notified about the destroyed signal
261 webChannel.exec({
262 type: QWebChannelMessageTypes.connectToSignal,
263 object: object.__id__,
264 signal: signalIndex
265 });
266 }
267 },
268 disconnect: function(callback) {
269 if (typeof(callback) !== "function") {
270 console.error("Bad callback given to disconnect from signal " + signalName);
271 return;
272 }
273 object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || [];
274 var idx = object.__objectSignals__[signalIndex].indexOf(callback);
275 if (idx === -1) {
276 console.error("Cannot find connection of signal " + signalName + " to " + callback.name);
277 return;
278 }
279 object.__objectSignals__[signalIndex].splice(idx, 1);
280 if (!isPropertyNotifySignal && object.__objectSignals__[signalIndex].length === 0) {
281 // only required for "pure" signals, handled separately for properties in propertyUpdate
282 webChannel.exec({
283 type: QWebChannelMessageTypes.disconnectFromSignal,
284 object: object.__id__,
285 signal: signalIndex
286 });
287 }
288 }
289 };
290 }
291
292 /**
293 * Invokes all callbacks for the given signalname. Also works for property notify callbacks.

Callers 2

bindGetterSetterFunction · 0.70
QObjectFunction · 0.70

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected