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
1b1b495e
Commit
1b1b495e
authored
Feb 25, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix object de-reference crash on deletion
Fix for Issue #1255
parent
fd6b895b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
42 deletions
+42
-42
QGCWaypointListMulti.cc
src/ui/QGCWaypointListMulti.cc
+31
-33
QGCWaypointListMulti.h
src/ui/QGCWaypointListMulti.h
+11
-9
No files found.
src/ui/QGCWaypointListMulti.cc
View file @
1b1b495e
...
...
@@ -2,73 +2,71 @@
#include "ui_QGCWaypointListMulti.h"
#include "UASManager.h"
void
*
QGCWaypointListMulti
::
_offlineUAS
=
NULL
;
QGCWaypointListMulti
::
QGCWaypointListMulti
(
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
);
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
());
lists
.
insert
(
offline_uas_id
,
list
);
ui
->
stackedWidget
->
addWidget
(
list
);
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
());
_lists
.
insert
(
_offlineUAS
,
list
);
_ui
->
stackedWidget
->
addWidget
(
list
);
if
(
UASManager
::
instance
()
->
getActiveUAS
())
{
systemCreated
(
UASManager
::
instance
()
->
getActiveUAS
());
systemSetActive
(
UASManager
::
instance
()
->
getActiveUAS
());
_
systemCreated
(
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
// been destroyed.
UASInterface
*
mav
=
static_cast
<
UASInterface
*>
(
uas
);
if
(
mav
)
{
int
id
=
mav
->
getUASID
();
WaypointList
*
list
=
lists
.
value
(
id
,
NULL
);
if
(
list
)
{
if
(
uas
)
{
WaypointList
*
list
=
_lists
.
value
(
uas
,
NULL
);
if
(
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
());
lists
.
insert
(
uas
->
getUASID
()
,
list
);
ui
->
stackedWidget
->
addWidget
(
list
);
WaypointList
*
list
=
new
WaypointList
(
_
ui
->
stackedWidget
,
uas
->
getWaypointManager
());
_lists
.
insert
(
uas
,
list
);
_
ui
->
stackedWidget
->
addWidget
(
list
);
// 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
)
{
ui
->
stackedWidget
->
setCurrentWidget
(
list
);
_
ui
->
stackedWidget
->
setCurrentWidget
(
list
);
}
}
QGCWaypointListMulti
::~
QGCWaypointListMulti
()
{
delete
ui
;
}
void
QGCWaypointListMulti
::
changeEvent
(
QEvent
*
e
)
{
QWidget
::
changeEvent
(
e
);
switch
(
e
->
type
())
{
case
QEvent
:
:
LanguageChange
:
ui
->
retranslateUi
(
this
);
_
ui
->
retranslateUi
(
this
);
break
;
default:
break
;
...
...
src/ui/QGCWaypointListMulti.h
View file @
1b1b495e
...
...
@@ -20,18 +20,20 @@ public:
explicit
QGCWaypointListMulti
(
QWidget
*
parent
=
0
);
~
QGCWaypointListMulti
();
public
slots
:
void
systemDeleted
(
QObject
*
uas
);
void
systemCreated
(
UASInterface
*
uas
);
void
systemSetActive
(
UASInterface
*
uas
);
protected:
quint16
offline_uas_id
;
void
changeEvent
(
QEvent
*
e
);
QMap
<
int
,
WaypointList
*>
lists
;
// Override from Widget
virtual
void
changeEvent
(
QEvent
*
e
);
private
slots
:
void
_systemDeleted
(
QObject
*
uas
);
void
_systemCreated
(
UASInterface
*
uas
);
void
_systemSetActive
(
UASInterface
*
uas
);
private:
Ui
::
QGCWaypointListMulti
*
ui
;
static
void
*
_offlineUAS
;
QMap
<
void
*
,
WaypointList
*>
_lists
;
Ui
::
QGCWaypointListMulti
*
_ui
;
};
#endif // QGCWAYPOINTLISTMULTI_H
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