Skip to content

Commit

Permalink
engine: fix Script crash on Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Feb 27, 2025
1 parent 8759720 commit 9c303f3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
qlcplus (4.14.1) stable; urgency=low

* engine: fix crash when using multiple RGBMtrix
* engine: fix crash when using a Script function
* Show Manager: fix hanging with an infinite duration EFX
* Simple Desk: fix crash when resetting a channel with no fixture associated
* Input Profiles: update Launchpad Mini profiles with color table (thanks to Jan Fries)
Expand Down
24 changes: 15 additions & 9 deletions engine/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ if(UNIX AND NOT ANDROID AND NOT IOS AND NOT APPLE)
)
endif()

if(UNIX)
target_sources(${module_name} PRIVATE
mastertimer-unix.cpp mastertimer-unix.h
)
endif()

if(WIN32)
target_sources(${module_name} PRIVATE
mastertimer-win32.cpp mastertimer-win32.h
Expand Down Expand Up @@ -141,32 +147,32 @@ if(APPLE)
)
endif()

if(qmlui OR (QT_VERSION_MAJOR GREATER 5))
if(QT_VERSION_MAJOR GREATER 5)
target_sources(${module_name} PRIVATE
rgbscriptv4.cpp rgbscriptv4.h
scriptrunner.cpp scriptrunner.h
scriptv4.cpp scriptv4.h
)

target_link_libraries(${module_name} PUBLIC
Qt${QT_MAJOR_VERSION}::Qml
)
endif()

if(NOT (qmlui OR (QT_VERSION_MAJOR GREATER 5)))
else()
target_sources(${module_name} PRIVATE
rgbscript.cpp rgbscript.h
script.cpp script.h
)

target_link_libraries(${module_name} PUBLIC
Qt${QT_MAJOR_VERSION}::Script
)
endif()

if(UNIX)
if(qmlui)
target_sources(${module_name} PRIVATE
mastertimer-unix.cpp mastertimer-unix.h
scriptrunner.cpp scriptrunner.h
scriptv4.cpp scriptv4.h
)
else()
target_sources(${module_name} PRIVATE
script.cpp script.h
)
endif()

Expand Down
17 changes: 16 additions & 1 deletion engine/src/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QRegularExpression>
#endif

#include "genericfader.h"
#include "fadechannel.h"
#include "mastertimer.h"
Expand Down Expand Up @@ -146,7 +149,11 @@ bool Script::setData(const QString& str)
if (m_data.isEmpty() == false)
{
int i = 1;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QStringList lines = m_data.split(QRegularExpression("(\\r\\n|\\n\\r|\\r|\\n)"));
#else
QStringList lines = m_data.split(QRegExp("(\r\n|\n\r|\r|\n)"));
#endif
foreach (QString line, lines)
{
bool ok = false;
Expand Down Expand Up @@ -196,7 +203,11 @@ QString Script::data() const

QStringList Script::dataLines() const
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QStringList result = m_data.split(QRegularExpression("(\\r\\n|\\n\\r|\\r|\\n)"));
#else
QStringList result = m_data.split(QRegExp("(\r\n|\n\r|\r|\n)"));
#endif
while (result.count() && result.last().isEmpty())
result.takeLast();

Expand Down Expand Up @@ -948,7 +959,11 @@ QList <QStringList> Script::tokenizeLine(const QString& str, bool* ok)
else
{
// No quotes. Find the next whitespace.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
right = line.indexOf(QRegularExpression("\\s"), left);
#else
right = line.indexOf(QRegExp("\\s"), left);
#endif
if (right == -1)
{
qDebug() << "Syntax error:" << line.mid(left);
Expand Down

0 comments on commit 9c303f3

Please sign in to comment.