Przemysław Czerpak wrote:
> 
> After replacing HBXBP and HBQT references with some other OOP code
> all works without any problems so I can confirm that the problem is
> inside HBXBP and/or HBQT.
> 

No, it is not hbXBP and/or hbQT problem.

The problem lies in when GC pointer is retrieved.


Code in tgui.prg compiled as .dll
=======================

Function TestGPF()
   
   Local oWnd
   
   oWnd := QMainWindow():new()
   oWnd:setWindowTitle( "Window" )
   oWnd:show()

   Return Nil

Call in tst.prg linked as .exe
=====================

Function Main()
   
   TestGPF()

   Return Nil


The above code is enough to demonstrate.

The analysis
=========

oWnd:setWindowTitle( "Window" ) calls QWidget.cpp's 

HB_FUNC( QT_QWIDGET_SETWINDOWTITLE )
{
   QWidget * p = hbqt_par_QWidget( 1 );
   if( p )
   {
      ( p )->setWindowTitle( QWidget::tr( hb_parc( 2 ) ) );
   }
}


QWidget * p = hbqt_par_QWidget( 1 ); maps to hbqt_gcpointer( iParam )


void * hbqt_gcpointer( int iParam )
{
   QGC_POINTER * p;

   HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcpointer( %d )", iParam ) );

   p = ( QGC_POINTER * ) hb_parptrGC( hbqt_gcFuncs(), iParam );

   if( p && p->ph )
      return p->ph;
   else if( HB_ISPOINTER( iParam ) )
   {
      HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcpointer(): returns raw pointer: %p",
hb_parptr( iParam ) ) );
      return hb_parptr( iParam ); 
   }
   else
   {
      HB_TRACE( HB_TR_DEBUG, ( "hbqt_gcpointer(): returns NULL" ) );
      return NULL; /* TODO: Still better if RTE. */
   }
}


Here I am returned 

   else if( HB_ISPOINTER( iParam ) )
   {
      HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcpointer(): returns raw pointer: %p",
hb_parptr( iParam ) ) );
      return hb_parptr( iParam ); 
   }

which should not be as the pointer is created with new() and is a valid GC
collectible pointer.


In composite linked application without .dll part I am returned 
   if( p && p->ph )
      return p->ph;

which is correct and so no GPF.


Hope it helps.



-----
     enjoy hbIDEing...
        Pritpal Bedi 
http://hbide.vouch.info/
-- 
View this message in context: 
http://harbour-devel.1590103.n2.nabble.com/CLASSES-Instance-Variable-as-Object-Access-Assign-Elsewhere-tp4941404p4956946.html
Sent from the harbour-devel mailing list archive at Nabble.com.
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to