mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
Clean up null pointer printout in weightsystem description
If there's no weightsystem description, as in most imported dives, print a literal "unknown" instead of null pointer or blank. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
348c590ac6
commit
3fb80bcaeb
1 changed files with 3 additions and 2 deletions
5
print.c
5
print.c
|
@ -286,7 +286,7 @@ static void print_weight_data (struct dive *dive, cairo_t *cr, int maxwidth, int
|
||||||
{
|
{
|
||||||
int decimals,i;
|
int decimals,i;
|
||||||
double totalweight, systemweight, weightsystemcounter;
|
double totalweight, systemweight, weightsystemcounter;
|
||||||
const char *unit_weight;
|
const char *unit_weight, *desc;
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
|
|
||||||
|
@ -310,7 +310,8 @@ static void print_weight_data (struct dive *dive, cairo_t *cr, int maxwidth, int
|
||||||
systemweight = get_weight_units(dive->weightsystem[i].weight.grams, &decimals, &unit_weight);
|
systemweight = get_weight_units(dive->weightsystem[i].weight.grams, &decimals, &unit_weight);
|
||||||
if (systemweight != 0){
|
if (systemweight != 0){
|
||||||
cairo_move_to(cr, 0, 0);
|
cairo_move_to(cr, 0, 0);
|
||||||
snprintf(buffer, sizeof(buffer), _("%s"),dive->weightsystem[i].description);
|
desc = dive->weightsystem[i].description ? : _("unknown");
|
||||||
|
snprintf(buffer, sizeof(buffer), _("%s"), desc);
|
||||||
pango_layout_set_text(layout, buffer, -1);
|
pango_layout_set_text(layout, buffer, -1);
|
||||||
pango_cairo_show_layout(cr, layout);
|
pango_cairo_show_layout(cr, layout);
|
||||||
cairo_move_to(cr,(2 * maxwidth) / (3 * (double) PANGO_SCALE), 0);
|
cairo_move_to(cr,(2 * maxwidth) / (3 * (double) PANGO_SCALE), 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue