fixed for Qt >= 5.12

This commit is contained in:
Uwe Rathmann 2020-03-12 11:17:43 +01:00
parent c23b3fae18
commit 1d4b8763b4
1 changed files with 31 additions and 2 deletions

View File

@ -30,6 +30,12 @@ QSK_QT_PRIVATE_END
#include <qloggingcategory.h> #include <qloggingcategory.h>
Q_LOGGING_CATEGORY( logTiming, "qsk.window.timing", QtCriticalMsg ) Q_LOGGING_CATEGORY( logTiming, "qsk.window.timing", QtCriticalMsg )
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
QSK_QT_PRIVATE_BEGIN
#include <qpa/qplatformwindow_p.h>
QSK_QT_PRIVATE_END
#endif
#endif #endif
static void qskResolveLocale( QskWindow* ); static void qskResolveLocale( QskWindow* );
@ -58,6 +64,28 @@ static QQuickItem* qskDefaultFocusItem( QQuickWindow* window )
return window->contentItem()->nextItemInFocusChain( true ); 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 namespace
{ {
class ChildListener final : public QQuickItemChangeListener class ChildListener final : public QQuickItemChangeListener
@ -323,8 +351,9 @@ bool QskWindow::event( QEvent* event )
{ {
if ( logTiming().isDebugEnabled() ) if ( logTiming().isDebugEnabled() )
{ {
// updateTimer was removed with Qt 5.??? TODO ... const int updateTimerId = qskUpdateTimerId( this );
if ( static_cast<QTimerEvent *>( event )->timerId() == d->updateTimer )
if ( static_cast<QTimerEvent *>( event )->timerId() == updateTimerId )
{ {
if ( !d->renderInterval.isValid() ) if ( !d->renderInterval.isValid() )
d->renderInterval.start(); d->renderInterval.start();