Skip to content

Commit 7231474

Browse files
committed
Renamed aboutToShutdown signal in wrapper in accordance with Ros2Qml singleton.
Fixed test after change of how cleanup is done.
1 parent 565acc8 commit 7231474

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

include/qml_ros2_plugin/ros2.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ class Ros2QmlSingletonWrapper : public QObject
229229
//! @copydoc Ros2Qml::init(const QStringList &, const QString &, Ros2InitOptions)
230230
Q_INVOKABLE void init( const QString &name, const QStringList &args, QObject *options = nullptr );
231231

232+
//! @copydoc Ros2Qml::shutdown
233+
Q_INVOKABLE void shutdown();
234+
232235
//! @copydoc Ros2Qml::ok
233236
Q_INVOKABLE bool ok() const;
234237

@@ -391,7 +394,7 @@ class Ros2QmlSingletonWrapper : public QObject
391394
void initialized();
392395

393396
//! @copydoc Ros2Qml::aboutToShutdown
394-
void shutdown();
397+
void aboutToShutdown();
395398

396399
private:
397400
bool initLogging();

src/ros2.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ Ros2QmlSingletonWrapper::Ros2QmlSingletonWrapper()
362362
connect( &Ros2Qml::getInstance(), &Ros2Qml::initialized, this,
363363
&Ros2QmlSingletonWrapper::initialized );
364364
connect( &Ros2Qml::getInstance(), &Ros2Qml::aboutToShutdown, this,
365-
&Ros2QmlSingletonWrapper::shutdown );
365+
&Ros2QmlSingletonWrapper::aboutToShutdown );
366366
Ros2Qml::getInstance().registerDependant();
367367
}
368368

@@ -410,6 +410,8 @@ void Ros2QmlSingletonWrapper::init( const QString &name, const QStringList &args
410410
Ros2Qml::getInstance().init( name, args, qobject_cast<Ros2InitOptions *>( options ) );
411411
}
412412

413+
void Ros2QmlSingletonWrapper::shutdown() { Ros2Qml::getInstance().shutdown(); }
414+
413415
bool Ros2QmlSingletonWrapper::ok() const { return Ros2Qml::getInstance().ok(); }
414416

415417
Time Ros2QmlSingletonWrapper::now() const

test/ros_life_cycle.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ TEST( Ros2LifeCycle, testLifeCycle )
8585
EXPECT_TRUE( mock_ros.initialized );
8686
delete publisher_before_init;
8787
delete publisher_after_init;
88+
89+
ros_wrapper.shutdown();
8890
}
89-
// Wrappers are destroyed, this should clear node etc.
91+
// After shutdown everything should be uninitialized again
9092
EXPECT_FALSE( qml_ros2_plugin::Ros2Qml::getInstance().isInitialized() );
9193
EXPECT_FALSE( qml_ros2_plugin::TfTransformListener::getInstance().isInitialized() );
9294
}

0 commit comments

Comments
 (0)