From 686f4ff2d88cbb0b76cb6414b814d596ee2ebe8e Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Fri, 2 Mar 2018 07:23:12 +0100 Subject: [PATCH] dh --- playground/invoker/main.cpp | 17 ++++++++++++----- src/common/QskMetaInvokable.h | 16 ++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/playground/invoker/main.cpp b/playground/invoker/main.cpp index 96dd10d6..d4941395 100644 --- a/playground/invoker/main.cpp +++ b/playground/invoker/main.cpp @@ -18,14 +18,19 @@ static void debugNone2() qDebug() << "None 2"; } -static void debugValueI( int i ) +static void debugValueI1( int i ) { - qDebug() << i; + qDebug() << "I1" << i; +} + +static void debugValueI2( int i ) +{ + qDebug() << "I2" << i; } static void debugValueD( qreal d ) { - qDebug() << d; + qDebug() << "D" << d; } static void debugValue( qreal d, int i ) @@ -103,7 +108,8 @@ int main( int argc, char* argv[] ) invoker.addCallback( debugNone1 ); invoker.addCallback( debugNone2 ); invoker.addCallback( debugValue ); - invoker.addCallback( debugValueI ); + invoker.addCallback( debugValueI1 ); + invoker.addCallback( debugValueI2 ); invoker.addCallback( debugValueD ); invoker.addCallback( &object, &MyObject::print1 ); invoker.addCallback( &object2, &MyObject2::print1 ); @@ -120,7 +126,8 @@ int main( int argc, char* argv[] ) invoker.addCallback( &object, []( double d ) { qDebug() << d; } ); invoker.addCallback( []() { qDebug() << "HERE"; } ); invoker.addCallback( []( int i, double d ) { qDebug() << i << d; } ); - invoker.addCallback( []( int i ) { qDebug() << i; } ); + invoker.addCallback( []( int i ) { qDebug() << "I1" << i; } ); + invoker.addCallback( []( int i ) { qDebug() << "I2" << i; } ); invoker.addCallback( []( double d ) { qDebug() << d; } ); #endif diff --git a/src/common/QskMetaInvokable.h b/src/common/QskMetaInvokable.h index 430f9d0f..645de1fc 100644 --- a/src/common/QskMetaInvokable.h +++ b/src/common/QskMetaInvokable.h @@ -74,30 +74,26 @@ public: { } - static void invoke(int which, QtPrivate::QSlotObjectBase*, + static void invoke(int which, QtPrivate::QSlotObjectBase* invokable, QObject* object, void** args, bool* ) { - static Invokable* invokable = nullptr; - switch ( which ) { case Find: { - *reinterpret_cast< void** >( args[0] ) = invokable; + *reinterpret_cast< void** >( args[0] ) = nullptr; break; } case Create: { - invokable = new Invokable( *reinterpret_cast< Function* >( args[1] ) ); - *reinterpret_cast< void** >( args[0] ) = invokable; + *reinterpret_cast< void** >( args[0] ) = + new Invokable( *reinterpret_cast< Function* >( args[1] ) ); break; } case Destroy: { - delete invokable; - invokable = nullptr; - + delete static_cast< Invokable* >( invokable ); break; } case Call: @@ -105,7 +101,7 @@ public: typedef QtPrivate::FunctionPointer< Function > FuncType; FuncType::template call< Args, R >( - invokable->m_function, object, args ); + static_cast< Invokable* >( invokable )->m_function, object, args ); break; } case TypeInfo: