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
5fe34d0b
Commit
5fe34d0b
authored
Feb 20, 2015
by
dogmaphobic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning dangling links
parent
b1a9d302
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
LinkInterface.h
src/comm/LinkInterface.h
+3
-1
LinkManager.cc
src/comm/LinkManager.cc
+21
-4
LinkManager.h
src/comm/LinkManager.h
+1
-0
No files found.
src/comm/LinkInterface.h
View file @
5fe34d0b
...
...
@@ -57,7 +57,8 @@ public:
LinkInterface
()
:
QThread
(
0
),
_ownedByLinkManager
(
false
),
_deletedByLinkManager
(
false
)
_deletedByLinkManager
(
false
),
_flaggedForDeletion
(
false
)
{
// Initialize everything for the data rate calculation buffers.
inDataIndex
=
0
;
...
...
@@ -340,6 +341,7 @@ private:
bool
_ownedByLinkManager
;
///< true: This link has been added to LinkManager, false: Link not added to LinkManager
bool
_deletedByLinkManager
;
///< true: Link being deleted from LinkManager, false: error, Links should only be deleted from LinkManager
bool
_flaggedForDeletion
;
///< true: Garbage colletion ready
};
#endif // _LINKINTERFACE_H_
src/comm/LinkManager.cc
View file @
5fe34d0b
...
...
@@ -193,20 +193,37 @@ bool LinkManager::disconnectLink(LinkInterface* link)
{
Q_ASSERT
(
link
);
if
(
link
->
_disconnect
())
{
// TODO There is no point in disconnecting it if will stay around.
// This should be turned into a delete link instead. Deleting a link
// is not yet possible as LinkManager is broken.
// Disconnect this link from its configuration
LinkConfiguration
*
config
=
link
->
getLinkConfiguration
();
if
(
config
)
{
config
->
setLink
(
NULL
);
}
// Link is now done and over with. We can't yet delete it because it
// takes a while for the MAVLink protocol to take notice of it. We
// flag it for delayed deletion for final clean up.
link
->
_flaggedForDeletion
=
true
;
QTimer
::
singleShot
(
1000
,
this
,
&
LinkManager
::
_delayedDeleteLink
);
return
true
;
}
else
{
return
false
;
}
}
void
LinkManager
::
_delayedDeleteLink
()
{
_linkListMutex
.
lock
();
foreach
(
LinkInterface
*
link
,
_links
)
{
Q_ASSERT
(
link
);
if
(
link
->
_flaggedForDeletion
)
{
qDebug
()
<<
"Link deleted: "
<<
link
->
getName
();
_linkListMutex
.
unlock
();
deleteLink
(
link
);
return
;
}
}
_linkListMutex
.
unlock
();
}
void
LinkManager
::
deleteLink
(
LinkInterface
*
link
)
{
Q_ASSERT
(
link
);
...
...
src/comm/LinkManager.h
View file @
5fe34d0b
...
...
@@ -141,6 +141,7 @@ signals:
private
slots
:
void
_linkConnected
(
void
);
void
_linkDisconnected
(
void
);
void
_delayedDeleteLink
();
private:
/// All access to LinkManager is through LinkManager::instance
...
...
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