Remove the last references to kjs from the JS executor

This commit is contained in:
Volker Krause 2023-06-22 17:45:08 +02:00
parent ec0e848c58
commit fd459910b9
3 changed files with 21 additions and 21 deletions

View File

@ -31,15 +31,15 @@
using namespace Okular;
class Okular::ExecutorKJSPrivate
class Okular::ExecutorJSPrivate
{
public:
explicit ExecutorKJSPrivate(DocumentPrivate *doc)
explicit ExecutorJSPrivate(DocumentPrivate *doc)
: m_doc(doc)
{
initTypes();
}
~ExecutorKJSPrivate()
~ExecutorJSPrivate()
{
m_watchdogTimer->deleteLater();
m_watchdogThread.quit();
@ -55,7 +55,7 @@ public:
QTimer *m_watchdogTimer = nullptr;
};
void ExecutorKJSPrivate::initTypes()
void ExecutorJSPrivate::initTypes()
{
m_watchdogThread.start();
m_watchdogTimer = new QTimer;
@ -73,19 +73,19 @@ void ExecutorKJSPrivate::initTypes()
m_interpreter.globalObject().setProperty(QStringLiteral("util"), m_interpreter.newQObject(new JSUtil));
}
ExecutorKJS::ExecutorKJS(DocumentPrivate *doc)
: d(new ExecutorKJSPrivate(doc))
ExecutorJS::ExecutorJS(DocumentPrivate *doc)
: d(new ExecutorJSPrivate(doc))
{
}
ExecutorKJS::~ExecutorKJS()
ExecutorJS::~ExecutorJS()
{
JSField::clearCachedFields();
JSApp::clearCachedFields();
delete d;
}
void ExecutorKJS::execute(const QString &script, Event *event)
void ExecutorJS::execute(const QString &script, Event *event)
{
const auto eventVal = event ? d->m_interpreter.newQObject(new JSEvent(event)) : QJSValue(QJSValue::UndefinedValue);
d->m_interpreter.globalObject().setProperty(QStringLiteral("event"), eventVal);

View File

@ -12,23 +12,23 @@ class QString;
namespace Okular
{
class DocumentPrivate;
class ExecutorKJSPrivate;
class ExecutorJSPrivate;
class Event;
class ExecutorKJS
class ExecutorJS
{
public:
explicit ExecutorKJS(DocumentPrivate *doc);
~ExecutorKJS();
explicit ExecutorJS(DocumentPrivate *doc);
~ExecutorJS();
ExecutorKJS(const ExecutorKJS &) = delete;
ExecutorKJS &operator=(const ExecutorKJS &) = delete;
ExecutorJS(const ExecutorJS &) = delete;
ExecutorJS &operator=(const ExecutorJS &) = delete;
void execute(const QString &script, Event *event);
private:
friend class ExecutorKJSPrivate;
ExecutorKJSPrivate *d;
friend class ExecutorJSPrivate;
ExecutorJSPrivate *d;
};
}

View File

@ -22,7 +22,7 @@ public:
explicit ScripterPrivate(DocumentPrivate *doc)
: m_doc(doc)
#if HAVE_JS
, m_kjs(nullptr)
, m_js(nullptr)
#endif
, m_event(nullptr)
{
@ -30,7 +30,7 @@ public:
DocumentPrivate *m_doc;
#if HAVE_JS
QScopedPointer<ExecutorKJS> m_kjs;
QScopedPointer<ExecutorJS> m_js;
#endif
Event *m_event;
};
@ -62,10 +62,10 @@ void Scripter::execute(ScriptType type, const QString &script)
switch (type) {
case JavaScript:
if (!d->m_kjs) {
d->m_kjs.reset(new ExecutorKJS(d->m_doc));
if (!d->m_js) {
d->m_js.reset(new ExecutorJS(d->m_doc));
}
d->m_kjs->execute(builtInScript + script, d->m_event);
d->m_js->execute(builtInScript + script, d->m_event);
}
#endif
}