X-Git-Url: https://git.sur5r.net/?p=minitube;a=blobdiff_plain;f=lib%2Fjs%2Fjs.h;fp=lib%2Fjs%2Fjs.h;h=104bc4615a57999b5867a9b002af1712ece43b69;hp=8f0e33ade8a218eda9223e42b8166612f061cb8d;hb=9ff1806f2db97d617aa96185b7bf17f77bbacbcb;hpb=707b121e136bbb650f012ad9a55010acf6dea6fd diff --git a/lib/js/js.h b/lib/js/js.h index 8f0e33a..104bc46 100644 --- a/lib/js/js.h +++ b/lib/js/js.h @@ -18,14 +18,15 @@ public: auto getId() const { return id; } // This should be static but cannot bind static functions to QJSEngine - Q_INVOKABLE QJSValue clearTimeout(QJSValue id) { + Q_INVOKABLE void clearTimeout(QJSValue id) { + // qDebug() << "Clearing timer" << id.toString(); auto timer = getTimers().take(id.toUInt()); if (timer) { timer->stop(); timer->deleteLater(); } else qDebug() << "Unknown id" << id.toUInt(); - return QJSValue(); + return; } // This should be static but cannot bind static functions to QJSEngine Q_INVOKABLE QJSValue setTimeout(QJSValue callback, QJSValue delayTime, QJSValue args) { @@ -57,7 +58,7 @@ public: } Q_INVOKABLE JSTimer(QObject *parent = nullptr) : QTimer(parent) { - setTimerType(Qt::CoarseTimer); + setTimerType(Qt::PreciseTimer); setSingleShot(true); // avoid 0 static uint counter = 1; @@ -87,6 +88,7 @@ public: QQmlEngine &getEngine() { return *engine; } JSResult &callFunction(JSResult *result, const QString &name, const QJSValueList &args); + void resetNAM(); signals: void initialized();