Skip to content

Commit f8bea05

Browse files
MinyazevRiakov
andauthored
Wait for the plugin initialization (trikset#1872)
* Wait for the plugin initialization --------- Upon initialization of the `EV3` kit plugin, a subscription to the [sensorAdded](https://github.com/trikset/trik-studio/blob/1281f48c8d1e50c7c16b4f164bd7cffa55d4d001/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp#L128()) event in the `Box2DPhysicsEngine` is registered with a delay using [QTimerSingleShot(10)](https://github.com/trikset/trik-studio/blob/1281f48c8d1e50c7c16b4f164bd7cffa55d4d001/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp#L112). While this does not pose an issue when utilizing `TRIK Studio`, it becomes problematic when using the `2D-model` [projectManager->open function](https://github.com/trikset/trik-studio/blob/1281f48c8d1e50c7c16b4f164bd7cffa55d4d001/plugins/robots/checker/twoDModelRunner/runner.cpp#L69), as the subscription is established too late. As a consequence, the sensors are not properly processed by `Box2D`. Co-authored-by: iakov <iakov@users.noreply.github.com>
1 parent 1281f48 commit f8bea05

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

plugins/robots/checker/twoDModelRunner/runner.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ Runner::Runner(const QString &report, const QString &trajectory,
6666
connect(&*mErrorReporter, &qReal::ConsoleErrorReporter::criticalAdded, &*mReporter, &Reporter::addError);
6767
connect(&*mErrorReporter, &qReal::ConsoleErrorReporter::logAdded, &*mReporter, &Reporter::addLog);
6868

69+
/*
70+
HACK: Upon initialization of the EV3 kit plugin, a subscription to the sensorAdded event in the Box2DPhysicsEngine
71+
is registered with a delay using QTimerSingleShot(10). While this does not pose an issue when
72+
utilizing TRIK Studio, it becomes problematic when using the 2D-model projectManager->open function,
73+
as the subscription is established too late. As a consequence, the sensors are not properly processed by Box2D.
74+
*/
75+
QEventLoop loop;
76+
QTimer::singleShot(0, &loop, &QEventLoop::quit);
77+
loop.exec();
6978
mProjectManager->open(mSaveFile);
7079
}
7180

qrtranslations/fr/plugins/robots/twoDModelRunner_fr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ In background mode the session will be terminated just after the execution ended
8787
<context>
8888
<name>twoDModel::Runner</name>
8989
<message>
90-
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+225"/>
90+
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+234"/>
9191
<source>Robot console</source>
9292
<translation type="unfinished"></translation>
9393
</message>

qrtranslations/ru/plugins/robots/twoDModelRunner_ru.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ In background mode the session will be terminated just after the execution ended
8989
<context>
9090
<name>twoDModel::Runner</name>
9191
<message>
92-
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+225"/>
92+
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+234"/>
9393
<source>Robot console</source>
9494
<translation>Консоль робота</translation>
9595
</message>

0 commit comments

Comments
 (0)