From 09a12fc7a83c62ebc7bea72a3ef69ae6b7341b9b Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sat, 16 Apr 2022 17:02:53 +0200 Subject: [PATCH] pre Qt 5.15 code removed --- src/common/QskMetaFunction.cpp | 41 ++++++++------------------------ src/common/QskMetaInvokable.cpp | 42 +++++++++------------------------ 2 files changed, 21 insertions(+), 62 deletions(-) diff --git a/src/common/QskMetaFunction.cpp b/src/common/QskMetaFunction.cpp index 6cd5e817..cef8eaba 100644 --- a/src/common/QskMetaFunction.cpp +++ b/src/common/QskMetaFunction.cpp @@ -14,23 +14,12 @@ QSK_QT_PRIVATE_BEGIN #include QSK_QT_PRIVATE_END -static inline void qskInvokeFunctionQueued( QObject* object, - QskMetaFunction::FunctionCall* functionCall, int argc, int* types, void* argv[], - QSemaphore* semaphore = nullptr ) +static inline void qskInvokeFunctionQueued( + QObject* object, QskMetaFunction::FunctionCall* functionCall, + void* argv[], QSemaphore* semaphore ) { - constexpr QObject* sender = nullptr; - constexpr int signalId = 0; - -#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) - Q_UNUSED( types ) - Q_UNUSED( argc ) - auto event = new QMetaCallEvent( - functionCall, sender, signalId, argv, semaphore ); -#else - auto event = new QMetaCallEvent( - functionCall, sender, signalId, argc, types, argv, semaphore ); -#endif + functionCall, nullptr, 0, argv, semaphore ); QCoreApplication::postEvent( object, event ); } @@ -231,8 +220,7 @@ void QskMetaFunction::invoke( QObject* object, QSemaphore semaphore; - qskInvokeFunctionQueued( receiver, - m_functionCall, 0, nullptr, argv, &semaphore ); + qskInvokeFunctionQueued( receiver, m_functionCall, argv, &semaphore ); semaphore.acquire(); @@ -247,18 +235,11 @@ void QskMetaFunction::invoke( QObject* object, const auto argc = parameterCount() + 1; // return value + arguments - auto types = static_cast< int* >( std::malloc( argc * sizeof( int ) ) ); auto arguments = static_cast< void** >( std::malloc( argc * sizeof( void* ) ) ); - if ( types == nullptr || arguments == nullptr ) - { - std::free( types ); - std::free( arguments ); - + if ( arguments == nullptr ) return; - } - types[ 0 ] = QMetaType::UnknownType; arguments[ 0 ] = nullptr; const int* parameterTypes = m_functionCall->parameterTypes(); @@ -271,26 +252,24 @@ void QskMetaFunction::invoke( QObject* object, break; } - types[ i ] = parameterTypes[ i - 1 ]; + const auto type = parameterTypes[ i - 1 ]; arguments[ i ] = #if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) - QMetaType( types[ i ] ).create( argv[ i ] ); + QMetaType( type ).create( argv[ i ] ); #else - QMetaType::create( types[ i ], argv[ i ] ); + QMetaType::create( type, argv[ i ] ); #endif } if ( receiver.isNull() ) { // object might have died in the meantime - std::free( types ); std::free( arguments ); - return; } - qskInvokeFunctionQueued( object, m_functionCall, argc, types, arguments ); + qskInvokeFunctionQueued( object, m_functionCall, arguments, nullptr ); break; } } diff --git a/src/common/QskMetaInvokable.cpp b/src/common/QskMetaInvokable.cpp index 5dc746e2..da217c27 100644 --- a/src/common/QskMetaInvokable.cpp +++ b/src/common/QskMetaInvokable.cpp @@ -62,19 +62,12 @@ namespace public: MetaCallEvent( QMetaObject::Call call, CallFunction callFunction, ushort offset, - ushort index, int nargs, int* types, void* args[], - QSemaphore* semaphore = nullptr ) - : QMetaCallEvent( offset, index, callFunction, nullptr, -1, -#if QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) - nargs, types, -#endif - args, semaphore ) + ushort index, void* args[], QSemaphore* semaphore ) + : QMetaCallEvent( offset, index, callFunction, nullptr, -1, args, semaphore ) , m_call( call ) , m_callFunction( callFunction ) , m_index( index ) { - Q_UNUSED( nargs ) - Q_UNUSED( types ) } void placeMetaCall( QObject* object ) override @@ -93,13 +86,12 @@ namespace static inline void qskInvokeMetaCallQueued( QObject* object, QMetaObject::Call call, ushort offset, - ushort index, int nargs, int* types, void* args[], - QSemaphore* semaphore = nullptr ) + ushort index, void* args[], QSemaphore* semaphore ) { const auto callFunction = object->metaObject()->d.static_metacall; auto event = new MetaCallEvent( call, callFunction, - offset, index, nargs, types, args, semaphore ); + offset, index, args, semaphore ); QCoreApplication::postEvent( object, event ); } @@ -205,7 +197,7 @@ static void qskInvokeMetaCall( QSemaphore semaphore; qskInvokeMetaCallQueued( receiver, call, - offset, index, 0, nullptr, argv, &semaphore ); + offset, index, argv, &semaphore ); semaphore.acquire(); @@ -216,9 +208,7 @@ static void qskInvokeMetaCall( if ( receiver == nullptr ) return; - int* types = nullptr; void** arguments = nullptr; - int argc = 0; if ( call == QMetaObject::InvokeMetaMethod ) { @@ -226,9 +216,8 @@ static void qskInvokeMetaCall( // should be doable without QMetaMethod. TODO ... const auto method = metaObject->method( offset + index ); #endif - argc = method.parameterCount() + 1; + const int argc = method.parameterCount() + 1; - types = static_cast< int* >( malloc( argc * sizeof( int ) ) ); arguments = static_cast< void** >( malloc( argc * sizeof( void* ) ) ); /* @@ -236,7 +225,6 @@ static void qskInvokeMetaCall( invalid for Queued Connections. */ - types[ 0 ] = QMetaType::UnknownType; arguments[ 0 ] = nullptr; for ( int i = 1; i < argc; i++ ) @@ -248,8 +236,8 @@ static void qskInvokeMetaCall( break; } - types[ i ] = method.parameterType( i - 1 ); - arguments[ i ] = qskMetaTypeCreate( types[ i ], argv[ i ] ); + const auto type = method.parameterType( i - 1 ); + arguments[ i ] = qskMetaTypeCreate( type, argv[ i ] ); } } else @@ -257,26 +245,18 @@ static void qskInvokeMetaCall( // should be doable without QMetaMethod. TODO ... const auto property = metaObject->property( offset + index ); - argc = 1; - - types = static_cast< int* >( malloc( argc * sizeof( int ) ) ); - arguments = static_cast< void** >( malloc( argc * sizeof( void* ) ) ); - - types[ 0 ] = property.userType(); - arguments[ 0 ] = qskMetaTypeCreate( types[ 0 ], argv[ 0 ] ); + arguments = static_cast< void** >( malloc( 1 * sizeof( void* ) ) ); + arguments[ 0 ] = qskMetaTypeCreate( property.userType(), argv[ 0 ] ); } if ( receiver.isNull() ) { // object might have died in the meantime - free( types ); free( arguments ); - return; } - qskInvokeMetaCallQueued( object, call, - offset, index, argc, types, arguments ); + qskInvokeMetaCallQueued( object, call, offset, index, arguments, nullptr ); break; }