From 8c0fd2706a06bafbd0b01281f34e22dbeaf7ae49 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 10 Jul 2023 22:27:20 +0200 Subject: [PATCH] Qt6: fix possible build failure * add CMake definitions 'QT_NO_KEYWORDS' to avoid the Qt definition of the 'slots' macro that causes a conflict when including Python headers * drop QT3_SUPPORT define --- cMake/FreeCAD_Helpers/SetupQt.cmake | 2 ++ src/FCConfig.h | 10 +++++++--- src/Gui/QSint/actionpanel/actionbox.cpp | 2 +- src/Gui/QSint/actionpanel/actionpanel.cpp | 2 +- src/Gui/Quarter/ContextMenu.cpp | 6 +++--- src/Gui/Quarter/EventFilter.cpp | 6 +++--- src/Gui/Quarter/QuarterWidget.cpp | 2 +- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cMake/FreeCAD_Helpers/SetupQt.cmake b/cMake/FreeCAD_Helpers/SetupQt.cmake index f710bb1185..70d2154fa4 100644 --- a/cMake/FreeCAD_Helpers/SetupQt.cmake +++ b/cMake/FreeCAD_Helpers/SetupQt.cmake @@ -38,6 +38,8 @@ set(CMAKE_AUTOMOC TRUE) set(CMAKE_AUTOUIC TRUE) set(QtCore_MOC_EXECUTABLE ${Qt${FREECAD_QT_MAJOR_VERSION}Core_MOC_EXECUTABLE}) +add_definitions(-DQT_NO_KEYWORDS) + message(STATUS "Set up to compile with Qt ${Qt${FREECAD_QT_MAJOR_VERSION}Core_VERSION}") # In Qt 5.15 they added more generic names for these functions: "backport" those new names diff --git a/src/FCConfig.h b/src/FCConfig.h index c47ea3eb78..9ddce84b52 100644 --- a/src/FCConfig.h +++ b/src/FCConfig.h @@ -230,9 +230,13 @@ typedef unsigned __int64 uint64_t; // Qt // Make sure to explicitly use the correct conversion -#define QT_NO_CAST_FROM_ASCII -#undef QT3_SUPPORT -#define QT_NO_KEYWORDS +#ifndef QT_NO_CAST_FROM_ASCII +# define QT_NO_CAST_FROM_ASCII +#endif + +#ifndef QT_NO_KEYWORDS +# define QT_NO_KEYWORDS +#endif #if defined (FC_OS_WIN32) || defined(FC_OS_CYGWIN) # ifndef QT_DLL diff --git a/src/Gui/QSint/actionpanel/actionbox.cpp b/src/Gui/QSint/actionpanel/actionbox.cpp index bc9d582c79..88f6665f3c 100644 --- a/src/Gui/QSint/actionpanel/actionbox.cpp +++ b/src/Gui/QSint/actionpanel/actionbox.cpp @@ -148,7 +148,7 @@ QList ActionBox::createItems(QList actions) QLayout *l = createHBoxLayout(); - foreach (QAction *action, actions) { + Q_FOREACH (QAction *action, actions) { ActionLabel *act = createItem(action, l); if (act) list.append(act); diff --git a/src/Gui/QSint/actionpanel/actionpanel.cpp b/src/Gui/QSint/actionpanel/actionpanel.cpp index c376926271..3b31e3dc38 100644 --- a/src/Gui/QSint/actionpanel/actionpanel.cpp +++ b/src/Gui/QSint/actionpanel/actionpanel.cpp @@ -39,7 +39,7 @@ void ActionPanel::setScheme(ActionPanelScheme *scheme) // set scheme for children QObjectList list(children()); - foreach(QObject *obj, list) { + Q_FOREACH(QObject *obj, list) { if (dynamic_cast(obj)) { ((ActionGroup*)obj)->setScheme(scheme); continue; diff --git a/src/Gui/Quarter/ContextMenu.cpp b/src/Gui/Quarter/ContextMenu.cpp index 9cd4e1becd..8ad8eab991 100644 --- a/src/Gui/Quarter/ContextMenu.cpp +++ b/src/Gui/Quarter/ContextMenu.cpp @@ -60,7 +60,7 @@ ContextMenu::ContextMenu(QuarterWidget * quarterwidget) QActionGroup * stereomodegroup = nullptr; QActionGroup * transparencytypegroup = nullptr; - foreach (QAction * action, quarterwidget->renderModeActions()) { + Q_FOREACH (QAction * action, quarterwidget->renderModeActions()) { if (!rendermodegroup) { rendermodegroup = action->actionGroup(); } else { @@ -73,7 +73,7 @@ ContextMenu::ContextMenu(QuarterWidget * quarterwidget) rendermenu->addAction(action); } - foreach (QAction * action, quarterwidget->stereoModeActions()) { + Q_FOREACH (QAction * action, quarterwidget->stereoModeActions()) { if (!stereomodegroup) { stereomodegroup = action->actionGroup(); } else { @@ -86,7 +86,7 @@ ContextMenu::ContextMenu(QuarterWidget * quarterwidget) stereomenu->addAction(action); } - foreach (QAction * action, quarterwidget->transparencyTypeActions()) { + Q_FOREACH (QAction * action, quarterwidget->transparencyTypeActions()) { if (!transparencytypegroup) { transparencytypegroup = action->actionGroup(); } else { diff --git a/src/Gui/Quarter/EventFilter.cpp b/src/Gui/Quarter/EventFilter.cpp index 51a72a7c60..5f381f1229 100644 --- a/src/Gui/Quarter/EventFilter.cpp +++ b/src/Gui/Quarter/EventFilter.cpp @@ -58,7 +58,7 @@ public: this->windowsize = SbVec2s(event->size().width(), event->size().height()); - foreach(InputDevice * device, this->devices) { + Q_FOREACH(InputDevice * device, this->devices) { device->setWindowSize(this->windowsize); } } @@ -75,7 +75,7 @@ public: SbVec2s mousepos(event->pos().x(), this->windowsize[1] - event->pos().y() - 1); // the following corrects for high-dpi displays (e.g. mac retina) mousepos *= quarterwidget->devicePixelRatio(); - foreach(InputDevice * device, this->devices) { + Q_FOREACH(InputDevice * device, this->devices) { device->setMousePosition(mousepos); } } @@ -162,7 +162,7 @@ EventFilter::eventFilter(QObject * obj, QEvent * qevent) // translate QEvent into SoEvent and see if it is handled by scene // graph - foreach(InputDevice * device, PRIVATE(this)->devices) { + Q_FOREACH(InputDevice * device, PRIVATE(this)->devices) { const SoEvent * soevent = device->translateEvent(qevent); if (soevent && PRIVATE(this)->quarterwidget->processSoEvent(soevent)) { return true; diff --git a/src/Gui/Quarter/QuarterWidget.cpp b/src/Gui/Quarter/QuarterWidget.cpp index f43c168712..26e12dce72 100644 --- a/src/Gui/Quarter/QuarterWidget.cpp +++ b/src/Gui/Quarter/QuarterWidget.cpp @@ -828,7 +828,7 @@ QuarterWidget::updateDevicePixelRatio() { } if(PRIVATE(this)->device_pixel_ratio != dev_pix_ratio) { PRIVATE(this)->device_pixel_ratio = dev_pix_ratio; - emit devicePixelRatioChanged(dev_pix_ratio); + Q_EMIT devicePixelRatioChanged(dev_pix_ratio); return true; } return false;