diff --git a/core/equipment.c b/core/equipment.c index 07e468c1c..ebdff9772 100644 --- a/core/equipment.c +++ b/core/equipment.c @@ -26,11 +26,13 @@ void free_weightsystem(weightsystem_t ws) { free((void *)ws.description); + ws.description = NULL; } static void free_cylinder(cylinder_t c) { free((void *)c.type.description); + c.type.description = NULL; } void copy_weights(const struct weightsystem_table *s, struct weightsystem_table *d) diff --git a/qt-models/weightmodel.cpp b/qt-models/weightmodel.cpp index ec0ea0259..21e363592 100644 --- a/qt-models/weightmodel.cpp +++ b/qt-models/weightmodel.cpp @@ -82,14 +82,12 @@ void WeightModel::setTempWS(int row, weightsystem_t ws) return; clearTempWS(); // Shouldn't be necessary, just in case: Reset old temporary row. - free_weightsystem(tempWS); // It is really hard to get the editor-close-hints and setModelData calls under // control. Therefore, if the row is set to the already existing entry, don't // enter temporary mode. if (same_string(d->weightsystems.weightsystems[row].description, ws.description)) { free_weightsystem(ws); - tempWS.description = nullptr; } else { tempRow = row; tempWS = ws; @@ -103,6 +101,7 @@ void WeightModel::clearTempWS() return; int oldRow = tempRow; tempRow = -1; + free_weightsystem(tempWS); dataChanged(index(oldRow, TYPE), index(oldRow, WEIGHT)); }