diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/divelist.c | 11 | ||||
-rw-r--r-- | core/downloadfromdcthread.cpp | 23 | ||||
-rw-r--r-- | core/downloadfromdcthread.h | 4 | ||||
-rw-r--r-- | core/libdivecomputer.c | 7 | ||||
-rw-r--r-- | core/libdivecomputer.h | 2 | ||||
-rw-r--r-- | core/uemis-downloader.c | 15 |
6 files changed, 12 insertions, 50 deletions
diff --git a/core/divelist.c b/core/divelist.c index fc4e58877..bab581eec 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -1661,8 +1661,10 @@ bool try_to_merge_trip(struct dive_trip *trip_import, struct dive_table *import_ * 3) Trips to be added * The dives to be added are owning (i.e. the caller is responsible * for freeing them). - * The dives and trips in import_table and import_trip table are + * The dives and trips in "import_table" and "import_trip_table" are * consumed. On return, both tables have size 0. + * "import_trip_table" may be NULL if all dives are not associated + * with a trip. * The output parameters should be empty - if not, their content * will be cleared! * @@ -1690,6 +1692,13 @@ void process_imported_dives(struct dive_table *import_table, struct trip_table * bool sequence_changed = false; bool new_dive_has_number = false; + /* If the caller didn't pass an import_trip_table because all + * dives are tripless, provide a local table. This may be + * necessary if the trips are autogrouped */ + struct trip_table local_trip_table = { 0 }; + if (!import_trip_table) + import_trip_table = &local_trip_table; + /* Make sure that output parameters don't contain garbage */ clear_table(dives_to_add); clear_table(dives_to_remove); diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp index 0774c5e8b..97e04c48b 100644 --- a/core/downloadfromdcthread.cpp +++ b/core/downloadfromdcthread.cpp @@ -60,7 +60,6 @@ static void updateRememberedDCs() DownloadThread::DownloadThread() : downloadTable({ 0 }), - tripTable({ 0 }), m_data(DCDeviceData::instance()) { } @@ -70,7 +69,6 @@ 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"; @@ -83,10 +81,6 @@ void DownloadThread::run() #endif qDebug() << "Starting download from " << (internalData->bluetooth_mode ? "BT" : internalData->devname); clear_table(&downloadTable); - if (tripTable.nr > 0) { - qWarning() << "DownloadThread::run(): Trip table not empty after reset"; - tripTable.nr = 0; - } Q_ASSERT(internalData->download_table != nullptr); const char *errorText; @@ -265,7 +259,6 @@ 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) @@ -274,7 +267,6 @@ DCDeviceData::DCDeviceData() data.bluetooth_mode = false; #endif data.force_download = false; - data.create_new_trip = false; data.libdc_dump = false; #if defined(SUBSURFACE_MOBILE) data.libdc_log = true; @@ -314,11 +306,6 @@ struct dive_table *DownloadThread::table() return &downloadTable; } -struct trip_table *DownloadThread::trips() -{ - return &tripTable; -} - QString DCDeviceData::vendor() const { return data.vendor; @@ -354,11 +341,6 @@ bool DCDeviceData::forceDownload() const return data.force_download; } -bool DCDeviceData::createNewTrip() const -{ - return data.create_new_trip; -} - int DCDeviceData::deviceId() const { return data.deviceid; @@ -415,11 +397,6 @@ void DCDeviceData::setForceDownload(bool force) data.force_download = force; } -void DCDeviceData::setCreateNewTrip(bool create) -{ - data.create_new_trip = create; -} - void DCDeviceData::setDeviceId(int deviceId) { data.deviceid = deviceId; diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h index 506a75ac0..da8bec994 100644 --- a/core/downloadfromdcthread.h +++ b/core/downloadfromdcthread.h @@ -26,7 +26,6 @@ public: QString devBluetoothName() const; QString descriptor() const; bool forceDownload() const; - bool createNewTrip() const; bool saveLog() const; int deviceId() const; int diveId() const; @@ -48,7 +47,6 @@ public: void setDevBluetoothName(const QString& devBluetoothName); void setBluetoothMode(bool mode); void setForceDownload(bool force); - void setCreateNewTrip(bool create); void setSaveDump(bool dumpMode); void setSaveLog(bool saveLog); private: @@ -61,7 +59,6 @@ private: class DownloadThread : public QThread { Q_OBJECT Q_PROPERTY(dive_table_t *table READ table CONSTANT) - Q_PROPERTY(trip_table_t *trips READ trips CONSTANT) public: DownloadThread(); @@ -69,7 +66,6 @@ public: DCDeviceData *data(); struct dive_table *table(); - struct trip_table *trips(); QString error; private: diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index 15dd1132a..b3dd8f5e4 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -824,13 +824,6 @@ static int dive_cb(const unsigned char *data, unsigned int size, dive->dc.sample[0].temperature.mkelvin = 0; } - if (devdata->create_new_trip) { - if (!devdata->trip) - devdata->trip = create_and_hookup_trip_from_dive(dive, devdata->trip_table); - else - add_dive_to_trip(dive, devdata->trip); - } - record_dive_to_table(dive, devdata->download_table); mark_divelist_changed(true); return true; diff --git a/core/libdivecomputer.h b/core/libdivecomputer.h index 2732adfb5..8f6d222db 100644 --- a/core/libdivecomputer.h +++ b/core/libdivecomputer.h @@ -41,13 +41,11 @@ typedef struct dc_user_device_t struct dive_trip *trip; int preexisting; bool force_download; - bool create_new_trip; bool libdc_log; bool libdc_dump; 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); diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c index 5dd6567b6..35dc817b0 100644 --- a/core/uemis-downloader.c +++ b/core/uemis-downloader.c @@ -211,17 +211,6 @@ static struct dive *get_dive_by_uemis_diveid(device_data_t *devdata, uint32_t ob return NULL; } -static void record_uemis_dive(device_data_t *devdata, struct dive *dive) -{ - if (devdata->create_new_trip) { - if (!devdata->trip) - devdata->trip = create_and_hookup_trip_from_dive(dive, &trip_table); - else - add_dive_to_trip(dive, devdata->trip); - } - record_dive_to_table(dive, devdata->download_table); -} - /* send text to the importer progress bar */ static void uemis_info(const char *fmt, ...) { @@ -1024,14 +1013,14 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char * * be a short read because of some error */ if (done && ++bp < endptr && *bp != '{' && strstr(bp, "{{")) { done = false; - record_uemis_dive(devdata, dive); + record_dive_to_table(dive, devdata->download_table); mark_divelist_changed(true); dive = uemis_start_dive(deviceid); } } if (is_log) { if (dive->dc.diveid) { - record_uemis_dive(devdata, dive); + record_dive_to_table(dive, devdata->download_table); mark_divelist_changed(true); } else { /* partial dive */ free(dive); |