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
d6bcee73
Commit
d6bcee73
authored
Jul 08, 2017
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delay creation of MAVLinkDecoder until it is needed
Helps battery life
parent
257fc085
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
14 deletions
+25
-14
MainWindow.cc
src/ui/MainWindow.cc
+23
-13
MainWindow.h
src/ui/MainWindow.h
+2
-1
No files found.
src/ui/MainWindow.cc
View file @
d6bcee73
...
@@ -108,10 +108,11 @@ void MainWindow::deleteInstance(void)
...
@@ -108,10 +108,11 @@ void MainWindow::deleteInstance(void)
/// by MainWindow::_create method. Hence no other code should have access to
/// by MainWindow::_create method. Hence no other code should have access to
/// constructor.
/// constructor.
MainWindow
::
MainWindow
()
MainWindow
::
MainWindow
()
:
_lowPowerMode
(
false
)
:
_mavlinkDecoder
(
NULL
)
,
_showStatusBar
(
false
)
,
_lowPowerMode
(
false
)
,
_mainQmlWidgetHolder
(
NULL
)
,
_showStatusBar
(
false
)
,
_forceClose
(
false
)
,
_mainQmlWidgetHolder
(
NULL
)
,
_forceClose
(
false
)
{
{
_instance
=
this
;
_instance
=
this
;
...
@@ -272,10 +273,13 @@ MainWindow::MainWindow()
...
@@ -272,10 +273,13 @@ MainWindow::MainWindow()
MainWindow
::~
MainWindow
()
MainWindow
::~
MainWindow
()
{
{
// Enforce thread-safe shutdown of the mavlink decoder
if
(
_mavlinkDecoder
)
{
mavlinkDecoder
->
finish
();
// Enforce thread-safe shutdown of the mavlink decoder
mavlinkDecoder
->
wait
(
1000
);
_mavlinkDecoder
->
finish
();
mavlinkDecoder
->
deleteLater
();
_mavlinkDecoder
->
wait
(
1000
);
_mavlinkDecoder
->
deleteLater
();
_mavlinkDecoder
=
NULL
;
}
// This needs to happen before we get into the QWidget dtor
// This needs to happen before we get into the QWidget dtor
// otherwise the QML engine reads freed data and tries to
// otherwise the QML engine reads freed data and tries to
...
@@ -290,12 +294,18 @@ QString MainWindow::_getWindowGeometryKey()
...
@@ -290,12 +294,18 @@ QString MainWindow::_getWindowGeometryKey()
}
}
#ifndef __mobile__
#ifndef __mobile__
void
MainWindow
::
_buildCommonWidgets
(
void
)
MAVLinkDecoder
*
MainWindow
::
_mavLinkDecoderInstance
(
void
)
{
{
// Add generic MAVLink decoder
if
(
_mavlinkDecoder
)
{
mavlinkDecoder
=
new
MAVLinkDecoder
(
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
());
_mavlinkDecoder
=
new
MAVLinkDecoder
(
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
());
connect
(
mavlinkDecoder
.
data
(),
&
MAVLinkDecoder
::
valueChanged
,
this
,
&
MainWindow
::
valueChanged
);
connect
(
_mavlinkDecoder
,
&
MAVLinkDecoder
::
valueChanged
,
this
,
&
MainWindow
::
valueChanged
);
}
return
_mavlinkDecoder
;
}
void
MainWindow
::
_buildCommonWidgets
(
void
)
{
// Log player
// Log player
// TODO: Make this optional with a preferences setting or under a "View" menu
// TODO: Make this optional with a preferences setting or under a "View" menu
logPlayer
=
new
QGCMAVLinkLogPlayer
(
statusBar
());
logPlayer
=
new
QGCMAVLinkLogPlayer
(
statusBar
());
...
@@ -363,7 +373,7 @@ bool MainWindow::_createInnerDockWidget(const QString& widgetName)
...
@@ -363,7 +373,7 @@ bool MainWindow::_createInnerDockWidget(const QString& widgetName)
widget
=
new
HILDockWidget
(
widgetName
,
action
,
this
);
widget
=
new
HILDockWidget
(
widgetName
,
action
,
this
);
break
;
break
;
case
ANALYZE
:
case
ANALYZE
:
widget
=
new
Linecharts
(
widgetName
,
action
,
mavlinkDecoder
,
this
);
widget
=
new
Linecharts
(
widgetName
,
action
,
_mavLinkDecoderInstance
()
,
this
);
break
;
break
;
}
}
if
(
widget
)
{
if
(
widget
)
{
...
...
src/ui/MainWindow.h
View file @
d6bcee73
...
@@ -127,7 +127,6 @@ protected:
...
@@ -127,7 +127,6 @@ protected:
QSettings
settings
;
QSettings
settings
;
QPointer
<
MAVLinkDecoder
>
mavlinkDecoder
;
QGCMAVLinkLogPlayer
*
logPlayer
;
QGCMAVLinkLogPlayer
*
logPlayer
;
#ifdef QGC_MOUSE_ENABLED_WIN
#ifdef QGC_MOUSE_ENABLED_WIN
/** @brief 3d Mouse support (WIN only) */
/** @brief 3d Mouse support (WIN only) */
...
@@ -181,7 +180,9 @@ private:
...
@@ -181,7 +180,9 @@ private:
void
_showDockWidget
(
const
QString
&
name
,
bool
show
);
void
_showDockWidget
(
const
QString
&
name
,
bool
show
);
void
_loadVisibleWidgetsSettings
(
void
);
void
_loadVisibleWidgetsSettings
(
void
);
void
_storeVisibleWidgetsSettings
(
void
);
void
_storeVisibleWidgetsSettings
(
void
);
MAVLinkDecoder
*
_mavLinkDecoderInstance
(
void
);
MAVLinkDecoder
*
_mavlinkDecoder
;
bool
_lowPowerMode
;
///< If enabled, QGC reduces the update rates of all widgets
bool
_lowPowerMode
;
///< If enabled, QGC reduces the update rates of all widgets
bool
_showStatusBar
;
bool
_showStatusBar
;
QVBoxLayout
*
_centralLayout
;
QVBoxLayout
*
_centralLayout
;
...
...
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