Commit graph

1656 commits

Author SHA1 Message Date
Lubomir I. Ivanov
df8fb3be98 gps.c: Make two more memory leak fixes and a small coding style change
1)
add_gps_point():
Apparently osm_gps_map_point_new_*() is leaking memory if the
point struct is not freed after the point is added to the
map osm_gps_map_track_add_point().

However the API for releasing a point is missing on
older Windows builds of the map library, so instead of
osm_gps_map_point_free() we simply call:
	free((void *)point);

2)
init_map()
According to memory management tools
osm_gps_map_get_default_cache_directory() is using g_realloc
for eventual string expansion therefore we have to release at the
returned pointer.

3)
add_gps_point()
Also a small coding style change is made:
move the pointer symbol (*) near the name of the variable
instead of leaving spaces on both sides, like:
<type> * <name>

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>

...

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:41:20 -08:00
Lubomir I. Ivanov
801b0832ae gps.c: Use only one instance of the map object and window
Both show_gps_locations() and show_gps_location() have
static local variables 'map' (OSM_TYPE_GPS_MAP) and 'window',
so technically both would create their own instances of these
objects.

This patch promotes the two variables to global, so that only
one instance per type ever exists.

A memory leak that is addressed is at the flag pixbuf
allocation, which has to be freed right after the image
is added to the map:
picture = gdk_pixbuf_from_pixdata(&flag_pixbuf, TRUE, NULL);
...
gdk_pixbuf_unref(picture);

There is also a heap-lifespan memory leak at:
map = g_object_new(OSM_TYPE_GPS_MAP,...
but GLib isn't exacly happy about us unrefing it right before
exiting the GTK main loop, so no fix is provided for that
unfortunately.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:40:55 -08:00
Lubomir I. Ivanov
ea21126f62 Fixed a memory leak related to the satelite icon
divelist.c:get_gps_icon_for_dive()
In all callers of the function use gdk_pixbuf_unref() to
release the returned GdkPixbuf (but also check for NULL).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:40:20 -08:00
Lubomir I. Ivanov
363c38f557 Fixed some memory leaks in divelist.c related to gtk_tree_iter_copy()
divelist.c:
get_iter_from_idx() goes trought the tree model and calls
iter_has_index(), until a match is found. when the match is found
we use gtk_tree_iter_copy() to make a copy of the iterator.

This means that the caller of get_iter_from_idx() has to take care
the de-allocation using gtk_tree_iter_free().

Also take care of the eventual:
parent = gtk_tree_iter_copy(...)
allocation in select_prev_dive(), select_next_dive()

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:40:03 -08:00
Lubomir I. Ivanov
3848cac30f Fixed a memory leak in webservice.c
webservice.c:webservice_download_dialog()
If a value for previous UID is returned from the user config
via subsurface_get_conf("webservice_uid"), make sure to
free the string near the function return.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:39:42 -08:00
Lubomir I. Ivanov
2af818bf91 Fixed some memory leaks in windows.c and main.c
windows.c:subsurface_gettext_domainpath():
- memory at pointer returned from g_win32_getlocale() should be released

main.c:setup_system_prefs()
- it seems all calls to <os_file>:system_default_filename()
return a pre-allocated buffer, therefore we don't need to call strdup()
on the result itself.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:38:51 -08:00
Henrik Brautaset Aronsen
a4ae0a4650 Probably the final Norwegian PO-file update before 3.0
Yeah, right :)

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:32:32 -08:00
Dirk Hohndel
a40e56dc8c Updated Swiss German translation
Just to show the advantage of running make prepare-po-files before
submitting a patch.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 10:54:02 -08:00
Dirk Hohndel
16dda3ec12 New Makefile target to create smaller diffs for translations
Simply run

make prepare-po-files

and msgcat will be run over all po files to create consistent location
references. That plus the change I made earlier to how we update the po
files should create much smaller and easier to read diffs for translators.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 10:52:01 -08:00
Dirk Hohndel
e7389874fb Updated German translation
This translation update was done with poedit which usually creates hugh
amounts of noise because of the different format of text location
references. By post-processing the file with

msgcat --no-wrap po/de_DE.po -o po/de_DE.po

the diff becomes MUCH smaller and much easier to read...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 10:46:07 -08:00
Dirk Hohndel
9d9eff718b Hopefully last change to po files
While this is a pain for everyone, I decided not to edit out the code
reference noise - after all this is supposed to help translators find
where the text is used in case it's unclear how to translate something.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 10:39:11 -08:00
Dirk Hohndel
460060c430 Small update to German translation
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 10:11:20 -08:00
Miika Turkia
752ee66968 Improvements on MacDive import
New information of the upcoming MacDive log format is taken into account, more
Imperial conversions are added and a couple of bugs fixed.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 09:49:31 -08:00
Henrik Brautaset Aronsen
312f553aee Enable XSLT transforms on OSX
We still need proper paths and install options for the install-macosx
and create-macosx-bundle targets.  This enables XSLT support when
running as ./subsurface, but doesn't hurt the other install targets.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 09:48:16 -08:00
Henrik Brautaset Aronsen
eb7acc1d96 Add XSLT support for the macosx install and bundle targets
Works like it should for the install-macosx target.  I haven't tested
the create-macosx-bundle target, but it shouldn't be any different.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 09:44:51 -08:00
Martin Gysel
fe87ed182e Updates to German translation
resynced with de_CH, some spelling bugs fixe,
improved translation (hopefully)

Signed-off-by: Martin Gysel <me@bearsh.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 09:42:43 -08:00
Martin Gysel
adb997f5ff Updates to Swiss German translation
synced with de_DE, fixed some bugs

Signed-off-by: Martin Gysel <m.gysel@consonics.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 09:42:39 -08:00
Dirk Hohndel
ebcbe5aedd Finish removing accesses to first divecomputer instead of dive
This adds watertemp and airtemp to the dive, populates them in fixup and
uses them elsewhere in the code.

WARNING: as a sideeffect we now edit the airtemp in the dive, but we never
display this in the DIve Info notebook (as that always displays the data
from the specific selected divecomputer). This is likely to cause
confusion. It's consistent behavior, but... odd. This brings back the
desire to have a view of "best data available" for a dive, in addition to
the "per divecomputer" view. This would also allow us to consolidate the
different pressure graphs we may be getting from different divecomputers
(consider the case where you dive with multiple air integrated computers
that are connected to different tanks - now we could have one profile with
all the correct tank pressure plots overlayed - and the best available (or
edited) data in the corresponding Dive Info notebook.

This commit also fixes a few remaining accesses to the first divecomputer
that fell through the cracks earlier and does a couple of other related
cleanups.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 07:41:15 -08:00
Dirk Hohndel
b9865d6bbc Move duration to dive structure and replace accessor function
When starting on this quest to stop using the first divecomputer instead
of data for the whole dive in commit eb73b5a528c8 ("Duration of a dive is
the maximum duration from all divecomputers") I introduced an accessor
function that calculates the dive duration on the fly as the maximum of
the durations in the divecomputers.

Since then Linus and I have added quite a few of the variables back to the
dive data structure and it makes perfect sense to do the same thing for
the duration as well and simply do the calculation once during fixup.

This commit also replaces accesses to the first divecomputer in
likely_same_dive to use the maxdepth and meandepth of the dive (those two
slipped through the cracks in the previous commits, it seems).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 07:19:29 -08:00
Dirk Hohndel
c7efcb23a9 Add a meandepth to the dive structure
This is currently only used in one place (in statistics.c), but it
certainly is consistent with the other recent changes to avoid using only
the first divecomputer when trying to make statements about a dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 07:02:43 -08:00
Dirk Hohndel
0755cc522b Show the actice divecomputer's data in the Info notebook
While the profile switched between different divecomputers, the Dive Info
notebook always showed either information from the first divecomputer or
(with some of the recent changes) information that had been collected from
all divecomputers and somehow consolidated for the dive.

With this commit we now show the data from the same divecomputer that is
also shown in the profile (which means if some data is available from one
of the divecomputers and not from another that will be correctly reflected
in the Dive Info notebook as the user cycles through the divecomputers.

This does beg the question if we should have some kind of "best data
available, considering all divecomputers" mode - but that's definitely not
something I'll tackle prior to 3.0.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 06:17:25 -08:00
Dirk Hohndel
9e66312d6a Initialize variables in helper functions
In commit 904aa0be0d0e ("Do more dive fixup for each dive computer") two
new helper functions were introduced that sadly both incremented variables
without initializing them, first.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 05:45:58 -08:00
Dirk Hohndel
1511271201 Add maxdepth back to the dive structure
Populate during dive fixup as the maximum depth shown by all the
divecomputers. Use this value (instead of the one in the first
divecomputer) in printing, statistics, etc.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 20:44:04 -08:00
Dirk Hohndel
b8c7992bbf Improve calculation of maxtemp and mintemp of dive
The existing code only populated the maxtemp based on the samples of a
dive and then in statistics.c checked if there was no such temperature and
replaced it with the water temperature of the first divecomputer.

It makes much more sense to add the water temperature information in every
divecomputer to the min / max calculation during the dive fixup phase.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 20:14:13 -08:00
Dirk Hohndel
51f97a97ce Avoid using float when dealing with GPS location
Float values have insufficient precision compared to the udeg we usually
store - so we create a special callback function to use from osm-gps-map
and everywhere else use integers.

This patch also increases the decimal places displayed in the GPS text
entry box - this way we can cut and paste the text without loss of
precision.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 19:30:30 -08:00
Linus Torvalds
b12b2f1c85 Walk over each divecomputer entry in fixup_dives()
The fixup_dives() code used to only look at the first divecomputer,
which meant that minimun temperatures etc for the dive would only ever
come from the primary divecomputer.

This splits up the code that walks over the divecomputer into a function
of its own, and iterates over all computers in fixup_dive() calling into
it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 18:28:38 -08:00
Linus Torvalds
926fcef2a1 Do more dive fixup for each dive computer
In commit b6c9301e58 ("Move more dive computer filled data to the
divecomputer structure") we moved the fields that get filled in by the
dive computers to be per-divecomputer data structures.

This patch re-creates some of those fields back in the "struct dive",
but now the fields are initialized to be a reasonable average from the
dive computer data.  We already did some of this for the temperature
min/max fields for the statistics, so this just continues that trend.

The goal is to make it easy to look at "dive values" without having to
iterate over dive computers every time you do.  Just do it once in
"fixup_dive()" instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 18:22:30 -08:00
Linus Torvalds
b286ea638c Simplify/clarify the get_surface_pressure_in_mbar() function
Instead of maintaining a rolling average and re-calculating it at each
stage, just calculate the surface_pressure average the natural way: as
the sum divided by the number of entries.

This results in a single rounding, rather than doing rounding multiple
times and possibly rounding wrong as a result.

Not that we care all that deeply about the LSB of the mbar value, but
the code is simpler and more obvious this way too.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 18:15:51 -08:00
Reinout Hoornweg
ff969cd5c8 Updated Dutch translation
Translated all missing and fuzzy strings in preparation for v3.0
Abbreviated a few Dutch strings to take up less space on screen.

Signed-off-by: Reinout Hoornweg <reinout@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 10:04:09 +11:00
Dirk Hohndel
61861d2611 Clean up the handling of surface pressure
There are two ways to look at surface pressure. One is to say "what was
the surface pressure during that dive?" - in that case we now return an
average over the pressure reported by the different divecomputers (or the
standard 1013mbar if none reported any).

Or you want to do specific calculations for a specific divecomputer - in
which case we access only the pressure reported by THAT divecomputer, if
present (and fall back to the previous case, otherwise).

We still have lots of places in Subsurface that only act on the first
divecomputer. As a side effect of this change we now make this more
obvious as we in those cases pass a pointer to the first divecomputer
explicitly to the calculations.

Either way, this commit should prevent us from ever mistakenly basing our
calculations on a surface pressure of 0 (which is the initial bug in
deco.c that triggered all this).

Similar changes need to be made for other elements that we currently only
use from the first divecomputer, i.e., salinity.

Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 08:01:59 +11:00
Fredrik Steen
54ff04c61b Updates to the Swedish translation (2)
I forgot to include the list in my reply to Linus, but here comes
an updated translation with fix for some spelling and change of
"Långkalsonger" to "Longjohn" which seems like the accepted wording
used for that kind of wetsuit.

Dirk, I hope I got it right this time (wrapping/utf-8)

Signed-off-by: Fredrik Steen <fredrik@ppo2.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 00:29:03 +11:00
Dirk Hohndel
79e55b019b Add a more stronly worded warning / disclaimer for dive planning
This is a late string change, but I think this may be a valid exception of
the string freeze...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 22:53:42 +11:00
Linus Torvalds
3e66319e82 Remove the tissue_tolerated_ambient_pressure[] array
It wasn't really used.  The only reader of that array was the same thing
that wrote the entry, so instead of storing it in the array (and never
using it ever after), just use the calculation directly, and remove the
array entirely.

This makes it much easier to see that the gradient factors are not used
for any long-term state.  We use them only for the pressure tolerance
calculations at that particular point, and there is no "history"
associated with it.

This matters mainly because it means that we can do all the deco
initialization and setup without worrying about exactly which gradient
factors we will use.  And we can use different gradient factors for
diving and planning and no-fly calculations without the GF choice
affecting the tissue state.

Acked-by: Robert C. Helling <helling@lmu.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 22:14:53 +11:00
Dirk Hohndel
74ff9f1ead Fix duration calculation
Some days I'm just a f*cking moron. That code was so stupid that I'm
lacking words. I replaced using the first divecomputer with using the last
divecomputer. When what I wanted was to use the maximum duration.

This looks better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 21:40:26 +11:00
Fredrik Steen
b119f7fcd4 Updated Swedish translation
Some updates to the Swedish translation.

Signed-off-by: Fredrik Steen <fredrik@ppo2.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 21:21:17 +11:00
Linus Torvalds
9750b0ce06 The 'gasmix' argument to add_segment() is read-only
We'll want to use a 'static const' gasmix for the upcoming no-fly-time
code, so prepare for it by just marking the read-only gasmix argument as
'const'.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 19:41:45 +11:00
Dirk Hohndel
9846ba9e94 Duration of a dive is the maximum duration from all divecomputers
So far we always used the duration of the first divecomputer. The same fix
needs to be done for some of the other calculations that always use the
first divecomputer.

This commit also removes some obsolete code from the webservice merging.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 17:48:07 +11:00
Dirk Hohndel
5692131a79 Fix Uemis downloader to download all matching dive infomration
The Uemis SDA returns the data for each dive from several different
databases. And oddly, the getDive data uses a different key than the
getDivelog data. We have always compensated for that by looking up the
correct key and applying the data to that dive, but unfortunately we
didn't adjust the loop to correctly retrieve the getDive data for the
dives that were downloaded. So depending on how big the offset between
those two keys was we wouldn't get all of the necessary data.

With this change we try one, calculate the offset and then restart the
loop. Insane, but appears to be the only way to make this work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 12:53:32 +11:00
Linus Torvalds
b18c34373f Properly de-select dives in collapsed trips that are unselected
We had the logic for the "select" case, but not for the "deselect" case. Ugh.

Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 11:46:06 +11:00
Linus Torvalds
e53a7d87ec Update "Swedish" translation
This is only slightly better than "Bork bork bork".  I've never done any
diving in Swedish.  It's probably hilarious, but should be mostly
understandable.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 11:45:24 +11:00
Miika Turkia
b85d5a36fc Support for Imperial units on MacDive log import
The cylinder size is treated as metric as the samples received indicate
it would be so.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 07:51:21 +11:00
Miika Turkia
3150c1a6e8 Skip XSL transformation for old Subsurface format
Making sure the XSL transformation does not occur on Subsurface's old
XML format. A deeper inspection on the XML content is required as
MacDive and Subsurface (old format) have the same root element (dives).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 07:50:55 +11:00
Dirk Hohndel
cee75b0f49 Tiny change to German translation
Suggested-by: Lutz Vieweg <lvml@5t9.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 07:21:13 +11:00
Amit Chaudhuri
7705ee3565 Documentation update for driver installation on OSX
Helping people to find the right drivers.

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-07 20:56:57 +11:00
Dirk Hohndel
3638da6fac Some changes to the README file
This is not getting us ready for 3.0, it mostly fixes some of the obvious
errors in there that were correct for Subsurface 2.1 but clearly are no
longer true (like the suggestion to specifically check out libdivecomputer
0.2.0).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-07 20:46:22 +11:00
Lubomir I. Ivanov
67604ccae3 print.c: show_dive_header() Reserve more space for strings
Increase the size of "buffer" to 160 bytes. This was causing
a problem with the first call to pango_layout_text(), where
for the "bg_BG" locale, not enought space was allocated for the
month name, the translation of "dive" and the other values.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-07 18:19:42 +11:00
Lubomir I. Ivanov
30466b9abb Use GDK methods to retrieve the actual screen DPI
gtk-gui.c:
+ added the method get_screen_dpi() that uses a simple
formula to retrieve the actual screen DPI
display.h:
+ use get_screen_dpi() in the SCALE_PRINT macro

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-07 18:19:28 +11:00
Tommi Saviranta
6bec608ea0 Updated Finnish translation
- Translated some missing strings
 - Paraphrased some longer sentences in Finnish
 - Inserted missing whitespaces

Signed-off-by: Tommi Saviranta <wnd@iki.fi>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-07 18:18:18 +11:00
Dirk Hohndel
85fad3f2a9 Fix German translation of ceiling
Suggested-by: Lutz Vieweg <lvml@5t9.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-07 07:40:37 +11:00
Miika Turkia
b9a19813ea Import MacDive divelogs
This XSLT converts MacDive logs into Subsurface format. It supports both
the current version and the upcoming version of the log format.

Conversion was not tested with Imperial units as no samples were
available of such logs. Thus functionality with Imperial units is not
guaranteed.

Note that the gear inventory is currently discarded.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-07 07:06:49 +11:00