Widen out parameter "result" of the native event filters for Qt 6

LRESULT on Windows 64 is a 64bit type, adapt filter functions of
QAbstractNativeEventFilter and QAbstractEventDispatcher accordingly.

Fixes: QTBUG-72968
Change-Id: Ie53193e355f0b8e9bd59fa377f43e2b4664a2ded
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Friedemann Kleint 2019-03-22 11:20:31 +01:00
parent e8bde992e0
commit 3b38c73c7f
28 changed files with 147 additions and 0 deletions

View File

@ -108,7 +108,11 @@ public:
// Call from QFileSystemWatcher::addPaths() to set up notifications on drives
void addPath(const QString &path);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool nativeEventFilter(const QByteArray &, void *messageIn, qintptr *) override;
#else
bool nativeEventFilter(const QByteArray &, void *messageIn, long *) override;
#endif
signals:
void driveAdded();
@ -255,7 +259,11 @@ inline void QWindowsRemovableDriveListener::handleDbtDriveArrivalRemoval(const M
}
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QWindowsRemovableDriveListener::nativeEventFilter(const QByteArray &, void *messageIn, qintptr *)
#else
bool QWindowsRemovableDriveListener::nativeEventFilter(const QByteArray &, void *messageIn, long *)
#endif
{
const MSG *msg = reinterpret_cast<const MSG *>(messageIn);
if (msg->message == WM_DEVICECHANGE) {

View File

@ -470,7 +470,11 @@ void QAbstractEventDispatcher::removeNativeEventFilter(QAbstractNativeEventFilte
\sa installNativeEventFilter(), QAbstractNativeEventFilter::nativeEventFilter()
\since 5.0
*/
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, void *message, qintptr *result)
#else
bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, void *message, long *result)
#endif
{
Q_D(QAbstractEventDispatcher);
if (!d->eventFilters.isEmpty()) {

View File

@ -110,7 +110,11 @@ public:
void installNativeEventFilter(QAbstractNativeEventFilter *filterObj);
void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool filterNativeEvent(const QByteArray &eventType, void *message, qintptr *result);
#else
bool filterNativeEvent(const QByteArray &eventType, void *message, long *result);
#endif
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED bool filterEvent(void *message)
{ return filterNativeEvent("", message, nullptr); }

View File

@ -74,6 +74,7 @@ QAbstractNativeEventFilter::~QAbstractNativeEventFilter()
eventDispatcher->removeNativeEventFilter(this);
}
// ### fixme Qt 6: result will be qintptr *
/*!
\fn bool QAbstractNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)

View File

@ -52,7 +52,11 @@ public:
QAbstractNativeEventFilter();
virtual ~QAbstractNativeEventFilter();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) = 0;
#else
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) = 0;
#endif
private:
Q_DISABLE_COPY(QAbstractNativeEventFilter)

View File

@ -136,7 +136,11 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
msg.wParam = wp;
msg.lParam = lp;
QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr result;
#else
long result;
#endif
if (!dispatcher) {
if (message == WM_TIMER)
KillTimer(hwnd, wp);

View File

@ -1825,7 +1825,11 @@ bool QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow *window,
return platformWindow->windowEvent(event);
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result)
#else
bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result)
#endif
{
return window->nativeEvent(eventType, message, result);
}

View File

@ -172,7 +172,11 @@ public:
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
#endif
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result);
#else
static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);
#endif
static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event);

View File

@ -2523,7 +2523,12 @@ void QWindow::tabletEvent(QTabletEvent *ev)
Should return true only if the event was handled.
*/
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
#else
bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
#endif
{
Q_UNUSED(eventType);
Q_UNUSED(message);

View File

@ -364,7 +364,11 @@ protected:
#if QT_CONFIG(tabletevent)
virtual void tabletEvent(QTabletEvent *);
#endif
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
#else
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
#endif
QWindow(QWindowPrivate &dd, QWindow *parent);

View File

@ -863,7 +863,11 @@ QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, cons
\note This function can only be called from the GUI thread.
*/
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result)
#else
bool QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result)
#endif
{
return QGuiApplicationPrivate::processNativeEvent(window, eventType, message, result);
}

View File

@ -230,7 +230,11 @@ public:
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
#endif // QT_CONFIG(draganddrop)
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result);
#else
static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);
#endif
// Changes to the screen
static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation);

View File

@ -242,7 +242,11 @@ void QQnxScreenEventHandler::processEvents()
break;
++count;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr result = 0;
#else
long result = 0;
#endif
QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance();
bool handled = dispatcher && dispatcher->filterNativeEvent(QByteArrayLiteral("screen_event_t"), event, &result);
if (!handled)

View File

@ -1605,7 +1605,11 @@ static inline QByteArray nativeEventType() { return QByteArrayLiteral("windows_g
bool QWindowsContext::filterNativeEvent(MSG *msg, LRESULT *result)
{
QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr filterResult = 0;
#else
long filterResult = 0;
#endif
if (dispatcher && dispatcher->filterNativeEvent(nativeEventType(), msg, &filterResult)) {
*result = LRESULT(filterResult);
return true;
@ -1616,7 +1620,11 @@ bool QWindowsContext::filterNativeEvent(MSG *msg, LRESULT *result)
// Send to QWindowSystemInterface
bool QWindowsContext::filterNativeEvent(QWindow *window, MSG *msg, LRESULT *result)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr filterResult = 0;
#else
long filterResult = 0;
#endif
if (QWindowSystemInterface::handleNativeEvent(window, nativeEventType(), msg, &filterResult)) {
*result = LRESULT(filterResult);
return true;

View File

@ -164,7 +164,11 @@ bool QXcbGlxIntegration::handleXcbEvent(xcb_generic_event_t *event, uint respons
XUnlockDisplay(xdisplay);
locked = false;
auto eventType = m_connection->nativeInterface()->nativeEventType();
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr result = 0;
# else
long result = 0;
# endif
handled = dispatcher->filterNativeEvent(eventType, &ev, &result);
}
#endif

View File

@ -439,7 +439,11 @@ const char *xcb_protocol_request_codes[] =
void QXcbConnection::handleXcbError(xcb_generic_error_t *error)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr result = 0;
#else
long result = 0;
#endif
QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance();
if (dispatcher && dispatcher->filterNativeEvent(m_nativeInterface->nativeEventType(), error, &result))
return;
@ -536,7 +540,11 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
if (Q_UNLIKELY(lcQpaEvents().isDebugEnabled()))
printXcbEvent(lcQpaEvents(), "Event", event);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr result = 0; // Used only by MS Windows
#else
long result = 0; // Used only by MS Windows
#endif
if (QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance()) {
if (dispatcher->filterNativeEvent(m_nativeInterface->nativeEventType(), event, &result))
return;

View File

@ -1657,7 +1657,11 @@ bool QXcbWindow::requestSystemTrayWindowDock()
bool QXcbWindow::handleNativeEvent(xcb_generic_event_t *event)
{
auto eventType = connection()->nativeInterface()->nativeEventType();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr result = 0; // Used only by MS Windows
#else
long result = 0; // Used only by MS Windows
#endif
return QWindowSystemInterface::handleNativeEvent(window(), eventType, event, &result);
}

View File

@ -96,7 +96,11 @@ QTest::QBenchmarkMetric QBenchmarkEvent::metricType()
}
// This could be done in a much better way, this is just the beginning.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QBenchmarkEvent::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result)
#else
bool QBenchmarkEvent::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
#endif
{
Q_UNUSED(eventType);
Q_UNUSED(message);

View File

@ -71,7 +71,11 @@ public:
int adjustMedianCount(int suggestion) override;
bool repeatCount() override { return 1; }
QTest::QBenchmarkMetric metricType() override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
#else
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
#endif
qint64 eventCounter;
};

View File

@ -3257,7 +3257,11 @@ void QWizard::paintEvent(QPaintEvent * event)
/*!
\reimp
*/
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QWizard::nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
# else
bool QWizard::nativeEvent(const QByteArray &eventType, void *message, long *result)
# endif
{
#if QT_CONFIG(style_windowsvista)
Q_D(QWizard);

View File

@ -188,7 +188,11 @@ protected:
void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent *event) override;
#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
# else
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
# endif
#endif
void done(int result) override;
virtual void initializePage(int id);

View File

@ -339,7 +339,11 @@ void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible)
SetWindowThemeAttribute(handle, WTA_NONCLIENT, &opt, sizeof(WTA_OPTIONS));
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QVistaHelper::winEvent(MSG* msg, qintptr *result)
#else
bool QVistaHelper::winEvent(MSG* msg, long* result)
#endif
{
switch (msg->message) {
case WM_NCHITTEST: {
@ -401,7 +405,11 @@ void QVistaHelper::mouseEvent(QEvent *event)
}
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QVistaHelper::handleWinEvent(MSG *message, qintptr *result)
#else
bool QVistaHelper::handleWinEvent(MSG *message, long *result)
#endif
{
if (message->message == WM_THEMECHANGED || message->message == WM_DWMCOMPOSITIONCHANGED)
cachedVistaState = Dirty;
@ -509,7 +517,11 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event)
if (event->type() == QEvent::MouseMove) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr result;
#else
long result;
#endif
MSG msg;
msg.message = WM_NCHITTEST;
msg.wParam = 0;
@ -523,7 +535,11 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event)
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent->button() == Qt::LeftButton) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr result;
#else
long result;
#endif
MSG msg;
msg.message = WM_NCHITTEST;
msg.wParam = 0;
@ -538,7 +554,11 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event)
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent->button() == Qt::LeftButton) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qintptr result;
#else
long result;
#endif
MSG msg;
msg.message = WM_NCHITTEST;
msg.wParam = 0;

View File

@ -93,7 +93,11 @@ public:
bool setDWMTitleBar(TitleBarChangeType type);
void setTitleBarIconAndCaptionVisible(bool visible);
void mouseEvent(QEvent *event);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool handleWinEvent(MSG *message, qintptr *result);
#else
bool handleWinEvent(MSG *message, long *result);
#endif
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *event);
QVistaBackButton *backButton() const { return backButton_; }
@ -130,7 +134,11 @@ private:
void drawTitleBar(QPainter *painter);
void setMouseCursor(QPoint pos);
void collapseTopFrameStrut();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool winEvent(MSG *message, qintptr *result);
#else
bool winEvent(MSG *message, long *result);
#endif
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);

View File

@ -10149,7 +10149,11 @@ void QWidget::hideEvent(QHideEvent *)
\endtable
*/
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QWidget::nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
#else
bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
#endif
{
Q_UNUSED(eventType);
Q_UNUSED(message);

View File

@ -648,7 +648,12 @@ protected:
virtual void showEvent(QShowEvent *event);
virtual void hideEvent(QHideEvent *event);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
#else
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
#endif
// Misc. protected functions
virtual void changeEvent(QEvent *);

View File

@ -1020,7 +1020,11 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event
}
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
#else
bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
#endif
{
return m_widget->nativeEvent(eventType, message, result);
}

View File

@ -103,7 +103,11 @@ protected:
#endif
void handleExposeEvent(QExposeEvent *);
void handleWindowStateChangedEvent(QWindowStateChangeEvent *event);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
#else
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#endif
#if QT_CONFIG(tabletevent)
void handleTabletEvent(QTabletEvent *);
#endif

View File

@ -6146,7 +6146,11 @@ public:
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *) override
#else
bool nativeEvent(const QByteArray &eventType, void *message, long *) override
#endif
{
if (isMapNotify(eventType, message))
gotExpectedMapNotify = true;
@ -6154,7 +6158,11 @@ public:
}
// QAbstractNativeEventFilter interface
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override
#else
bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override
#endif
{
if (isMapNotify(eventType, message))
gotExpectedGlobalEvent = true;