Commit 50341875 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

Fix build with Qt6

QT_BEGIN/END_HEADER has been defined to nothing for a long time:
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=1e33f30f75dea6481c85b5f636f1136eb1a3da15

In Qt6 use const in qobject_cast<const QObject*>, otherwise the build fails with some
interesting errors (note that the build fails in Qt5 if I add const in
qobject_cast< QObject*>...):
/usr/include/qt6/QtCore/qobjectdefs.h: In instantiation of ‘struct QtPrivate::HasQ_OBJECT_Macro<Akonadi::GidExtractorInterface>’:
/usr/include/qt6/QtCore/qobject.h:481:58:   required from ‘T qobject_cast(const QObject*) [with T = Akonadi::GidExtractorInterface*]’
/home/ahmad/kdesrc/kde/src/kde/pim/akonadi/src/core/gidextractor.cpp:18:87:   required from here
/usr/include/qt6/QtCore/qobjectdefs.h:486:37: error: ‘qt_metacall’ is not a member of ‘Akonadi::GidExtractorInterface’
  486 |         enum { Value =  sizeof(test(&Object::qt_metacall)) == sizeof(int) };
      |                                     ^~~~~~~~~~~~~~~~~~~~
/usr/include/qt6/QtCore/qobject.h: In instantiation of ‘T qobject_cast(const QObject*) [with T = Akonadi::GidExtractorInterface*]’:
/home/ahmad/kdesrc/kde/src/kde/pim/akonadi/src/core/gidextractor.cpp:18:87:   required from here
/usr/include/qt6/QtCore/qobject.h:481:58: error: static assertion failed: qobject_cast requires the type to have a Q_OBJECT macro
  481 |     static_assert(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
      |                                                          ^~~~~
/usr/include/qt6/QtCore/qobject.h:481:58: note: ‘QtPrivate::HasQ_OBJECT_Macro<Akonadi::GidExtractorInterface>::Value’ evaluates to false
/usr/include/qt6/QtCore/qobject.h:483:53: error: ‘staticMetaObject’ is not a member of ‘ObjType’ {aka ‘Akonadi::GidExtractorInterface’}
  483 |     return static_cast<T>(ObjType::staticMetaObject.cast(object));
parent d279087d
......@@ -15,7 +15,11 @@ QString GidExtractor::extractGid(const Item &item)
{
const QObject *object = TypePluginLoader::objectForMimeTypeAndClass(item.mimeType(), item.availablePayloadMetaTypeIds());
if (object) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const GidExtractorInterface *extractor = qobject_cast<const GidExtractorInterface *>(object);
#else
const GidExtractorInterface *extractor = qobject_cast<GidExtractorInterface *>(object);
#endif
if (extractor) {
return extractor->extractGid(item);
}
......
......@@ -597,7 +597,11 @@ bool QSQLiteDriver::open(const QString &db, const QString &, const QString &, co
for (const QString &option : opts) {
if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) {
bool ok;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const int nt = QStringView(option).mid(21).toInt(&ok);
#else
const int nt = option.midRef(21).toInt(&ok);
#endif
if (ok) {
timeout = nt;
}
......
......@@ -17,8 +17,6 @@
struct sqlite3;
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QSQLiteDriverPrivate;
class QSQLiteResultPrivate;
......@@ -52,6 +50,3 @@ private:
};
QT_END_NAMESPACE
QT_END_HEADER
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment