From 11d19abc7412b76c9ee1be39ffe992afb02b710b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 10 Jan 2019 17:00:39 +0200 Subject: Dive download: add trip_table to device_data_t Since recent commits, dive-trips are not added directly to the core, but into separate trip tables (see ec37c71f5eeb7d4b0c4b8719b52583fadb0b8f4c). These commits did not finish the work for the download-from-dc case. Add an extra trip_table field to device_data_t. If trips are created (user selected "Download into new trip"), the trip will be created in that table. Signed-off-by: Berthold Stoeger --- core/downloadfromdcthread.cpp | 2 ++ core/libdivecomputer.c | 2 +- core/libdivecomputer.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp index 4e72f5b16..0774c5e8b 100644 --- a/core/downloadfromdcthread.cpp +++ b/core/downloadfromdcthread.cpp @@ -70,6 +70,7 @@ void DownloadThread::run() auto internalData = m_data->internalData(); internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()]; internalData->download_table = &downloadTable; + internalData->trip_table = &tripTable; internalData->btname = strdup(m_data->devBluetoothName().toUtf8()); if (!internalData->descriptor) { qDebug() << "No download possible when DC type is unknown"; @@ -264,6 +265,7 @@ DCDeviceData::DCDeviceData() memset(&data, 0, sizeof(data)); data.trip = nullptr; data.download_table = nullptr; + data.trip_table = nullptr; data.diveid = 0; data.deviceid = 0; #if defined(BT_SUPPORT) diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index 47c769275..15dd1132a 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -826,7 +826,7 @@ static int dive_cb(const unsigned char *data, unsigned int size, if (devdata->create_new_trip) { if (!devdata->trip) - devdata->trip = create_and_hookup_trip_from_dive(dive, &trip_table); + devdata->trip = create_and_hookup_trip_from_dive(dive, devdata->trip_table); else add_dive_to_trip(dive, devdata->trip); } diff --git a/core/libdivecomputer.h b/core/libdivecomputer.h index b06b5ae0d..2732adfb5 100644 --- a/core/libdivecomputer.h +++ b/core/libdivecomputer.h @@ -47,6 +47,7 @@ typedef struct dc_user_device_t bool bluetooth_mode; FILE *libdc_logfile; struct dive_table *download_table; + struct trip_table *trip_table; } device_data_t; const char *errmsg (dc_status_t rc); -- cgit v1.2.3-70-g09d2