diff options
-rw-r--r-- | dive.c | 8 | ||||
-rw-r--r-- | equipment.c | 4 | ||||
-rw-r--r-- | qt-ui/modeldelegates.cpp | 4 | ||||
-rw-r--r-- | qt-ui/models.cpp | 2 |
4 files changed, 13 insertions, 5 deletions
@@ -434,6 +434,10 @@ void clear_dive(struct dive *d) taglist_free(d->tag_list); STRUCTURED_LIST_FREE(struct divecomputer, d->dc.next, free_dc); STRUCTURED_LIST_FREE(struct picture, d->picture_list, free_pic); + for (int i = 0; i < MAX_CYLINDERS; i++) + free((void *)d->cylinder[i].type.description); + for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) + free((void *)d->weightsystem[i].description); memset(d, 0, sizeof(struct dive)); } @@ -452,6 +456,10 @@ void copy_dive(struct dive *s, struct dive *d) d->location = copy_string(s->location); d->notes = copy_string(s->notes); d->suit = copy_string(s->suit); + for (int i = 0; i < MAX_CYLINDERS; i++) + d->cylinder[i].type.description = copy_string(s->cylinder[i].type.description); + for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) + d->weightsystem[i].description = copy_string(s->weightsystem[i].description); STRUCTURED_LIST_COPY(struct picture, s->picture_list, d->picture_list, copy_pl); STRUCTURED_LIST_COPY(struct tag_entry, s->tag_list, d->tag_list, copy_tl); STRUCTURED_LIST_COPY(struct divecomputer, s->dc.next, d->dc.next, copy_dc); diff --git a/equipment.c b/equipment.c index 2a96aec80..6396df0ca 100644 --- a/equipment.c +++ b/equipment.c @@ -23,7 +23,7 @@ void add_cylinder_description(cylinder_type_t *type) return; } if (i < 100) { - tank_info[i].name = desc; + tank_info[i].name = strdup(desc); tank_info[i].ml = type->size.mliter; tank_info[i].bar = type->workingpressure.mbar / 1000; } @@ -43,7 +43,7 @@ void add_weightsystem_description(weightsystem_t *weightsystem) } } if (i < 100) { - ws_info[i].name = desc; + ws_info[i].name = strdup(desc); ws_info[i].grams = weightsystem->weight.grams; } } diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 8b70b48b3..7079173c4 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -271,7 +271,7 @@ QWidget *TankInfoDelegate::createEditor(QWidget *parent, const QStyleOptionViewI QWidget *delegate = ComboBoxDelegate::createEditor(parent, option, index); CylindersModel *mymodel = qobject_cast<CylindersModel *>(currCombo.model); cylinder_t *cyl = mymodel->cylinderAt(index); - currCylinderData.type = cyl->type.description; + currCylinderData.type = copy_string(cyl->type.description); currCylinderData.pressure = cyl->type.workingpressure.mbar; currCylinderData.size = cyl->type.size.mliter; return delegate; @@ -323,7 +323,7 @@ QWidget *WSInfoDelegate::createEditor(QWidget *parent, const QStyleOptionViewIte QWidget *editor = ComboBoxDelegate::createEditor(parent, option, index); WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model); weightsystem_t *ws = mymodel->weightSystemAt(index); - currWeight.type = ws->description; + currWeight.type = copy_string(ws->description); currWeight.weight = ws->weight.grams; return editor; } diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index e62598479..f73b1dc94 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -632,7 +632,7 @@ bool WeightModel::setData(const QModelIndex &index, const QVariant &value, int r int i = -1; while (ws_info[++i].name) { if (gettextFromC::instance()->tr(ws_info[i].name) == vString) { - ws->description = ws_info[i].name; + ws->description = copy_string(ws_info[i].name); break; } } |