[PATCH 6/6] qthelper.cpp: improve getFormattedCylinder()

Lubomir I. Ivanov neolit123 at gmail.com
Mon Nov 16 14:29:22 PST 2015


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

When the user requests "dive.cylinders" from Grantlee HTML
we need to always put at least the default cylinder and mark
the description as "unknown" (same as other locations) if it's
not set (i.e. when the description pointer is NULL).

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 subsurface-core/qthelper.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/subsurface-core/qthelper.cpp b/subsurface-core/qthelper.cpp
index c3ea37c..cc41db2 100644
--- a/subsurface-core/qthelper.cpp
+++ b/subsurface-core/qthelper.cpp
@@ -337,9 +337,10 @@ void Dive::put_suit()
 static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
 {
 	cylinder_t *cyl = &dive->cylinder[idx];
-	if (!cyl->type.description)
+	const char *desc = cyl->type.description;
+	if (!desc && idx > 0)
 		return QString(EMPTY_DIVE_STRING);
-	QString fmt = QString(cyl->type.description);
+	QString fmt = desc ? QString(desc) : QObject::tr("unknown");
 	fmt += ", " + get_volume_string(cyl->type.size, true, 0);
 	fmt += ", " + get_pressure_string(cyl->type.workingpressure, true);
 	fmt += ", " + get_pressure_string(cyl->start, false) + " - " + get_pressure_string(cyl->end, true);
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list