diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3e37cd179d..0dff20e72a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,22 @@ The license applies to all entries newer than 2009-04-28. */ +2011-04-26 03:07 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/qtcore/hbqt_hbqevents.cpp + * contrib/hbqt/qtcore/hbqt_hbqevents.h + * contrib/hbqt/qtcore/hbqt_hbqslots.cpp + * contrib/hbqt/qtcore/hbqt_hbqslots.h + * contrib/hbqt/qtcore/hbqt_misc.prg + * contrib/hbqt/qtcore/hbqt_pointer.cpp + * contrib/hbqt/qtcore/hbqtcore.hbx + * contrib/hbqt/qtcore/qth/HBQEvents.qth + * contrib/hbqt/qtcore/qth/HBQSlots.qth + * contrib/hbqt/tests/demoqt.prg + * contrib/hbxbp/xbptabpage.prg + ! Removed: entirely - raw-pointers from hbQT. + + WARNING: this may cause a temporary instability, please report. + 2011-04-26 11:09 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * INSTALL + Added 'comparing xharbour to harbour' document direct URL diff --git a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp index 10557474ee..7d9cd4e222 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp @@ -64,6 +64,7 @@ #include #include +#include /*----------------------------------------------------------------------*/ @@ -107,11 +108,18 @@ void hbqt_events_unregister_createobj( QEvent::Type eventtype ) /*----------------------------------------------------------------------*/ -HBQEvents::HBQEvents( QObject * parent ) : QObject( parent ) +HBQEvents::HBQEvents( PHB_ITEM pObj ) : QObject() { + if( pObj ) + { + QObject * object = ( QObject * ) hbqt_pPtrFromObject( pObj ); + if( object ) + { + object->installEventFilter( this ); + } + } } -/* QUESTION: Shouldn't all events be disconnected at this point? */ HBQEvents::~HBQEvents() { HB_TRACE( HB_TR_DEBUG, ( " HBQEvents::~HBQEvents()" ) ); @@ -121,81 +129,88 @@ HBQEvents::~HBQEvents() { if( listBlock[ i ] != NULL ) { - HB_TRACE( HB_TR_DEBUG, ( " HBQEvents::~HBQEvents() %d", i ) ); - hb_itemRelease( listBlock.at( i ) ); listBlock[ i ] = NULL; - - HB_TRACE( HB_TR_DEBUG, ( " X" ) ); } } } -bool HBQEvents::hbConnect( PHB_ITEM pObj, int iEvent, PHB_ITEM bBlock ) +int HBQEvents::hbConnect( PHB_ITEM pObj, int type, PHB_ITEM bBlock ) { - HB_SYMBOL_UNUSED( pObj ); - HB_SYMBOL_UNUSED( iEvent ); - HB_SYMBOL_UNUSED( bBlock ); + int nResult = -1; - QObject * object = ( QObject* ) hbqt_pPtrFromObj( 1 ); /* get sender */ - - if( object ) + if( true ) { - PHB_ITEM codeblock = hb_itemNew( hb_param( 3, HB_IT_BLOCK | HB_IT_BYREF ) ); + QObject * object = ( QObject * ) hbqt_pPtrFromObject( pObj ); + if( object ) + { + PHB_ITEM codeblock = hb_itemNew( bBlock ); + if( codeblock ) + { + hb_gcUnlock( codeblock ); - char prop[ 20 ]; - hb_snprintf( prop, sizeof( prop ), "%s%i%s", "P", iEvent, "P" ); /* Make it a unique identifier */ + char prop[ 20 ]; + hb_snprintf( prop, sizeof( prop ), "P%iP", type ); /* Make it a unique identifier */ - listBlock << codeblock; - - object->setProperty( prop, ( int ) listBlock.size() ); - - return true; + int i = object->property( prop ).toInt(); + if( i == 0 ) + { + listBlock << codeblock; + object->setProperty( prop, ( int ) listBlock.size() ); + } + else + { + if( listBlock.at( i - 1 ) != NULL ) + { + hb_itemRelease( listBlock.at( i - 1 ) ); + } + listBlock[ i - 1 ] = codeblock; + } + nResult = 0; + } + else + nResult = -3; + } + else + nResult = -2; } - return false; + else + nResult = -1; + + return nResult; } -bool HBQEvents::hbDisconnect( PHB_ITEM pObj, int iEvent ) +int HBQEvents::hbDisconnect( PHB_ITEM pObj, int type ) { - HB_SYMBOL_UNUSED( pObj ); - - QObject * object = ( QObject* ) hbqt_pPtrFromObj( 1 ); + int nResult = -1; + QObject * object = ( QObject * ) hbqt_pPtrFromObject( pObj ); if( object ) { char prop[ 20 ]; - hb_snprintf( prop, sizeof( prop ), "%s%i%s", "P", iEvent, "P" ); /* Make it a unique identifier */ + hb_snprintf( prop, sizeof( prop ), "P%iP", type ); /* Make it a unique identifier */ int i = object->property( prop ).toInt(); if( i > 0 && i <= listBlock.size() ) { - hb_itemRelease( listBlock.at( i - 1 ) ); - listBlock[ i - 1 ] = NULL; object->setProperty( prop, QVariant() ); - HB_TRACE( HB_TR_DEBUG, ( " QT_EVENTS_DISCONNECT: %i", iEvent ) ); - return true; + if( listBlock[ i - 1 ] != NULL ) + { + hb_itemRelease( listBlock.at( i - 1 ) ); + listBlock[ i - 1 ] = NULL; + } + nResult = 0; } + else + nResult = -3; } - return false; + else + nResult = -2; + + return nResult; } -bool HBQEvents::hbClear() -{ - HB_TRACE( HB_TR_DEBUG, ( " HBQEvents::hbClear()" ) ); - int i; - - for( i = 0; i < listBlock.size(); i++ ) - { - if( listBlock[ i ] != NULL ) - { - hb_itemRelease( listBlock.at( i ) ); - listBlock[ i ] = NULL; - } - } - listBlock.clear(); - return true; -} /* DO NOT Reformat */ bool HBQEvents::eventFilter( QObject * object, QEvent * event ) @@ -239,111 +254,6 @@ bool HBQEvents::eventFilter( QObject * object, QEvent * event ) return false; } -HB_FUNC( __HBQT_EVENTS_CONNECT ) -{ - int nResult; - HBQEvents * t_events = hbqt_par_HBQEvents( 1 ); - - if( t_events ) - { - QObject * object = ( QObject * ) hbqt_pPtrFromObj( 2 ); /* get sender */ - - if( object ) - { - PHB_ITEM codeblock = hb_itemNew( hb_param( 4, HB_IT_BLOCK | HB_IT_BYREF ) ); - if( codeblock ) - { - int type = hb_parni( 3 ); - hb_gcUnlock( codeblock ); - - char prop[ 20 ]; - hb_snprintf( prop, sizeof( prop ), "P%iP", type ); /* Make it a unique identifier */ - - int i = object->property( prop ).toInt(); - if( i == 0 ) - { - t_events->listBlock << codeblock; - object->setProperty( prop, ( int ) t_events->listBlock.size() ); - } - else - { - if( t_events->listBlock.at( i - 1 ) != NULL ) - { - hb_itemRelease( t_events->listBlock.at( i - 1 ) ); - } - t_events->listBlock[ i - 1 ] = codeblock; - } - nResult = 0; - } - else - nResult = -3; - } - else - nResult = -2; - } - else - nResult = -1; - - hb_retni( nResult ); -} - -HB_FUNC( __HBQT_EVENTS_DISCONNECT ) -{ - int nResult; - HBQEvents * t_events = hbqt_par_HBQEvents( 1 ); - - if( t_events ) - { - QObject * object = ( QObject * ) hbqt_pPtrFromObj( 2 ); - - if( object ) - { - int type = hb_parni( 3 ); - - char prop[ 20 ]; - hb_snprintf( prop, sizeof( prop ), "P%iP", type ); /* Make it a unique identifier */ - - int i = object->property( prop ).toInt(); - if( i > 0 && i <= t_events->listBlock.size() ) - { - object->setProperty( prop, QVariant() ); - - if( t_events->listBlock[ i - 1 ] != NULL ) - { - HB_TRACE( HB_TR_DEBUG, ( " __HBQT_EVENTS_DISCONNECT %d=", i-1 ) ); - hb_itemRelease( t_events->listBlock.at( i - 1 ) ); - t_events->listBlock[ i - 1 ] = NULL; - HB_TRACE( HB_TR_DEBUG, ( " X=" ) ); - } - nResult = 0; - - HB_TRACE( HB_TR_DEBUG, ( " QT_EVENTS_DISCONNECT: %i", type ) ); - } - else - nResult = -3; - } - else - nResult = -2; - } - else - nResult = -1; - - hb_retni( nResult ); -} - -HB_FUNC( __HBQT_EVENTS_NEW ) -{ - HBQEvents * p; - QObject * o; - - o = (QObject *) hbqt_pPtrFromObj( 1 ); - - p = new HBQEvents(); - o->installEventFilter( p ); - - hb_retptrGC( hbqt_gcAllocate_HBQEvents( p, true ) ); -} - static void hbqt_events_init( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); diff --git a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.h b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.h index 12a35ae306..eb02170278 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.h +++ b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.h @@ -68,13 +68,12 @@ class HBQEvents: public QObject Q_OBJECT public: - HBQEvents( QObject *parent = 0 ); + HBQEvents( PHB_ITEM pObj ); ~HBQEvents(); - QList listBlock; + QList listBlock; - bool hbConnect( PHB_ITEM pObj, int iEvent, PHB_ITEM bBlock ); - bool hbDisconnect( PHB_ITEM pObj, int iEvent ); - bool hbClear(); + int hbConnect( PHB_ITEM pObj, int iEvent, PHB_ITEM bBlock ); + int hbDisconnect( PHB_ITEM pObj, int iEvent ); protected: bool eventFilter( QObject * obj, QEvent * event ); diff --git a/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp b/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp index 99beaefef3..632d85420e 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp @@ -106,8 +106,12 @@ void hbqt_slots_unregister_callback( QByteArray sig ) /*----------------------------------------------------------------------*/ -HBQSlots::HBQSlots( QObject* parent ) : QObject( parent ) +HBQSlots::HBQSlots( PHB_ITEM pObj ) : QObject() { + if( pObj ) + { + // Nothing to do + } } HBQSlots::~HBQSlots() @@ -118,13 +122,132 @@ HBQSlots::~HBQSlots() { if( listBlock[ i ] != NULL ) { - HB_TRACE( HB_TR_DEBUG, ( " HBQSlots::~HBQSlots() %d", i ) ); hb_itemRelease( listBlock.at( i ) ); listBlock[ i ] = NULL; } } } +int HBQSlots::hbConnect( PHB_ITEM pObj, char * pszSignal, PHB_ITEM bBlock ) +{ + int nResult = 1; + + if( true ) + { + QObject * object = ( QObject * ) hbqt_pPtrFromObject( pObj ); + if( object ) + { + PHB_ITEM pBlock = hb_itemNew( bBlock ); + if( pBlock ) + { + hb_gcUnlock( pBlock ); + + int i = object->property( pszSignal ).toInt(); + if( i == 0 ) + { + QString signal = pszSignal; + QByteArray theSignal = QMetaObject::normalizedSignature( signal.toAscii() ); + + if( QMetaObject::checkConnectArgs( theSignal, theSignal ) ) + { + int signalId = object->metaObject()->indexOfSignal( theSignal ); + if( signalId != -1 ) + { + int slotId = object->metaObject()->indexOfMethod( theSignal ); + if( slotId != -1 ) + { + if( QMetaObject::connect( object, signalId, this, slotId + QObject::staticMetaObject.methodCount(), Qt::AutoConnection ) ) + { + listBlock << pBlock; + + char szSlotName[ 20 ]; + hb_snprintf( szSlotName, sizeof( szSlotName ), "SLOT_%d", slotId ); + + object->setProperty( szSlotName, ( int ) listBlock.size() ); + object->setProperty( pszSignal, ( int ) listBlock.size() ); + + nResult = 0; + } + else + nResult = 8; + } + else + nResult = 7; + } + else + nResult = 6; + } + else + nResult = 5; + } + else + { + if( listBlock.at( i - 1 ) != NULL ) + { + hb_itemRelease( listBlock.at( i - 1 ) ); + } + listBlock[ i - 1 ] = pBlock; + nResult = 0; + } + + if( nResult > 0 ) + { + hb_itemRelease( pBlock ); + } + } + else + { + nResult = 3; + } + } + else + nResult = 2; + } + + return nResult; +} + +int HBQSlots::hbDisconnect( PHB_ITEM pObj, char * pszSignal ) +{ + int nResult = 1; + + QObject * object = ( QObject * ) hbqt_pPtrFromObject( pObj ); + if( object ) + { + int i = object->property( pszSignal ).toInt(); + if( i > 0 && i <= listBlock.size() ) + { + object->setProperty( pszSignal, QVariant() ); + + QString signal = pszSignal; + QByteArray theSignal = signal.toAscii(); + + int signalId = object->metaObject()->indexOfSignal( QMetaObject::normalizedSignature( theSignal ) ); + if( signalId != -1 ) + { + if( QMetaObject::disconnect( object, signalId, 0, 0 ) ) + nResult = 0; + else + nResult = 5; + } + else + nResult = 4; + + if( listBlock.at( i - 1 ) != NULL ) + { + hb_itemRelease( listBlock.at( i - 1 ) ); + listBlock[ i - 1 ] = NULL; + } + } + else + nResult = 3; + } + else + nResult = 2; + + return nResult; +} + int HBQSlots::qt_metacall( QMetaObject::Call c, int id, void ** arguments ) { id = QObject::qt_metacall( c, id, arguments ); @@ -207,148 +330,5 @@ int HBQSlots::qt_metacall( QMetaObject::Call c, int id, void ** arguments ) } /*----------------------------------------------------------------------*/ -/* - * Harbour function to connect signals with slots - */ -HB_FUNC( __HBQT_SLOTS_CONNECT ) -{ - int nResult = 0; - HBQSlots * t_slots = hbqt_par_HBQSlots( 1 ); - - if( t_slots ) - { - QObject * object = ( QObject * ) hbqt_pPtrFromObj( 2 ); /* get sender */ - if( object ) - { - PHB_ITEM pBlock = hb_itemNew( hb_param( 4, HB_IT_BLOCK | HB_IT_BYREF ) ); /* get codeblock */ - if( pBlock ) - { - const char * pszSignal = hb_parcx( 3 ); - hb_gcUnlock( pBlock ); - - int i = object->property( pszSignal ).toInt(); - if( i == 0 ) - { - QString signal = pszSignal; - QByteArray theSignal = QMetaObject::normalizedSignature( signal.toAscii() ); - - if( QMetaObject::checkConnectArgs( theSignal, theSignal ) ) - { - int signalId = object->metaObject()->indexOfSignal( theSignal ); - if( signalId != -1 ) - { - int slotId = object->metaObject()->indexOfMethod( theSignal ); - if( slotId != -1 ) - { - if( QMetaObject::connect( object, signalId, t_slots, slotId + QObject::staticMetaObject.methodCount(), Qt::AutoConnection ) ) - { - t_slots->listBlock << pBlock; - - char szSlotName[ 20 ]; - hb_snprintf( szSlotName, sizeof( szSlotName ), "SLOT_%d", slotId ); - - object->setProperty( szSlotName, ( int ) t_slots->listBlock.size() ); - object->setProperty( pszSignal, ( int ) t_slots->listBlock.size() ); - - nResult = 0; - } - else - nResult = 8; - } - else - nResult = 7; - } - else - nResult = 6; - } - else - nResult = 5; - } - else - { - if( t_slots->listBlock.at( i - 1 ) != NULL ) - { - hb_itemRelease( t_slots->listBlock.at( i - 1 ) ); - } - t_slots->listBlock[ i - 1 ] = pBlock; - nResult = 0; - } - - if( nResult > 0 ) - { - hb_itemRelease( pBlock ); - } - } - else - { - nResult = 3; - } - } - else - nResult = 2; - } - else - nResult = 1; - - hb_retni( nResult ); -} - -/* - * Harbour function to disconnect signals - */ - -HB_FUNC( __HBQT_SLOTS_DISCONNECT ) -{ - int nResult; - HBQSlots * t_slots = hbqt_par_HBQSlots( 1 ); - - if( t_slots ) - { - QObject * object = ( QObject * ) hbqt_pPtrFromObj( 2 ); - if( object ) - { - const char * pszSignal = hb_parcx( 3 ); - - int i = object->property( pszSignal ).toInt(); - if( i > 0 && i <= t_slots->listBlock.size() ) - { - object->setProperty( pszSignal, QVariant() ); - - QString signal = pszSignal; - QByteArray theSignal = signal.toAscii(); - - int signalId = object->metaObject()->indexOfSignal( QMetaObject::normalizedSignature( theSignal ) ); - if( signalId != -1 ) - { - if( QMetaObject::disconnect( object, signalId, 0, 0 ) ) - nResult = 0; - else - nResult = 5; - } - else - nResult = 4; - - if( t_slots->listBlock.at( i - 1 ) != NULL ) - { - hb_itemRelease( t_slots->listBlock.at( i - 1 ) ); - t_slots->listBlock[ i - 1 ] = NULL; - } - } - else - nResult = 3; - } - else - nResult = 2; - } - else - nResult = 1; - - hb_retni( nResult ); -} - -HB_FUNC( __HBQT_SLOTS_NEW ) -{ - hb_retptrGC( hbqt_gcAllocate_HBQSlots( ( HBQSlots * ) new HBQSlots(), true ) ); -} #endif diff --git a/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.h b/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.h index a56852877d..cbc2b7de3a 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.h +++ b/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.h @@ -70,10 +70,13 @@ class HBQSlots: public QObject { public: - HBQSlots( QObject *parent = 0 ); + HBQSlots( PHB_ITEM pObj ); ~HBQSlots(); QList listBlock; + int hbConnect( PHB_ITEM obj, char * pszSignal, PHB_ITEM block ); + int hbDisconnect( PHB_ITEM obj, char * pszSignal ); + int qt_metacall( QMetaObject::Call call, int id, void **arguments ); }; diff --git a/harbour/contrib/hbqt/qtcore/hbqt_misc.prg b/harbour/contrib/hbqt/qtcore/hbqt_misc.prg index 74c43ad029..af03778939 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_misc.prg +++ b/harbour/contrib/hbqt/qtcore/hbqt_misc.prg @@ -63,7 +63,7 @@ CREATE CLASS HbQtObjectHandler VAR __pSlots PROTECTED VAR __pEvents PROTECTED - METHOD fromPointer( pPtr ) + //METHOD fromPointer( pPtr ) METHOD hasValidPointer() METHOD connect( cnEvent, bBlock ) @@ -76,18 +76,6 @@ ENDCLASS /*----------------------------------------------------------------------*/ -/* TODO: Drop this function when all raw QT pointers are fully eliminated from .prg level. */ -METHOD HbQtObjectHandler:fromPointer( pPtr ) - /* NOTE: Non-GC collected pointers are allowed here. */ - IF hb_isPointer( pPtr ) - ::pPtr := pPtr - ELSE - __hbqt_error() - ENDIF - RETURN Self - -/*----------------------------------------------------------------------*/ - /* TODO: Drop this function, as it's not desired to have invalid QT pointers wrapped into valid .prg level QT objects. Currently it will return .F. for objects created using :fromPointer() */ @@ -123,16 +111,6 @@ METHOD HbQtObjectHandler:onError() /*----------------------------------------------------------------------*/ -/* TOFIX: Eliminate that */ -STATIC FUNCTION HBQEventsFromPointer( ... ) - LOCAL p - FOR EACH p IN { ... } - hb_pvalue( p:__enumIndex(), __hbqt_ptr( p ) ) - NEXT - RETURN HB_HBQEvents():fromPointer( ... ) - -/*----------------------------------------------------------------------*/ - METHOD HbQtObjectHandler:connect( cnEvent, bBlock ) LOCAL nResult @@ -144,9 +122,9 @@ METHOD HbQtObjectHandler:connect( cnEvent, bBlock ) CASE "C" IF Empty( ::__pSlots ) - ::__pSlots := __hbqt_slots_new() + ::__pSlots := HBQSlots( Self ) ENDIF - nResult := __hbqt_slots_connect( ::__pSlots, ::pPtr, cnEvent, bBlock ) + nResult := ::__pSlots:hbconnect( Self, cnEvent, bBlock ) SWITCH nResult CASE 0 @@ -157,11 +135,10 @@ METHOD HbQtObjectHandler:connect( cnEvent, bBlock ) EXIT CASE "N" - IF Empty( ::__pEvents ) - ::__pEvents := __hbqt_events_new(Self) + ::__pEvents := HBQEvents( Self ) ENDIF - nResult := __hbqt_events_connect( ::__pEvents, ::pPtr, cnEvent, bBlock ) + nResult := ::__pEvents:hbConnect( Self, cnEvent, bBlock ) SWITCH nResult CASE 0 @@ -183,11 +160,12 @@ METHOD HbQtObjectHandler:connect( cnEvent, bBlock ) METHOD HbQtObjectHandler:disconnect( cnEvent ) - LOCAL nResult + LOCAL nResult := 0 SWITCH ValType( cnEvent ) CASE "C" - - nResult := __hbqt_slots_disconnect( ::__pSlots, ::pPtr, cnEvent ) + IF ! empty( ::__pSlots ) + nResult := ::__pSlots:hbdisconnect( Self, cnEvent ) + ENDIF SWITCH nResult CASE 0 @@ -202,8 +180,9 @@ METHOD HbQtObjectHandler:disconnect( cnEvent ) EXIT CASE "N" - - nResult := __hbqt_events_disconnect( ::__pEvents, ::pPtr, cnEvent ) + IF ! empty( ::__pEvents ) + nResult := ::__pEvents:hbdisconnect( Self, cnEvent ) + ENDIF SWITCH nResult CASE 0 @@ -226,12 +205,8 @@ METHOD HbQtObjectHandler:disconnect( cnEvent ) METHOD HbQtObjectHandler:_destroy() - HB_TRACE( HB_TR_DEBUG, " _destroy()", ::className(), 0 ) - - ::__pSlots := NIL - ::__pEvents := NIL - - HB_TRACE( HB_TR_DEBUG, " _destroy()", ::className(), 1 ) +// ::__pSlots := NIL +// ::__pEvents := NIL RETURN NIL diff --git a/harbour/contrib/hbqt/qtcore/hbqt_pointer.cpp b/harbour/contrib/hbqt/qtcore/hbqt_pointer.cpp index 9c3be6be38..91e09fa8df 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_pointer.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_pointer.cpp @@ -191,18 +191,6 @@ void * hbqt_pPtrFromObj( int iParam ) return pointer; } -#if 1 /* TOFIX: This is the only raw pointers usage - HBQEvents and HBQSlots */ - else if( hb_itemType( pObj ) == HB_IT_POINTER ) - { - HB_TRACE( HB_TR_DEBUG, ( "hbqt_pPtrFromObj= IS_POINTER" ) ); - pointer = hbqt_gcpointer( iParam ); - - if( iParam == 0 && ! pointer ) - hb_errRT_BASE( EG_ARG, 9999, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); - - return pointer; - } -#endif else { HB_TRACE( HB_TR_DEBUG, ( "hbqt_pPtrFromObj(): returns NULL" ) ); @@ -212,6 +200,34 @@ void * hbqt_pPtrFromObj( int iParam ) } } +void * hbqt_pPtrFromObject( PHB_ITEM pObj ) +{ + static PHB_DYNS s_pDyns_hPPtrAssign = NULL; + void * pointer; + + if( ! s_pDyns_hPPtrAssign ) + s_pDyns_hPPtrAssign = hb_dynsymGetCase( "PPTR" ); + + if( hb_itemType( pObj ) == HB_IT_OBJECT ) + { + hb_vmPushDynSym( s_pDyns_hPPtrAssign ); + hb_vmPush( pObj ); + hb_vmSend( 0 ); + + pointer = hbqt_gcpointer( -1 ); + + if( ! pointer ) + hb_errRT_BASE( EG_ARG, 9999, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + + return pointer; + } + else + { + hb_errRT_BASE( EG_ARG, 9999, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } + return NULL; +} + void hbqt_set_pptr( void * ptr, PHB_ITEM pSelf ) { static PHB_DYNS s_pDyns_hPPtrAssign = NULL; diff --git a/harbour/contrib/hbqt/qtcore/hbqtcore.hbx b/harbour/contrib/hbqt/qtcore/hbqtcore.hbx index 87174df026..cd3b5ae53d 100644 --- a/harbour/contrib/hbqt/qtcore/hbqtcore.hbx +++ b/harbour/contrib/hbqt/qtcore/hbqtcore.hbx @@ -163,15 +163,9 @@ DYNAMIC QVARIANT DYNAMIC QVERSION DYNAMIC __HBQTCORE DYNAMIC __HBQT_ERROR -DYNAMIC __HBQT_EVENTS_CONNECT -DYNAMIC __HBQT_EVENTS_DISCONNECT -DYNAMIC __HBQT_EVENTS_NEW DYNAMIC __HBQT_ISPOINTER DYNAMIC __HBQT_PTR DYNAMIC __HBQT_SETUTF8 -DYNAMIC __HBQT_SLOTS_CONNECT -DYNAMIC __HBQT_SLOTS_DISCONNECT -DYNAMIC __HBQT_SLOTS_NEW #if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBQTCORE__REQUEST ) #uncommand DYNAMIC => EXTERNAL diff --git a/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth b/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth index 325139ebda..724f414f8f 100644 --- a/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth +++ b/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth @@ -36,7 +36,7 @@ New = */ HB_FUNC( QT_HBQEVENTS ) { - __HB_RETPTRGC__( new HBQEvents() ); + __HB_RETPTRGC__( new HBQEvents( hb_param( 1, HB_IT_OBJECT ) ) ); } static HB_GARBAGE_FUNC( hbqt_gcMark_HBQEvents ) @@ -69,9 +69,8 @@ static HB_GARBAGE_FUNC( hbqt_gcMark_HBQEvents ) -bool hbConnect( PHB_ITEM obj, int event, PHB_ITEM block ) -bool hbDisconnect( PHB_ITEM obj, int event ) -bool hbClear() +int hbConnect( PHB_ITEM obj, int event, PHB_ITEM block ) +int hbDisconnect( PHB_ITEM obj, int event ) diff --git a/harbour/contrib/hbqt/qtcore/qth/HBQSlots.qth b/harbour/contrib/hbqt/qtcore/qth/HBQSlots.qth index a5ec952294..bdd6336e6c 100644 --- a/harbour/contrib/hbqt/qtcore/qth/HBQSlots.qth +++ b/harbour/contrib/hbqt/qtcore/qth/HBQSlots.qth @@ -58,7 +58,7 @@ HB_GARBAGE_FUNC( hbqt_gcMark_HBQSlots ) */ HB_FUNC( QT_HBQSLOTS ) { - __HB_RETPTRGC__( new HBQSlots() ); + __HB_RETPTRGC__( new HBQSlots( hb_param( 1, HB_IT_OBJECT ) ) ); } @@ -66,6 +66,8 @@ HB_FUNC( QT_HBQSLOTS ) +int hbConnect( PHB_ITEM obj, char * event, PHB_ITEM block ) +int hbDisconnect( PHB_ITEM obj, char * event ) diff --git a/harbour/contrib/hbqt/tests/demoqt.prg b/harbour/contrib/hbqt/tests/demoqt.prg index aac891360c..738ee0c154 100644 --- a/harbour/contrib/hbqt/tests/demoqt.prg +++ b/harbour/contrib/hbqt/tests/demoqt.prg @@ -78,8 +78,7 @@ STATIC oSys, oMenuSys, oActShow, oActHide /*----------------------------------------------------------------------*/ FUNCTION My_Events( e ) - HB_SYMBOL_UNUSED( e ) - HB_TRACE( HB_TR_DEBUG, "Key Pressed", e:key() ) + MsgInfo( "Pressed: " + hb_ntos( e:key() ) ) RETURN nil /*----------------------------------------------------------------------*/ @@ -188,8 +187,6 @@ PROCEDURE ExecOneMore() xReleaseMemory( { oBtn, oLabel, oProg, oSBar, aGrid, aList, aMenu, aTool, aTabs, oDA, oWnd, oEventLoop } ) - HB_GCALL( .T.) - RETURN /*----------------------------------------------------------------------*/ @@ -528,7 +525,6 @@ STATIC FUNCTION MsgInfo( cMsg ) oMB:exec() oMB := NIL - HB_GCALL( .T.) RETURN nil @@ -542,7 +538,6 @@ STATIC FUNCTION FileDialog() oFD:exec() oFD := NIL - HB_GCALL( .T.) RETURN nil @@ -583,7 +578,6 @@ STATIC FUNCTION Dialogs( cType ) ENDCASE oDlg := NIL - HB_GCALL( .T. ) RETURN nil diff --git a/harbour/contrib/hbxbp/xbptabpage.prg b/harbour/contrib/hbxbp/xbptabpage.prg index 5cfdd79fe5..dc17e2230d 100644 --- a/harbour/contrib/hbxbp/xbptabpage.prg +++ b/harbour/contrib/hbxbp/xbptabpage.prg @@ -308,8 +308,8 @@ METHOD XbpTabWidget:disconnect() METHOD XbpTabWidget:destroy() - ::disconnect() ::oParent:oTabWidget := NIL + //::disconnect() ::xbpWindow:destroy() RETURN NIL