Bug 404599 - Fails to build with Qt < 5.8 (missing Qt::ISODateWithMs)
Summary: Fails to build with Qt < 5.8 (missing Qt::ISODateWithMs)
Status: CLOSED FIXED
Alias: None
Product: KDb
Classification: Frameworks and Libraries
Component: General (show other bugs)
Version: 3.2.0 Beta
Platform: unspecified Linux
: NOR normal
Target Milestone: 3.2
Assignee: Jarosław Staniek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-20 15:02 UTC by Wolfgang Bauer
Modified: 2023-09-03 20:40 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 3.2.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bauer 2019-02-20 15:02:32 UTC
When trying to build kdb-3.1.91 on openSUSE Leap 42.3 (with Qt 5.6.2), I got compiler errors like this one:
/home/abuild/rpmbuild/BUILD/kdb-3.1.91/src/tools/KDbUtils.cpp: In function 'QDateTime KDbUtils::stringToHackedQTime(const QString&)':
/home/abuild/rpmbuild/BUILD/kdb-3.1.91/src/tools/KDbUtils.cpp:147:59: error: 'ISODateWithMs' is not a member of 'Qt'
     return QDateTime(QDate(0, 1, 2), QTime::fromString(s, Qt::ISODateWithMs));

The reason is that Qt::ISODateWithMs is only available since Qt 5.8 it seems (according to https://bugreports.qt.io/browse/QTBUG-59235).

The specified minimum version in KDb's CMakeLists.txt is 5.4.0 though.

FWIW, replacing Qt:ISODateWithMs by Qt::ISODate in these files (using sed) made it build successfully (i.e. there were no other errors):
src/tools/KDbUtils.cpp
src/KDbField.cpp
src/KDbRecordEditBuffer.cpp
src/KDbTransaction.cpp
src/KDbRecordEditBuffer.cpp
src/KDbPreparedStatement.cpp
src/KDb.cpp
src/drivers/sqlite/SqlitePreparedStatement.cpp
src/drivers/mysql/MysqlPreparedStatement.cpp
src/drivers/sqlite/SqliteCursor.cpp
src/drivers/postgresql/PostgresqlPreparedStatement.cpp
src/drivers/mysql/MysqlKeywords.cpp
src/drivers/postgresql/PostgresqlCursor.cpp
Comment 1 Jarosław Staniek 2019-02-20 16:19:21 UTC
Thanks, fixing it, I was convinced it's in all Qt 5 but it's not: https://bugreports.qt.io/browse/QTBUG-59235
Comment 2 Jarosław Staniek 2019-03-08 21:15:17 UTC
Git commit d6291d605ac6e3355210512c0f1f039e9d5d5a74 by Jaroslaw Staniek.
Committed on 08/03/2019 at 21:15.
Pushed by staniek into branch '3.2'.

Fix build with Qt < 5.8 (missing Qt::ISODateWithMs)

Add some replacement implementation.
Add autotests.

FIXED-IN:3.2.0

M  +1    -0    autotests/tools/CMakeLists.txt
A  +163  -0    autotests/tools/UtilsTest.cpp     [License: LGPL (v2+)]
M  +9    -0    src/CMakeLists.txt
M  +2    -2    src/KDbField.cpp
M  +57   -1    src/tools/KDbUtils.cpp
M  +47   -1    src/tools/KDbUtils.h

https://commits.kde.org/kdb/d6291d605ac6e3355210512c0f1f039e9d5d5a74
Comment 3 Wolfgang Bauer 2019-03-09 11:28:26 UTC
It's not fixed yet.

https://commits.kde.org/kdb/d6291d605ac6e3355210512c0f1f039e9d5d5a74 adds new functions that should work also with older Qt versions, but the existing code is unchanged and still uses Qt::ISODateWithMs unconditionally.

Btw, "if(Qt5_VERSION VERSION_GREATER_EQUAL ${QT_ISODATEWITHMS_MIN_VERSION})" requires at least cmake 3.7, VERSION_GREATER_EQUAL didn't exist before.
It would probably be better to use VERSION_LESS instead (and swap the if/else branches), which would also work with older cmake versions.
Comment 4 Jarosław Staniek 2019-03-09 17:27:28 UTC
Thanks for the detailed notes, Wolfgang. It will be updated.

I've not used the code review feature (Phabricator) before pushing because we lack reviewers so there would be too big delays. So we have post-review, like this.
If you feel otherwise - that you're able to review things please share your opinions.
Comment 5 Jarosław Staniek 2019-03-09 21:02:51 UTC
Git commit fc9713255aee4535ac0b0f255a3457355c01f3ba by Jaroslaw Staniek.
Committed on 09/03/2019 at 21:02.
Pushed by staniek into branch '3.2'.

Port KDb to the Qt::ISODateWithMs fix

FIXED-IN:3.2.0

M  +4    -4    src/CMakeLists.txt
M  +2    -2    src/KDb.cpp
M  +4    -5    src/KDb.h
M  +2    -2    src/KDbField.cpp
M  +2    -2    src/drivers/postgresql/PostgresqlCursor.cpp
M  +1    -1    src/drivers/sqlite/SqliteCursor.cpp
M  +2    -2    src/drivers/sqlite/SqlitePreparedStatement.cpp

https://commits.kde.org/kdb/fc9713255aee4535ac0b0f255a3457355c01f3ba
Comment 6 Wolfgang Bauer 2019-03-12 14:40:46 UTC
*Nearly* fixed, but there is one error left:

/home/abuild/rpmbuild/BUILD/kdb-3.1.91/src/tools/KDbUtils.cpp: In function 'QDateTime KDbUtils::stringToHackedQTime(const QString&)':
/home/abuild/rpmbuild/BUILD/kdb-3.1.91/src/tools/KDbUtils.cpp:203:59: error: 'ISODateWithMs' is not a member of 'Qt'
     return QDateTime(QDate(0, 1, 2), QTime::fromString(s, Qt::ISODateWithMs));
                                                           ^
Changing that line to use the corresponding new function (KDbUtils::timeFromISODateStringWithMs(s) ) makes it compile successfully, so this is really the last one... ;-)
Comment 7 Jarosław Staniek 2019-03-12 17:15:36 UTC
Git commit 630853810bc1d048d7e580740b05cdb311830340 by Jaroslaw Staniek.
Committed on 12/03/2019 at 17:15.
Pushed by staniek into branch '3.2'.

Port KDbUtils::stringToHackedQTime the Qt::ISODateWithMs fix

FIXED-IN:3.2.0

M  +1    -3    src/tools/KDbUtils.cpp

https://commits.kde.org/kdb/630853810bc1d048d7e580740b05cdb311830340
Comment 8 Jarosław Staniek 2019-03-12 17:19:28 UTC
Thanks again Wolfgang!
Comment 9 Wolfgang Bauer 2019-03-12 18:41:19 UTC
I can confirm that the latest source in the 3.2 branch compiles fine now with Qt 5.6.2 (and also 5.5.1).