Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
3237dd41
Commit
3237dd41
authored
Jan 27, 2017
by
Nate Weibley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforce threadsafe shutdown and deletion of MAVLinkDecoder
parent
02441ff5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
6 deletions
+13
-6
MAVLinkDecoder.cc
src/ui/MAVLinkDecoder.cc
+4
-3
MAVLinkDecoder.h
src/ui/MAVLinkDecoder.h
+3
-1
MainWindow.cc
src/ui/MainWindow.cc
+6
-2
No files found.
src/ui/MAVLinkDecoder.cc
View file @
3237dd41
...
...
@@ -3,10 +3,9 @@
#include <QDebug>
MAVLinkDecoder
::
MAVLinkDecoder
(
MAVLinkProtocol
*
protocol
,
QObject
*
parent
)
:
QThread
()
MAVLinkDecoder
::
MAVLinkDecoder
(
MAVLinkProtocol
*
protocol
)
:
QThread
()
,
creationThread
(
QThread
::
currentThread
())
{
Q_UNUSED
(
parent
);
// We're doing it wrong - because the Qt folks got the API wrong:
// http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
moveToThread
(
this
);
...
...
@@ -52,6 +51,7 @@ MAVLinkDecoder::MAVLinkDecoder(MAVLinkProtocol* protocol, QObject *parent) :
// textMessageFilter.insert(MAVLINK_MSG_ID_HIGHRES_IMU, false);
connect
(
protocol
,
&
MAVLinkProtocol
::
messageReceived
,
this
,
&
MAVLinkDecoder
::
receiveMessage
);
connect
(
this
,
&
MAVLinkDecoder
::
finish
,
this
,
&
QThread
::
quit
);
start
(
LowPriority
);
}
...
...
@@ -63,6 +63,7 @@ MAVLinkDecoder::MAVLinkDecoder(MAVLinkProtocol* protocol, QObject *parent) :
void
MAVLinkDecoder
::
run
()
{
exec
();
moveToThread
(
creationThread
);
}
void
MAVLinkDecoder
::
receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
)
...
...
src/ui/MAVLinkDecoder.h
View file @
3237dd41
...
...
@@ -8,13 +8,14 @@ class MAVLinkDecoder : public QThread
{
Q_OBJECT
public:
MAVLinkDecoder
(
MAVLinkProtocol
*
protocol
,
QObject
*
parent
=
0
);
MAVLinkDecoder
(
MAVLinkProtocol
*
protocol
);
void
run
();
signals:
void
textMessageReceived
(
int
uasid
,
int
componentid
,
int
severity
,
const
QString
&
text
);
void
valueChanged
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
QVariant
&
value
,
const
quint64
msec
);
void
finish
();
///< Trigger a thread safe shutdown
public
slots
:
/** @brief Receive one message from the protocol and decode it */
...
...
@@ -35,6 +36,7 @@ protected:
quint64
onboardTimeOffset
[
cMessageIds
];
///< Offset of onboard time from Unix epoch (of the receiving GCS)
qint64
onboardToGCSUnixTimeOffsetAndDelay
[
cMessageIds
];
///< Offset of onboard time and GCS Unix time
quint64
firstOnboardTime
[
cMessageIds
];
///< First seen onboard time
QThread
*
creationThread
;
///< QThread on which the object is created
};
#endif // MAVLINKDECODER_H
src/ui/MainWindow.cc
View file @
3237dd41
...
...
@@ -274,6 +274,11 @@ MainWindow::MainWindow()
MainWindow
::~
MainWindow
()
{
// Enforce thread-safe shutdown of the mavlink decoder
mavlinkDecoder
->
finish
();
mavlinkDecoder
->
wait
(
1000
);
mavlinkDecoder
->
deleteLater
();
// This needs to happen before we get into the QWidget dtor
// otherwise the QML engine reads freed data and tries to
// destroy MainWindow a second time.
...
...
@@ -290,8 +295,7 @@ QString MainWindow::_getWindowGeometryKey()
void
MainWindow
::
_buildCommonWidgets
(
void
)
{
// Add generic MAVLink decoder
// TODO: This is never deleted
mavlinkDecoder
=
new
MAVLinkDecoder
(
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
(),
this
);
mavlinkDecoder
=
new
MAVLinkDecoder
(
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
());
connect
(
mavlinkDecoder
.
data
(),
&
MAVLinkDecoder
::
valueChanged
,
this
,
&
MainWindow
::
valueChanged
);
// Log player
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment