Rate limit conversion from script

This commit is contained in:
2024-03-26 14:54:19 +01:00
parent 174134a9ee
commit c3588e1c36
4 changed files with 15 additions and 5 deletions
+4 -1
View File
@@ -17,6 +17,7 @@ ScriptEngine::ScriptEngine(QObject *parent) : QObject(parent)
QJSValue engine = _jsEngine->newQObject(this);
_jsEngine->globalObject().setProperty("engine", engine);
_database->init(QLatin1String("scriptengine"));
_semaphore.release(_pool->maxThreadCount());
}
void ScriptEngine::setParams(const QString &scriptPath, const QStringList &paths, const QString &outputDir)
@@ -79,7 +80,8 @@ bool ScriptEngine::convert(File *file, QString &outpath, QString format, QVarian
info.setFile(path);
//qDebug() << info.absolutePath() + "/" + info.completeBaseName() + "." + format.toLower();
_pool->start(new ConvertRunable(file->absoluteFilePath(), info.absolutePath() + "/" + info.completeBaseName() + "." + format.toLower(), format, params));
_semaphore.acquire();
_pool->start(new ConvertRunable(file->absoluteFilePath(), info.absolutePath() + "/" + info.completeBaseName() + "." + format.toLower(), format, params, &_semaphore));
return true;
}
@@ -109,6 +111,7 @@ void ScriptEngine::run()
scriptFile.close();
QJSValue result = _jsEngine->evaluate(contents, _scriptPath);
qDebug() << result.isError() << result.toString();
_pool->waitForDone();
if(result.isError())
{
QString error = result.property("name").toString() + " on line " + result.property("lineNumber").toString() + " : " + result.toString();