diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 62c50e5b77..436b3074f8 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,7 +16,20 @@ The license applies to all entries newer than 2009-04-28. */ -2011-09-05 10:32 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) +2011-09-06 11:03 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbqt/qtcore/hbqt_hbqevents.cpp + + patch for implementation of events handling according to Qt docs. + It MAY break existing code, please read: + up to now the event handler always returned false. That means the + event was propagated to parent widget. Sometimes it is necessary to + stop event propagation and so we must return the boolean value + returned from the codeblock. + So, if your codeblock returned .F. or a non-boolean value the code is + ok, if it returned .T. it may broke functionality. + Patch from Francesco Perillo (with minor type fix) + * minor formatting/indenting, removed old 'DO NOT Reformat' comment + +2011-09-06 10:32 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbgs/hbgs.hbp * contrib/hbodbc/hbodbc.hbp * contrib/sddodbc/sddodbc.hbp diff --git a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp index 774d9fc488..71efc2d955 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp @@ -211,10 +211,10 @@ int HBQEvents::hbDisconnect( PHB_ITEM pObj, int type ) return nResult; } - -/* DO NOT Reformat */ bool HBQEvents::eventFilter( QObject * object, QEvent * event ) { + bool stopTheEventChain = false; + if( object ) { QEvent::Type eventtype = event->type(); @@ -237,7 +237,11 @@ bool HBQEvents::eventFilter( QObject * object, QEvent * event ) if( hb_vmRequestReenter() ) { PHB_ITEM pItem = hb_itemNew( hbqt_create_objectGC( ( * pCallback )( event, false ), s_lstCreateObj.at( eventId ) ) ); - hb_vmEvalBlockV( ( PHB_ITEM ) listBlock.at( found - 1 ), 1, pItem ); + PHB_ITEM ret = hb_vmEvalBlockV( ( PHB_ITEM ) listBlock.at( found - 1 ), 1, pItem ); + + if( hb_itemType( ret ) & HB_IT_LOGICAL ) + stopTheEventChain = ( bool ) hb_itemGetL( ret ); + hb_itemRelease( pItem ); hb_vmRequestRestore(); } @@ -245,13 +249,13 @@ bool HBQEvents::eventFilter( QObject * object, QEvent * event ) } } } + if( eventtype == QEvent::Close ) - { - return true; - } + return true; } } - return false; + + return stopTheEventChain; } static void hbqt_events_init( void * cargo )