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.
This commit is contained in:
Pritpal Bedi
2009-12-14 18:03:45 +00:00
parent 90a125c300
commit 2fbfe2d315
8 changed files with 105 additions and 80 deletions

View File

@@ -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,

View File

@@ -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 */

View File

@@ -6,8 +6,6 @@
* Harbour Project source code:
* QT wrapper main header
*
* Copyright 2009 Marcos Antonio Gambeta <marcosgambeta at gmail dot com>
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* 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

View File

@@ -6,8 +6,6 @@
* Harbour Project source code:
* QT wrapper main header
*
* Copyright 2009 Marcos Antonio Gambeta <marcosgambeta at gmail dot com>
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* www - http://www.harbour-project.org
*
@@ -60,6 +58,7 @@
/*----------------------------------------------------------------------*/
#include <QAbstractItemModel>
#include <QPointer>
class HBDbfModel : public QAbstractItemModel
{

View File

@@ -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 )

View File

@@ -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 )

View File

@@ -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 )
</SUBCLASS>
<CODE>
@@ -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();
}
</CODE>

View File

@@ -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