Hi

This is the code how object is created and GC applied.
This code compiles perfect but receive GPF at its first invocation.

//---------------------------------------//

HB_GARBAGE_FUNC( Q_release )
{
   QGC_POINTER * p = ( QGC_POINTER * ) Cargo;
   if( p && p->ph )
   {
      p->func( p->ph );
   }
}

const HB_GC_FUNCS QT_gcFuncs =
{
   Q_release,
   hb_gcDummyMark
};

HB_GC_FUNCS gcFuncs( void )
{
   return QT_gcFuncs;
}

void * hbqt_gcpointer( int iParam )
{
   HB_GC_FUNCS qt_gcFuncs = gcFuncs();
   QGC_POINTER * p = ( QGC_POINTER * ) hb_parptrGC( &qt_gcFuncs, iParam );

   ///////////////////      I cannot reach past this point   ///////////////

   if( p && p->ph )
   {
      return p->ph;
   }
   else
   {
      return hb_parptr( iParam );
   }
}

//--------------------------------------------------//

QT_G_FUNC( release_QMainWindow )
{
   void * ph = ( void * ) Cargo;
   if( ph )
   {
      const QMetaObject * m = ( ( QObject * ) ph )->metaObject();
      if( ( QString ) m->className() != ( QString ) "QObject" )
      {
         delete ( ( QMainWindow * ) ph );
         ph = NULL;
      }
   }
}

HB_FUNC( QT_QMAINWINDOW )
{
   HB_GC_FUNCS qt_gcFuncs = gcFuncs();

   QGC_POINTER * p = ( QGC_POINTER * ) hb_gcAllocate( sizeof( QGC_POINTER ),
&qt_gcFuncs );

   QPointer< QMainWindow > pObj = NULL;
   if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) )
   {
      pObj = new QMainWindow( hbqt_par_QWidget( 1 ), ( Qt::WindowFlags )
hb_parni( 2 ) ) ;
   }
   else
   {
      pObj = new QMainWindow();
   }
   p->ph = pObj;
   p->func = release_QMainWindow;

   hb_retptrGC( p );
}

//------------------------------------------------//

Where is the error ?

Regards
Pritpal Bedi
-- 
View this message in context: 
http://www.nabble.com/HBQT---Nearly-lost-how-to-implement-new-GC-tp26033190p26034815.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to