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
5471e8ff
Commit
5471e8ff
authored
Feb 26, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1266 from DonLakeFlyer/UASDelete
Fix object de-reference crash on deletion
parents
059df23d
df1adf70
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
42 deletions
+46
-42
QGCWaypointListMulti.cc
src/ui/QGCWaypointListMulti.cc
+31
-33
QGCWaypointListMulti.h
src/ui/QGCWaypointListMulti.h
+11
-9
UASView.cc
src/ui/uas/UASView.cc
+4
-0
No files found.
src/ui/QGCWaypointListMulti.cc
View file @
5471e8ff
...
@@ -2,73 +2,71 @@
...
@@ -2,73 +2,71 @@
#include "ui_QGCWaypointListMulti.h"
#include "ui_QGCWaypointListMulti.h"
#include "UASManager.h"
#include "UASManager.h"
void
*
QGCWaypointListMulti
::
_offlineUAS
=
NULL
;
QGCWaypointListMulti
::
QGCWaypointListMulti
(
QWidget
*
parent
)
:
QGCWaypointListMulti
::
QGCWaypointListMulti
(
QWidget
*
parent
)
:
QWidget
(
parent
),
QWidget
(
parent
),
offline_uas_id
(
0
),
_ui
(
new
Ui
::
QGCWaypointListMulti
)
ui
(
new
Ui
::
QGCWaypointListMulti
)
{
{
ui
->
setupUi
(
this
);
_
ui
->
setupUi
(
this
);
setMinimumSize
(
600
,
80
);
setMinimumSize
(
600
,
80
);
connect
(
UASManager
::
instance
(),
&
UASManager
::
UASCreated
,
this
,
&
QGCWaypointListMulti
::
systemCreated
);
connect
(
UASManager
::
instance
(),
&
UASManager
::
activeUASSet
,
this
,
&
QGCWaypointListMulti
::
systemSetActive
);
connect
(
UASManager
::
instance
(),
&
UASManager
::
UASCreated
,
this
,
&
QGCWaypointListMulti
::
_systemCreated
);
connect
(
UASManager
::
instance
(),
&
UASManager
::
activeUASSet
,
this
,
&
QGCWaypointListMulti
::
_systemSetActive
);
WaypointList
*
list
=
new
WaypointList
(
ui
->
stackedWidget
,
UASManager
::
instance
()
->
getActiveUASWaypointManager
());
WaypointList
*
list
=
new
WaypointList
(
_
ui
->
stackedWidget
,
UASManager
::
instance
()
->
getActiveUASWaypointManager
());
lists
.
insert
(
offline_uas_id
,
list
);
_lists
.
insert
(
_offlineUAS
,
list
);
ui
->
stackedWidget
->
addWidget
(
list
);
_
ui
->
stackedWidget
->
addWidget
(
list
);
if
(
UASManager
::
instance
()
->
getActiveUAS
())
{
if
(
UASManager
::
instance
()
->
getActiveUAS
())
{
systemCreated
(
UASManager
::
instance
()
->
getActiveUAS
());
_
systemCreated
(
UASManager
::
instance
()
->
getActiveUAS
());
systemSetActive
(
UASManager
::
instance
()
->
getActiveUAS
());
_
systemSetActive
(
UASManager
::
instance
()
->
getActiveUAS
());
}
}
}
}
void
QGCWaypointListMulti
::
systemDeleted
(
QObject
*
uas
)
QGCWaypointListMulti
::~
QGCWaypointListMulti
()
{
delete
_ui
;
}
void
QGCWaypointListMulti
::
_systemDeleted
(
QObject
*
uas
)
{
{
// Do not dynamic cast or de-reference QObject, since object is either in destructor or may have already
// Do not dynamic cast or de-reference QObject, since object is either in destructor or may have already
// been destroyed.
// been destroyed.
UASInterface
*
mav
=
static_cast
<
UASInterface
*>
(
uas
);
if
(
uas
)
{
if
(
mav
)
WaypointList
*
list
=
_lists
.
value
(
uas
,
NULL
);
{
if
(
list
)
{
int
id
=
mav
->
getUASID
();
WaypointList
*
list
=
lists
.
value
(
id
,
NULL
);
if
(
list
)
{
delete
list
;
delete
list
;
lists
.
remove
(
id
);
_lists
.
remove
(
uas
);
}
}
}
}
}
}
void
QGCWaypointListMulti
::
systemCreated
(
UASInterface
*
uas
)
void
QGCWaypointListMulti
::
_
systemCreated
(
UASInterface
*
uas
)
{
{
WaypointList
*
list
=
new
WaypointList
(
ui
->
stackedWidget
,
uas
->
getWaypointManager
());
WaypointList
*
list
=
new
WaypointList
(
_
ui
->
stackedWidget
,
uas
->
getWaypointManager
());
lists
.
insert
(
uas
->
getUASID
()
,
list
);
_lists
.
insert
(
uas
,
list
);
ui
->
stackedWidget
->
addWidget
(
list
);
_
ui
->
stackedWidget
->
addWidget
(
list
);
// Ensure widget is deleted when system is deleted
// Ensure widget is deleted when system is deleted
connect
(
uas
,
SIGNAL
(
destroyed
(
QObject
*
)),
this
,
SLOT
(
systemDeleted
(
QObject
*
))
);
connect
(
uas
,
&
QObject
::
destroyed
,
this
,
&
QGCWaypointListMulti
::
_systemDeleted
);
}
}
void
QGCWaypointListMulti
::
systemSetActive
(
UASInterface
*
uas
)
void
QGCWaypointListMulti
::
_
systemSetActive
(
UASInterface
*
uas
)
{
{
WaypointList
*
list
=
lists
.
value
(
uas
->
getUASID
()
,
NULL
);
WaypointList
*
list
=
_lists
.
value
(
uas
,
NULL
);
if
(
list
)
{
if
(
list
)
{
ui
->
stackedWidget
->
setCurrentWidget
(
list
);
_
ui
->
stackedWidget
->
setCurrentWidget
(
list
);
}
}
}
}
QGCWaypointListMulti
::~
QGCWaypointListMulti
()
{
delete
ui
;
}
void
QGCWaypointListMulti
::
changeEvent
(
QEvent
*
e
)
void
QGCWaypointListMulti
::
changeEvent
(
QEvent
*
e
)
{
{
QWidget
::
changeEvent
(
e
);
QWidget
::
changeEvent
(
e
);
switch
(
e
->
type
())
{
switch
(
e
->
type
())
{
case
QEvent
:
:
LanguageChange
:
case
QEvent
:
:
LanguageChange
:
ui
->
retranslateUi
(
this
);
_
ui
->
retranslateUi
(
this
);
break
;
break
;
default:
default:
break
;
break
;
...
...
src/ui/QGCWaypointListMulti.h
View file @
5471e8ff
...
@@ -20,18 +20,20 @@ public:
...
@@ -20,18 +20,20 @@ public:
explicit
QGCWaypointListMulti
(
QWidget
*
parent
=
0
);
explicit
QGCWaypointListMulti
(
QWidget
*
parent
=
0
);
~
QGCWaypointListMulti
();
~
QGCWaypointListMulti
();
public
slots
:
void
systemDeleted
(
QObject
*
uas
);
void
systemCreated
(
UASInterface
*
uas
);
void
systemSetActive
(
UASInterface
*
uas
);
protected:
protected:
quint16
offline_uas_id
;
// Override from Widget
void
changeEvent
(
QEvent
*
e
);
virtual
void
changeEvent
(
QEvent
*
e
);
QMap
<
int
,
WaypointList
*>
lists
;
private
slots
:
void
_systemDeleted
(
QObject
*
uas
);
void
_systemCreated
(
UASInterface
*
uas
);
void
_systemSetActive
(
UASInterface
*
uas
);
private:
private:
Ui
::
QGCWaypointListMulti
*
ui
;
static
void
*
_offlineUAS
;
QMap
<
void
*
,
WaypointList
*>
_lists
;
Ui
::
QGCWaypointListMulti
*
_ui
;
};
};
#endif // QGCWAYPOINTLISTMULTI_H
#endif // QGCWAYPOINTLISTMULTI_H
src/ui/uas/UASView.cc
View file @
5471e8ff
...
@@ -483,10 +483,14 @@ void UASView::contextMenuEvent (QContextMenuEvent* event)
...
@@ -483,10 +483,14 @@ void UASView::contextMenuEvent (QContextMenuEvent* event)
menu
.
addAction
(
selectAction
);
menu
.
addAction
(
selectAction
);
menu
.
addSeparator
();
menu
.
addSeparator
();
menu
.
addAction
(
renameAction
);
menu
.
addAction
(
renameAction
);
/*
FIXME: The code below is incorrect. removeAction should only be available when link is
disconnected. fSee Issue #1275
if (timeout)
if (timeout)
{
{
menu.addAction(removeAction);
menu.addAction(removeAction);
}
}
*/
menu
.
addAction
(
hilAction
);
menu
.
addAction
(
hilAction
);
menu
.
addAction
(
selectAirframeAction
);
menu
.
addAction
(
selectAirframeAction
);
menu
.
addAction
(
setBatterySpecsAction
);
menu
.
addAction
(
setBatterySpecsAction
);
...
...
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