diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-11-24 09:27:50 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-05 10:14:25 -0800 |
commit | e114522a44d67e03a2fa13e19c84a74cf5afca6d (patch) | |
tree | 2390a89ee0a02a2a497bf74e69d2dd8f8728e8af /qt-models | |
parent | a4c95fd8e8fa4b9a344ac437cfc0e01fc852f277 (diff) | |
download | subsurface-e114522a44d67e03a2fa13e19c84a74cf5afca6d.tar.gz |
Cleanup: set description to null in free_[weightsystem|cylinder]
Currently, the caller is responsible for not reusing a freed
weightsystem / cylinder or resetting the description field to
null. This is very unfriendly. Set the description field to null,
because that allows us to call free_* repeatedly on the same
object. Use the new behavior to make the weightsystem model code
a bit cleaner.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/weightmodel.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
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)); } |