Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into me/fix_memleak
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov committed Jan 29, 2025
2 parents 60c4aed + 6f9404f commit 2d9d095
Show file tree
Hide file tree
Showing 297 changed files with 1,863 additions and 275 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,22 @@ jobs:
run: |
PATH="" $SHELL -c 'for i in "$GITHUB_WORKSPACE"/tests/*.qrs; do "$TWOD_EXEC_NAME" --generate-path "$i".js --generate-mode javascript --close \
-s 5 --script-path "$i".js -m script "$i"; done'
if: ${{ !startsWith(inputs.os, 'macos') }}
timeout-minutes: 15

- name: Run minimal Python interpeter tests in direct script mode
run: |
PATH="" $SHELL -c 'for i in "$GITHUB_WORKSPACE"/tests/*.qrs; do "$TWOD_EXEC_NAME" --generate-path "$i".py \
--close -s 5 --script-path "$i".py -m script "$i"; done'
if: ${{ !startsWith(inputs.os, 'macos') }}
timeout-minutes: 15

- name: Run minimal Javascript interpeter tests as fields in .qrs (For backward compatibility)
run: |
PATH="" $SHELL -c 'for i in "$GITHUB_WORKSPACE"/tests/*.qrs; do "$PATCHER_NAME" -s "$i".js "$i" \
&& "$TWOD_EXEC_NAME" --close -s 5 -m script "$i"; done'
if: ${{ !startsWith(inputs.os, 'macos') }}
timeout-minutes: 5

- name: Run minimal Python interpeter tests as fields in .qrs (For backward compatibility)
run: |
PATH="" $SHELL -c 'for i in "$GITHUB_WORKSPACE"/tests/*.qrs; do "$PATCHER_NAME" -s "$i".py "$i" \
&& "$TWOD_EXEC_NAME" --close -s 5 -m script "$i"; done'
if: ${{ !startsWith(inputs.os, 'macos') }}
timeout-minutes: 5
16 changes: 8 additions & 8 deletions buildScripts/github/build_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ set -euxo pipefail
BRANCH_NAME="${BRANCH_NAME:-${GITHUB_REF#refs/*/}}"
BRANCH_NAME=${BRANCH_NAME//\//-}

QTBIN=${QTBIN:-$($EXECUTOR bash -c 'eval $(make qmake -n | cut -f 1 -d " ") -query QT_INSTALL_BINS')}
case $RUNNER_OS in
QTBIN="${QTBIN:-$($EXECUTOR bash -c 'eval $(make qmake -n | cut -f 1 -d " ") -query QT_INSTALL_BINS')}"
case "$RUNNER_OS" in
macOS)
QTIFWBIN=$HOME/qtifw/bin
QTIFWBIN="$HOME"/qtifw/bin
TSNAME="trik-studio-installer-mac-$BRANCH_NAME.dmg"
;;
Linux)
Expand All @@ -19,23 +19,23 @@ df -h .

NEED_DEPLOY=$([[ "$GITHUB_REPOSITORY" == "trikset/trik-studio" && "${PULLREQUESTNUMBER:-false}" == "false" ]] && echo true || echo false )

if $NEED_DEPLOY ; then
if "$NEED_DEPLOY" ; then
$EXECUTOR bash -c "mkdir -p $HOME/.ssh && install -m 600 /dev/null $HOME/.ssh/id_rsa && echo \"$ssh_key\" > $HOME/.ssh/id_rsa"
fi

if [[ $RUNNER_OS == Linux ]] ; then
if [[ "$RUNNER_OS" == Linux ]] ; then
echo Start build checker archive
$EXECUTOR bash -c "bin/build-checker-installer.sh"
if $NEED_DEPLOY ; then
if "$NEED_DEPLOY" ; then
$EXECUTOR bash -c "rsync -v --rsh='ssh -o StrictHostKeyChecking=no -vvv -i $HOME/.ssh/id_rsa' bin/trik_checker.tar.xz $username@$host:~/dl/ts/fresh/checker/checker-linux-$CONFIG-$BRANCH_NAME.tar.xz"
fi
fi

echo Start build installer
$EXECUTOR bash -c "installer/build-trik-studio.sh $QTBIN $QTIFWBIN ."

INSTALLER_NAME=$(find installer -name "trik-studio*installer*" -print -quit)
INSTALLER_NAME=$(find installer -name "trik-studio*installer*" -print -quit | grep . )

if $NEED_DEPLOY ; then
if "$NEED_DEPLOY" ; then
$EXECUTOR bash -c "rsync -v --rsh='ssh -o StrictHostKeyChecking=no -vvv -i $HOME/.ssh/id_rsa' $INSTALLER_NAME $username@$host:~/dl/ts/fresh/installer/$TSNAME"
fi
6 changes: 6 additions & 0 deletions buildScripts/github/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash
set -euxo pipefail
BUILD_INSTALLER=${BUILD_INSTALLER:-true}
TRIK_QT_VERSION=${TRIK_QT_VERSION:-5.15}
XCODE_VERSION=${XCODE_VERSION:-14.3} # 14.3 on GHA worker is compatible with Qt5.15
TRIK_PYTHON3_VERSION_MINOR=${TRIK_PYTHON3_VERSION_MINOR:-11}


TRIK_PYTHON=python3.${TRIK_PYTHON3_VERSION_MINOR}

install_qt(){
Expand Down
8 changes: 4 additions & 4 deletions installer/build-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ find $PWD/packages/$PRODUCT -name prebuild-$OS.sh | bash -xe
find . -type d -empty -delete

#echo "Building online installer..."
#$QTIFW_DIR/binarycreator --online-only -c config/$PRODUCT-$OS_EXT.xml -p packages/qreal-base -p packages/$PRODUCT ${*:4} $PRODUCT-online-$OS_EXT-installer
#$QTIFW_DIR/binarycreator --verbose --online-only -c config/$PRODUCT-$OS_EXT.xml -p packages/qreal-base -p packages/$PRODUCT ${*:4} $PRODUCT-online-$OS_EXT-installer

echo "Building offline installer..."
case $(uname -s || echo None) in
Linux) INSTALLER_EXT=.run;;
Darwin) INSTALLER_EXT=.dmg;;
*) INSTALLER_EXT=.exe;;
esac
$QTIFW_DIR/binarycreator --offline-only -c config/$PRODUCT-$OS_EXT.xml -p packages/qreal-base -p packages/$PRODUCT $PRODUCT-offline-$OS_EXT-installer$ADD_BIT-${FULL_VERSION}${INSTALLER_EXT}
"$QTIFW_DIR"/binarycreator --verbose --offline-only -c "config/$PRODUCT-$OS_EXT.xml" -p packages/qreal-base -p "packages/$PRODUCT" "$PRODUCT-offline-$OS_EXT-installer$ADD_BIT-${FULL_VERSION}${INSTALLER_EXT}"

grep -r -l --include=*.xml '<Version>.*</Version>' . | xargs $GNU_SED_COMMAND -i -e "s/<Version>.*<\/Version>/<Version><\/Version>/"

[ -f $SSH_DIR/id_rsa ] && : || { echo "Done"; exit 0; }
[ -f "$SSH_DIR/id_rsa" ] && : || { echo "Done"; exit 0; }

#echo "Building updates repository... This step can be safely skipped, the offline installer is already ready, press Ctrl+C if you are not sure what to do next."
#rm -rf $PRODUCT-repository
Expand All @@ -103,6 +103,6 @@ grep -r -l --include=*.xml '<Version>.*</Version>' . | xargs $GNU_SED_COMMAND -i
#scp -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -r $PRODUCT-repository/* [email protected]:/home/qrealproject/public/packages/$PRODUCT-repo-$OS_EXT

echo "Removing temporary files..."
rm -rf $PRODUCT-repository
rm -rf "$PRODUCT-repository"

echo "Done"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pyinstaller==6.11.1
numpy==2.2.1; python_version >= "3.11"
numpy==2.2.2; python_version >= "3.11"
numpy==2.0.1; python_version < "3.11"

8 changes: 4 additions & 4 deletions installer/platform/trik-studio-safe.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ SETLOCAL ENABLEEXTENSIONS
IF ERRORLEVEL 1 ECHO Failed to enable extensions
TITLE TRIK Studio Safe Mode
rem if JAVA_HOME is missing try to find the first Java executable in PATH
IF DEFINED JAVA_HOME (ECHO JAVA_HOME is "%JAVA_HOME%" && set JAVA_PATH=%JAVA_HOME%\bin) ^
IF DEFINED JAVA_HOME (ECHO JAVA_HOME is "%JAVA_HOME%" && set "JAVA_PATH=%JAVA_HOME%\bin") ^
ELSE (
java -version 2>NUL
IF ERRORLEVEL 1 ECHO Missing working java.exe in PATH="%PATH%"
FOR /f "usebackq tokens=1* delims=:" %%F IN (`where java 2^>NUL ^| findstr /n "^"`) DO @IF %%F == 1 ( ECHO Using Java: "%%G" && SET JAVA_PATH=%%~dpG)
FOR /f "usebackq tokens=1* delims=:" %%F IN (`where java 2^>NUL ^| findstr /n "^"`) DO @IF %%F == 1 ( ECHO Using Java: "%%G" && SET "JAVA_PATH=%%~dpG")
)
rem Clear PATH after Java detection attempt
SET PATH=%SystemRoot%;%SystemRoot%\system32
IF "%JAVA_PATH%" == "" ( ECHO Failed to detect Java/JRE ) ELSE (SET PATH=%PATH%;%JAVA_PATH%&& java -version)
SET "PATH=%SystemRoot%;%SystemRoot%\system32"
IF "%JAVA_PATH%" == "" ( ECHO Failed to detect Java/JRE ) ELSE (SET "PATH=%PATH%;%JAVA_PATH%" && java -version)
ENDLOCAL

%~dp0trik-studio.exe "%*"
1 change: 1 addition & 0 deletions plugins/robots/checker/twoDModelRunner/reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum class Level
/// Collects information about the interpretation process and writes it into the given file as JSON report.
class Reporter : public QObject
{
Q_OBJECT
public:
/// Constructor.
/// @param messagesFile If non-empty the information about all error reporter messages will be stored there in JSON.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace common {
class ROBOTS_KIT_BASE_EXPORT CalibrateGyroscopeBlock :
public kitBase::blocksBase::common::DeviceBlock<kitBase::robotModel::robotParts::GyroscopeSensor>
{
Q_OBJECT
public:
explicit CalibrateGyroscopeBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DeviceBlock : public RobotsBlock

void run() override
{
const robotModel::DeviceInfo deviceInfo = robotModel::DeviceInfo::create<Device>();
const robotModel::DeviceInfo &deviceInfo = robotModel::DeviceInfo::create<Device>();
const QString portProperty = eval<QString>("Port");
const QString port = !portProperty.isEmpty() ? portProperty :
deviceInfo.name()[0].toUpper() + deviceInfo.name().mid(1) + "Port";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <QtCore/QMetaObject>
#include <QtCore/QMetaProperty>

#include <QReadWriteLock>

#include "direction.h"
#include "kitBase/kitBaseDeclSpec.h"

Expand All @@ -30,12 +32,15 @@ namespace robotModel {
class ROBOTS_KIT_BASE_EXPORT DeviceInfo
{
public:
/// Constructs invalid DeviceInfo instance.
DeviceInfo();

/// Creates a new instance of a Device descriptor. The resulting object will
/// correspond to a given type only if Q_OBJECT macro is used inside its declaration.
/// @warning Given device type must contain friendlyName() and direction() static functions
/// and Q_OBJECT macro.
template <typename T>
static DeviceInfo create()
static DeviceInfo &create()
{
// This line performs Q_OBJECT macro checking in the given type declaration.
// Without Q_OBJECT macro incorrect metaObject will be passed and it will lead
Expand All @@ -47,15 +52,13 @@ class ROBOTS_KIT_BASE_EXPORT DeviceInfo
const bool simulated = property(metaObject, "simulated") == "true";
const Direction direction = property(metaObject, "direction").toLower() == "input" ? input : output;
DeviceInfo result(metaObject, name, friendlyName, simulated, direction);
mCreatedInfos[QString(metaObject->className())] = result;
return result;
QWriteLocker w(&mRWLock);
auto &r = mCreatedInfos[QString(metaObject->className())] = std::move(result);
return r;
}

/// Deserializes inner string representation obtained by toString().
static DeviceInfo fromString(const QString &string);

/// Constructs invalid DeviceInfo instance.
DeviceInfo();
static DeviceInfo &fromString(const QString &string);

/// Serializes given device info into inner string representation.
QString toString() const;
Expand Down Expand Up @@ -115,6 +118,7 @@ class ROBOTS_KIT_BASE_EXPORT DeviceInfo

static QString property(const QMetaObject * const metaObject, const QString &name);

static QReadWriteLock mRWLock;
static QMap<QString, DeviceInfo> mCreatedInfos;

const QMetaObject *mDeviceType;
Expand Down
16 changes: 8 additions & 8 deletions plugins/robots/common/kitBase/src/robotModel/deviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

using namespace kitBase::robotModel;

QMap<QString, DeviceInfo> DeviceInfo::mCreatedInfos = QMap<QString, DeviceInfo>();
QMap<QString, DeviceInfo> DeviceInfo::mCreatedInfos = {{QString(), DeviceInfo()}};
QReadWriteLock DeviceInfo::mRWLock;


DeviceInfo::DeviceInfo()
: mDeviceType(nullptr)
Expand Down Expand Up @@ -90,17 +92,15 @@ QString DeviceInfo::toString() const
return QString(mDeviceType ? mDeviceType->className() : QString());
}

DeviceInfo DeviceInfo::fromString(const QString &string)
DeviceInfo &DeviceInfo::fromString(const QString &string)
{
if (string.isEmpty()) {
return DeviceInfo();
}

if (!mCreatedInfos.contains(string)) {
QReadLocker r(&mRWLock);
auto i = mCreatedInfos.find(string);
if (i == mCreatedInfos.end()) {
throw qReal::Exception(QString("QMetaObject for %1 not found").arg(string));
}

return mCreatedInfos[string];
return *i;
}

QString DeviceInfo::property(const QMetaObject * const metaObject, const QString &name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace details {
/// Interpreter implementation for "Detect by Videocamera" block.
class DetectLineBlock : public kitBase::blocksBase::common::DeviceBlock<trik::robotModel::parts::TrikLineSensor>
{
Q_OBJECT
public:
DetectLineBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class DrawArcBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
DrawArcBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class DrawEllipseBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
DrawEllipseBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class DrawLineBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
DrawLineBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class DrawPixelBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
DrawPixelBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class DrawRectBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
DrawRectBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace details {
/// Interpreter implementation for "Initialize Videocamera" block.
class InitCameraBlock : public kitBase::blocksBase::common::DeviceBlock<trik::robotModel::parts::TrikLineSensor>
{
Q_OBJECT
public:
InitCameraBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace details {
/// Interpreter implementation for "Enable Video Streaming" block.
class InitVideoStreamingBlock : public kitBase::blocksBase::common::DeviceBlock<trik::robotModel::parts::TrikShell>
{
Q_OBJECT
public:
InitVideoStreamingBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace details {
/// Interpreter implementation for "Line Detector into Variable" block.
class LineDetectorToVariableBlock : public qReal::interpretation::Block
{
Q_OBJECT
public:
LineDetectorToVariableBlock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class SetBackgroundBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
explicit SetBackgroundBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class SetPainterColorBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
SetPainterColorBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class SetPainterWidthBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
SetPainterWidthBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class SmileBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
SmileBlock(kitBase::robotModel::RobotModelInterface &robotModel, bool isSmileSad);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class TrikPrintTextBlock : public kitBase::blocksBase::common::DisplayBlock
{
Q_OBJECT
public:
TrikPrintTextBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class WaitForMotionBlock : public kitBase::blocksBase::common::WaitForSensorBlock
{
Q_OBJECT
public:
explicit WaitForMotionBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace details {
class WaitGamepadConnectBlock
: public kitBase::blocksBase::common::WaitForSensorBlock
{
Q_OBJECT
public:
explicit WaitGamepadConnectBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class WaitGamepadDisconnectBlock : public kitBase::blocksBase::common::WaitForSensorBlock
{
Q_OBJECT
public:
explicit WaitGamepadDisconnectBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace details {

class WaitGamepadWheelBlock : public kitBase::blocksBase::common::WaitForSensorBlock
{
Q_OBJECT
public:
explicit WaitGamepadWheelBlock(kitBase::robotModel::RobotModelInterface &robotModel);

Expand Down
Loading

0 comments on commit 2d9d095

Please sign in to comment.