> Let me _repeat_ again:

I know exactly what you have been saying for a long time :-)
this specific proposal was only to do parameter checking

> Problem is not with functioning of the objects,
> that is working perfect. It lies when object is _destructed_
> by Qt and when Harbour tries to _free_ the pointer.
>
> This is the scenario we should base our findings...
>
>    oWnd contains oPushButton, oMenu's and lot other controls - comples
>    parent child hirarchy. Now suppose oWnd goes out of scope, Harbour
>    schedules garbage collection and it is not know in what order it will
>    release the variables. Assume, oWidget is released first which contains
>    many others. Our destructor will be called which in turn will issue
>    delete ( QWidget * ) p->ph . The request will reach Qt GC ( they may
> call is
>    with another name ) and Qt deletes oWidget and, by its way of
> handellings,
>    Qt will also delete all childeren.

Perfect, this is exactly what Qt documentation says. This is normal.
And I checked this via the trace logs.

> The pointers held in Harbour GC of
> those
>    children are still there to be released as per same cycle. And voila
> GPF, because
>    those are already been freed by Qt.

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.

in pseudo-code,
in hbqt_gcAllocate_*
  hash[ p->ph ] = p

in  the overloaded delete:
  if ( t := hash[ ptr ] ) {
     t->ph := 0;
     remove hash[ ptr ];
  }

If you accept my first idea to change bNew in a bitmap "status" you can
 t->bNew |= QT_DELETED ;

In this way you should not care about object destruction order....


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

Francesco
PS: Qt has an hash class, QHash...
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to