On Sat, 24 Oct 2009, Pritpal Bedi wrote:

Hi,

> There is a slight change as follows and it works.
> This is not a proper change so show me what is the 
> proper code skeleton.
>    QWidget * hbqt_par_QWidget( int iParam )
>    {
>       QPointer< QWidget > * pObj;
>       QWidget * obj = NULL;
> 
>       pObj = ( QPointer< QWidget > * ) hb_parptrGC( &s_gcQWidget, iParam );
>       if( pObj == NULL )
>       {
>          /* Not a QWidget pointer item, check all registered
>           * descendant classes
>           */
>          QT_PARAM_INFO * paramInfo = s_paramList;
>          while( paramInfo )
>          {
> /////////////////      This is the change   ////////////////////////
> //////     hbqt_par_Q*() functions are returning pure object without
> QPointer<> cast. //////
> ////////////////                                   ////////////////////////
>             obj = ( QWidget * ) paramInfo->pFunc( iParam );
>             if( obj )
>                return obj;

Exactly. Sorry it was my typo. I haven't tested above code and I've wrote it
only for this message. Now I see that it needs also yet another modification.
We need parameter to enable/disable RTE in this function. So final version
should look like:

   typedef void * ( * QT_PARAM_FUNC ) ( int, BOOL );
   [...]

   QPageSetupDialog * hbqt_par_QPageSetupDialog( int iParam, BOOL fError )
   {
      QPointer< QPageSetupDialog > * pObj;
      QPageSetupDialog * obj = NULL;

      pObj = ( QPointer< QPageSetupDialog > * )
                                 hb_parptrGC( &s_gcQPageSetupDialog, iParam );
      if( pObj == NULL )
      {
         /* Not a QPageSetupDialog pointer item, check all registered
          * descendant classes
          */
         QT_PARAM_INFO * paramInfo = s_paramList;
         while( paramInfo )
         {
            obj = ( QPageSetupDialog * ) paramInfo->pFunc( iParam, FALSE );
            if( obj )
               return obj;
            paramInfo = paramInfo->pNext;
         }
      }

      if( pObj == NULL )
      {
         if( fError )
         {
            /* RT ERROR - wrong parameter */
         }
      }
      else
      {
         obj = * pObj;
         if( obj == NULL && fError )
         {
            /* RT ERROR - object deleted by other code */
         }
      }

      return obj;
   }

If you want then instead of adding new parameter you can define that
iParam < 0 disables RTE and change this function to:

   QPageSetupDialog * hbqt_par_QPageSetupDialog( int iParam )
   {
      QPointer< QPageSetupDialog > * pObj;
      QPageSetupDialog * obj = NULL;
      BOOL fError = TRUE;

      if( iParam < 0 )
      {
         fError = TRUE;
         iParam = -iParam;
      }
      pObj = ( QPointer< QPageSetupDialog > * )
                                 hb_parptrGC( &s_gcQPageSetupDialog, iParam );
      if( pObj == NULL )
      {
         /* Not a QPageSetupDialog pointer item, check all registered
          * descendant classes
          */
         QT_PARAM_INFO * paramInfo = s_paramList;
         while( paramInfo )
         {
            obj = ( QPageSetupDialog * ) paramInfo->pFunc( -iParam );
            if( obj )
               return obj;
            paramInfo = paramInfo->pNext;
         }
      }

      if( pObj == NULL )
      {
         if( fError )
         {
            /* RT ERROR - wrong parameter */
         }
      }
      else
      {
         obj = * pObj;
         if( obj == NULL && fError )
         {
            /* RT ERROR - object deleted by other code */
         }
      }

      return obj;
   }

though maybe such version is less readable.

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

Reply via email to