[PATCH 02/17] Free memory returned from get_dive_gas_string
Anton Lundin
glance at acc.umu.se
Wed Dec 17 23:47:43 PST 2014
After we created a QString from it, we need to free the char*.
Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
qt-ui/models.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 2bb40ef..0778b7b 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -1217,9 +1217,6 @@ QVariant DiveItem::data(int column, int role) const
case CYLINDER:
retVal = QString(dive->cylinder[0].type.description);
break;
- case GAS:
- retVal = QString(get_dive_gas_string(dive));
- break;
case SAC:
retVal = displaySac();
break;
@@ -1232,6 +1229,11 @@ QVariant DiveItem::data(int column, int role) const
case LOCATION:
retVal = QString(dive->location);
break;
+ case GAS:
+ const char *gas_string = get_dive_gas_string(dive);
+ retVal = QString(gas_string);
+ free((void*)gas_string);
+ break;
}
break;
case Qt::ToolTipRole:
--
2.1.0
More information about the subsurface
mailing list