From b72cc1f31784346884c8552c22f1e4c3c6d5ed1d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 25 Feb 2018 13:51:41 +0100 Subject: [PATCH] Cleanup: consistently use qPrintable() Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger --- core/android.cpp | 2 +- core/configuredivecomputerthreads.cpp | 12 ++-- core/divecomputer.cpp | 10 +-- core/divelogexportlogic.cpp | 2 +- core/prefs-macros.h | 10 +-- core/qt-ble.cpp | 2 +- core/qthelper.cpp | 38 ++++++------ core/subsurface-qt/SettingsObjectWrapper.cpp | 8 +-- .../configuredivecomputerdialog.cpp | 8 +-- desktop-widgets/divelistview.cpp | 2 +- desktop-widgets/divelogexportdialog.cpp | 16 ++--- desktop-widgets/divelogimportdialog.cpp | 16 ++--- desktop-widgets/downloadfromdivecomputer.cpp | 6 +- desktop-widgets/locationinformation.cpp | 8 +-- desktop-widgets/mainwindow.cpp | 10 +-- desktop-widgets/modeldelegates.cpp | 2 +- desktop-widgets/simplewidgets.cpp | 6 +- desktop-widgets/subsurfacewebservices.cpp | 2 +- desktop-widgets/tab-widgets/maintab.cpp | 24 +++---- desktop-widgets/templatelayout.cpp | 2 +- mobile-widgets/qmlmanager.cpp | 4 +- profile-widget/diveeventitem.cpp | 6 +- profile-widget/profilewidget2.cpp | 6 +- qt-models/cylindermodel.cpp | 24 +++---- qt-models/divepicturemodel.cpp | 2 +- qt-models/diveplannermodel.cpp | 10 +-- qt-models/filtermodels.cpp | 2 +- qt-models/messagehandlermodel.cpp | 2 +- qt-models/weightmodel.cpp | 4 +- smtk-import/smrtk2ssrfc_window.cpp | 2 +- subsurface-desktop-main.cpp | 16 ++--- subsurface-mobile-main.cpp | 2 +- tests/testgitstorage.cpp | 62 ++++++++++--------- 33 files changed, 166 insertions(+), 162 deletions(-) diff --git a/core/android.cpp b/core/android.cpp index 7c9965c16..5234f35a9 100644 --- a/core/android.cpp +++ b/core/android.cpp @@ -52,7 +52,7 @@ static const char *system_default_path_append(const char *append) if (append) path += QString("/%1").arg(append); - return strdup(path.toUtf8().data()); + return strdup(qPrintable(path)); } const char *system_default_directory(void) diff --git a/core/configuredivecomputerthreads.cpp b/core/configuredivecomputerthreads.cpp index 0d9a553e8..885cd0226 100644 --- a/core/configuredivecomputerthreads.cpp +++ b/core/configuredivecomputerthreads.cpp @@ -293,7 +293,7 @@ static dc_status_t write_suunto_vyper_settings(dc_device_t *device, DeviceDetail rc = dc_device_write(device, SUUNTO_VYPER_CUSTOM_TEXT, // Convert the customText to a 30 char wide padded with " " - (const unsigned char *)QString("%1").arg(m_deviceDetails->customText, -30, QChar(' ')).toUtf8().data(), + (const unsigned char *)qPrintable(QString("%1").arg(m_deviceDetails->customText, -30, QChar(' '))), SUUNTO_VYPER_CUSTOM_TEXT_LENGTH); if (rc != DC_STATUS_SUCCESS) return rc; @@ -812,7 +812,7 @@ static dc_status_t write_ostc4_settings(dc_device_t *device, DeviceDetails *m_de //write general settings //custom text - rc = hw_ostc3_device_customtext(device, m_deviceDetails->customText.toUtf8().data()); + rc = hw_ostc3_device_customtext(device, qPrintable(m_deviceDetails->customText)); if (rc != DC_STATUS_SUCCESS) return rc; EMIT_PROGRESS(); @@ -1356,7 +1356,7 @@ static dc_status_t write_ostc3_settings(dc_device_t *device, DeviceDetails *m_de //write general settings //custom text - rc = hw_ostc3_device_customtext(device, m_deviceDetails->customText.toUtf8().data()); + rc = hw_ostc3_device_customtext(device, qPrintable(m_deviceDetails->customText)); if (rc != DC_STATUS_SUCCESS) return rc; @@ -1891,7 +1891,7 @@ static dc_status_t write_ostc_settings(dc_device_t *device, DeviceDetails *m_dev } else { data[64] = 1; // Copy the string to the right place in the memory, padded with 0x20 (" ") - strncpy((char *)data + 65, QString("%1").arg(m_deviceDetails->customText, -23, QChar(' ')).toUtf8().data(), 23); + strncpy((char *)data + 65, qPrintable(QString("%1").arg(m_deviceDetails->customText, -23, QChar(' '))), 23); // And terminate the string. if (m_deviceDetails->customText.length() <= 23) data[65 + m_deviceDetails->customText.length()] = '}'; @@ -2227,10 +2227,10 @@ void FirmwareUpdateThread::run() switch (dc_device_get_type(m_data->device)) { #if DC_VERSION_CHECK(0, 5, 0) case DC_FAMILY_HW_OSTC3: - rc = hw_ostc3_device_fwupdate(m_data->device, m_fileName.toUtf8().data()); + rc = hw_ostc3_device_fwupdate(m_data->device, qPrintable(m_fileName)); break; case DC_FAMILY_HW_OSTC: - rc = hw_ostc_device_fwupdate(m_data->device, m_fileName.toUtf8().data()); + rc = hw_ostc_device_fwupdate(m_data->device, qPrintable(m_fileName)); break; #endif // divecomputer 0.5.0 default: diff --git a/core/divecomputer.cpp b/core/divecomputer.cpp index 43219ed05..08b6948d4 100644 --- a/core/divecomputer.cpp +++ b/core/divecomputer.cpp @@ -57,11 +57,11 @@ const DiveComputerNode *DiveComputerList::get(const QString &m) void DiveComputerNode::showchanges(const QString &n, const QString &s, const QString &f) const { if (nickName != n) - qDebug("new nickname %s for DC model %s deviceId 0x%x", n.toUtf8().data(), model.toUtf8().data(), deviceId); + qDebug("new nickname %s for DC model %s deviceId 0x%x", qPrintable(n), qPrintable(model), deviceId); if (serialNumber != s) - qDebug("new serial number %s for DC model %s deviceId 0x%x", s.toUtf8().data(), model.toUtf8().data(), deviceId); + qDebug("new serial number %s for DC model %s deviceId 0x%x", qPrintable(s), qPrintable(model), deviceId); if (firmware != f) - qDebug("new firmware version %s for DC model %s deviceId 0x%x", f.toUtf8().data(), model.toUtf8().data(), deviceId); + qDebug("new firmware version %s for DC model %s deviceId 0x%x", qPrintable(f), qPrintable(model), deviceId); } void DiveComputerList::addDC(QString m, uint32_t d, QString n, QString s, QString f) @@ -132,8 +132,8 @@ extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char * found = true; } if (found) - callback(f, node->model.toUtf8().data(), node->deviceId, node->nickName.toUtf8().data(), - node->serialNumber.toUtf8().data(), node->firmware.toUtf8().data()); + callback(f, qPrintable(node->model), node->deviceId, qPrintable(node->nickName), + qPrintable(node->serialNumber), qPrintable(node->firmware)); } } diff --git a/core/divelogexportlogic.cpp b/core/divelogexportlogic.cpp index 5df24dce2..283cffbca 100644 --- a/core/divelogexportlogic.cpp +++ b/core/divelogexportlogic.cpp @@ -143,7 +143,7 @@ void exportHtmlInitLogic(const QString &filename, struct htmlExportSetting &hes) exportHTMLsettings(json_settings, hes); exportHTMLstatistics(stat_file, hes); - export_translation(translation.toUtf8().data()); + export_translation(qPrintable(translation)); export_HTML(qPrintable(json_dive_data), qPrintable(photosDirectory), hes.selectedOnly, hes.listOnly); diff --git a/core/prefs-macros.h b/core/prefs-macros.h index 15a9a9867..16a92aa24 100644 --- a/core/prefs-macros.h +++ b/core/prefs-macros.h @@ -60,11 +60,11 @@ else \ prefs.field = defval -#define GET_TXT(name, field) \ - v = s.value(QString(name)); \ - if (v.isValid()) \ - prefs.field = strdup(v.toString().toUtf8().constData()); \ - else \ +#define GET_TXT(name, field) \ + v = s.value(QString(name)); \ + if (v.isValid()) \ + prefs.field = strdup(qPrintable(v.toString())); \ + else \ prefs.field = copy_string(default_prefs.field) #define SAVE_OR_REMOVE_SPECIAL(_setting, _default, _compare, _value) \ diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index b39bd5331..cc1f4e00a 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -334,7 +334,7 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d return DC_STATUS_IO; default: qDebug() << "failed to connect to the controller " << devaddr << "with error" << controller->errorString(); - report_error("Failed to connect to %s: '%s'", devaddr, controller->errorString().toUtf8().data()); + report_error("Failed to connect to %s: '%s'", devaddr, qPrintable(controller->errorString())); delete controller; return DC_STATUS_IO; } diff --git a/core/qthelper.cpp b/core/qthelper.cpp index bbbb1e0f2..483e90b21 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -94,12 +94,12 @@ extern "C" const char *printGPSCoords(int lat, int lon) latsec = (latmin % 1000000) * 60; lonsec = (lonmin % 1000000) * 60; result.sprintf("%u%s%02d\'%06.3f\"%s %u%s%02d\'%06.3f\"%s", - latdeg, UTF8_DEGREE, latmin / 1000000, latsec / 1000000, lath.toUtf8().data(), - londeg, UTF8_DEGREE, lonmin / 1000000, lonsec / 1000000, lonh.toUtf8().data()); + latdeg, UTF8_DEGREE, latmin / 1000000, latsec / 1000000, qPrintable(lath), + londeg, UTF8_DEGREE, lonmin / 1000000, lonsec / 1000000, qPrintable(lonh)); } else { result.sprintf("%f %f", (double) lat / 1000000.0, (double) lon / 1000000.0); } - return strdup(result.toUtf8().data()); + return strdup(qPrintable(result)); } /** @@ -354,7 +354,7 @@ extern "C" timestamp_t picture_get_timestamp(const char *filename) int retval; // filename might not be the actual filename, so let's go via the hash. - if (readfile(localFilePath(QString(filename)).toUtf8().data(), &mem) <= 0) + if (readfile(qPrintable(localFilePath(QString(filename))), &mem) <= 0) return 0; retval = exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size); free(mem.buffer); @@ -998,7 +998,7 @@ QString get_short_dive_date_string(timestamp_t when) const char *get_dive_date_c_string(timestamp_t when) { QString text = get_dive_date_string(when); - return strdup(text.toUtf8().data()); + return strdup(qPrintable(text)); } extern "C" const char *get_current_date() @@ -1008,7 +1008,7 @@ extern "C" const char *get_current_date() current_date = loc.toString(ts, QString(prefs.date_format_short)); - return strdup(current_date.toUtf8().data()); + return strdup(qPrintable(current_date)); } bool is_same_day(timestamp_t trip_when, timestamp_t dive_when) @@ -1066,7 +1066,7 @@ extern "C" void reverseGeoLookup(degrees_t latitude, degrees_t longitude, uint32 QJsonObject address = obj.value("address").toObject(); qDebug() << "found country:" << address.value("country").toString(); struct dive_site *ds = get_dive_site_by_uuid(uuid); - ds->notes = add_to_string(ds->notes, "countrytag: %s", address.value("country").toString().toUtf8().data()); + ds->notes = add_to_string(ds->notes, "countrytag: %s", qPrintable(address.value("country").toString())); } } @@ -1098,7 +1098,7 @@ const QString hashfile_name() extern "C" char *hashfile_name_string() { - return strdup(hashfile_name().toUtf8().data()); + return strdup(qPrintable(hashfile_name())); } void read_hashes() @@ -1266,7 +1266,7 @@ const QString picturedir() extern "C" char *picturedir_string() { - return strdup(picturedir().toUtf8().data()); + return strdup(qPrintable(picturedir())); } /* when we get a picture from git storage (local or remote) and can't find the picture @@ -1293,7 +1293,7 @@ extern "C" void picture_load_exif_data(struct picture *p) easyexif::EXIFInfo exif; memblock mem; - if (readfile(localFilePath(QString(p->filename)).toUtf8().data(), &mem) <= 0) + if (readfile(qPrintable(localFilePath(QString(p->filename))), &mem) <= 0) goto picture_load_exit; if (exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size) != PARSE_EXIF_SUCCESS) goto picture_load_exit; @@ -1458,7 +1458,7 @@ extern "C" char *cloud_url() { QString filename; getCloudURL(filename); - return strdup(filename.toUtf8().data()); + return strdup(qPrintable(filename)); } extern "C" bool getProxyString(char **buffer) @@ -1558,7 +1558,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr) while ((parseLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) { if (parseLine.contains("//DIVE NR: ")) { params[pnr++] = strdup("diveNro"); - params[pnr++] = strdup(parseLine.replace(QString::fromLatin1("//DIVE NR: "), QString::fromLatin1("")).toUtf8().data()); + params[pnr++] = strdup(qPrintable(parseLine.replace(QString::fromLatin1("//DIVE NR: "), QString::fromLatin1("")))); break; } } @@ -1573,7 +1573,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr) while ((parseLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) { if (parseLine.contains("//Hardware Version: ")) { params[pnr++] = strdup("hw"); - params[pnr++] = strdup(parseLine.replace(QString::fromLatin1("//Hardware Version: "), QString::fromLatin1("\"Seabear ")).trimmed().append("\"").toUtf8().data()); + params[pnr++] = strdup(qPrintable(parseLine.replace(QString::fromLatin1("//Hardware Version: "), QString::fromLatin1("\"Seabear ")).trimmed().append("\""))); break; } } @@ -1586,7 +1586,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr) while ((parseLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) { if (parseLine.contains("//Log interval: ")) { params[pnr++] = strdup("delta"); - params[pnr++] = strdup(parseLine.remove(QString::fromLatin1("//Log interval: ")).trimmed().remove(QString::fromLatin1(" s")).toUtf8().data()); + params[pnr++] = strdup(qPrintable(parseLine.remove(QString::fromLatin1("//Log interval: ")).trimmed().remove(QString::fromLatin1(" s")))); break; } } @@ -1601,7 +1601,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr) QString needle = "//Mode: "; if (parseLine.contains(needle)) { params[pnr++] = strdup("diveMode"); - params[pnr++] = strdup(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"").toUtf8().data()); + params[pnr++] = strdup(qPrintable(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\""))); } } f.seek(0); @@ -1614,7 +1614,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr) QString needle = "//Firmware Version: "; if (parseLine.contains(needle)) { params[pnr++] = strdup("Firmware"); - params[pnr++] = strdup(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"").toUtf8().data()); + params[pnr++] = strdup(qPrintable(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\""))); } } f.seek(0); @@ -1623,7 +1623,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr) QString needle = "//Serial number: "; if (parseLine.contains(needle)) { params[pnr++] = strdup("Serial"); - params[pnr++] = strdup(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"").toUtf8().data()); + params[pnr++] = strdup(qPrintable(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\""))); } } f.seek(0); @@ -1632,7 +1632,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr) QString needle = "//GF: "; if (parseLine.contains(needle)) { params[pnr++] = strdup("GF"); - params[pnr++] = strdup(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"").toUtf8().data()); + params[pnr++] = strdup(qPrintable(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\""))); } } f.seek(0); @@ -1735,7 +1735,7 @@ extern "C" void cache_insert(int tissue, int timestep, enum inertgas inertgas, d extern "C" void print_qt_versions() { - printf("%s\n", QStringLiteral("built with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()).toUtf8().data()); + printf("%s\n", qPrintable(QStringLiteral("built with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()))); } QMutex planLock; diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 04dcbe64d..dcb1f8382 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1914,9 +1914,9 @@ void DisplaySettingsObjectWrapper::setDivelistFont(const QString& value) s.beginGroup(group); s.setValue("divelist_font", value); - if (!subsurface_ignore_font(newValue.toUtf8().constData())) { + if (!subsurface_ignore_font(qPrintable(newValue))) { free((void *)prefs.divelist_font); - prefs.divelist_font = strdup(newValue.toUtf8().constData()); + prefs.divelist_font = strdup(qPrintable(newValue)); qApp->setFont(QFont(newValue)); } emit divelistFontChanged(newValue); @@ -2265,11 +2265,11 @@ void SettingsObjectWrapper::load() QString fontName = defaultFont.toString(); if (fontName.contains(",")) fontName = fontName.left(fontName.indexOf(",")); - if (subsurface_ignore_font(fontName.toUtf8().constData())) { + if (subsurface_ignore_font(qPrintable(fontName))) { defaultFont = QFont(prefs.divelist_font); } else { free((void *)prefs.divelist_font); - prefs.divelist_font = strdup(fontName.toUtf8().constData()); + prefs.divelist_font = strdup(qPrintable(fontName)); } defaultFont.setPointSizeF(prefs.font_size); qApp->setFont(defaultFont); diff --git a/desktop-widgets/configuredivecomputerdialog.cpp b/desktop-widgets/configuredivecomputerdialog.cpp index b615b453a..165f4d0d9 100644 --- a/desktop-widgets/configuredivecomputerdialog.cpp +++ b/desktop-widgets/configuredivecomputerdialog.cpp @@ -910,9 +910,9 @@ void ConfigureDiveComputerDialog::getDeviceData() #else QString device = ui.device->currentText(); #endif - device_data.devname = strdup(device.toUtf8().data()); - device_data.vendor = strdup(selected_vendor.toUtf8().data()); - device_data.product = strdup(selected_product.toUtf8().data()); + device_data.devname = strdup(qPrintable(device)); + device_data.vendor = strdup(qPrintable(selected_vendor)); + device_data.product = strdup(qPrintable(selected_product)); device_data.descriptor = descriptorLookup.value(selected_vendor + selected_product); device_data.deviceid = device_data.diveid = 0; @@ -1479,7 +1479,7 @@ void ConfigureDiveComputerDialog::pickLogFile() filename, tr("Log files") + " (*.log)"); if (!logFile.isEmpty()) { free(logfile_name); - logfile_name = strdup(logFile.toUtf8().data()); + logfile_name = strdup(qPrintable(logFile)); } } diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index b32493a5d..ce9f2e47d 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -949,7 +949,7 @@ void DiveListView::matchImagesToDives(QStringList fileNames) for_each_dive (j, dive) { if (!dive->selected) continue; - dive_create_picture(dive, copy_string(fileName.toUtf8().data()), shiftDialog.amount(), shiftDialog.matchAll()); + dive_create_picture(dive, copy_string(qPrintable(fileName)), shiftDialog.amount(), shiftDialog.matchAll()); } } diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp index 2af8d1b80..078e5d0d1 100644 --- a/desktop-widgets/divelogexportdialog.cpp +++ b/desktop-widgets/divelogexportdialog.cpp @@ -154,7 +154,7 @@ void DiveLogExportDialog::on_buttonBox_accepted() filename = QFileDialog::getSaveFileName(this, tr("Export world map"), lastDir, tr("HTML files") + " (*.html)"); if (!filename.isNull() && !filename.isEmpty()) - export_worldmap_HTML(filename.toUtf8().data(), ui->exportSelected->isChecked()); + export_worldmap_HTML(qPrintable(filename), ui->exportSelected->isChecked()); } else if (ui->exportSubsurfaceXML->isChecked()) { filename = QFileDialog::getSaveFileName(this, tr("Export Subsurface XML"), lastDir, tr("Subsurface files") + " (*.ssrf *.xml)"); @@ -167,11 +167,11 @@ void DiveLogExportDialog::on_buttonBox_accepted() } else if (ui->exportImageDepths->isChecked()) { filename = QFileDialog::getSaveFileName(this, tr("Save image depths"), lastDir); if (!filename.isNull() && !filename.isEmpty()) - export_depths(filename.toUtf8().data(), ui->exportSelected->isChecked()); + export_depths(qPrintable(filename), ui->exportSelected->isChecked()); } else if (ui->exportTeX->isChecked()) { filename = QFileDialog::getSaveFileName(this, tr("Export to TeX file"), lastDir, tr("TeX files") + " (*.tex)"); if (!filename.isNull() && !filename.isEmpty()) - export_TeX(filename.toUtf8().data(), ui->exportSelected->isChecked()); + export_TeX(qPrintable(filename), ui->exportSelected->isChecked()); } break; case 1: @@ -226,7 +226,7 @@ void DiveLogExportDialog::export_depths(const char *filename, const bool selecte f = subsurface_fopen(filename, "w+"); if (!f) { - report_error(tr("Can't open file %s").toUtf8().data(), filename); + report_error(qPrintable(tr("Can't open file %s")), filename); } else { flush_buffer(&buf, f); /*check for writing errors? */ fclose(f); @@ -325,7 +325,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o site ? put_format(&buf, "\\def\\gpslat{%f}\n", site->latitude.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslat{}\n"); site ? put_format(&buf, "\\def\\gpslon{%f}\n", site->longitude.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslon{}\n"); put_format(&buf, "\\def\\computer{%s}\n", dive->dc.model); - put_format(&buf, "\\def\\country{%s}\n", country.toUtf8().data()); + put_format(&buf, "\\def\\country{%s}\n", qPrintable(country)); put_format(&buf, "\\def\\time{%u:%02u}\n", FRACTION(dive->duration.seconds, 60)); put_format(&buf, "\n%% Dive Profile Details:\n"); @@ -337,8 +337,8 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o dive->meandepth.mm ? put_format(&buf, "\\def\\meandepth{%.1f\\depthunit}\n", get_depth_units(dive->meandepth.mm, NULL, &unit)) : put_format(&buf, "\\def\\meandepth{}\n"); put_format(&buf, "\\def\\type{%s}\n", dive->tag_list ? dive->tag_list->tag->name : ""); - put_format(&buf, "\\def\\viz{%s}\n", viz.toUtf8().data()); - put_format(&buf, "\\def\\rating{%s}\n", rating.toUtf8().data()); + put_format(&buf, "\\def\\viz{%s}\n", qPrintable(viz)); + put_format(&buf, "\\def\\rating{%s}\n", qPrintable(rating)); put_format(&buf, "\\def\\plot{\\includegraphics[width=9cm,height=4cm]{profile%d}}\n", dive->number); put_format(&buf, "\\def\\comment{%s}\n", dive->notes ? dive->notes : ""); put_format(&buf, "\\def\\buddy{%s}\n", dive->buddy ? dive->buddy : ""); @@ -408,7 +408,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o f = subsurface_fopen(filename, "w+"); if (!f) { - report_error(tr("Can't open file %s").toUtf8().data(), filename); + report_error(qPrintable(tr("Can't open file %s")), filename); } else { flush_buffer(&buf, f); /*check for writing errors? */ fclose(f); diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp index aa1359b9b..091de35e0 100644 --- a/desktop-widgets/divelogimportdialog.cpp +++ b/desktop-widgets/divelogimportdialog.cpp @@ -788,10 +788,10 @@ int DiveLogImportDialog::setup_csv_params(QStringList r, char **params, int pnr) params[pnr++] = intdup(ui->CSVUnits->currentIndex()); if (hw.length()) { params[pnr++] = strdup("hw"); - params[pnr++] = strdup(hw.toUtf8().data()); + params[pnr++] = strdup(qPrintable(hw)); } else if (ui->knownImports->currentText().length() > 0) { params[pnr++] = strdup("hw"); - params[pnr++] = strdup(ui->knownImports->currentText().prepend("\"").append("\"").toUtf8().data()); + params[pnr++] = strdup(qPrintable(ui->knownImports->currentText().prepend("\"").append("\""))); } params[pnr++] = NULL; @@ -850,7 +850,7 @@ void DiveLogImportDialog::on_buttonBox_accepted() for (int i = 0; i < fileNames.size(); ++i) { if (ui->knownImports->currentText() == "Seabear CSV") { - parse_seabear_log(fileNames[i].toUtf8().data()); + parse_seabear_log(qPrintable(fileNames[i])); } else { char *params[49]; @@ -866,8 +866,8 @@ void DiveLogImportDialog::on_buttonBox_accepted() params[pnr++] = strdup("1" + apdRe.cap(2).toLatin1()); } pnr = setup_csv_params(r, params, pnr); - parse_csv_file(fileNames[i].toUtf8().data(), params, pnr - 1, - specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv"); + parse_csv_file(qPrintable(fileNames[i]), params, pnr - 1, + specialCSV.contains(ui->knownImports->currentIndex()) ? qPrintable(CSVApps[ui->knownImports->currentIndex()].name) : "csv"); } } } else { @@ -927,7 +927,7 @@ void DiveLogImportDialog::on_buttonBox_accepted() params[pnr++] = intdup(r.indexOf(tr("Water temp."))); params[pnr++] = NULL; - parse_manual_file(fileNames[i].toUtf8().data(), params, pnr - 1); + parse_manual_file(qPrintable(fileNames[i]), params, pnr - 1); } else { char *params[51]; int pnr = 0; @@ -942,8 +942,8 @@ void DiveLogImportDialog::on_buttonBox_accepted() params[pnr++] = strdup("1" + apdRe.cap(2).toLatin1()); } pnr = setup_csv_params(r, params, pnr); - parse_csv_file(fileNames[i].toUtf8().data(), params, pnr - 1, - specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv"); + parse_csv_file(qPrintable(fileNames[i]), params, pnr - 1, + specialCSV.contains(ui->knownImports->currentIndex()) ? qPrintable(CSVApps[ui->knownImports->currentIndex()].name) : "csv"); } } } diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index ba1196826..c2bf7740e 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -297,7 +297,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() #endif if (data->vendor() == "Uemis") { char *colon; - char *devname = strdup(ui.device->currentText().toUtf8().data()); + char *devname = strdup(qPrintable(ui.device->currentText())); if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) { *(colon + 2) = '\0'; @@ -362,7 +362,7 @@ void DownloadFromDCWidget::pickLogFile() filename, tr("Log files") + " (*.log)"); if (!logFile.isEmpty()) { free(logfile_name); - logfile_name = copy_string(logFile.toUtf8().data()); + logfile_name = copy_string(qPrintable(logFile)); } } @@ -388,7 +388,7 @@ void DownloadFromDCWidget::pickDumpFile() filename, tr("Dump files") + " (*.bin)"); if (!dumpFile.isEmpty()) { free(dumpfile_name); - dumpfile_name = copy_string(dumpFile.toUtf8().data()); + dumpfile_name = copy_string(qPrintable(dumpFile)); } } diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index f968fd8fa..7818bc29e 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -158,7 +158,7 @@ void LocationInformationWidget::acceptChanges() { char *uiString; struct dive_site *currentDs; - uiString = copy_string(ui.diveSiteName->text().toUtf8().data()); + uiString = copy_string(qPrintable(ui.diveSiteName->text())); if (get_dive_site_by_uuid(displayed_dive_site.uuid) != NULL) { currentDs = get_dive_site_by_uuid(displayed_dive_site.uuid); } else { @@ -175,14 +175,14 @@ void LocationInformationWidget::acceptChanges() } else { free(uiString); } - uiString = copy_string(ui.diveSiteDescription->text().toUtf8().data()); + uiString = copy_string(qPrintable(ui.diveSiteDescription->text())); if (!same_string(uiString, currentDs->description)) { free(currentDs->description); currentDs->description = uiString; } else { free(uiString); } - uiString = copy_string(ui.diveSiteCountry->text().toUtf8().data()); + uiString = copy_string(qPrintable(ui.diveSiteCountry->text())); // if the user entered a different contriy, first update the taxonomy // for the displayed dive site; this below will get copied into the currentDs if (!same_string(uiString, taxonomy_get_country(&displayed_dive_site.taxonomy)) && @@ -193,7 +193,7 @@ void LocationInformationWidget::acceptChanges() // now update the currentDs (which we then later copy back ontop of displayed_dive_site copy_dive_site_taxonomy(&displayed_dive_site, currentDs); - uiString = copy_string(ui.diveSiteNotes->document()->toPlainText().toUtf8().data()); + uiString = copy_string(qPrintable(ui.diveSiteNotes->document()->toPlainText())); if (!same_string(uiString, currentDs->notes)) { free(currentDs->notes); currentDs->notes = uiString; diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index ac6289f34..990629154 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -623,12 +623,12 @@ void MainWindow::on_actionCloudstoragesave_triggered() information()->acceptChanges(); showProgressBar(); - int error = save_dives(filename.toUtf8().data()); + int error = save_dives(qPrintable(filename)); hideProgressBar(); if (error) return; - setCurrentFile(filename.toUtf8().data()); + setCurrentFile(qPrintable(filename)); mark_divelist_changed(false); } @@ -935,7 +935,7 @@ void MainWindow::updateVariations(QString variations) { QString notes = QString(displayed_dive.notes); free(displayed_dive.notes); - displayed_dive.notes = strdup(notes.replace("VARIATIONS", variations).toUtf8().data()); + displayed_dive.notes = strdup(qPrintable(notes.replace("VARIATIONS", variations))); plannerDetails()->divePlanOutput()->setHtml(displayed_dive.notes); } @@ -1683,10 +1683,10 @@ int MainWindow::file_save_as(void) if (information()->isEditing()) information()->acceptChanges(); - if (save_dives(filename.toUtf8().data())) + if (save_dives(qPrintable(filename))) return -1; - setCurrentFile(filename.toUtf8().data()); + setCurrentFile(qPrintable(filename)); mark_divelist_changed(false); addRecentFile(filename, true); return 0; diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp index bdeaf9138..871033ebb 100644 --- a/desktop-widgets/modeldelegates.cpp +++ b/desktop-widgets/modeldelegates.cpp @@ -324,7 +324,7 @@ void TankUseDelegate::setEditorData(QWidget * editor, const QModelIndex & index) { QComboBox *comboBox = qobject_cast(editor); QString indexString = index.data().toString(); - comboBox->setCurrentIndex(cylinderuse_from_text(indexString.toUtf8().data())); + comboBox->setCurrentIndex(cylinderuse_from_text(qPrintable(indexString))); } void TankUseDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index 446a3a468..48e30036a 100644 --- a/desktop-widgets/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -319,7 +319,7 @@ void ShiftImageTimesDialog::syncCameraClicked() scene->addPixmap(picture.scaled(ui.DCImage->size())); ui.DCImage->setScene(scene); - dcImageEpoch = picture_get_timestamp(fileNames.at(0).toUtf8().data()); + dcImageEpoch = picture_get_timestamp(qPrintable(fileNames.at(0))); QDateTime dcDateTime = QDateTime::fromTime_t(dcImageEpoch, Qt::UTC); ui.dcTime->setDateTime(dcDateTime); connect(ui.dcTime, SIGNAL(dateTimeChanged(const QDateTime &)), this, SLOT(dcDateTimeChanged(const QDateTime &))); @@ -393,11 +393,11 @@ void ShiftImageTimesDialog::updateInvalid() ui.invalidFilesText->append(tr("\nFiles with inappropriate date/time") + ":"); Q_FOREACH (const QString &fileName, fileNames) { - if (picture_check_valid(fileName.toUtf8().data(), m_amount)) + if (picture_check_valid(qPrintable(fileName), m_amount)) continue; // We've found invalid image - timestamp = picture_get_timestamp(fileName.toUtf8().data()); + timestamp = picture_get_timestamp(qPrintable(fileName)); time_first.setTime_t(timestamp + m_amount); if (timestamp == 0) ui.invalidFilesText->append(fileName + " - " + tr("No Exif date/time found")); diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp index 2db35b88a..d9ccb190c 100644 --- a/desktop-widgets/subsurfacewebservices.cpp +++ b/desktop-widgets/subsurfacewebservices.cpp @@ -335,7 +335,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) bool d_eq_f = (qDialogUid == qFileUid); if (!d_eq_f || s_eq_d) s.setValue("subsurface_webservice_uid", qDialogUid); - set_userid(qDialogUid.toLocal8Bit().data()); + set_userid(qPrintable(qDialogUid)); } s.sync(); hide(); diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 553eac77c..3a1f80cea 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -1082,7 +1082,7 @@ void MainTab::on_buddy_textChanged() if (editMode == IGNORE || acceptingEdit == true) return; - if (same_string(displayed_dive.buddy, ui.buddy->toPlainText().toUtf8().data())) + if (same_string(displayed_dive.buddy, qPrintable(ui.buddy->toPlainText()))) return; QStringList text_list = ui.buddy->toPlainText().split(",", QString::SkipEmptyParts); @@ -1090,7 +1090,7 @@ void MainTab::on_buddy_textChanged() text_list[i] = text_list[i].trimmed(); QString text = text_list.join(", "); free(displayed_dive.buddy); - displayed_dive.buddy = strdup(text.toUtf8().data()); + displayed_dive.buddy = strdup(qPrintable(text)); markChangedWidget(ui.buddy); } @@ -1099,7 +1099,7 @@ void MainTab::on_divemaster_textChanged() if (editMode == IGNORE || acceptingEdit == true) return; - if (same_string(displayed_dive.divemaster, ui.divemaster->toPlainText().toUtf8().data())) + if (same_string(displayed_dive.divemaster, qPrintable(ui.divemaster->toPlainText()))) return; QStringList text_list = ui.divemaster->toPlainText().split(",", QString::SkipEmptyParts); @@ -1107,7 +1107,7 @@ void MainTab::on_divemaster_textChanged() text_list[i] = text_list[i].trimmed(); QString text = text_list.join(", "); free(displayed_dive.divemaster); - displayed_dive.divemaster = strdup(text.toUtf8().data()); + displayed_dive.divemaster = strdup(qPrintable(text)); markChangedWidget(ui.divemaster); } @@ -1241,7 +1241,7 @@ void MainTab::saveTags() taglist_free(displayed_dive.tag_list); displayed_dive.tag_list = NULL; Q_FOREACH (const QString& tag, ui.tagWidget->getBlockStringList()) - taglist_add_tag(&displayed_dive.tag_list, tag.toUtf8().data()); + taglist_add_tag(&displayed_dive.tag_list, qPrintable(tag)); taglist_cleanup(&displayed_dive.tag_list); // figure out which tags were added and which tags were removed @@ -1352,7 +1352,7 @@ void MainTab::on_tagWidget_textChanged() return; taglist_get_tagstring(displayed_dive.tag_list, buf, 1024); - if (same_string(buf, ui.tagWidget->toPlainText().toUtf8().data())) + if (same_string(buf, qPrintable(ui.tagWidget->toPlainText()))) return; markChangedWidget(ui.tagWidget); @@ -1407,7 +1407,7 @@ void MainTab::on_suit_textChanged(const QString &text) if (editMode == IGNORE || acceptingEdit == true) return; free(displayed_dive.suit); - displayed_dive.suit = strdup(text.toUtf8().data()); + displayed_dive.suit = strdup(qPrintable(text)); markChangedWidget(ui.suit); } @@ -1416,18 +1416,18 @@ void MainTab::on_notes_textChanged() if (editMode == IGNORE || acceptingEdit == true) return; if (currentTrip) { - if (same_string(displayedTrip.notes, ui.notes->toPlainText().toUtf8().data())) + if (same_string(displayedTrip.notes, qPrintable(ui.notes->toPlainText()))) return; free(displayedTrip.notes); - displayedTrip.notes = strdup(ui.notes->toPlainText().toUtf8().data()); + displayedTrip.notes = strdup(qPrintable(ui.notes->toPlainText())); } else { - if (same_string(displayed_dive.notes, ui.notes->toPlainText().toUtf8().data())) + if (same_string(displayed_dive.notes, qPrintable(ui.notes->toPlainText()))) return; free(displayed_dive.notes); if (ui.notes->toHtml().indexOf("toHtml().toUtf8().data()); + displayed_dive.notes = strdup(qPrintable(ui.notes->toHtml())); else - displayed_dive.notes = strdup(ui.notes->toPlainText().toUtf8().data()); + displayed_dive.notes = strdup(qPrintable(ui.notes->toPlainText())); } markChangedWidget(ui.notes); } diff --git a/desktop-widgets/templatelayout.cpp b/desktop-widgets/templatelayout.cpp index 6c5a19fdd..9831bc934 100644 --- a/desktop-widgets/templatelayout.cpp +++ b/desktop-widgets/templatelayout.cpp @@ -250,7 +250,7 @@ void TemplateLayout::writeTemplate(QString template_name, QString grantlee_templ { QFile qfile(getPrintingTemplatePathUser() + QDir::separator() + template_name); if (qfile.open(QFile::ReadWrite | QFile::Text)) { - qfile.write(grantlee_template.toUtf8().data()); + qfile.write(qPrintable(grantlee_template)); qfile.resize(qfile.pos()); qfile.close(); } diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 9a8666a8c..7e11f8c2d 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -144,7 +144,7 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), connect(qobject_cast(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged); QString libdcLogFileName = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).first() + "/libdivecomputer.log"; - logfile_name = strdup(libdcLogFileName.toUtf8().data()); + logfile_name = strdup(qPrintable(libdcLogFileName)); #if defined(Q_OS_ANDROID) appLogFileName = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).first() + "/subsurface.log"; appLogFile.setFileName(appLogFileName); @@ -1640,7 +1640,7 @@ void writeToAppLogFile(QString logText) void QMLManager::writeToAppLogFile(QString logText) { if (appLogFileOpen) { - appLogFile.write(logText.toUtf8().data()); + appLogFile.write(qPrintable(logText)); appLogFile.flush(); } } diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index 8c8db6fd4..22c451e93 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -179,9 +179,9 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix) bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data); if (icd_data.dHe < 0) { put_format(&mb, "\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%", - tr("ICD").toUtf8().constData(), - tr("ΔHe").toUtf8().constData(), icd_data.dHe / 10.0, - tr("ΔN₂").toUtf8().constData(), icd_data.dN2 / 10.0, + qPrintable(tr("ICD")), + qPrintable(tr("ΔHe")), icd_data.dHe / 10.0, + qPrintable(tr("ΔN₂")), icd_data.dN2 / 10.0, icd ? ">" : "<", lrint(-icd_data.dHe / 5.0) / 10.0); name += QString::fromUtf8(mb.buffer, mb.len); free_buffer(&mb); diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index b1ba31620..b65e76743 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1582,7 +1582,7 @@ void ProfileWidget2::changeGas() gasChangeEvent = gasChangeEvent->next; } } - validate_gas(gas.toUtf8().constData(), &gasmix); + validate_gas(qPrintable(gas), &gasmix); QRegExp rx("\\(\\D*(\\d+)"); int tank; if (rx.indexIn(action->text()) > -1) { @@ -1667,8 +1667,8 @@ void ProfileWidget2::editName() // order is important! first update the current dive (by matching the unchanged event), // then update the displayed dive (as event is part of the events on displayed dive // and will be freed as part of changing the name! - update_event_name(current_dive, event, newName.toUtf8().data()); - update_event_name(&displayed_dive, event, newName.toUtf8().data()); + update_event_name(current_dive, event, qPrintable(newName)); + update_event_name(&displayed_dive, event, qPrintable(newName)); invalidate_dive_cache(current_dive); mark_divelist_changed(true); replot(); diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index e81a127a9..652f57dbf 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -320,7 +320,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in TankInfoModel *tanks = TankInfoModel::instance(); QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cyl->type.description); - cyl->type.size = string_to_volume(vString.toUtf8().data(), cyl->type.workingpressure); + cyl->type.size = string_to_volume(qPrintable(vString), cyl->type.workingpressure); mark_divelist_changed(true); if (!matches.isEmpty()) tanks->setData(tanks->index(matches.first().row(), TankInfoModel::ML), cyl->type.size.mliter); @@ -331,7 +331,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in if (CHANGED()) { TankInfoModel *tanks = TankInfoModel::instance(); QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cyl->type.description); - cyl->type.workingpressure = string_to_pressure(vString.toUtf8().data()); + cyl->type.workingpressure = string_to_pressure(qPrintable(vString)); if (!matches.isEmpty()) tanks->setData(tanks->index(matches.first().row(), TankInfoModel::BAR), cyl->type.workingpressure.mbar / 1000.0); changed = true; @@ -339,20 +339,20 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in break; case START: if (CHANGED()) { - cyl->start = string_to_pressure(vString.toUtf8().data()); + cyl->start = string_to_pressure(qPrintable(vString)); changed = true; } break; case END: if (CHANGED()) { - //&& (!cyl->start.mbar || string_to_pressure(vString.toUtf8().data()).mbar <= cyl->start.mbar)) { - cyl->end = string_to_pressure(vString.toUtf8().data()); + //&& (!cyl->start.mbar || string_to_pressure(qPrintable(vString)).mbar <= cyl->start.mbar)) { + cyl->end = string_to_pressure(qPrintable(vString)); changed = true; } break; case O2: if (CHANGED()) { - cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data()); + cyl->gasmix.o2 = string_to_fraction(qPrintable(vString)); // fO2 + fHe must not be greater than 1 if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000) cyl->gasmix.he.permille = 1000 - get_o2(&cyl->gasmix); @@ -369,7 +369,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in break; case HE: if (CHANGED()) { - cyl->gasmix.he = string_to_fraction(vString.toUtf8().data()); + cyl->gasmix.he = string_to_fraction(qPrintable(vString)); // fO2 + fHe must not be greater than 1 if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000) cyl->gasmix.o2.permille = 1000 - get_he(&cyl->gasmix); @@ -379,20 +379,20 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in break; case DEPTH: if (CHANGED()) { - cyl->depth = string_to_depth(vString.toUtf8().data()); + cyl->depth = string_to_depth(qPrintable(vString)); changed = true; } break; case MOD: if (CHANGED()) { - if (QString::compare(vString.toUtf8().data(), "*") == 0) { + if (QString::compare(qPrintable(vString), "*") == 0) { cyl->bestmix_o2 = true; // Calculate fO2 for max. depth cyl->gasmix.o2 = best_o2(displayed_dive.maxdepth, &displayed_dive); } else { cyl->bestmix_o2 = false; // Calculate fO2 for input depth - cyl->gasmix.o2 = best_o2(string_to_depth(vString.toUtf8().data()), &displayed_dive); + cyl->gasmix.o2 = best_o2(string_to_depth(qPrintable(vString)), &displayed_dive); } pressure_t modpO2; modpO2.mbar = prefs.decopo2; @@ -402,14 +402,14 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in break; case MND: if (CHANGED()) { - if (QString::compare(vString.toUtf8().data(), "*") == 0) { + if (QString::compare(qPrintable(vString), "*") == 0) { cyl->bestmix_he = true; // Calculate fO2 for max. depth cyl->gasmix.he = best_he(displayed_dive.maxdepth, &displayed_dive); } else { cyl->bestmix_he = false; // Calculate fHe for input depth - cyl->gasmix.he = best_he(string_to_depth(vString.toUtf8().data()), &displayed_dive); + cyl->gasmix.he = best_he(string_to_depth(qPrintable(vString)), &displayed_dive); } changed = true; } diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp index ef60001b4..6cb8cae07 100644 --- a/qt-models/divepicturemodel.cpp +++ b/qt-models/divepicturemodel.cpp @@ -161,7 +161,7 @@ void DivePictureModel::removePicture(const QString &fileUrl, bool last) int i; struct dive *dive; for_each_dive (i, dive) { - if (dive->selected && dive_remove_picture(dive, fileUrl.toUtf8().data())) + if (dive->selected && dive_remove_picture(dive, qPrintable(fileUrl))) break; } if (last) { diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 9af6833f0..831fe7842 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -160,7 +160,7 @@ void DivePlannerPointsModel::setupCylinders() } if (cylinder_none(&displayed_dive.cylinder[0])) { // roughly an AL80 - displayed_dive.cylinder[0].type.description = strdup(tr("unknown").toUtf8().constData()); + displayed_dive.cylinder[0].type.description = strdup(qPrintable(tr("unknown"))); displayed_dive.cylinder[0].type.size.mliter = 11100; displayed_dive.cylinder[0].type.workingpressure.mbar = 207000; } @@ -1063,9 +1063,9 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s restore_deco_state(save, &ds, false); char buf[200]; - sprintf(buf, ", %s: + %d:%02d /%s + %d:%02d /min", tr("Stop times").toUtf8().data(), - FRACTION(analyzeVariations(shallower, original, deeper, depth_units.toUtf8().data()), 60), depth_units.toUtf8().data(), - FRACTION(analyzeVariations(shorter, original, longer, time_units.toUtf8().data()), 60)); + sprintf(buf, ", %s: + %d:%02d /%s + %d:%02d /min", qPrintable(tr("Stop times")), + FRACTION(analyzeVariations(shallower, original, deeper, qPrintable(depth_units)), 60), qPrintable(depth_units), + FRACTION(analyzeVariations(shorter, original, longer, qPrintable(time_units)), 60)); emit variationsComputed(QString(buf)); #ifdef DEBUG_STOPVAR @@ -1123,7 +1123,7 @@ void DivePlannerPointsModel::createPlan(bool replanCopy) // Deal with line breaks oldnotes.replace("\n", "
"); oldnotes.append(displayed_dive.notes); - displayed_dive.notes = strdup(oldnotes.toUtf8().data()); + displayed_dive.notes = strdup(qPrintable(oldnotes)); // If we save as new create a copy of the dive here if (replanCopy) { struct dive *copy = alloc_dive(); diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 6eb94736d..89fd2853f 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -88,7 +88,7 @@ QVariant FilterModelBase::data(const QModelIndex &index, int role) const return checkState[index.row()] ? Qt::Checked : Qt::Unchecked; } else if (role == Qt::DisplayRole) { QString value = stringList()[index.row()]; - int count = countDives((index.row() == rowCount() - 1) ? "" : value.toUtf8().data()); + int count = countDives((index.row() == rowCount() - 1) ? "" : qPrintable(value)); return value + QString(" (%1)").arg(count); } return QVariant(); diff --git a/qt-models/messagehandlermodel.cpp b/qt-models/messagehandlermodel.cpp index d783a3da6..e14aaf89c 100644 --- a/qt-models/messagehandlermodel.cpp +++ b/qt-models/messagehandlermodel.cpp @@ -42,7 +42,7 @@ void MessageHandlerModel::addLog(QtMsgType type, const QString& message) beginInsertRows(QModelIndex(), rowCount(), rowCount()); m_data.append({message, type}); endInsertRows(); - INFO("%s", message.toUtf8().constData()); + INFO("%s", qPrintable(message)); #if defined (Q_OS_ANDROID) writeToAppLogFile(message); #endif diff --git a/qt-models/weightmodel.cpp b/qt-models/weightmodel.cpp index 66c8158c4..0c91c467d 100644 --- a/qt-models/weightmodel.cpp +++ b/qt-models/weightmodel.cpp @@ -114,14 +114,14 @@ bool WeightModel::setData(const QModelIndex &index, const QVariant &value, int r } } if (ws_info[i].name == NULL) // didn't find a match - ws->description = strdup(vString.toUtf8().constData()); + ws->description = strdup(qPrintable(vString)); changed = true; } } break; case WEIGHT: if (CHANGED()) { - ws->weight = string_to_weight(vString.toUtf8().data()); + ws->weight = string_to_weight(qPrintable(vString)); // now update the ws_info changed = true; WSInfoModel *wsim = WSInfoModel::instance(); diff --git a/smtk-import/smrtk2ssrfc_window.cpp b/smtk-import/smrtk2ssrfc_window.cpp index fffa170dc..344bd4642 100644 --- a/smtk-import/smrtk2ssrfc_window.cpp +++ b/smtk-import/smrtk2ssrfc_window.cpp @@ -92,7 +92,7 @@ void Smrtk2ssrfcWindow::on_importButton_clicked() ui->plainTextEdit->appendPlainText(error_buf); } ui->progressBar->setValue(inputFiles.size()); - save_dives_logic(outputFile.toUtf8().data(), false); + save_dives_logic(qPrintable(outputFile), false); ui->progressBar->setDisabled(true); } diff --git a/subsurface-desktop-main.cpp b/subsurface-desktop-main.cpp index c439179c8..765b3e943 100644 --- a/subsurface-desktop-main.cpp +++ b/subsurface-desktop-main.cpp @@ -56,7 +56,7 @@ int main(int argc, char **argv) if (a.isEmpty()) continue; if (a.at(0) == '-') { - parse_argument(a.toLocal8Bit().data()); + parse_argument(qPrintable(a)); continue; } if (imported) { @@ -142,7 +142,7 @@ void validateGL() if (!quickBackend.isEmpty()) { if (verbose) { qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "'QT_QUICK_BACKEND' is set to '%1'. " - "Skipping validation.").arg(quickBackend).toUtf8().data(); + "Skipping validation.").arg(quickBackend); } return; } @@ -160,7 +160,7 @@ void validateGL() goto exit; } if (verbose) - qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "created OpenGLContext.").toUtf8().data(); + qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "created OpenGLContext."); ctx.makeCurrent(&surface); func = ctx.functions(); if (!func) { @@ -168,7 +168,7 @@ void validateGL() goto exit; } if (verbose) - qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "obtained QOpenGLFunctions.").toUtf8().data(); + qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "obtained QOpenGLFunctions."); // detect version for legacy profiles verChar = (const char *)func->glGetString(GL_VERSION); if (verChar) { @@ -178,7 +178,7 @@ void validateGL() "Attempting to run with the available profile!\n" "If this fails try manually setting the environment variable\n" "'QT_QUICK_BACKEND' with the value of 'software'\n" - "before running Subsurface!\n").toUtf8().data(); + "before running Subsurface!\n"); return; } int min, maj; @@ -197,7 +197,7 @@ void validateGL() goto exit; } if (verbose) - qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "detected OpenGL version %1.%2.").arg(verMajor).arg(verMinor).toUtf8().data(); + qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "detected OpenGL version %1.%2.").arg(verMajor).arg(verMinor); if (verMajor * 10 + verMinor < 21) { // set 2.1 as the minimal version glError = "OpenGL 2.1 or later is required"; goto exit; @@ -211,10 +211,10 @@ exit: qWarning() << QStringLiteral(VALIDATE_GL_PREFIX "ERROR: %1.\n" "Cannot automatically fallback to a software renderer!\n" "Set the environment variable 'QT_QUICK_BACKEND' with the value of 'software'\n" - "before running Subsurface!\n").arg(glError).toUtf8().data(); + "before running Subsurface!\n").arg(glError); exit(0); #else - qWarning() << QStringLiteral(VALIDATE_GL_PREFIX "WARNING: %1. Using a software renderer!").arg(glError).toUtf8().data(); + qWarning() << QStringLiteral(VALIDATE_GL_PREFIX "WARNING: %1. Using a software renderer!").arg(glError); QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software); #endif } diff --git a/subsurface-mobile-main.cpp b/subsurface-mobile-main.cpp index 291a25125..f0199819f 100644 --- a/subsurface-mobile-main.cpp +++ b/subsurface-mobile-main.cpp @@ -34,7 +34,7 @@ int main(int argc, char **argv) for (i = 1; i < arguments.length(); i++) { QString a = arguments.at(i); if (!a.isEmpty() && a.at(0) == '-') { - parse_argument(a.toLocal8Bit().data()); + parse_argument(qPrintable(a)); continue; } } diff --git a/tests/testgitstorage.cpp b/tests/testgitstorage.cpp index 2edc8e305..d6a460edf 100644 --- a/tests/testgitstorage.cpp +++ b/tests/testgitstorage.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include // this is a local helper function in git-access.c @@ -19,6 +20,9 @@ extern "C" char *get_local_dir(const char *remote, const char *branch); void TestGitStorage::initTestCase() { + // Set UTF8 text codec as in real applications + QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106)); + // first, setup the preferences an proxy information copy_prefs(&default_prefs, &prefs); QCoreApplication::setOrganizationName("Subsurface"); @@ -39,7 +43,7 @@ void TestGitStorage::initTestCase() QString gitUrl(prefs.cloud_base_url); if (gitUrl.right(1) != "/") gitUrl += "/"; - prefs.cloud_git_url = strdup(qUtf8Printable(gitUrl + "git")); + prefs.cloud_git_url = strdup(qPrintable(gitUrl + "git")); s.endGroup(); prefs.cloud_storage_email_encoded = strdup("ssrftest@hohndel.org"); prefs.cloud_storage_password = strdup("geheim"); @@ -93,11 +97,11 @@ void TestGitStorage::testGitStorageLocal() QCOMPARE(QDir().mkdir(testDirName), true); QString repoNameRead = prefixRead + testDirName; QString repoNameWrite = prefixWrite + testDirName; - QCOMPARE(git_repository_init(&repo, qUtf8Printable(testDirName), false), 0); - QCOMPARE(save_dives(qUtf8Printable(repoNameWrite + "[test]")), 0); + QCOMPARE(git_repository_init(&repo, qPrintable(testDirName), false), 0); + QCOMPARE(save_dives(qPrintable(repoNameWrite + "[test]")), 0); QCOMPARE(save_dives("./SampleDivesV3.ssrf"), 0); clear_dive_file_data(); - QCOMPARE(parse_file(qUtf8Printable(repoNameRead + "[test]")), 0); + QCOMPARE(parse_file(qPrintable(repoNameRead + "[test]")), 0); QCOMPARE(save_dives("./SampleDivesV3viagit.ssrf"), 0); QFile org("./SampleDivesV3.ssrf"); org.open(QFile::ReadOnly); @@ -117,9 +121,9 @@ void TestGitStorage::testGitStorageCloud() // and repeat the same test as before with the local git storage QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]"); QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0); - QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); clear_dive_file_data(); - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); QCOMPARE(save_dives("./SampleDivesV3viacloud.ssrf"), 0); QFile org("./SampleDivesV3.ssrf"); org.open(QFile::ReadOnly); @@ -140,17 +144,17 @@ void TestGitStorage::testGitStorageCloudOfflineSync() QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org")); QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]"; // read the local repo from the previous test and add dive 10 - QCOMPARE(parse_file(qUtf8Printable(localCacheRepo)), 0); + QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0); QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml"), 0); // calling process_dive() sorts the table, but calling it with // is_imported == true causes it to try to update the window title... let's not do that process_dives(false, false); // now save only to the local cache but not to the remote server - QCOMPARE(save_dives(qUtf8Printable(localCacheRepo)), 0); + QCOMPARE(save_dives(qPrintable(localCacheRepo)), 0); QCOMPARE(save_dives("./SampleDivesV3plus10local.ssrf"), 0); clear_dive_file_data(); // open the cloud storage and compare - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); QCOMPARE(save_dives("./SampleDivesV3plus10viacloud.ssrf"), 0); QFile org("./SampleDivesV3plus10local.ssrf"); org.open(QFile::ReadOnly); @@ -162,13 +166,13 @@ void TestGitStorage::testGitStorageCloudOfflineSync() QString written = outS.readAll(); QCOMPARE(readin, written); // write back out to cloud storage, move away the local cache, open again and compare - QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); clear_dive_file_data(); QDir localCacheDirectory(localCacheDir); QDir localCacheDirectorySave(localCacheDir + "save"); QCOMPARE(localCacheDirectorySave.removeRecursively(), true); QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true); - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); QCOMPARE(save_dives("./SampleDivesV3plus10fromcloud.ssrf"), 0); org.close(); org.open(QFile::ReadOnly); @@ -189,17 +193,17 @@ void TestGitStorage::testGitStorageCloudMerge() QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]"); QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org")); QString localCacheRepoSave = localCacheDir + "save[ssrftest@hohndel.org]"; - QCOMPARE(parse_file(qUtf8Printable(localCacheRepoSave)), 0); + QCOMPARE(parse_file(qPrintable(localCacheRepoSave)), 0); QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0); process_dives(false, false); - QCOMPARE(save_dives(qUtf8Printable(localCacheRepoSave)), 0); + QCOMPARE(save_dives(qPrintable(localCacheRepoSave)), 0); clear_dive_file_data(); // now we open the cloud storage repo and add a different dive to it - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0); process_dives(false, false); - QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); clear_dive_file_data(); // now we move the saved local cache into place and try to open the cloud repo @@ -208,7 +212,7 @@ void TestGitStorage::testGitStorageCloudMerge() QCOMPARE(localCacheDirectory.removeRecursively(), true); QDir localCacheDirectorySave(localCacheDir + "save"); QCOMPARE(localCacheDirectory.rename(localCacheDir + "save", localCacheDir), true); - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); QCOMPARE(save_dives("./SampleDivesV3plus10-11-12-merged.ssrf"), 0); clear_dive_file_data(); QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf"), 0); @@ -236,12 +240,12 @@ void TestGitStorage::testGitStorageCloudMerge2() QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]"); QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org")); QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]"; - QCOMPARE(parse_file(qUtf8Printable(localCacheRepo)), 0); + QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0); process_dives(false, false); struct dive *dive = get_dive(1); delete_single_dive(1); QCOMPARE(save_dives("./SampleDivesMinus1.ssrf"), 0); - QCOMPARE(save_dives(qUtf8Printable(localCacheRepo)), 0); + QCOMPARE(save_dives(qPrintable(localCacheRepo)), 0); clear_dive_file_data(); // move the local cache away @@ -252,13 +256,13 @@ void TestGitStorage::testGitStorageCloudMerge2() QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true); } // now we open the cloud storage repo and modify that first dive - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); process_dives(false, false); dive = get_dive(1); QVERIFY(dive != NULL); free(dive->notes); dive->notes = strdup("These notes have been modified by TestGitStorage"); - QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); clear_dive_file_data(); // now we move the saved local cache into place and try to open the cloud repo @@ -268,9 +272,9 @@ void TestGitStorage::testGitStorageCloudMerge2() QCOMPARE(localCacheDirectory.removeRecursively(), true); QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true); - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); QCOMPARE(save_dives("./SampleDivesMinus1-merged.ssrf"), 0); - QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); QFile org("./SampleDivesMinus1-merged.ssrf"); org.open(QFile::ReadOnly); QFile out("./SampleDivesMinus1.ssrf"); @@ -292,7 +296,7 @@ void TestGitStorage::testGitStorageCloudMerge3() QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]"); QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org")); QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]"; - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); process_dives(false, false); struct dive *dive = get_dive(0); QVERIFY(dive != 0); @@ -301,10 +305,10 @@ void TestGitStorage::testGitStorageCloudMerge3() dive->notes = strdup("Create multi line dive notes\nLine 2\nLine 3\nLine 4\nLine 5\nThat should be enough"); dive = get_dive(2); dive->notes = strdup("Create multi line dive notes\nLine 2\nLine 3\nLine 4\nLine 5\nThat should be enough"); - QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); clear_dive_file_data(); - QCOMPARE(parse_file(qUtf8Printable(localCacheRepo)), 0); + QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0); process_dives(false, false); dive = get_dive(0); dive->notes = strdup("Create multi line dive notes\nDifferent line 2 and removed 3-5\n\nThat should be enough"); @@ -312,7 +316,7 @@ void TestGitStorage::testGitStorageCloudMerge3() dive->notes = strdup("Line 2\nLine 3\nLine 4\nLine 5"); // keep the middle, remove first and last"); dive = get_dive(2); dive->notes = strdup("single line dive notes"); - QCOMPARE(save_dives(qUtf8Printable(localCacheRepo)), 0); + QCOMPARE(save_dives(qPrintable(localCacheRepo)), 0); clear_dive_file_data(); // move the local cache away @@ -323,7 +327,7 @@ void TestGitStorage::testGitStorageCloudMerge3() QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true); } // now we open the cloud storage repo and modify those first dive notes differently - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); process_dives(false, false); dive = get_dive(0); dive->notes = strdup("Completely different dive notes\nBut also multi line"); @@ -331,7 +335,7 @@ void TestGitStorage::testGitStorageCloudMerge3() dive->notes = strdup("single line dive notes"); dive = get_dive(2); dive->notes = strdup("Line 2\nLine 3\nLine 4\nLine 5"); // keep the middle, remove first and last"); - QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0); clear_dive_file_data(); // now we move the saved local cache into place and try to open the cloud repo @@ -341,7 +345,7 @@ void TestGitStorage::testGitStorageCloudMerge3() QCOMPARE(localCacheDirectory.removeRecursively(), true); QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true); - QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0); + QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0); QCOMPARE(save_dives("./SampleDivesMerge3.ssrf"), 0); // we are not trying to compare this to a pre-determined result... what this test // checks is that there are no parsing errors with the merge