summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-01-21 16:30:28 +0100
committerKonstantin Käfer <mail@kkaefer.com>2014-01-21 16:30:28 +0100
commita637ad54735493c76cb72c92baa0755f3d76a16f (patch)
tree6b595117fad683d0eb0e3c368a1d1aec47ba4a1c /src
parent474fb42807e855825909ed818a6d410b1b062d4c (diff)
downloadqtlocation-mapboxgl-a637ad54735493c76cb72c92baa0755f3d76a16f.tar.gz
move pbf parsing to use exceptions
Diffstat (limited to 'src')
-rw-r--r--src/map/tile.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/map/tile.cpp b/src/map/tile.cpp
index 59cf2e4c61..fb21f9d408 100644
--- a/src/map/tile.cpp
+++ b/src/map/tile.cpp
@@ -85,24 +85,22 @@ bool Tile::parse() {
// fprintf(stderr, "[%p] parsing tile [%d/%d/%d]...\n", this, z, x, y);
pbf tile(data, bytes);
-
- int code = setjmp(tile.jump_buffer);
- if (code > 0) {
- fprintf(stderr, "[%p] parsing tile [%d/%d/%d]... failed: %s\n", this, id.z, id.x, id.y, tile.msg.c_str());
+ try {
+ while (tile.next()) {
+ if (tile.tag == 3) { // layer
+ uint32_t bytes = (uint32_t)tile.varint();
+ parseLayer(tile.data, bytes);
+ tile.skipBytes(bytes);
+ } else {
+ tile.skip();
+ }
+ }
+ } catch(const pbf::exception& ex) {
+ fprintf(stderr, "[%p] parsing tile [%d/%d/%d]... failed: %s\n", this, id.z, id.x, id.y, ex.what());
cancel();
return false;
}
- while (tile.next()) {
- if (tile.tag == 3) { // layer
- uint32_t bytes = (uint32_t)tile.varint();
- parseLayer(tile.data, bytes);
- tile.skipBytes(bytes);
- } else {
- tile.skip();
- }
- }
-
if (state == obsolete) {
return false;
} else {