francesco perillo wrote:
> 
>> Let me _repeat_ again:
> This should only happen if in this hierarchy there are objects without
> QPointer...  if all objects have QPointers then there is something
> wrong... If there are objects that are not deriving from QObject so
> that they can't have QPointer (is it ever possible for display classes
> ????) I agree with you that this doing a recursion and deleting
> objects ourself is the only way.... unless we overload the delete
> operator, take the pointer value, lookup the address (via an HASH ???)
> and discover the QGC_POINTER_* whose ph is equal to the pointer value.
> 

We can overload new() and delete() operators.
Read previsous messages and flag -hbnocppmm to hbMK2.

How you can do so:

1. Put following code in cppstub.cpp and add to hbide.hbp

   const char * __hbmk2_hbcppmm( void )
   {
      return "HBCPPMM";
   }
   int getnew( void )
   {
      static int i = 0;
      return ++i;
   }
   int getdelete( void )
   {
      static int i = 0;
      return ++i;
   }
   void * operator new( size_t nSize )
   {
      if( nSize == 0 )
      {
         nSize = 1;
      }
      void * ptr = hb_xgrab( nSize );
HB_TRACE( HB_TR_ALWAYS, ( "                new(  %p ) %i  %i", ptr, nSize,
getnew() ) );
      return ptr;
   }
   void operator delete( void * ptr )
   {
      if( ptr )
      {
         hb_xfree( ptr );
HB_TRACE( HB_TR_ALWAYS, ( "<      delete( void * %p ) %s  %i", ptr, "        
0", getdelete() ) );
         ptr = 0;
      }
   }

2. Build hbide as hbmk2 hbide.hbp -hbnocppmm
3. Then follow the tracelog.

Hopefully you will understand how delete() is called.
You will also be surprised to know that new() is always called 
but delete() is only called for non-QObject derived objects, 
and that too are missing sometimes.



> I just found but not completely "understood" these two links:
> http://silmor.de/33
> http://search.cpan.org/~awin/PerlQt-2.105/doc/starting.pod#Object_destruction
> 

First link I studied at when we started this project.
It gave me wider insight into the subject, though today
I got one more tip: destroyed() signal. I will check how
it can be exploited, though, the same functionality 
is achieved with p->pq already.

2nd link I never read but it has little for us.
BTW as many links about Qt destruction mechanism state 
the complexity of approach trolltech adopted in this regard.
Every binding is in trouble.



-----
     enjoy hbIDEing...
        Pritpal Bedi 
http://hbide.vouch.info/
-- 
View this message in context: 
http://n2.nabble.com/Improve-on-hbqt-object-handling-tp4887521p4887858.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