Cast NativeResourceForIntegrationFunction via QFunctionPointer

To fix warnings with Xcode 16.3:

/Users/torarne/dev/qt/qtbase/src/widgets/widgets/qtabbar.cpp:117:6: warning: cast from 'QPlatformNativeInterface::NativeResourceForIntegrationFunction' (aka 'void *(*)()') to 'SetContentBorderAreaEnabledFunction' (aka 'void (*)(QWindow *, unsigned long long, bool)') converts to incompatible function type [-Wcast-function-type-mismatch]
  117 |     (reinterpret_cast<SetContentBorderAreaEnabledFunction>(function))(q->window()->windowHandle(), identifier, q->isVisible());
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Pick-to: 6.9 6.8
Change-Id: Ie7b5ace64c1aad5f970bc1a23e59c5724fcd92b5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Tor Arne Vestbø 2025-03-27 11:12:31 +01:00
parent 002badc3ab
commit cf8f9580da
6 changed files with 21 additions and 16 deletions

View File

@ -60,17 +60,17 @@ void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceS
QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
{
if (resource.toLower() == "registerdraggedtypes")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerDraggedTypes);
return NativeResourceForIntegrationFunction(QFunctionPointer(QCocoaNativeInterface::registerDraggedTypes));
if (resource.toLower() == "registertouchwindow")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerTouchWindow);
return NativeResourceForIntegrationFunction(QFunctionPointer(QCocoaNativeInterface::registerTouchWindow));
if (resource.toLower() == "setembeddedinforeignview")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setEmbeddedInForeignView);
return NativeResourceForIntegrationFunction(QFunctionPointer(QCocoaNativeInterface::setEmbeddedInForeignView));
if (resource.toLower() == "registercontentborderarea")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerContentBorderArea);
return NativeResourceForIntegrationFunction(QFunctionPointer(QCocoaNativeInterface::registerContentBorderArea));
if (resource.toLower() == "setcontentborderareaenabled")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setContentBorderAreaEnabled);
return NativeResourceForIntegrationFunction(QFunctionPointer(QCocoaNativeInterface::setContentBorderAreaEnabled));
if (resource.toLower() == "testcontentborderposition")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::testContentBorderPosition);
return NativeResourceForIntegrationFunction(QFunctionPointer(QCocoaNativeInterface::testContentBorderPosition));
return nullptr;
}

View File

@ -437,7 +437,7 @@ static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY)
return false; // Not Cocoa platform plugin.
typedef bool (*TestContentBorderPositionFunction)(QWindow *, int);
return (reinterpret_cast<TestContentBorderPositionFunction>(function))(window, windowY);
return (reinterpret_cast<TestContentBorderPositionFunction>(QFunctionPointer(function)))(window, windowY);
}

View File

@ -3234,8 +3234,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
typedef void (*RegisterTouchWindowFn)(QWindow *, bool);
case QEvent::Enter:
if (w->testAttribute(Qt::WA_AcceptTouchEvents)) {
RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>
(platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow"));
RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>(
QFunctionPointer(platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow")));
if (registerTouchWindow)
registerTouchWindow(w->window()->windowHandle(), true);
}
@ -3243,8 +3243,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
break;
case QEvent::Leave:
if (w->testAttribute(Qt::WA_AcceptTouchEvents)) {
RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>
(platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow"));
RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>(
QFunctionPointer(platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow")));
if (registerTouchWindow)
registerTouchWindow(w->window()->windowHandle(), false);
}

View File

@ -106,14 +106,16 @@ void QTabBarPrivate::updateMacBorderMetrics()
if (!function)
return; // Not Cocoa platform plugin.
typedef void (*RegisterContentBorderAreaFunction)(QWindow *window, quintptr identifier, int upper, int lower);
(reinterpret_cast<RegisterContentBorderAreaFunction>(function))(q->window()->windowHandle(), identifier, upper, lower);
(reinterpret_cast<RegisterContentBorderAreaFunction>(QFunctionPointer(function)))(
q->window()->windowHandle(), identifier, upper, lower);
// Set visibility state
function = nativeInterface->nativeResourceFunctionForIntegration("setContentBorderAreaEnabled");
if (!function)
return;
typedef void (*SetContentBorderAreaEnabledFunction)(QWindow *window, quintptr identifier, bool enable);
(reinterpret_cast<SetContentBorderAreaEnabledFunction>(function))(q->window()->windowHandle(), identifier, q->isVisible());
(reinterpret_cast<SetContentBorderAreaEnabledFunction>(QFunctionPointer(function)))(
q->window()->windowHandle(), identifier, q->isVisible());
#endif
}

View File

@ -1000,7 +1000,8 @@ static void enableMacToolBar(QToolBar *toolbar, bool enable)
return; // Not Cocoa platform plugin.
typedef void (*SetContentBorderAreaEnabledFunction)(QWindow *window, void *identifier, bool enabled);
(reinterpret_cast<SetContentBorderAreaEnabledFunction>(function))(toolbar->window()->windowHandle(), toolbar, enable);
(reinterpret_cast<SetContentBorderAreaEnabledFunction>(QFunctionPointer(function)))(
toolbar->window()->windowHandle(), toolbar, enable);
}
#endif

View File

@ -336,9 +336,11 @@ void QToolBarLayout::updateMacBorderMetrics()
typedef void (*RegisterContentBorderAreaFunction)(QWindow *window, void *identifier, int upper, int lower);
if (mainWindow->toolBarArea(tb) == Qt::TopToolBarArea) {
(reinterpret_cast<RegisterContentBorderAreaFunction>(function))(tb->window()->windowHandle(), tb, upper.y(), lower.y());
(reinterpret_cast<RegisterContentBorderAreaFunction>(QFunctionPointer(function)))(
tb->window()->windowHandle(), tb, upper.y(), lower.y());
} else {
(reinterpret_cast<RegisterContentBorderAreaFunction>(function))(tb->window()->windowHandle(), tb, 0, 0);
(reinterpret_cast<RegisterContentBorderAreaFunction>(QFunctionPointer(function)))(
tb->window()->windowHandle(), tb, 0, 0);
}
#endif
}