diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3c7695f5c3..4799670acf 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,16 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-14 10:01 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbqt/hbqt.h + * contrib/hbqt/hbqt_hbdbfmodel.cpp + * contrib/hbqt/hbqt_hbdbfmodel.h + * contrib/hbqt/qtcore/QAbstractItemModel.cpp + * contrib/hbqt/qtcore/TQAbstractItemModel.prg + * contrib/hbqt/qth/QAbstractItemModel.qth + * contrib/hbxbp/xbpbrowse.prg + + Implemented GC collectible pointer for HBDbfModel() class. + 2009-12-14 17:25 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/hbcrc.c ! fixed hb_crcct() to work with polynomials smaller then 8 bit, diff --git a/harbour/contrib/hbqt/hbqt.h b/harbour/contrib/hbqt/hbqt.h index 939dd5937a..743991c889 100644 --- a/harbour/contrib/hbqt/hbqt.h +++ b/harbour/contrib/hbqt/hbqt.h @@ -377,9 +377,10 @@ extern int hbqt_getmemused( void ); #define hbqt_par_QWizardPage( n ) ( ( QWizardPage * ) hbqt_gcpointer( n ) ) #define hbqt_par_QWSEvent( n ) ( ( QWSEvent * ) hbqt_gcpointer( n ) ) -#define hbqt_par_HBDbfModel( n ) ( ( HBDbfModel* ) hb_parptr( n ) ) +#define hbqt_par_HBDbfModel( n ) ( ( HBDbfModel * ) hbqt_gcpointer( n ) ) +#define hbqt_par_HBQMainWindow( n ) ( ( HBQMainWindow * ) hbqt_gcpointer( n ) ) + #define hbqt_par_HBQTableView( n ) ( ( HBQTableView* ) hb_parptr( n ) ) -#define hbqt_par_HBQMainWindow( n ) ( ( HBQMainWindow* ) hb_parptr( n ) ) #define hbqt_par_QString( n ) ( ( QString ) hb_parcx( n ) ) #define hbqt_par_QRgb( n ) ( hb_parnint( n ) ) @@ -391,6 +392,10 @@ extern int hbqt_getmemused( void ); #define hbqt_ret_QAbstractItemModel( p ) ( hb_retptr( ( QAbstractItemModel* ) p ) ) #define hbqt_ret_QPrinter( p ) ( hb_retptr( ( QPrinter* ) p ) ) +/* Declarations which will not be generated auto */ +extern QT_G_FUNC( release_HBDbfModel ); +extern void * gcAllocate_HBDbfModel( void * pObj ); + #endif #endif /* __HBQT_H */ diff --git a/harbour/contrib/hbqt/hbqt_hbdbfmodel.cpp b/harbour/contrib/hbqt/hbqt_hbdbfmodel.cpp index 560bebee8e..7da682dfe1 100644 --- a/harbour/contrib/hbqt/hbqt_hbdbfmodel.cpp +++ b/harbour/contrib/hbqt/hbqt_hbdbfmodel.cpp @@ -6,8 +6,6 @@ * Harbour Project source code: * QT wrapper main header * - * Copyright 2009 Marcos Antonio Gambeta - * * Copyright 2009 Pritpal Bedi * www - http://www.harbour-project.org * @@ -308,4 +306,84 @@ void HBDbfModel::hbSetRowColumns( int rows, int cols ) iCols = cols; } +typedef struct +{ + void * ph; + QT_G_FUNC_PTR func; + QPointer< HBDbfModel > pq; +} QGC_POINTER_HBDbfModel; + +QT_G_FUNC( release_HBDbfModel ) +{ + QGC_POINTER_HBDbfModel * p = ( QGC_POINTER_HBDbfModel * ) Cargo; + + HB_TRACE( HB_TR_DEBUG, ( "release_HBDbfModel p=%p", p)); + HB_TRACE( HB_TR_DEBUG, ( "release_HBDbfModel ph=%p pq=%p", p->ph, (void *)(p->pq))); + + if( p && p->ph && p->pq ) + { + const QMetaObject * m = ( ( QObject * ) p->ph )->metaObject(); + if( ( QString ) m->className() != ( QString ) "QObject" ) + { + switch( hbqt_get_object_release_method() ) + { + case HBQT_RELEASE_WITH_DELETE: + delete ( ( HBDbfModel * ) p->ph ); + break; + case HBQT_RELEASE_WITH_DESTRUTOR: + ( ( HBDbfModel * ) p->ph )->~HBDbfModel(); + break; + case HBQT_RELEASE_WITH_DELETE_LATER: + ( ( HBDbfModel * ) p->ph )->deleteLater(); + break; + } + p->ph = NULL; + HB_TRACE( HB_TR_DEBUG, ( "release_HBDbfModel Object deleted! %i B %i KB", ( int ) hb_xquery( 1001 ), hbqt_getmemused() ) ); + } + else + { + HB_TRACE( HB_TR_DEBUG, ( "NO release_HBDbfModel Object Name Missing!" ) ); + } + } + else + { + HB_TRACE( HB_TR_DEBUG, ( "DEL release_HBDbfModel Object Already deleted!" ) ); + } +} + +void * gcAllocate_HBDbfModel( void * pObj ) +{ + QGC_POINTER_HBDbfModel * p = ( QGC_POINTER_HBDbfModel * ) hb_gcAllocate( sizeof( QGC_POINTER_HBDbfModel ), gcFuncs() ); + + p->ph = pObj; + p->func = release_HBDbfModel; + new( & p->pq ) QPointer< HBDbfModel >( ( HBDbfModel * ) pObj ); + HB_TRACE( HB_TR_DEBUG, ( " new_HBDbfModel %i B %i KB", ( int ) hb_xquery( 1001 ), hbqt_getmemused() ) ); + return( p ); +} + +HB_FUNC( QT_HBDBFMODEL ) +{ + void * pObj = NULL; + + pObj = ( HBDbfModel * ) new HBDbfModel( ( PHB_ITEM ) hb_param( 1, HB_IT_BLOCK ) ); + + hb_retptrGC( gcAllocate_HBDbfModel( pObj ) ); +} + +HB_FUNC( QT_HBDBFMODEL_RESET ) +{ + hbqt_par_HBDbfModel( 1 )->reset(); +} + +HB_FUNC( QT_HBDBFMODEL_INDEX ) +{ + hb_retptrGC( gcAllocate_QModelIndex( new QModelIndex( hbqt_par_HBDbfModel( 1 )->index( hb_parni( 2 ), hb_parni( 3 ), QModelIndex() ) ) ) ); +} + +HB_FUNC( QT_HBDBFMODEL_HBSETROWCOLUMNS ) +{ + hbqt_par_HBDbfModel( 1 )->hbSetRowColumns( hb_parni( 2 ), hb_parni( 3 ) ); +} + #endif diff --git a/harbour/contrib/hbqt/hbqt_hbdbfmodel.h b/harbour/contrib/hbqt/hbqt_hbdbfmodel.h index 870e5b96f4..ca11cddf76 100644 --- a/harbour/contrib/hbqt/hbqt_hbdbfmodel.h +++ b/harbour/contrib/hbqt/hbqt_hbdbfmodel.h @@ -6,8 +6,6 @@ * Harbour Project source code: * QT wrapper main header * - * Copyright 2009 Marcos Antonio Gambeta - * * Copyright 2009 Pritpal Bedi * www - http://www.harbour-project.org * @@ -60,6 +58,7 @@ /*----------------------------------------------------------------------*/ #include +#include class HBDbfModel : public QAbstractItemModel { diff --git a/harbour/contrib/hbqt/qtcore/QAbstractItemModel.cpp b/harbour/contrib/hbqt/qtcore/QAbstractItemModel.cpp index 91eb570244..6a6f85f7f7 100644 --- a/harbour/contrib/hbqt/qtcore/QAbstractItemModel.cpp +++ b/harbour/contrib/hbqt/qtcore/QAbstractItemModel.cpp @@ -94,35 +94,6 @@ * virtual ~QAbstractItemModel () */ -HB_FUNC( QT_HBDBFMODEL ) -{ - //hb_retptrGC( hbqt_ptrTOgcpointer( new HBDbfModel( ( PHB_ITEM ) hb_param( 1, HB_IT_BLOCK ) ), release_QAbstractItemModel ) ); - hb_retptr( new HBDbfModel( ( PHB_ITEM ) hb_param( 1, HB_IT_BLOCK ) ) ); -} - -HB_FUNC( QT_HBDBFMODEL_RESET ) -{ - hbqt_par_HBDbfModel( 1 )->reset(); -} - -HB_FUNC( QT_HBDBFMODEL_INDEX ) -{ -// BI hb_retptrGC( hbqt_ptrTOgcpointer( new QModelIndex( hbqt_par_HBDbfModel( 1 )->index( hb_parni( 2 ), hb_parni( 3 ), QModelIndex() ) ), release_QModelIndex ) ); - hb_retptrGC( gcAllocate_QModelIndex( new QModelIndex( hbqt_par_HBDbfModel( 1 )->index( hb_parni( 2 ), hb_parni( 3 ), QModelIndex() ) ) ) ); -} - -HB_FUNC( QT_HBDBFMODEL_HBSETROWCOLUMNS ) -{ - hbqt_par_HBDbfModel( 1 )->hbSetRowColumns( hb_parni( 2 ), hb_parni( 3 ) ); -} - -/* TOFIX: Leak if .prg code doesn't call this explicitly. */ -HB_FUNC( QT_HBDBFMODEL_DESTROY ) -{ -// BI:TODO fix the GPF hbqt_par_HBDbfModel( 1 )->~HBDbfModel(); -// BUT WITHOUT THIS FM STATISTICS GENERATE A BIG LOG SO THIS IS NOT THE OPTION NOW - hbqt_par_HBDbfModel( 1 )->~HBDbfModel(); -} QT_G_FUNC( release_QAbstractItemModel ) diff --git a/harbour/contrib/hbqt/qtcore/TQAbstractItemModel.prg b/harbour/contrib/hbqt/qtcore/TQAbstractItemModel.prg index 0da95c6e89..71f735dc5d 100644 --- a/harbour/contrib/hbqt/qtcore/TQAbstractItemModel.prg +++ b/harbour/contrib/hbqt/qtcore/TQAbstractItemModel.prg @@ -256,7 +256,6 @@ CREATE CLASS HBDbfModel INHERIT QAbstractItemModel METHOD reset() METHOD index( nRow, nCol ) METHOD hbSetRowColumns( nRows, nCols ) - METHOD destroy() ENDCLASS @@ -273,7 +272,4 @@ METHOD HBDbfModel:index( nRow, nCol ) METHOD HBDbfModel:hbSetRowColumns( nRows, nCols ) RETURN Qt_HBDbfModel_hbSetRowColumns( ::pPtr, nRows, nCols ) -METHOD HBDbfModel:destroy() - RETURN Qt_HBDbfModel_destroy( ::pPtr ) - diff --git a/harbour/contrib/hbqt/qth/QAbstractItemModel.qth b/harbour/contrib/hbqt/qth/QAbstractItemModel.qth index 9c343121c4..c6f083334d 100644 --- a/harbour/contrib/hbqt/qth/QAbstractItemModel.qth +++ b/harbour/contrib/hbqt/qth/QAbstractItemModel.qth @@ -67,7 +67,6 @@ CREATE CLASS HBDbfModel INHERIT QAbstractItemModel METHOD reset() METHOD index( nRow, nCol ) METHOD hbSetRowColumns( nRows, nCols ) - METHOD destroy() ENDCLASS @@ -84,9 +83,6 @@ METHOD HBDbfModel:index( nRow, nCol ) METHOD HBDbfModel:hbSetRowColumns( nRows, nCols ) RETURN Qt_HBDbfModel_hbSetRowColumns( ::pPtr, nRows, nCols ) -METHOD HBDbfModel:destroy() - RETURN Qt_HBDbfModel_destroy( ::pPtr ) - @@ -100,39 +96,9 @@ METHOD HBDbfModel:destroy() * QAbstractItemModel ( QObject * parent = 0 ) * virtual ~QAbstractItemModel () */ + HB_FUNC( QT_QABSTRACTITEMMODEL ) { - //hb_retptr( ( QAbstractItemModel* ) new QAbstractItemModel( hbqt_par_QObject( 1 ) ) ); -} - -HB_FUNC( QT_HBDBFMODEL ) -{ - //hb_retptrGC( hbqt_ptrTOgcpointer( new HBDbfModel( ( PHB_ITEM ) hb_param( 1, HB_IT_BLOCK ) ), release_QAbstractItemModel ) ); - hb_retptr( new HBDbfModel( ( PHB_ITEM ) hb_param( 1, HB_IT_BLOCK ) ) ); -} - -HB_FUNC( QT_HBDBFMODEL_RESET ) -{ - hbqt_par_HBDbfModel( 1 )->reset(); -} - -HB_FUNC( QT_HBDBFMODEL_INDEX ) -{ -// BI hb_retptrGC( hbqt_ptrTOgcpointer( new QModelIndex( hbqt_par_HBDbfModel( 1 )->index( hb_parni( 2 ), hb_parni( 3 ), QModelIndex() ) ), release_QModelIndex ) ); - hb_retptrGC( gcAllocate_QModelIndex( new QModelIndex( hbqt_par_HBDbfModel( 1 )->index( hb_parni( 2 ), hb_parni( 3 ), QModelIndex() ) ) ) ); -} - -HB_FUNC( QT_HBDBFMODEL_HBSETROWCOLUMNS ) -{ - hbqt_par_HBDbfModel( 1 )->hbSetRowColumns( hb_parni( 2 ), hb_parni( 3 ) ); -} - -/* TOFIX: Leak if .prg code doesn't call this explicitly. */ -HB_FUNC( QT_HBDBFMODEL_DESTROY ) -{ -// BI:TODO fix the GPF hbqt_par_HBDbfModel( 1 )->~HBDbfModel(); -// BUT WITHOUT THIS FM STATISTICS GENERATE A BIG LOG SO THIS IS NOT THE OPTION NOW - hbqt_par_HBDbfModel( 1 )->~HBDbfModel(); } diff --git a/harbour/contrib/hbxbp/xbpbrowse.prg b/harbour/contrib/hbxbp/xbpbrowse.prg index 01ec0d1f12..d7b3d5c699 100644 --- a/harbour/contrib/hbxbp/xbpbrowse.prg +++ b/harbour/contrib/hbxbp/xbpbrowse.prg @@ -719,24 +719,24 @@ METHOD XbpBrowse:destroy() ::oVScrollBar:pPtr := 0 ::oLeftView:destroy() - ::oLeftDbfModel:destroy() + ::oLeftDbfModel:pPtr := 0 ::oLeftVHeaderView:pPtr := 0 ::oLeftHeaderView:pPtr := 0 ::oLeftFooterView:pPtr := 0 - ::oLeftFooterModel:destroy() + ::oLeftFooterModel:pPtr := 0 ::oRightView:destroy() ::oRightHeaderView:pPtr := 0 - ::oRightDbfModel:destroy() + ::oRightDbfModel:pPtr := 0 ::oRightFooterView:pPtr := 0 - ::oRightFooterModel:destroy() + ::oRightFooterModel:pPtr := 0 ::oTableView:destroy() ::oVHeaderView:pPtr := 0 - ::oDbfModel:destroy() + ::oDbfModel:pPtr := 0 ::oFooterView:pPtr := 0 - ::oFooterModel:destroy() + ::oFooterModel:pPtr := 0 ::oGridLayout:pPtr := 0