Skip to content

Commit

Permalink
prepare for Qt 6.8 deprecations (#1346)
Browse files Browse the repository at this point in the history
* fix Qt 6.8.0 deprecation warnings.

Also, the exif writer now prefers to establish a timestamp from
GPS_IFD_TAG_DATESTAMP/GPS_IFD_TAG_TIMESTAMP if they exist, as the
exif reader does.

* avoid installing *.debug_information modules

which appeared with 6.7.0

* centralize decision on lightweight time zones.

* correct sort order for includes, duplicates

* remove debug statement

* remove const from declaration.

* simplify lightweight timezone usage via

qt version depependent defined constants.

* fix for QTimeZone not a QLiteralType

* cleanup lightweight time constants.

* enhance exif offset test

* add missing reference

* fix test comment

* revert changes to exif writer regarding gps tags.

I beleive the original intent of the writer is to create the gps tags
from a waypoint.

* update qt modules

* qt 6.8 work

1. allow builds to succeed without webengine by default.  This is
needed by CI until aqt catches up.
2. macos minos change for 6.8
3. add macos 6.8.0 to CI, remove macos-12 build.

* avoid Wunused-const-variable

* add 6.8.0 to ci for windows
  • Loading branch information
tsteven4 authored Oct 8, 2024
1 parent 48cdbec commit bee3999
Show file tree
Hide file tree
Showing 31 changed files with 208 additions and 41 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ jobs:
fail-fast: false
matrix:
include:
- QT_VERSION: '6.2.4'
XCODE_VERSION: '13.4.1'
GENERATOR: 'Ninja'
RELEASE: false
os: macos-12
- QT_VERSION: '6.2.4'
XCODE_VERSION: '14.3.1'
GENERATOR: 'Ninja'
Expand All @@ -38,6 +33,11 @@ jobs:
GENERATOR: 'Ninja'
RELEASE: true
os: macos-14
- QT_VERSION: '6.8.0'
XCODE_VERSION: '16.0'
GENERATOR: 'Ninja'
RELEASE: false
os: macos-15

steps:
- name: Checkout repository
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ jobs:
RELEASE: true
GENERATOR: 'Ninja'
os: windows-latest
- QT_VERSION: '6.8.0'
ARCH: 'amd64'
HOST_ARCH: 'amd64'
COMPILER: 'msvc2022_64'
METHOD: 'aqt'
RELEASE: false
GENERATOR: 'Ninja'
os: windows-latest

steps:
- name: Checkout repository
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ if(${Qt6Core_VERSION} VERSION_LESS 6.2)
else()
message(STATUS "Using Qt6 version ${Qt6Core_VERSION}")
endif()
if(${Qt6Core_VERSION} VERSION_GREATER_EQUAL 6.5)
target_compile_definitions(gpsbabel PRIVATE LIGHTWEIGHT_TIMEZONES_SUPPORTED)
endif()

option(GPSBABEL_ENABLE_PCH "enable precompiled headers." ON)
if (GPSBABEL_ENABLE_PCH)
Expand Down
11 changes: 11 additions & 0 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include <QString> // for QString
#include <QStringView> // for QStringView
#include <QTextCodec> // for QTextCodec
#ifdef LIGHTWEIGHT_TIMEZONES_SUPPORTED
#include <QTimeZone> // for QTimeZone
#endif
#include <Qt> // for CaseInsensitive
#include <QtGlobal> // for QForeachContainer, qMakeForeachContainer, foreach, qint64

Expand Down Expand Up @@ -1042,4 +1045,12 @@ int color_to_bbggrr(const char* cname);
constexpr double unknown_alt = -99999999.0;
constexpr int unknown_color = -1;

#ifdef LIGHTWEIGHT_TIMEZONES_SUPPORTED
constexpr QTimeZone::Initialization QtLocalTime = QTimeZone::LocalTime;
constexpr QTimeZone::Initialization QtUTC = QTimeZone::UTC;
#else
constexpr Qt::TimeSpec QtLocalTime = Qt::LocalTime;
constexpr Qt::TimeSpec QtUTC = Qt::UTC;
#endif

#endif // DEFS_H_INCLUDED_
2 changes: 1 addition & 1 deletion dg-100.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Dg100Format::bintime2utc(int date, int time)
date /= 100;
int day = date;

return QDateTime(QDate(year, mon, day), QTime(hour, min, sec), Qt::UTC);
return QDateTime(QDate(year, mon, day), QTime(hour, min, sec), QtUTC);
}

void
Expand Down
9 changes: 8 additions & 1 deletion exif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
#include <QString> // for QString
#include <QTextCodec> // for QTextCodec
#include <QTime> // for QTime
#ifdef LIGHTWEIGHT_TIMEZONES_SUPPORTED
#include <QTimeZone> // for QTimeZone
#endif
#include <QVariant> // for QVariant
#include <QVector> // for QVector
#include <Qt> // for UTC, ISODate
Expand Down Expand Up @@ -728,7 +731,11 @@ ExifFormat::exif_get_exif_time(ExifApp* app) const
// Correct the date time by supplying the offset from UTC.
int offset_hours = match.captured(1).append(match.captured(2)).toInt();
int offset_mins = match.captured(1).append(match.captured(3)).toInt();
#ifdef LIGHTWEIGHT_TIMEZONES_SUPPORTED
res.setTimeZone(QTimeZone::fromSecondsAheadOfUtc(((offset_hours * 60) + offset_mins) * 60));
#else
res.setOffsetFromUtc(((offset_hours * 60) + offset_mins) * 60);
#endif
} else if (opt_offsettime) {
// Only warn for user supplied offsets.
// Offset tags may indicate the offset was unknown, e.g. " : ".
Expand Down Expand Up @@ -912,7 +919,7 @@ ExifFormat::exif_waypt_from_exif_app(ExifApp* app) const
}
}

gps_datetime = QDateTime(datestamp, timestamp, Qt::UTC);
gps_datetime = QDateTime(datestamp, timestamp, QtUTC);
if (gps_datetime.isValid()) {
if (global_opts.debug_level >= 3) {
printf(MYNAME "-GPSTimeStamp = %s\n", qPrintable(gps_datetime.toString(Qt::ISODateWithMs)));
Expand Down
2 changes: 1 addition & 1 deletion garmin_gpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ GarminGPIFormat::read_header()
if (GPI_DBG) {
time_t crdate = GPS_Math_Gtime_To_Utime(rdata->crdate);
warning("crdate = %lld (%s)\n", (long long) rdata->crdate,
CSTR(QDateTime::fromSecsSinceEpoch(crdate, Qt::UTC).toString(Qt::ISODate)));
CSTR(QDateTime::fromSecsSinceEpoch(crdate, QtUTC).toString(Qt::ISODate)));
}

(void) gbfgetint16(fin); /* 0 */
Expand Down
4 changes: 2 additions & 2 deletions gdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ constexpr unsigned int GDB_DBG_TRK = 4;

constexpr unsigned int GDB_DBG_WPTe = 8;
constexpr unsigned int GDB_DBG_RTEe = 16;
constexpr unsigned int GDB_DBG_TRKe = 32;
//constexpr unsigned int GDB_DBG_TRKe = 32;

//constexpr unsigned int GDB_DEBUG = (GDB_DBG_WPTe) /* | GDB_DBG_RTE) */;
//constexpr unsigned int GDB_DEBUG = 0xff;
Expand Down Expand Up @@ -1126,7 +1126,7 @@ GdbFormat::write_header()
* This is our "Watermark" to show this file was created by GPSbabel.
* The date/time used to be from CVS, and may be from git in the future.
*/
static const QDateTime gdb_release_dt = QDateTime(QDate(2011, 4, 14), QTime(1, 30, 1), Qt::UTC);
static const QDateTime gdb_release_dt = QDateTime(QDate(2011, 4, 14), QTime(1, 30, 1), QtUTC);
gdb_write_cstr(QStringLiteral("GPSBabel-%1").arg(gpsbabel_version));
gdb_write_cstr(gdb_release_dt.toString(u"MMM dd yyyy"));
gdb_write_cstr(gdb_release_dt.toString(u"HH:mm:ss"));
Expand Down
2 changes: 1 addition & 1 deletion globalsat_sport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ GlobalsatSportFormat::track_read()
if (timezn != nullptr) {
gpsDateTime = gpsbabel::DateTime(QDateTime(gpsDate, gpsTime, *timezn).toUTC());
} else {
gpsDateTime = gpsbabel::DateTime(QDateTime(gpsDate, gpsTime, Qt::LocalTime).toUTC());
gpsDateTime = gpsbabel::DateTime(QDateTime(gpsDate, gpsTime, QtLocalTime).toUTC());
}

int laps_in_package = header.gh_laprec.LapIndex - header.gh_ptrec.Index + 1;
Expand Down
2 changes: 1 addition & 1 deletion gpx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ xml_parse_time(const QString& dateTimeString)
if (res > 0) {
QDate date(year, mon, mday);
QTime time(hour, min, sec);
dt = QDateTime(date, time, Qt::UTC);
dt = QDateTime(date, time, QtUTC);

// Fractional part of time.
if (fsec) {
Expand Down
8 changes: 5 additions & 3 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ if(NOT UNIX OR APPLE)
endif()

# Find the QtCore library
find_package(Qt6 REQUIRED COMPONENTS Core Gui Network SerialPort Widgets Xml)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Network SerialPort Widgets Xml OPTIONAL_COMPONENTS WebEngineWidgets WebChannel)
list(APPEND QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Network Qt6::SerialPort Qt6::Widgets Qt6::Xml)
if(${Qt6Core_VERSION} VERSION_LESS 6.2)
message(FATAL_ERROR "Qt version ${Qt6Core_VERSION} found, but version 6.2 or newer is required.")
else()
message(STATUS "Using Qt6 version ${Qt6Core_VERSION}")
endif()

option(GPSBABEL_MAPPREVIEW "enable map preview." ON)
cmake_dependent_option(GPSBABEL_MAPPREVIEW "enable map preview." ON "Qt6WebEngineWidgets_FOUND;Qt6WebChannel_FOUND" OFF)
if (GPSBABEL_MAPPREVIEW)
find_package(Qt6 REQUIRED COMPONENTS WebEngineWidgets WebChannel)
list(APPEND QT_LIBRARIES Qt6::WebEngineWidgets Qt6::WebChannel)
else()
if (NOT Qt6WebEngineWidgets_FOUND OR NOT Qt6WebChannel_FOUND)
message(WARNING "Optional components Qt6 WebEngineWidgets and/or Qt6 WebChannel not found, MAPPREVIEW is not available.")
endif()
target_compile_definitions(gpsbabelfe PRIVATE DISABLE_MAPPREVIEW)
endif()

Expand Down
27 changes: 25 additions & 2 deletions gui/filterwidgets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include <QEvent> // for QEvent, QEvent::LocaleChange
#include <QLabel> // for QLabel
#include <QRadioButton> // for QRadioButton
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
#include <QTimeZone> // for QTimeZone
#endif
#include <Qt> // for LocalTime, UTC


Expand Down Expand Up @@ -75,17 +78,27 @@ TrackWidget::TrackWidget(QWidget* parent, TrackFilterData& tfd): FilterWidget(pa
ui.startEdit->setDisplayFormat("dd MMM yyyy hh:mm:ss AP");
ui.stopEdit->setDisplayFormat("dd MMM yyyy hh:mm:ss AP");

assert(tfd.startTime.timeSpec() == tfd.stopTime.timeSpec());
assert((tfd.startTime.timeSpec() == Qt::UTC) || (tfd.startTime.timeSpec() == Qt::LocalTime));
// Qt5 QDateTimeEdit::setDateTime ignored the passed QDateTime::timeSpec.
// Qt6 QDateTimeEdit::setDateTime will convert the passed QDateTime if the passed
// QDateTime::timeSpec doesn't match QDateTimeEdit::timeSpec.
// If the two timeSpecs match Qt5 and Qt6 behave the same.
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
assert(tfd.startTime.timeZone() == tfd.stopTime.timeZone());
assert((tfd.startTime.timeZone() == QTimeZone::UTC) || (tfd.startTime.timeZone() == QTimeZone::LocalTime));
ui.startEdit->setTimeZone(tfd.startTime.timeZone());
ui.stopEdit->setTimeZone(tfd.stopTime.timeZone());
// Make sure the initial state of the localTime and utc radio buttons
// is in agreement with the startTime::timeSpec and stopTime::timeSpec.
tfd.localTime = tfd.startTime.timeZone() == QTimeZone::LocalTime;
#else
assert(tfd.startTime.timeSpec() == tfd.stopTime.timeSpec());
assert((tfd.startTime.timeSpec() == Qt::UTC) || (tfd.startTime.timeSpec() == Qt::LocalTime));
ui.startEdit->setTimeSpec(tfd.startTime.timeSpec());
ui.stopEdit->setTimeSpec(tfd.stopTime.timeSpec());
// Make sure the initial state of the localTime and utc radio buttons
// is in agreement with the startTime::timeSpec and stopTime::timeSpec.
tfd.localTime = tfd.startTime.timeSpec() == Qt::LocalTime;
#endif
tfd.utc = !tfd.localTime;

// Collect the data fields.
Expand Down Expand Up @@ -188,11 +201,21 @@ void TrackWidget::splitDistanceX()
void TrackWidget::TZX()
{
if (ui.localTime->isChecked()) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
ui.startEdit->setTimeZone(QTimeZone::LocalTime);
ui.stopEdit->setTimeZone(QTimeZone::LocalTime);
#else
ui.startEdit->setTimeSpec(Qt::LocalTime);
ui.stopEdit->setTimeSpec(Qt::LocalTime);
#endif
} else {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
ui.startEdit->setTimeZone(QTimeZone::UTC);
ui.stopEdit->setTimeZone(QTimeZone::UTC);
#else
ui.startEdit->setTimeSpec(Qt::UTC);
ui.stopEdit->setTimeSpec(Qt::UTC);
#endif
}
// Force update of Edit displays, so the displayed
// datetimes are in sync with the specified time spec.
Expand Down
16 changes: 11 additions & 5 deletions gui/upgrade.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,20 @@ void UpgradeCheck::httpRequestFinished(QNetworkReply* reply)
QString oresponse(reply->readAll());

QDomDocument document;
int line = -1;
QString error_text;
// This shouldn't ever be seen by a user.
if (!document.setContent(oresponse, &error_text, &line)) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
if (auto result = document.setContent(oresponse); !result) {
#else
struct {
int errorLine{-1};
QString errorMessage;
} result;
if (!document.setContent(oresponse, &result.errorMessage, &result.errorLine)) {
#endif
QMessageBox::critical(nullptr, tr("Error"),
tr("Invalid return data at line %1: %2.")
.arg(line)
.arg(error_text));
.arg(result.errorLine)
.arg(result.errorMessage));
babelData_.upgradeErrors_++;
replyId_ = nullptr;
reply->deleteLater();
Expand Down
4 changes: 2 additions & 2 deletions igc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void IgcFormat::TaskRecordReader::igc_task_rec(const char* rec)
} else {
year += 1900;
}
creation = QDateTime(QDate(year, month, day), QTime(hour, minute, second), Qt::UTC);
creation = QDateTime(QDate(year, month, day), QTime(hour, minute, second), QtUTC);
if (!creation.isValid()) {
fatal(MYNAME ": bad date time\n%s\n", rec);
}
Expand Down Expand Up @@ -398,7 +398,7 @@ void IgcFormat::read()
pres_wpt->fs.FsChainAdd(fsdata);
}

pres_wpt->SetCreationTime(QDateTime(date, tod, Qt::UTC));
pres_wpt->SetCreationTime(QDateTime(date, tod, QtUTC));

// Add the waypoint to the pressure altitude track
if (pres_alt) {
Expand Down
2 changes: 1 addition & 1 deletion lowranceusr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ LowranceusrFormat::lowranceusr4_writestr(const QString& buf, gbfile* file, int b
gpsbabel::DateTime
LowranceusrFormat::lowranceusr4_get_timestamp(unsigned int jd_number, unsigned int msecs)
{
QDateTime qdt = QDateTime(QDate::fromJulianDay(jd_number), QTime(0, 0, 0), Qt::UTC).addMSecs(msecs);
QDateTime qdt = QDateTime(QDate::fromJulianDay(jd_number), QTime(0, 0, 0), QtUTC).addMSecs(msecs);
return qdt;
}

Expand Down
2 changes: 1 addition & 1 deletion mtk_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ int MtkLoggerBase::csv_line(gbfile* csvFile, int idx, unsigned long bmask, data_
, (itm->rcr&0x0004)?"D":"", (itm->rcr&0x0008)?"B":"");

if (bmask & (1U<<UTC)) {
QDateTime dt = QDateTime::fromSecsSinceEpoch(itm->timestamp, Qt::UTC);
QDateTime dt = QDateTime::fromSecsSinceEpoch(itm->timestamp, QtUTC);
dt = dt.addMSecs(itm->timestamp_ms);

QString timestamp = dt.toUTC().toString(u"yyyy/MM/dd,hh:mm:ss.zzz");
Expand Down
10 changes: 5 additions & 5 deletions nmea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,14 @@ void
NmeaFormat::nmea_set_waypoint_time(Waypoint* wpt, QDateTime* prev, const QDate& date, const QTime& time)
{
if (date.isValid()) {
wpt->SetCreationTime(QDateTime(date, time, Qt::UTC));
wpt->SetCreationTime(QDateTime(date, time, QtUTC));
if (wpt->wpt_flags.fmt_use != 0) {
wpt->wpt_flags.fmt_use = 0;
without_date--;
}
*prev = wpt->GetCreationTime();
} else if (prev->date().isValid()) {
wpt->SetCreationTime(QDateTime(prev->date(), time, Qt::UTC));
wpt->SetCreationTime(QDateTime(prev->date(), time, QtUTC));
if (*prev > wpt->creation_time) {
/* go over midnight ? */
wpt->creation_time = wpt->creation_time.addDays(1);
Expand All @@ -342,7 +342,7 @@ NmeaFormat::nmea_set_waypoint_time(Waypoint* wpt, QDateTime* prev, const QDate&
}
*prev = wpt->GetCreationTime();
} else {
wpt->SetCreationTime(QDateTime(QDate(), time, Qt::UTC));
wpt->SetCreationTime(QDateTime(QDate(), time, QtUTC));
if (wpt->wpt_flags.fmt_use == 0) {
wpt->wpt_flags.fmt_use = 1;
without_date++;
Expand Down Expand Up @@ -639,7 +639,7 @@ NmeaFormat::gpzda_parse(const QString& ibuf)

// The prev_datetime data member might be used by
// nmea_fix_timestamps and nmea_set_waypoint_time.
prev_datetime = QDateTime(date, time, Qt::UTC);
prev_datetime = QDateTime(date, time, QtUTC);
}
}

Expand Down Expand Up @@ -839,7 +839,7 @@ NmeaFormat::nmea_fix_timestamps(route_head* track)
return;
}

QDateTime prev = QDateTime(opt_tm, QTime(0, 0), Qt::UTC);
QDateTime prev = QDateTime(opt_tm, QTime(0, 0), QtUTC);

foreach (Waypoint* wpt, track->waypoint_list) {

Expand Down
Binary file modified reference/ricoh-rdc5300.jpg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions reference/ricoh-rdc5300_offset.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
No,Latitude,Longitude,Name,Speed,utc_d,utc_t
1,44.315150,15.265690,"ricoh-rdc5300",0.00,2000/05/31,22:50:40
Binary file added reference/ricoh-rdc5300_offsettime.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added reference/ricoh-rdc5300_offsettime.jpg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions skytraq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ SkytraqBase::gpstime_to_qdatetime(int week, int sec) const
int override = xstrtoi(opt_gps_utc_offset, nullptr, 10);
if (override) {
gps_timet -= override;
return QDateTime::fromSecsSinceEpoch(gps_timet, Qt::UTC);
return QDateTime::fromSecsSinceEpoch(gps_timet, QtUTC);
}

/* leap second compensation: */
Expand All @@ -557,7 +557,7 @@ SkytraqBase::gpstime_to_qdatetime(int week, int sec) const
// Future: Consult http://maia.usno.navy.mil/ser7/tai-utc.dat
// use http://www.stevegs.com/utils/jd_calc/ for Julian to UNIX sec

return QDateTime::fromSecsSinceEpoch(gps_timet, Qt::UTC);
return QDateTime::fromSecsSinceEpoch(gps_timet, QtUTC);
}

void
Expand Down
7 changes: 7 additions & 0 deletions src/core/datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include <QtGlobal>
#include <QDateTime>
#include <QString>
#ifdef LIGHTWEIGHT_TIMEZONES_SUPPORTED
#include <QTimeZone>
#endif

// As this code began in C, we have several hundred places that set and
// read creation_time as a time_t. Provide some operator overloads to make
Expand All @@ -54,7 +57,11 @@ class DateTime : public QDateTime
// Qt::LocalTime compared to Qt::UTC on ubuntu bionic.
// Note that these conversions can be required if the Qt::TimeSpec is
// set to Qt:LocalTime after construction.
#ifdef LIGHTWEIGHT_TIMEZONES_SUPPORTED
DateTime() : QDateTime(QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC))
#else
DateTime() : QDateTime(QDateTime::fromMSecsSinceEpoch(0, Qt::UTC))
#endif
{
}

Expand Down
Loading

0 comments on commit bee3999

Please sign in to comment.