Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
753bafa7
Commit
753bafa7
authored
Nov 24, 2017
by
Andreas Bircher
Browse files
error handling
parent
5fb4a54f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/QtLocationPlugin/QGeoMapReplyQGC.cpp
View file @
753bafa7
...
@@ -104,6 +104,7 @@ QGeoTiledMapReplyQGC::abort()
...
@@ -104,6 +104,7 @@ QGeoTiledMapReplyQGC::abort()
_timer
.
stop
();
_timer
.
stop
();
if
(
_reply
)
if
(
_reply
)
_reply
->
abort
();
_reply
->
abort
();
emit
aborted
();
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
...
@@ -112,11 +113,11 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
...
@@ -112,11 +113,11 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
{
{
_timer
.
stop
();
_timer
.
stop
();
if
(
!
_reply
)
{
if
(
!
_reply
)
{
abort
();
emit
abort
ed
();
return
;
return
;
}
}
if
(
_reply
->
error
()
!=
QNetworkReply
::
NoError
)
{
if
(
_reply
->
error
()
!=
QNetworkReply
::
NoError
)
{
abort
();
emit
abort
ed
();
return
;
return
;
}
}
QByteArray
a
=
_reply
->
readAll
();
QByteArray
a
=
_reply
->
readAll
();
...
@@ -197,5 +198,5 @@ QGeoTiledMapReplyQGC::timeout()
...
@@ -197,5 +198,5 @@ QGeoTiledMapReplyQGC::timeout()
if
(
_reply
)
{
if
(
_reply
)
{
_reply
->
abort
();
_reply
->
abort
();
}
}
abort
();
emit
abort
ed
();
}
}
src/Terrain.cc
View file @
753bafa7
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
#include
"Terrain.h"
#include
"Terrain.h"
#include
"QGCMapEngine.h"
#include
"QGCMapEngine.h"
#include
"QGeoMapReplyQGC.h"
#include
"QGeoMapReplyQGC.h"
#include
<QtLocation/private/qgeotilespec_p.h>
#include
<QUrl>
#include
<QUrl>
#include
<QUrlQuery>
#include
<QUrlQuery>
...
@@ -20,6 +19,7 @@
...
@@ -20,6 +19,7 @@
#include
<QJsonDocument>
#include
<QJsonDocument>
#include
<QJsonObject>
#include
<QJsonObject>
#include
<QJsonArray>
#include
<QJsonArray>
#include
<QtLocation/private/qgeotilespec_p.h>
QGC_LOGGING_CATEGORY
(
TerrainLog
,
"TerrainLog"
)
QGC_LOGGING_CATEGORY
(
TerrainLog
,
"TerrainLog"
)
...
@@ -165,16 +165,37 @@ void ElevationProvider::_fetchedTile()
...
@@ -165,16 +165,37 @@ void ElevationProvider::_fetchedTile()
{
{
QGeoTiledMapReplyQGC
*
reply
=
qobject_cast
<
QGeoTiledMapReplyQGC
*>
(
QObject
::
sender
());
QGeoTiledMapReplyQGC
*
reply
=
qobject_cast
<
QGeoTiledMapReplyQGC
*>
(
QObject
::
sender
());
if
(
!
reply
||
!
reply
->
isFinished
())
{
if
(
!
reply
)
{
if
(
reply
)
{
qCDebug
(
TerrainLog
)
<<
"Elevation tile fetched but invalid reply data type."
;
qCDebug
(
TerrainLog
)
<<
"Error in fetching elevation tile: "
<<
reply
->
errorString
();
return
;
reply
->
deleteLater
();
}
// remove from download queue
QGeoTileSpec
spec
=
reply
->
tileSpec
();
QString
hash
=
QGCMapEngine
::
getTileHash
(
UrlFactory
::
AirmapElevation
,
spec
.
x
(),
spec
.
y
(),
spec
.
zoom
());
_tilesMutex
.
lock
();
if
(
_downloadQueue
.
contains
(
hash
))
{
_downloadQueue
.
removeOne
(
hash
);
}
_tilesMutex
.
unlock
();
// handle potential errors
if
(
reply
->
error
()
!=
QGeoTiledMapReply
::
NoError
)
{
if
(
reply
->
error
()
==
QGeoTiledMapReply
::
CommunicationError
)
{
qCDebug
(
TerrainLog
)
<<
"Elevation tile fetching returned communication error. "
<<
reply
->
errorString
();
}
else
{
}
else
{
qCDebug
(
TerrainLog
)
<<
"Elevation tile fetch
ed but invalid reply data type."
;
qCDebug
(
TerrainLog
)
<<
"Elevation tile fetch
ing returned error. "
<<
reply
->
errorString
()
;
}
}
reply
->
deleteLater
();
return
;
}
if
(
!
reply
->
isFinished
())
{
qCDebug
(
TerrainLog
)
<<
"Error in fetching elevation tile. Not finished. "
<<
reply
->
errorString
();
reply
->
deleteLater
();
return
;
return
;
}
}
// parse received data and insert into hash table
QByteArray
responseBytes
=
reply
->
mapImageData
();
QByteArray
responseBytes
=
reply
->
mapImageData
();
QJsonParseError
parseError
;
QJsonParseError
parseError
;
...
@@ -194,12 +215,12 @@ void ElevationProvider::_fetchedTile()
...
@@ -194,12 +215,12 @@ void ElevationProvider::_fetchedTile()
}
else
{
}
else
{
delete
terrainTile
;
delete
terrainTile
;
}
}
if
(
_downloadQueue
.
contains
(
_getTileHash
(
terrainTile
->
centerCoordinate
())))
{
_downloadQueue
.
removeOne
(
_getTileHash
(
terrainTile
->
centerCoordinate
()));
}
_tilesMutex
.
unlock
();
_tilesMutex
.
unlock
();
}
}
reply
->
deleteLater
();
reply
->
deleteLater
();
// now try to query the data again
queryTerrainData
(
_coordinates
);
}
}
QString
ElevationProvider
::
_getTileHash
(
const
QGeoCoordinate
&
coordinate
)
QString
ElevationProvider
::
_getTileHash
(
const
QGeoCoordinate
&
coordinate
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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