Commit 38725089 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(utils.js): `parent` is now a explicit parameter of `setTimeout`

parent 37e7954c
......@@ -95,7 +95,7 @@ Item {
// call.
//
// The timeout is destroyed with the `MouseArea` component.
_timeout = Utils.setTimeout.call(
_timeout = Utils.setTimeout(
this, 0, item.pressed.bind(this)
)
}
......
......@@ -84,13 +84,11 @@ function snakeToCamel (s) {
// -------------------------------------------------------------------
// A copy of `Window.setTimeout` from js.
// Use setTimeout.call(parentContext, delayTime, cb) to use it.
//
// delay is in milliseconds.
function setTimeout (delay, cb) {
function setTimeout (parent, delay, cb) {
var timer = new (function (parent) {
return Qt.createQmlObject('import QtQuick 2.7; Timer { }', parent)
})(this)
})(parent)
timer.interval = delay
timer.repeat = false
......
......@@ -50,7 +50,7 @@ TestCase {
function test_setTimeoutWithoutParent () {
try {
Utils.setTimeout(0, function () {
Utils.setTimeout(null, 0, function () {
fail('`setTimeout` was called without parent.')
})
} catch (e) {
......@@ -67,7 +67,7 @@ TestCase {
function test_setTimeout (data) {
var failed = true
Utils.setTimeout.call(testCase, data.time, function () {
Utils.setTimeout(testCase, data.time, function () {
failed = false
})
......@@ -93,7 +93,7 @@ TestCase {
function test_clearTimeout (data) {
var failed = false
var timeout = Utils.setTimeout.call(testCase, data.time, function () {
var timeout = Utils.setTimeout(testCase, data.time, function () {
failed = true
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment