Skip to content

Commit

Permalink
Merge pull request #3429 from Be-ing/remove_qscriptengine
Browse files Browse the repository at this point in the history
remove QtScript
  • Loading branch information
uklotzde committed Dec 11, 2020
2 parents adf6c49 + 2fa2cd7 commit bea2be9
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 440 deletions.
25 changes: 2 additions & 23 deletions CMakeLists.txt
Expand Up @@ -705,7 +705,6 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/skin/pixmapsource.cpp
src/skin/skincontext.cpp
src/skin/skinloader.cpp
src/skin/svgparser.cpp
src/skin/tooltips.cpp
src/soundio/sounddevice.cpp
src/soundio/sounddevicenetwork.cpp
Expand Down Expand Up @@ -1232,14 +1231,6 @@ install(
"${MIXXX_INSTALL_DATADIR}"
)

# QScriptEngine extensions
install(
DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/script"
DESTINATION
"${MIXXX_INSTALL_DATADIR}"
)

# Licenses
install(
FILES
Expand Down Expand Up @@ -1485,21 +1476,13 @@ if(UNIX AND USE_SYMLINKS)
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/res" "${CMAKE_CURRENT_BINARY_DIR}/res"
COMMENT "Symlinking resources to build directory..."
)
add_custom_target(mixxx-script
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/script" "${CMAKE_CURRENT_BINARY_DIR}/script"
COMMENT "Symlinking to build directory..."
)
else()
add_custom_target(mixxx-res
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/res" "${CMAKE_CURRENT_BINARY_DIR}/res"
COMMENT "Copying resources to build directory..."
)
add_custom_target(mixxx-script
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/script" "${CMAKE_CURRENT_BINARY_DIR}/script"
COMMENT "Copying QScriptEngine extensions to build directory..."
)
endif()
add_dependencies(mixxx-lib mixxx-res mixxx-script)
add_dependencies(mixxx-lib mixxx-res)

# Windows-only resource file
if(WIN32)
Expand Down Expand Up @@ -1816,8 +1799,6 @@ find_package(Qt5
Network
OpenGL
Qml
Script
ScriptTools
Sql
Svg
Test
Expand All @@ -1832,8 +1813,6 @@ target_link_libraries(mixxx-lib PUBLIC
Qt5::Network
Qt5::OpenGL
Qt5::Qml
Qt5::Script
Qt5::ScriptTools
Qt5::Sql
Qt5::Svg
Qt5::Test
Expand Down Expand Up @@ -1953,7 +1932,7 @@ if(WIN32)
# QT 5 translations have been separated into several files, and most of the qt_xx.qm files
# contain just shortcuts to load the qtbase, qtmultimedia etc files.
FILES_MATCHING REGEX
"qt_.+\.qm|qtbase_.*\.qm|qtmultimedia_.*\.qm|qtscript_.*\.qm|qtxmlpatterns_.*\.qm"
"qt_.+\.qm|qtbase_.*\.qm|qtmultimedia_.*\.qm|qtxmlpatterns_.*\.qm"
)

# ANGLE DLLs are dynamically linked even when the rest of Qt is built statically
Expand Down
7 changes: 0 additions & 7 deletions script/.eslintrc.json

This file was deleted.

20 changes: 0 additions & 20 deletions script/console/__init__.js

This file was deleted.

62 changes: 0 additions & 62 deletions script/svg/__init__.js

This file was deleted.

1 change: 1 addition & 0 deletions src/controllers/bulk/bulkcontroller.h
@@ -1,6 +1,7 @@
#pragma once

#include <QAtomicInt>
#include <QThread>

#include "controllers/controller.h"
#include "controllers/hid/hidcontrollerpreset.h"
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/controller.h
@@ -1,5 +1,7 @@
#pragma once

#include <QElapsedTimer>

#include "controllers/controllerpreset.h"
#include "controllers/controllerpresetfilehandler.h"
#include "controllers/controllerpresetinfo.h"
Expand Down
1 change: 1 addition & 0 deletions src/controllers/controllermanager.cpp
@@ -1,6 +1,7 @@
#include "controllers/controllermanager.h"

#include <QSet>
#include <QThread>

#include "controllers/controllerlearningeventfilter.h"
#include "controllers/defs_controllers.h"
Expand Down
1 change: 1 addition & 0 deletions src/controllers/controllermanager.h
@@ -1,6 +1,7 @@
#pragma once

#include <QSharedPointer>
#include <QTimer>

#include "controllers/controllerenumerator.h"
#include "controllers/controllerpreset.h"
Expand Down
1 change: 0 additions & 1 deletion src/controllers/engine/controllerengine.h
Expand Up @@ -5,7 +5,6 @@
#include <QJSValue>
#include <QMessageBox>
#include <QTimerEvent>
#include <QtScript>

#include "controllers/controllerpreset.h"
#include "controllers/softtakeover.h"
Expand Down
93 changes: 1 addition & 92 deletions src/skin/skincontext.cpp
@@ -1,11 +1,8 @@
#include <QtDebug>
#include <QStringList>
#include <QScriptValue>
#include <QAction>
#include <QScriptValueIterator>

#include "skin/skincontext.h"
#include "skin/svgparser.h"
#include "util/cmdlineargs.h"
#include "util/math.h"

Expand All @@ -15,23 +12,6 @@ SkinContext::SkinContext(UserSettingsPointer pConfig,
m_xmlPath(xmlPath),
m_pSharedState(std::make_shared<SharedState>()),
m_scaleFactor(1.0) {
DEBUG_ASSERT(isRoot());


// the extensions are imported once and will be passed to the children
// global object as properties of the parent's global object.
// TODO: Enable script extensions
//importScriptExtension("console");
//importScriptExtension("svg");
m_pSharedState->scriptEngine.installTranslatorFunctions();

// Retrieving hooks pattern from script extension
QScriptValue global = m_pSharedState->scriptEngine.globalObject();
QScriptValue svg = global.property("svg");
QScriptValue hooksPattern = svg.property("getHooksPattern").call(svg);
if (!hooksPattern.isNull()) {
m_hookRx.setPattern(hooksPattern.toString());
}
}

SkinContext::SkinContext(const SkinContext* parent)
Expand All @@ -40,36 +20,8 @@ SkinContext::SkinContext(const SkinContext* parent)
m_skinBasePath(parent->m_skinBasePath),
m_pSharedState(parent->m_pSharedState),
m_variables(parent->variables()),
m_parentGlobal(m_pSharedState->scriptEngine.globalObject()),
m_hookRx(parent->m_hookRx),
m_scaleFactor(parent->m_scaleFactor) {
DEBUG_ASSERT(!isRoot());

// we generate a new global object to preserve the scope between
// a context and its children
QScriptValue context = m_pSharedState->scriptEngine.pushContext()->activationObject();
QScriptValue newGlobal = m_pSharedState->scriptEngine.newObject();
QScriptValueIterator it(m_parentGlobal);
while (it.hasNext()) {
it.next();
newGlobal.setProperty(it.name(), it.value());
}

for (auto it = m_variables.constBegin();
it != m_variables.constEnd(); ++it) {
newGlobal.setProperty(it.key(), it.value());
}
m_pSharedState->scriptEngine.setGlobalObject(newGlobal);
}

SkinContext::~SkinContext() {
// Pop the context only if we're a child.
// m_pScriptEngine might be null after moving and the
// destructor then becomes a no-op!
if (m_pSharedState && !isRoot()) {
m_pSharedState->scriptEngine.popContext();
m_pSharedState->scriptEngine.setGlobalObject(m_parentGlobal);
}
}

QString SkinContext::variable(const QString& name) const {
Expand All @@ -78,8 +30,6 @@ QString SkinContext::variable(const QString& name) const {

void SkinContext::setVariable(const QString& name, const QString& value) {
m_variables[name] = value;
QScriptValue context = m_pSharedState->scriptEngine.currentContext()->activationObject();
context.setProperty(name, value);
}

void SkinContext::setXmlPath(const QString& xmlPath) {
Expand Down Expand Up @@ -118,13 +68,6 @@ void SkinContext::updateVariable(const QDomElement& element) {
}

QString SkinContext::variableNodeToText(const QDomElement& variableNode) const {
QString expression = variableNode.attribute("expression");
if (!expression.isNull()) {
QScriptValue result = m_pSharedState->scriptEngine.evaluate(
expression, m_xmlPath, variableNode.lineNumber());
return result.toString();
}

QString variableName = variableNode.attribute("name");
if (!variableName.isNull()) {
QString formatString = variableNode.attribute("format");
Expand Down Expand Up @@ -162,23 +105,7 @@ QString SkinContext::nodeToString(const QDomNode& node) const {
}

PixmapSource SkinContext::getPixmapSource(const QDomNode& pixmapNode) const {
if (!pixmapNode.isNull()) {
QDomNode svgNode = selectNode(pixmapNode, "svg");
if (!svgNode.isNull()) {
// inline svg
SvgParser svgParser(this);
const QByteArray rslt = svgParser.saveToQByteArray(
svgParser.parseSvgTree(svgNode, m_xmlPath));
PixmapSource source;
source.setSVG(rslt);
return source;
} else {
// filename.
return getPixmapSourceInner(nodeToString(pixmapNode));
}
}

return PixmapSource();
return getPixmapSourceInner(nodeToString(pixmapNode));
}

PixmapSource SkinContext::getPixmapSource(const QString& filename) const {
Expand Down Expand Up @@ -208,24 +135,6 @@ PixmapSource SkinContext::getPixmapSourceInner(const QString& filename) const {
return PixmapSource();
}

/**
* All the methods below exist to access some of the scriptEngine features
* from the svgParser.
*/
QScriptValue SkinContext::evaluateScript(const QString& expression,
const QString& filename,
int lineNumber) const {
return m_pSharedState->scriptEngine.evaluate(expression, filename, lineNumber);
}

QScriptValue SkinContext::importScriptExtension(const QString& extensionName) {
QScriptValue out = m_pSharedState->scriptEngine.importExtension(extensionName);
if (m_pSharedState->scriptEngine.hasUncaughtException()) {
qWarning() << out.toString();
}
return out;
}

QDebug SkinContext::logWarning(const char* file, const int line,
const QDomNode& node) const {
return qWarning() << QString("%1:%2 SKIN ERROR at %3:%4 <%5>:")
Expand Down

0 comments on commit bea2be9

Please sign in to comment.