From bcf90cd673d8cb5d79d25a79285a51e8eaec10a5 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Sun, 3 Jun 2012 10:15:33 +0000 Subject: [PATCH] 2012-06-03 03:02 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtcore/hbqt_bind.cpp + Implemented: requested by the group protocol - to handle parent-child relations internally by hbQT leading not to hold everything in scoped variables. All objects will behave accordingly except QAction() which is never get a parent accoring to Qt docs. ; NOTE: will explain this in detail in reply to the message of this commit. --- harbour/ChangeLog | 11 +++++++++++ harbour/contrib/hbqt/qtcore/hbqt_bind.cpp | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 031447408f..d63467f0ef 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,17 @@ The license applies to all entries newer than 2009-04-28. */ +2012-06-03 03:02 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/qtcore/hbqt_bind.cpp + + Implemented: requested by the group protocol - to handle + parent-child relations internally by hbQT leading not + to hold everything in scoped variables. All objects will + behave accordingly except QAction() which is never get a + parent accoring to Qt docs. + + ; NOTE: will explain this in detail in reply to the message + of this commit. + 2012-06-03 01:48 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/hbmk2_qt.hb ! Changed: hb_itemReturn() => hb_itemReturnRelease() to honor diff --git a/harbour/contrib/hbqt/qtcore/hbqt_bind.cpp b/harbour/contrib/hbqt/qtcore/hbqt_bind.cpp index 82eb4b3f56..44539f60af 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_bind.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_bind.cpp @@ -398,10 +398,21 @@ void hbqt_bindDestroyHbObject( PHB_ITEM pObject ) * bind_ptr = bind->next; if( bind->iFlags & HBQT_BIT_OWNER ) { - HB_TRACE( HB_TR_DEBUG, ( "hbqt_bindDestroyHbObject( %p )", bind->qtObject ) ); - bind->pDelFunc( bind->qtObject, bind->iFlags ); + if( bind->iFlags & HBQT_BIT_QOBJECT ) + { + QObject * obj = ( QObject * ) bind->qtObject; + if( obj && obj->parent() == NULL ) + { + HB_TRACE( HB_TR_ALWAYS, ( "hbqt_bindDestroyHbObject( %p )", bind->qtObject ) ); + bind->pDelFunc( bind->qtObject, bind->iFlags ); + } + } + else + { + bind->pDelFunc( bind->qtObject, bind->iFlags ); + } } - hb_xfree( bind ); + hb_xfree( bind ); /* By all means we need to clean Harbour ocuupied memory */ break; } bind_ptr = &bind->next; @@ -420,6 +431,7 @@ void hbqt_bindDestroyQtObject( void * qtObject ) { if( bind->qtObject == qtObject ) { + HB_TRACE( HB_TR_ALWAYS, ( "hbqt_bindDestroyQtObject( %p )", bind->qtObject ) ); * bind_ptr = bind->next; hb_xfree( bind ); break;