On Fri, 23 Oct 2009, Pritpal Bedi wrote: Hi,
> I am almost lost how to implement new GC structures > under dynamic scenario of HBQT. Just like me looking at hbqt code ;-) > Can you guide in this direction? I do not understand current hbqt code. It looks that it has three different versions of code to manage pointers to objects and only one is active. I'm afraid that it's hard for me to make any modifications in this code so I updated code for one of QT class (QPageSetupDialog). It's below. Please note that release_QPageSetupDialog and s_gcQPageSetupDialog are statics and only hbqt_par_QPageSetupDialog() is a public function not a macro which returns pointer to QPageSetupDialog. Such version gives very good encapsulation so you do not have to use any casting which may hide very serious bugs and you do not have to worry that pointer to different object is used by mistake. Inside GC block QPointer< QPageSetupDialog > is stored so it will be automatically cleared if object is released by other code. I also suggest to define .prg classes in a little bit different way which will be more efficient. In fact in Harbour and xHarbour INLINE messages are two times slower then normal messages because they need indirect EVAL() call. Anyhow it's a minor problem which can be easy done later when the base version will work as expected. best regards, Przemek /*** QPageSetupDialog.cpp ***/ [...] static HB_GARBAGE_FUNC( release_QPageSetupDialog ) { QPointer< QPageSetupDialog > * pObj = ( QPointer< QPageSetupDialog > * ) Cargo; QPageSetupDialog * obj = * pObj; if( obj ) { *pObj = NULL; delete obj; } } static const HB_GC_FUNCS s_gcQPageSetupDialog = { release_QPageSetupDialog, hb_gcDummyMark }; QPageSetupDialog * hbqt_par_QPageSetupDialog( int iParam ) { QPointer< QPageSetupDialog > * pObj = ( QPointer< QPageSetupDialog > * ) hb_parptrGC( &s_gcQPageSetupDialog, iParam ); QPageSetupDialog * obj = * pObj; /* TODO: RT ERROR if obj is NULL */ return obj; } HB_FUNC( QT_QPAGESETUPDIALOG ) { QPointer< QPageSetupDialog > * pObj = ( QPointer< QPageSetupDialog > * ) hb_gcAllocate( sizeof( QPointer< QPageSetupDialog > ), &s_gcQPageSetupDialog ); if( hb_pcount() >= 2 ) *pObj = new QPageSetupDialog( hbqt_par_QPrinter( 1 ), hbqt_par_QWidget( 1 ) ) ; else *pObj = new QPageSetupDialog( hbqt_par_QWidget( 1 ) ) ; hb_retptrGC( pObj ); } /* * virtual int exec () */ HB_FUNC( QT_QPAGESETUPDIALOG_EXEC ) { QPageSetupDialog * obj = hbqt_par_QPageSetupDialog( 1 ); if( obj ) hb_retni( obj->exec() ); } [...] _______________________________________________ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour