History

Use int handles for script timers instead of QTimer*

Ada committed 8 months ago

Commit 461e32f1 parent db38db73 files · +72 −83Browse files

Showing the changes to libraries/script-engine/src/ScriptManagerScriptingInterface.h (1 of 3 files). Show all

Unified · Split

libraries/script-engine/src/ScriptManagerScriptingInterface.h+6−12
@@ -298,26 +298,26 @@ public: · 297 unmodified lines
298298 * @function Script.setInterval
299299 * @param {function} function - The function to call. This can be either the name of a function or an in-line definition.
300300 * @param {number} interval - The interval at which to call the function, in ms.
301− * @returns {object} A handle to the interval timer. This can be used in {@link Script.clearInterval}.
301+ * @returns {number} A handle to the interval timer. This can be used in {@link Script.clearInterval}.
302302 * @example <caption>Print a message every second.</caption>
303303 * Script.setInterval(function () {
304304 * print("Interval timer fired");
305305 * }, 1000);
306306 */
307− Q_INVOKABLE QTimer* setInterval(const ScriptValue& function, int intervalMS) { return _manager->setInterval(function, intervalMS); }
307+ Q_INVOKABLE int setInterval(const ScriptValue& function, int intervalMS) { return _manager->setInterval(function, intervalMS); }
308308
309309 /*@jsdoc
310310 * Calls a function once, after a delay.
311311 * @function Script.setTimeout
312312 * @param {function} function - The function to call. This can be either the name of a function or an in-line definition.
313313 * @param {number} timeout - The delay after which to call the function, in ms.
314− * @returns {object} A handle to the timeout timer. This can be used in {@link Script.clearTimeout}.
314+ * @returns {number} A handle to the timeout timer. This can be used in {@link Script.clearTimeout}.
315315 * @example <caption>Print a message once, after a second.</caption>
316316 * Script.setTimeout(function () {
317317 * print("Timeout timer fired");
318318 * }, 1000);
319319 */
320− Q_INVOKABLE QTimer* setTimeout(const ScriptValue& function, int timeoutMS) { return _manager->setTimeout(function, timeoutMS); };
320+ Q_INVOKABLE int setTimeout(const ScriptValue& function, int timeoutMS) { return _manager->setTimeout(function, timeoutMS); };
321321
322322 /*@jsdoc
323323 * Stops an interval timer set by {@link Script.setInterval|setInterval}.
@@ -335,10 +335,7 @@ public: · 11 unmodified lines
335335 * Script.clearInterval(timer);
336336 * }, 10000);
337337 */
338− Q_INVOKABLE void clearInterval(QTimer* timer) { _manager->clearInterval(timer); }
339−
340− // Overloaded version is needed in case the timer has expired
341− Q_INVOKABLE void clearInterval(QVariantMap timer) { ; }
338+ Q_INVOKABLE void clearInterval(int timer) { _manager->clearInterval(timer); }
342339
343340 /*@jsdoc
344341 * Stops a timeout timer set by {@link Script.setTimeout|setTimeout}.
@@ -353,10 +350,7 @@ public: · 8 unmodified lines
353350 * // Uncomment the following line to stop the timer from firing.
354351 * //Script.clearTimeout(timer);
355352 */
356− Q_INVOKABLE void clearTimeout(QTimer* timer) { _manager->clearTimeout(timer); }
357−
358− // Overloaded version is needed in case the timer has expired
359− Q_INVOKABLE void clearTimeout(QVariantMap timer) { ; }
353+ Q_INVOKABLE void clearTimeout(int timer) { _manager->clearTimeout(timer); }
360354
361355 /*@jsdoc
362356 * Prints a message to the program log and emits {@link Script.printedMessage}.