Skip to content

Commit

Permalink
Fix countdown appearing with no screen controller configured
Browse files Browse the repository at this point in the history
Fix possible issue with the ScreenControllerFactory returning a nullptr
instead of throwing for certain input strings such as ";".
  • Loading branch information
Raphael Dumusc committed Jul 13, 2018
1 parent 50c5122 commit 5958a76
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
6 changes: 4 additions & 2 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ Changelog {#changelog}

# Release 1.5 (git master)

* [258](https://github.com/BlueBrain/Tide/pull/258):
Previous demo launcher replaced with a web ui version
* [260](https://github.com/BlueBrain/Tide/pull/260):
Add context menu to copy-paste selected contents from one session to another.
Fix a bug that caused the "Touch to prevent sleep" dialog appear even when no
screen controller was configured.
* [256](https://github.com/BlueBrain/Tide/pull/256):
Add "dimensions" property in surface configuration to let UI elements scale
to real-world sizes (in meters). Currently used for the Launcher only.
Expand Down
7 changes: 2 additions & 5 deletions tests/cpp/core/ScreenControllerFactoryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,10 @@ inline std::ostream& operator<<(std::ostream& str,
return str;
}

BOOST_AUTO_TEST_CASE(testEmptySerialDeviceReturnsNullptr)
{
BOOST_CHECK(!ScreenControllerFactory::create(""));
}

BOOST_AUTO_TEST_CASE(testExceptionWhenSerialDeviceCannotBeOpened)
{
BOOST_CHECK_THROW(ScreenControllerFactory::create(""), std::runtime_error);
BOOST_CHECK_THROW(ScreenControllerFactory::create(";"), std::runtime_error);
BOOST_CHECK_THROW(ScreenControllerFactory::create("/dev/null;/dev/das"),
std::runtime_error);
BOOST_CHECK_THROW(ScreenControllerFactory::create(
Expand Down
24 changes: 14 additions & 10 deletions tide/master/MasterApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ void MasterApplication::_init()
_pixelStreamerLauncher.reset(
new PixelStreamerLauncher(*_pixelStreamWindowManager, *_config));

_inactivityTimer.reset(
new InactivityTimer(_config->settings.inactivityTimeout));

if (_config->master.headless)
_initOffscreenView();
else
Expand Down Expand Up @@ -331,12 +328,15 @@ void MasterApplication::_setupMPIConnections()
},
Qt::DirectConnection);

connect(_inactivityTimer.get(), &InactivityTimer::countdownUpdated,
_masterToWallChannel.get(),
[this](CountdownStatusPtr status) {
_masterToWallChannel->sendAsync(status);
},
Qt::DirectConnection);
if (_inactivityTimer)
{
connect(_inactivityTimer.get(), &InactivityTimer::countdownUpdated,
_masterToWallChannel.get(),
[this](CountdownStatusPtr status) {
_masterToWallChannel->sendAsync(status);
},
Qt::DirectConnection);
}

connect(_lock.get(), &ScreenLock::modified, [this](ScreenLockPtr lock) {
_masterToWallChannel->sendAsync(lock);
Expand Down Expand Up @@ -435,6 +435,9 @@ void MasterApplication::_initScreenController()
_screenController =
ScreenControllerFactory::create(_config->master.planarSerialPort);

_inactivityTimer =
std::make_unique<InactivityTimer>(_config->settings.inactivityTimeout);

connect(_inactivityTimer.get(), &InactivityTimer::poweroff, [this]() {
_screenController->powerOff();
print_log(LOG_INFO, LOG_POWER,
Expand Down Expand Up @@ -533,7 +536,8 @@ bool MasterApplication::notify(QObject* receiver, QEvent* event)

void MasterApplication::_handle(const QTouchEvent* event)
{
_inactivityTimer->restart();
if (_inactivityTimer)
_inactivityTimer->restart();

if ((uint)event->touchPoints().length() >=
_config->settings.touchpointsToWakeup)
Expand Down
3 changes: 2 additions & 1 deletion tide/master/ScreenControllerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ std::unique_ptr<ScreenController> ScreenControllerFactory::create(
{
const auto connections = parseInputString(ports);
if (connections.empty())
return nullptr;
throw std::runtime_error("Invalid screen controller list: '" +
ports.toStdString() + "'");

std::vector<std::unique_ptr<ScreenController>> controllers;
QMapIterator<QString, PlanarController::Type> i(connections);
Expand Down
1 change: 1 addition & 0 deletions tide/master/ScreenControllerFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ScreenControllerFactory
/**
* Create a ScreenController.
* @param ports a configurable combination of port and device type.
* @throw std::runtime_error if an error occurs when opening the ports.
*/
static std::unique_ptr<ScreenController> create(const QString& ports);

Expand Down

0 comments on commit 5958a76

Please sign in to comment.