mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: move clear_dive() to struct dive
Feels natural in a C++ code base. Moreover, remove the fulltext-unregistration, as this is a layering violation. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
79bf79ad7f
commit
df1affc25b
3 changed files with 7 additions and 14 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "extradata.h"
|
#include "extradata.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
#include "fulltext.h"
|
||||||
#include "interpolate.h"
|
#include "interpolate.h"
|
||||||
#include "qthelper.h"
|
#include "qthelper.h"
|
||||||
#include "membuffer.h"
|
#include "membuffer.h"
|
||||||
|
@ -26,7 +27,6 @@
|
||||||
#include "sample.h"
|
#include "sample.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "trip.h"
|
#include "trip.h"
|
||||||
#include "fulltext.h"
|
|
||||||
|
|
||||||
// For user visible text but still not translated
|
// For user visible text but still not translated
|
||||||
const char *divemode_text_ui[] = {
|
const char *divemode_text_ui[] = {
|
||||||
|
@ -188,16 +188,9 @@ static void copy_dc_renumber(struct dive &d, const struct dive &s, const int cyl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy_dive makes duplicates of many components of a dive;
|
void dive::clear()
|
||||||
* in order not to leak memory, we need to free those.
|
|
||||||
* copy_dive doesn't play with the divetrip and forward/backward pointers
|
|
||||||
* so we can ignore those */
|
|
||||||
void clear_dive(struct dive *d)
|
|
||||||
{
|
{
|
||||||
if (!d)
|
*this = dive();
|
||||||
return;
|
|
||||||
fulltext_unregister(d);
|
|
||||||
*d = dive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make a true copy that is independent of the source dive;
|
/* make a true copy that is independent of the source dive;
|
||||||
|
@ -205,7 +198,7 @@ void clear_dive(struct dive *d)
|
||||||
* any impact on the source */
|
* any impact on the source */
|
||||||
void copy_dive(const struct dive *s, struct dive *d)
|
void copy_dive(const struct dive *s, struct dive *d)
|
||||||
{
|
{
|
||||||
/* simply copy things over, but then clear fulltext cache and dive cache. */
|
/* simply copy things over, but then the dive cache. */
|
||||||
*d = *s;
|
*d = *s;
|
||||||
d->invalidate_cache();
|
d->invalidate_cache();
|
||||||
}
|
}
|
||||||
|
@ -218,7 +211,7 @@ void copy_dive(const struct dive *s, struct dive *d)
|
||||||
void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_components what, bool clear)
|
void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_components what, bool clear)
|
||||||
{
|
{
|
||||||
if (clear)
|
if (clear)
|
||||||
clear_dive(d);
|
d->clear();
|
||||||
CONDITIONAL_COPY_STRING(notes);
|
CONDITIONAL_COPY_STRING(notes);
|
||||||
CONDITIONAL_COPY_STRING(diveguide);
|
CONDITIONAL_COPY_STRING(diveguide);
|
||||||
CONDITIONAL_COPY_STRING(buddy);
|
CONDITIONAL_COPY_STRING(buddy);
|
||||||
|
|
|
@ -82,6 +82,7 @@ struct dive {
|
||||||
void invalidate_cache();
|
void invalidate_cache();
|
||||||
bool cache_is_valid() const;
|
bool cache_is_valid() const;
|
||||||
|
|
||||||
|
void clear();
|
||||||
void fixup_no_cylinder(); /* to fix cylinders, we need the divelist (to calculate cns) */
|
void fixup_no_cylinder(); /* to fix cylinders, we need the divelist (to calculate cns) */
|
||||||
timestamp_t endtime() const; /* maximum over divecomputers (with samples) */
|
timestamp_t endtime() const; /* maximum over divecomputers (with samples) */
|
||||||
duration_t totaltime() const; /* maximum over divecomputers (with samples) */
|
duration_t totaltime() const; /* maximum over divecomputers (with samples) */
|
||||||
|
@ -183,7 +184,6 @@ extern void subsurface_console_init();
|
||||||
extern void subsurface_console_exit();
|
extern void subsurface_console_exit();
|
||||||
extern bool subsurface_user_is_root();
|
extern bool subsurface_user_is_root();
|
||||||
|
|
||||||
extern void clear_dive(struct dive *dive);
|
|
||||||
extern void copy_dive(const struct dive *s, struct dive *d);
|
extern void copy_dive(const struct dive *s, struct dive *d);
|
||||||
extern void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_components what, bool clear);
|
extern void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_components what, bool clear);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ void DivePlannerPointsModel::createSimpleDive(struct dive *dIn)
|
||||||
// clean out the dive and give it an id and the correct dc model
|
// clean out the dive and give it an id and the correct dc model
|
||||||
d = dIn;
|
d = dIn;
|
||||||
dcNr = 0;
|
dcNr = 0;
|
||||||
clear_dive(d);
|
d->clear();
|
||||||
d->id = dive_getUniqID();
|
d->id = dive_getUniqID();
|
||||||
d->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600;
|
d->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600;
|
||||||
make_planner_dc(&d->dcs[0]);
|
make_planner_dc(&d->dcs[0]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue