profile use unique_ptr to manage dive handler objects

Instead of manually deleting them (and the gases). Currently
there is only one point where these are deleted, but if
we implement proper Qt model/view semantics, this makes things
less headachy.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-24 09:13:56 +01:00 committed by Dirk Hohndel
parent 1b14a211f0
commit 396758d489
3 changed files with 31 additions and 26 deletions

View file

@ -227,7 +227,7 @@ private:
#endif
TankItem *tankItem;
QList<QGraphicsSimpleTextItem *> gases;
std::vector<std::unique_ptr<QGraphicsSimpleTextItem>> gases;
//specifics for ADD and PLAN
#ifndef SUBSURFACE_MOBILE
@ -251,7 +251,8 @@ private:
void updateThumbnailPaintOrder();
#endif
QList<DiveHandler *> handles;
std::vector<std::unique_ptr<DiveHandler>> handles;
int handleIndex(const DiveHandler *h) const;
#ifndef SUBSURFACE_MOBILE
void repositionDiveHandlers();
int fixHandlerIndex(DiveHandler *activeHandler);