mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: remove QList<> of DiveEventItems by std::vector
Turn the raw pointers into unique_ptrs to simplify memory management. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9a0b8678ca
commit
c6eeeb7d28
2 changed files with 5 additions and 13 deletions
|
@ -172,10 +172,6 @@ void ProfileScene::clear()
|
|||
for (AbstractProfilePolygonItem *item: profileItems)
|
||||
item->clear();
|
||||
|
||||
// the events will have connected slots which can fire after
|
||||
// the dive and its data have been deleted - so explictly delete
|
||||
// the DiveEventItems
|
||||
qDeleteAll(eventItems);
|
||||
eventItems.clear();
|
||||
plotInfo = plot_info();
|
||||
empty = true;
|
||||
|
@ -525,10 +521,6 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, int animSpeed, Div
|
|||
if (prefs.percentagegraph)
|
||||
percentageItem->replot(d, currentdc, plotInfo);
|
||||
|
||||
// The event items are a bit special since we don't know how many events are going to
|
||||
// exist on a dive, so I cant create cache items for that. that's why they are here
|
||||
// while all other items are up there on the constructor.
|
||||
qDeleteAll(eventItems);
|
||||
eventItems.clear();
|
||||
struct gasmix lastgasmix = d->get_gasmix_at_time(*currentdc, 1_sec);
|
||||
|
||||
|
@ -543,11 +535,11 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, int animSpeed, Div
|
|||
continue;
|
||||
}
|
||||
if (DiveEventItem::isInteresting(d, currentdc, event, plotInfo, firstSecond, lastSecond)) {
|
||||
auto item = new DiveEventItem(d, idx, event, lastgasmix, plotInfo,
|
||||
timeAxis, profileYAxis, animSpeed, *pixmaps);
|
||||
auto item = std::make_unique<DiveEventItem>(d, idx, event, lastgasmix, plotInfo,
|
||||
timeAxis, profileYAxis, animSpeed, *pixmaps);
|
||||
item->setZValue(2);
|
||||
addItem(item);
|
||||
eventItems.push_back(item);
|
||||
addItem(item.get());
|
||||
eventItems.push_back(std::move(item));
|
||||
}
|
||||
if (event.is_gaschange())
|
||||
lastgasmix = d->get_gasmix_from_event(event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue