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
dd78bb38
Commit
dd78bb38
authored
Aug 02, 2012
by
Jessica
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed memory leaks in the unit tests.
parent
c20ec5c6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
27 deletions
+78
-27
QGCFlightGearLink.cc
src/comm/QGCFlightGearLink.cc
+7
-2
QGCMAVLink.h
src/comm/QGCMAVLink.h
+1
-1
UASUnitTest.cc
src/qgcunittest/UASUnitTest.cc
+59
-21
UAS.cc
src/uas/UAS.cc
+11
-3
No files found.
src/comm/QGCFlightGearLink.cc
View file @
dd78bb38
...
...
@@ -53,8 +53,12 @@ QGCFlightGearLink::QGCFlightGearLink(UASInterface* mav, QString remoteHost, QHos
}
QGCFlightGearLink
::~
QGCFlightGearLink
()
{
{
//if it is connected, then process, terraSync and socket were allocated memory
//if they were not connected, then they were never allocated, so no need to free memory or
//to disconnect the simulation
if
(
connectState
){
disconnectSimulation
();
}
}
/**
...
...
@@ -136,6 +140,7 @@ void QGCFlightGearLink::setRemoteHost(const QString& host)
currentHost
=
info
.
addresses
().
first
();
}
}
}
void
QGCFlightGearLink
::
updateControls
(
uint64_t
time
,
float
rollAilerons
,
float
pitchElevator
,
float
yawRudder
,
float
throttle
,
uint8_t
systemMode
,
uint8_t
navMode
)
...
...
src/comm/QGCMAVLink.h
View file @
dd78bb38
...
...
@@ -30,7 +30,7 @@ This file is part of the QGROUNDCONTROL project
#ifndef QGCMAVLINK_H
#define QGCMAVLINK_H
#include <mavlink.h>
#include <
../../mavlink/include/mavlink/v1.0/common/
mavlink.h>
//#ifdef MAVLINK_CONF
//#define MY_MACRO(x) <x>
...
...
src/qgcunittest/UASUnitTest.cc
View file @
dd78bb38
...
...
@@ -14,12 +14,11 @@ void UASUnitTest::init()
//this function is called after every test
void
UASUnitTest
::
cleanup
()
{
delete
mav
;
mav
=
NULL
;
if
(
uas
!=
NULL
){
delete
uas
;
uas
=
NULL
;
}
delete
mav
;
mav
=
NULL
;
}
void
UASUnitTest
::
getUASID_test
()
...
...
@@ -125,7 +124,6 @@ void UASUnitTest::getStatusForCode_test()
uas
->
getStatusForCode
(
5325
,
state
,
desc
);
QVERIFY
(
state
==
"UNKNOWN"
);
}
void
UASUnitTest
::
getLocalX_test
()
...
...
@@ -260,7 +258,6 @@ void UASUnitTest::signalWayPoint_test()
Waypoint
*
wp
=
new
Waypoint
(
0
,
1.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
false
,
false
,
MAV_FRAME_GLOBAL
,
MAV_CMD_MISSION_START
,
"blah"
);
uas
->
getWaypointManager
()
->
addWaypointEditable
(
wp
,
true
);
QCOMPARE
(
spy
.
count
(),
1
);
// 1 listChanged for add wayPoint
uas
->
getWaypointManager
()
->
removeWaypoint
(
0
);
QCOMPARE
(
spy
.
count
(),
2
);
// 2 listChanged for remove wayPoint
...
...
@@ -283,18 +280,26 @@ void UASUnitTest::signalWayPoint_test()
uas
->
getWaypointManager
()
->
clearWaypointList
();
QVector
<
Waypoint
*>
wpList
=
uas
->
getWaypointManager
()
->
getWaypointEditableList
();
QCOMPARE
(
wpList
.
count
(),
1
);
delete
uas
;
uas
=
NULL
;
delete
wp2
;
}
//TODO:startHil. to make sure connect and disconnect simulation in QGCFlightGear works properly
//TODO:stopHil
void
UASUnitTest
::
signalUASLink_test
()
{
QSignalSpy
spy
(
uas
,
SIGNAL
(
modeChanged
(
int
,
QString
,
QString
)));
uas
->
setMode
(
2
);
QCOMPARE
(
spy
.
count
(),
0
);
// not solve for UAS not receiving message from UAS
QSignalSpy
spyS
(
LinkManager
::
instance
(),
SIGNAL
(
newLink
(
LinkInterface
*
)));
SerialLink
*
link
=
new
SerialLink
();
LinkManager
::
instance
()
->
add
(
link
);
LinkManager
::
instance
()
->
addProtocol
(
link
,
mav
);
QCOMPARE
(
spyS
.
count
(),
1
);
...
...
@@ -331,41 +336,74 @@ void UASUnitTest::signalUASLink_test()
LinkInterface
*
ff99
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
1
));
LinkManager
::
instance
()
->
removeLink
(
ff99
);
delete
link2
;
QCOMPARE
(
LinkManager
::
instance
()
->
getLinks
().
count
(),
1
);
QCOMPARE
(
uas
->
getLinks
()
->
count
(),
2
);
QCOMPARE
(
static_cast
<
LinkInterface
*>
(
LinkManager
::
instance
()
->
getLinks
().
at
(
0
))
->
getId
(),
static_cast
<
LinkInterface
*>
(
uas
->
getLinks
()
->
at
(
0
))
->
getId
());
link
=
new
SerialLink
();
LinkManager
::
instance
()
->
add
(
link
);
LinkManager
::
instance
()
->
addProtocol
(
link
,
mav
);
SerialLink
*
link3
=
new
SerialLink
();
LinkManager
::
instance
()
->
add
(
link
3
);
LinkManager
::
instance
()
->
addProtocol
(
link
3
,
mav
);
QCOMPARE
(
spyS
.
count
(),
3
);
QCOMPARE
(
LinkManager
::
instance
()
->
getLinks
().
count
(),
2
);
LinkManager
::
instance
()
->
removeLink
(
link3
);
delete
link3
;
QCOMPARE
(
LinkManager
::
instance
()
->
getLinks
().
count
(),
1
);
LinkManager
::
instance
()
->
removeLink
(
link
);
delete
link
;
QCOMPARE
(
LinkManager
::
instance
()
->
getLinks
().
count
(),
0
);
}
void
UASUnitTest
::
signalIdUASLink_test
()
{
QCOMPARE
(
LinkManager
::
instance
()
->
getLinks
().
count
(),
0
);
SerialLink
*
myLink
=
new
SerialLink
();
myLink
->
setPortName
(
"COM 17"
);
LinkManager
::
instance
()
->
add
(
myLink
);
LinkManager
::
instance
()
->
addProtocol
(
myLink
,
mav
);
myLink
=
new
SerialLink
();
myLink
->
setPortName
(
"COM 18"
);
LinkManager
::
instance
()
->
add
(
myLink
);
LinkManager
::
instance
()
->
addProtocol
(
myLink
,
mav
);
SerialLink
*
myLink2
=
new
SerialLink
();
myLink2
->
setPortName
(
"COM 18"
);
LinkManager
::
instance
()
->
add
(
myLink2
);
LinkManager
::
instance
()
->
addProtocol
(
myLink2
,
mav
);
SerialLink
*
myLink3
=
new
SerialLink
();
myLink3
->
setPortName
(
"COM 19"
);
LinkManager
::
instance
()
->
add
(
myLink3
);
LinkManager
::
instance
()
->
addProtocol
(
myLink3
,
mav
);
SerialLink
*
myLink4
=
new
SerialLink
();
myLink4
->
setPortName
(
"COM 20"
);
LinkManager
::
instance
()
->
add
(
myLink4
);
LinkManager
::
instance
()
->
addProtocol
(
myLink4
,
mav
);
QCOMPARE
(
LinkManager
::
instance
()
->
getLinks
().
count
(),
4
);
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinks
();
LinkInterface
*
a
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
2
));
LinkInterface
*
b
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
3
));
LinkInterface
*
a
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
0
));
LinkInterface
*
b
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
1
));
LinkInterface
*
c
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
2
));
LinkInterface
*
d
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
3
));
QCOMPARE
(
a
->
getName
(),
QString
(
"serial port COM 17"
));
QCOMPARE
(
b
->
getName
(),
QString
(
"serial port COM 18"
));
QCOMPARE
(
c
->
getName
(),
QString
(
"serial port COM 19"
));
QCOMPARE
(
d
->
getName
(),
QString
(
"serial port COM 20"
));
LinkManager
::
instance
()
->
removeLink
(
myLink4
);
delete
myLink4
;
LinkManager
::
instance
()
->
removeLink
(
myLink3
);
delete
myLink3
;
LinkManager
::
instance
()
->
removeLink
(
myLink2
);
delete
myLink2
;
LinkManager
::
instance
()
->
removeLink
(
myLink
);
delete
myLink
;
QCOMPARE
(
LinkManager
::
instance
()
->
getLinks
().
count
(),
0
);
}
src/uas/UAS.cc
View file @
dd78bb38
...
...
@@ -106,7 +106,6 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
}
color
=
UASInterface
::
getNextColor
();
setBatterySpecs
(
QString
(
"9V,9.5V,12.6V"
));
connect
(
statusTimeout
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
updateState
()));
connect
(
this
,
SIGNAL
(
systemSpecsChanged
(
int
)),
this
,
SLOT
(
writeSettings
()));
...
...
@@ -122,7 +121,16 @@ UAS::~UAS()
{
writeSettings
();
delete
links
;
links
=
NULL
;
if
(
statusTimeout
->
isActive
())
{
statusTimeout
->
deleteLater
();
}
delete
statusTimeout
;
delete
simulation
;
mavlink
->
deleteLater
();
delete
paramManager
;
}
void
UAS
::
writeSettings
()
{
...
...
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