Skip to content

Commit

Permalink
Widen out parameter "result" of the native event filters for Qt 6
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
FriedemannKleint committed Mar 22, 2019
1 parent e8bde99 commit 3b38c73
Show file tree
Hide file tree
Showing 28 changed files with 147 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/corelib/io/qfilesystemwatcher_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ class QWindowsRemovableDriveListener : public QObject, public QAbstractNativeEve
// 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();
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/corelib/kernel/qabstracteventdispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
4 changes: 4 additions & 0 deletions src/corelib/kernel/qabstracteventdispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ class Q_CORE_EXPORT QAbstractEventDispatcher : public QObject

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); }
Expand Down
1 change: 1 addition & 0 deletions src/corelib/kernel/qabstractnativeeventfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/corelib/kernel/qabstractnativeeventfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class Q_CORE_EXPORT QAbstractNativeEventFilter
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)
Expand Down
4 changes: 4 additions & 0 deletions src/corelib/kernel/qeventdispatcher_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/gui/kernel/qguiapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/gui/kernel/qguiapplication_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
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);

Expand Down
5 changes: 5 additions & 0 deletions src/gui/kernel/qwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/gui/kernel/qwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,11 @@ public Q_SLOTS:
#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);

Expand Down
4 changes: 4 additions & 0 deletions src/gui/kernel/qwindowsysteminterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/gui/kernel/qwindowsysteminterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ class Q_GUI_EXPORT QWindowSystemInterface
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);
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/platforms/windows/qwindowscontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/platforms/xcb/qxcbconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/platforms/xcb/qxcbwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions src/testlib/qbenchmarkevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/testlib/qbenchmarkevent_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ class QBenchmarkEvent : public QBenchmarkMeasurerBase, public QAbstractNativeEve
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;
};

Expand Down
4 changes: 4 additions & 0 deletions src/widgets/dialogs/qwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/dialogs/qwizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ public Q_SLOTS:
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);
Expand Down
20 changes: 20 additions & 0 deletions src/widgets/dialogs/qwizard_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/widgets/dialogs/qwizard_win_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ class QVistaHelper : public QObject
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_; }
Expand Down Expand Up @@ -130,7 +134,11 @@ class QVistaHelper : public QObject
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);
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/kernel/qwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/widgets/kernel/qwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,12 @@ public Q_SLOTS:

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 *);
Expand Down
Loading

0 comments on commit 3b38c73

Please sign in to comment.