Skip to content

Commit 54c6e95

Browse files
author
Raphael Dumusc
committed
QmlStreamer bugfix: gracefully exit on Stream connection error
A previous change made the Stream constructor throw, causing an uncaught exception.
1 parent cc4c732 commit 54c6e95

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Daniel Nachbaur <[email protected]>
55

66
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
7-
project(Deflect VERSION 0.14.0)
7+
project(Deflect VERSION 0.14.1)
88
set(Deflect_VERSION_ABI 7)
99

1010
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/common)

deflect/qt/QmlStreamerImpl.cpp

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*********************************************************************/
2-
/* Copyright (c) 2015-2016, EPFL/Blue Brain Project */
3-
/* Daniel.Nachbaur <[email protected]> */
4-
/* Raphael Dumusc <[email protected]> */
2+
/* Copyright (c) 2015-2018, EPFL/Blue Brain Project */
3+
/* Daniel.Nachbaur <[email protected]>*/
4+
/* Raphael Dumusc <[email protected]> */
55
/* All rights reserved. */
66
/* */
77
/* Redistribution and use in source and binary forms, with or */
@@ -105,10 +105,18 @@ void QmlStreamer::Impl::_afterRender(const QImage image)
105105
if (!_sendFuture.valid() || !_sendFuture.get())
106106
return;
107107

108-
if (!_stream && !_setupDeflectStream())
108+
if (!_stream)
109109
{
110-
qWarning() << "Could not setup Deflect stream";
111-
return;
110+
try
111+
{
112+
_setupDeflectStream();
113+
}
114+
catch (const std::runtime_error& e)
115+
{
116+
qWarning() << e.what();
117+
_onStreamClosed();
118+
return;
119+
}
112120
}
113121

114122
if (image.isNull())
@@ -248,16 +256,13 @@ std::string QmlStreamer::Impl::_getDeflectStreamIdentifier() const
248256
return streamId.empty() ? DEFAULT_STREAM_ID : streamId;
249257
}
250258

251-
bool QmlStreamer::Impl::_setupDeflectStream()
259+
void QmlStreamer::Impl::_setupDeflectStream()
252260
{
253261
if (!_stream)
254262
_stream.reset(new Stream(_getDeflectStreamIdentifier(), _streamHost));
255263

256-
if (!_stream->isConnected())
257-
return false;
258-
259264
if (!_stream->registerForEvents())
260-
return false;
265+
throw std::runtime_error("Stream failed to register for events");
261266

262267
if (_sizeHints != SizeHints())
263268
_stream->sendSizeHints(_sizeHints);
@@ -297,8 +302,6 @@ bool QmlStreamer::Impl::_setupDeflectStream()
297302

298303
connect(_eventReceiver.get(), &EventReceiver::closed, this,
299304
&QmlStreamer::Impl::_onStreamClosed);
300-
301-
return true;
302305
}
303306

304307
void QmlStreamer::Impl::_connectTouchInjector()

deflect/qt/QmlStreamerImpl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private slots:
9696
void _send(QKeyEvent& keyEvent);
9797
bool _sendToWebengineviewItems(QKeyEvent& keyEvent);
9898
std::string _getDeflectStreamIdentifier() const;
99-
bool _setupDeflectStream();
99+
void _setupDeflectStream();
100100

101101
void _connectTouchInjector();
102102
void _setupMouseModeSwitcher();

doc/Changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Changelog {#Changelog}
33

44
## Deflect 0.14
55

6+
### 0.14.1 (git master)
7+
* [192](https://github.com/BlueBrain/Deflect/pull/192):
8+
QmlStreamer bugfix: gracefully exit if the stream connection fails.
9+
610
### 0.14.0 (23-10-2017)
711

812
* [191](https://github.com/BlueBrain/Deflect/pull/191):

0 commit comments

Comments
 (0)