Hello Przemek, All
I did a few experiments which lead to some
satisfying results but also with some weired ones,
which at the moment I am unable to fix, your help is
requested in highest needs.
1. Download attached are files which outlines my concept.
http://www.nabble.com/file/p25865022/hbqt_misc.zip hbqt_misc.zip
2. Redistribute them in respective folders.
3. Make the following change in QWidget.cpp
/*
* QSize size () const
*/
HB_FUNC( QT_QWIDGET_SIZE )
{
#if 0
hb_retptr( new QSize( hbqt_par_QWidget( 1 )->size() ) );
#else
void ** ph = ( void ** ) hb_gcAlloc( sizeof( void * ), QObject_release );
* ph = new QSize( hbqt_par_QWidget( 1 )->size() ) ;
hb_retptrGC( ph );
#endif
}
4. Issue - \harbour\contrib\hbqt\generator:\>hbmk2 hbqtgen -run
5. Recompile HBQT.lib.
6. Move to tests folder and compile demoqt.prg as
hbmk2 demoqt -lxhb -Lc:\qt\2009.01\qt\lib -run
7. Open up some debugger utility to view the debug messages.
You may uncomment block at line # 143 to generate GPF right
after demoqt.exe shows up.
THE REAL ISSUE: hbqt_slots.cpp
===========
HB_GARBAGE_FUNC( QObject_release )
{
char str[50];
void ** ph = ( void ** ) Cargo;
hb_snprintf( str, sizeof( str ), "QObject_release 0" ); OutputDebugString(
str );
if( ph && * ph )
{
try
{
const QMetaObject * m = ( ( QObject * ) * ph )->metaObject();
hb_snprintf( str, sizeof( str ), "QObject_release 000" );
OutputDebugString( str );
if( m != NULL )
{
const char * name = m->className();
hb_snprintf( str, sizeof( str ), "QObject_release 1 %s", m->className() );
OutputDebugString( str );
delete ( ( QObject * ) * ph );
}
* ph = NULL;
}
catch ( int &e )
{
}
}
hb_snprintf( str, sizeof( str ), "QObject_release 2" ); OutputDebugString(
str );
}
The GPF is generated right at
const QMetaObject * m = ( ( QObject * ) * ph )->metaObject();
This can happen in two situations:
1. If the <ph> is not of type <QObject> : in case we
uncomment block shown above.
2. If the object is released by Qt itself and detection line if( ph && *
ph )
does not reconizes that the pointer has been releases.
Please note that try{}catch{} mechanism is not helping any way.
I need following favours:
1. If it can be detected the <ph> is a valid pointer.
2. If it could be determined which type of object <ph> is referring to.
[ All objects deriving from QObject are detected fine but any other
class does not respect this construct, i.e. QSize and allied
classes ]
3. If GPF could be trapped anyway if any of the above implementions are
not possible.
NOTE: Memory is almost constant with above changes if GPF is not generated
at the time of memory is freed.
Regards
Pritpal Bedi
--
View this message in context:
http://www.nabble.com/HBQT---HBXBP-%3A-Garbage-Collection-tp25813841p25865022.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour