mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: C++-ify plot_info
Use more C++ style memory management for plot_info: Use std::vector for array data. Return the plot_info instead of filling an output parameter. Add a constructor/destructor pair so that the caller isn't bothered with memory management. The bulk of the commit is replacement of pointers with references, which is kind of gratuitous. But I started and then went on... Default initializiation of gas_pressures made it necessary to convert gas.c to c++, though with minimal changes to the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
aaab5157d4
commit
48f7828d10
14 changed files with 635 additions and 670 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "profile-widget/divecartesianaxis.h"
|
||||
#include "profile-widget/divepixmapcache.h"
|
||||
#include "profile-widget/animationfunctions.h"
|
||||
#include "core/dive.h"
|
||||
#include "core/event.h"
|
||||
#include "core/eventtype.h"
|
||||
#include "core/format.h"
|
||||
|
@ -177,9 +178,9 @@ void DiveEventItem::eventVisibilityChanged(const QString&, bool)
|
|||
static int depthAtTime(const plot_info &pi, duration_t time)
|
||||
{
|
||||
// Do a binary search for the timestamp
|
||||
auto it = std::lower_bound(pi.entry, pi.entry + pi.nr, time,
|
||||
auto it = std::lower_bound(pi.entry.begin(), pi.entry.end(), time,
|
||||
[](const plot_data &d1, duration_t t) { return d1.sec < t.seconds; });
|
||||
if (it == pi.entry + pi.nr || it->sec != time.seconds) {
|
||||
if (it == pi.entry.end() || it->sec != time.seconds) {
|
||||
qWarning("can't find a spot in the dataModel");
|
||||
return DEPTH_NOT_FOUND;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue