From 1d4b8763b4560e3b392b922bcb54ac344ac373f2 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Thu, 12 Mar 2020 11:17:43 +0100 Subject: [PATCH] fixed for Qt >= 5.12 --- src/controls/QskWindow.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/controls/QskWindow.cpp b/src/controls/QskWindow.cpp index cd6a0a3c..426039b5 100644 --- a/src/controls/QskWindow.cpp +++ b/src/controls/QskWindow.cpp @@ -30,6 +30,12 @@ QSK_QT_PRIVATE_END #include Q_LOGGING_CATEGORY( logTiming, "qsk.window.timing", QtCriticalMsg ) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 ) +QSK_QT_PRIVATE_BEGIN +#include +QSK_QT_PRIVATE_END +#endif + #endif static void qskResolveLocale( QskWindow* ); @@ -58,6 +64,28 @@ static QQuickItem* qskDefaultFocusItem( QQuickWindow* window ) return window->contentItem()->nextItemInFocusChain( true ); } +#ifdef QSK_DEBUG_RENDER_TIMING +static inline int qskUpdateTimerId( const QWindow* window ) +{ +#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 ) + class PlatformWindow : public QPlatformWindow + { + public: + int updateTimerId() const + { + return d_ptr->updateTimer.timerId(); + } + }; + + auto platformWindow = static_cast< const PlatformWindow* >( window->handle() ); + return platformWindow->updateTimerId(); +#else + auto w = const_cast< QWindow* >( window ); + return QWindowPrivate::get( w )->updateTimer; +#endif +} +#endif + namespace { class ChildListener final : public QQuickItemChangeListener @@ -323,8 +351,9 @@ bool QskWindow::event( QEvent* event ) { if ( logTiming().isDebugEnabled() ) { - // updateTimer was removed with Qt 5.??? TODO ... - if ( static_cast( event )->timerId() == d->updateTimer ) + const int updateTimerId = qskUpdateTimerId( this ); + + if ( static_cast( event )->timerId() == updateTimerId ) { if ( !d->renderInterval.isValid() ) d->renderInterval.start();