@@ -522,6 +522,7 @@ GpxFormat::gpx_end(QStringView /*unused*/)
522
522
logpoint_ct = 0 ;
523
523
cur_tag = nullptr ;
524
524
wpt_tmp = nullptr ;
525
+ fs_ptr = nullptr ;
525
526
break ;
526
527
case tt_cache_name:
527
528
wpt_tmp->notes = cdatastr;
@@ -616,6 +617,7 @@ GpxFormat::gpx_end(QStringView /*unused*/)
616
617
delete rh_link_;
617
618
rh_link_ = nullptr ;
618
619
}
620
+ fs_ptr = nullptr ;
619
621
break ;
620
622
case tt_rte_rtept:
621
623
if (link_) {
@@ -631,6 +633,7 @@ GpxFormat::gpx_end(QStringView /*unused*/)
631
633
}
632
634
route_add_wpt (rte_head, wpt_tmp);
633
635
wpt_tmp = nullptr ;
636
+ fs_ptr = nullptr ;
634
637
break ;
635
638
case tt_rte_desc:
636
639
rte_head->rte_desc = cdatastr;
@@ -661,9 +664,11 @@ GpxFormat::gpx_end(QStringView /*unused*/)
661
664
delete rh_link_;
662
665
rh_link_ = nullptr ;
663
666
}
667
+ fs_ptr = nullptr ;
664
668
break ;
665
669
case tt_trk_trkseg:
666
670
next_trkpt_is_new_seg = 1 ;
671
+ fs_ptr = nullptr ;
667
672
break ;
668
673
case tt_trk_trkseg_trkpt:
669
674
if (link_) {
@@ -679,6 +684,7 @@ GpxFormat::gpx_end(QStringView /*unused*/)
679
684
}
680
685
track_add_wpt (trk_head, wpt_tmp);
681
686
wpt_tmp = nullptr ;
687
+ fs_ptr = nullptr ;
682
688
break ;
683
689
case tt_trk_desc:
684
690
trk_head->rte_desc = cdatastr;
@@ -920,7 +926,7 @@ GpxFormat::wr_init(const QString& fname)
920
926
// normalization makes them null.
921
927
if (gpx_write_version.isNull () || (gpx_write_version < gpx_1_0)) {
922
928
fatal (FatalMsg () << MYNAME " : gpx version number"
923
- << gpx_write_version << " not valid." );
929
+ << gpx_write_version << " not valid." );
924
930
}
925
931
926
932
writer->setAutoFormatting (true );
@@ -1092,9 +1098,9 @@ GpxFormat::read()
1092
1098
1093
1099
if (reader->hasError ()) {
1094
1100
fatal (FatalMsg () << MYNAME << " Read error:" << reader->errorString ()
1095
- << " File:" << iqfile->fileName ()
1096
- << " Line:" << reader->lineNumber ()
1097
- << " Column:" << reader->columnNumber ());
1101
+ << " File:" << iqfile->fileName ()
1102
+ << " Line:" << reader->lineNumber ()
1103
+ << " Column:" << reader->columnNumber ());
1098
1104
}
1099
1105
}
1100
1106
@@ -1369,7 +1375,7 @@ void GpxFormat::gpx_write_common_core(const Waypoint* waypointp,
1369
1375
const gpx_point_type point_type) const
1370
1376
{
1371
1377
const auto * fs_gpxwpt = reinterpret_cast <gpx_wpt_fsdata*>(waypointp->fs .FsChainFind (kFsGpxWpt ));
1372
-
1378
+
1373
1379
gpx_write_common_position (waypointp, point_type, fs_gpxwpt);
1374
1380
gpx_write_common_description (waypointp, point_type, fs_gpxwpt);
1375
1381
gpx_write_common_acc (waypointp, fs_gpxwpt);
@@ -1389,7 +1395,15 @@ GpxFormat::gpx_waypt_pr(const Waypoint* waypointp) const
1389
1395
auto * gmsd = garmin_fs_t::find (waypointp); /* gARmIN sPECIAL dATA */
1390
1396
if (fs_gpx) {
1391
1397
if (! gmsd) {
1392
- fprint_xml_chain (fs_gpx->tag );
1398
+ if (fs_gpx->tag ) {
1399
+ if (gpx_write_version > gpx_1_0) {
1400
+ writer->writeStartElement (" extensions" );
1401
+ }
1402
+ fprint_xml_chain (fs_gpx->tag );
1403
+ if (gpx_write_version > gpx_1_0) {
1404
+ writer->writeEndElement ();
1405
+ }
1406
+ }
1393
1407
}
1394
1408
}
1395
1409
if (gmsd && (gpx_write_version > gpx_1_0)) {
@@ -1416,23 +1430,21 @@ GpxFormat::gpx_track_hdr(const route_head* rte)
1416
1430
writer->writeTextElement (QStringLiteral (" number" ), QString::number (rte->rte_num ));
1417
1431
}
1418
1432
1419
- if (gpx_write_version > gpx_1_0) {
1420
- if (!(opt_humminbirdext || opt_garminext)) {
1421
- const auto * fs_gpx = reinterpret_cast <fs_xml*>(rte->fs .FsChainFind (kFsGpx ));
1422
- if (fs_gpx) {
1423
- fprint_xml_chain (fs_gpx->tag );
1424
- }
1425
- } else if (opt_garminext) {
1426
- if (rte->line_color .bbggrr > unknown_color) {
1427
- int ci = gt_color_index_by_rgb (rte->line_color .bbggrr );
1428
- if (ci > 0 ) {
1429
- writer->writeStartElement (QStringLiteral (" extensions" ));
1430
- writer->writeStartElement (QStringLiteral (" gpxx:TrackExtension" ));
1431
- writer->writeTextElement (QStringLiteral (" gpxx:DisplayColor" ), QStringLiteral (" %1" )
1432
- .arg (gt_color_name (ci)));
1433
- writer->writeEndElement (); // Close gpxx:TrackExtension tag
1434
- writer->writeEndElement (); // Close extensions tag
1435
- }
1433
+ if (!(opt_humminbirdext || opt_garminext)) {
1434
+ const auto * fs_gpx = reinterpret_cast <fs_xml*>(rte->fs .FsChainFind (kFsGpx ));
1435
+ if (fs_gpx) {
1436
+ fprint_xml_chain (fs_gpx->tag );
1437
+ }
1438
+ } else if (opt_garminext && (gpx_write_version > gpx_1_0)) {
1439
+ if (rte->line_color .bbggrr > unknown_color) {
1440
+ int ci = gt_color_index_by_rgb (rte->line_color .bbggrr );
1441
+ if (ci > 0 ) {
1442
+ writer->writeStartElement (QStringLiteral (" extensions" ));
1443
+ writer->writeStartElement (QStringLiteral (" gpxx:TrackExtension" ));
1444
+ writer->writeTextElement (QStringLiteral (" gpxx:DisplayColor" ), QStringLiteral (" %1" )
1445
+ .arg (gt_color_name (ci)));
1446
+ writer->writeEndElement (); // Close gpxx:TrackExtension tag
1447
+ writer->writeEndElement (); // Close extensions tag
1436
1448
}
1437
1449
}
1438
1450
}
@@ -1506,25 +1518,23 @@ GpxFormat::gpx_route_hdr(const route_head* rte) const
1506
1518
writer->writeTextElement (QStringLiteral (" number" ), QString::number (rte->rte_num ));
1507
1519
}
1508
1520
1509
- if (gpx_write_version > gpx_1_0) {
1510
- if (!(opt_humminbirdext || opt_garminext)) {
1511
- const auto * fs_gpx = reinterpret_cast <fs_xml*>(rte->fs .FsChainFind (kFsGpx ));
1512
- if (fs_gpx) {
1513
- fprint_xml_chain (fs_gpx->tag );
1514
- }
1515
- } else if (opt_garminext) {
1516
- if (rte->line_color .bbggrr > unknown_color) {
1517
- int ci = gt_color_index_by_rgb (rte->line_color .bbggrr );
1518
- if (ci > 0 ) {
1519
- writer->writeStartElement (QStringLiteral (" extensions" ));
1520
- writer->writeStartElement (QStringLiteral (" gpxx:RouteExtension" ));
1521
- // FIXME: the value to use for IsAutoNamed is questionable.
1522
- writer->writeTextElement (QStringLiteral (" gpxx:IsAutoNamed" ), rte->rte_name .isEmpty ()? QStringLiteral (" true" ) : QStringLiteral (" false" )); // Required element
1523
- writer->writeTextElement (QStringLiteral (" gpxx:DisplayColor" ), QStringLiteral (" %1" )
1524
- .arg (gt_color_name (ci)));
1525
- writer->writeEndElement (); // Close gpxx:RouteExtension tag
1526
- writer->writeEndElement (); // Close extensions tag
1527
- }
1521
+ if (!(opt_humminbirdext || opt_garminext)) {
1522
+ const auto * fs_gpx = reinterpret_cast <fs_xml*>(rte->fs .FsChainFind (kFsGpx ));
1523
+ if (fs_gpx) {
1524
+ fprint_xml_chain (fs_gpx->tag );
1525
+ }
1526
+ } else if (opt_garminext && (gpx_write_version > gpx_1_0)) {
1527
+ if (rte->line_color .bbggrr > unknown_color) {
1528
+ int ci = gt_color_index_by_rgb (rte->line_color .bbggrr );
1529
+ if (ci > 0 ) {
1530
+ writer->writeStartElement (QStringLiteral (" extensions" ));
1531
+ writer->writeStartElement (QStringLiteral (" gpxx:RouteExtension" ));
1532
+ // FIXME: the value to use for IsAutoNamed is questionable.
1533
+ writer->writeTextElement (QStringLiteral (" gpxx:IsAutoNamed" ), rte->rte_name .isEmpty ()? QStringLiteral (" true" ) : QStringLiteral (" false" )); // Required element
1534
+ writer->writeTextElement (QStringLiteral (" gpxx:DisplayColor" ), QStringLiteral (" %1" )
1535
+ .arg (gt_color_name (ci)));
1536
+ writer->writeEndElement (); // Close gpxx:RouteExtension tag
1537
+ writer->writeEndElement (); // Close extensions tag
1528
1538
}
1529
1539
}
1530
1540
}
0 commit comments