Howto solve bug when adding and editing gps locations

Onno developer at gorgoz.org
Sun Jan 18 07:53:27 PST 2015


Hi,

I tried to add gps coordinates to some existing dives (which were
downloaded from a divecomputer) and I noticed some strange behaviour (in
4.3 and the latest from git). I was adding the coordinates in decimal
and when you save the coordinate it is no longer correctly. And when
editing the coordinates as represented in degrees, minutes and seconds
the changes were not saved correctly either.

I traced the bug to the gpsHasChanged function in qthelper.cpp. This
function is called with every edit in the coordinate field.
Lets say I want to add the coordinate "20.491738,-87.258246"
Every time I add a digit to the field gpsHasChanged is called, which
calls parseGpsText to decode the field text. The first time the field is
recognized as a valid entry (after typing 20.491738,-87.2 in this case)
the latitude and longitude of the dive is updated.
However when you now add an other digit the latitude and longitude of
the dive no longer gets updated with the result that coordinate
"20.491738,-87.258246" is saved as "20.491738,-87.2".

The dive no longer gets updated after the first time due to the code:

/* if we have a master and the dive's gps address is different from it,
 * don't change the dive */
if (master && (master->latitude.udeg != dive->latitude.udeg ||
               master->longitude.udeg != dive->longitude.udeg))
        return false;

When I remove this check, I can edit the coordinates without any
problems. However, I do not know if this would affect the flow of the
application in other usecases.

The 'master' parameter of the function is only used in this check, so I
guess it is used in some cases.

Could you please advise how to solve this issue?

Grz,
Onno


More information about the subsurface mailing list