From 86ff65e79aeb2cf2c80263f7ac05c40921d69c17 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 22 Mar 2011 01:57:18 +0000 Subject: [PATCH] 2011-03-21 18:45 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtcore/hbqt_init.cpp * contrib/hbqt/qtgui/hbqt_init.cpp ! Transferred logic of destructors from core to gui. The whole lot should be in one source. We cannot control the order of execution of _init_ functions. Francessco, take care of these changes. NOTE: now hbIDE enters, used with all flavours, exits without GPF. The remaining issue is to control memory leaks. Francessco is working onto that. --- harbour/contrib/hbqt/qtcore/hbqt_init.cpp | 22 ------------------ harbour/contrib/hbqt/qtgui/hbqt_init.cpp | 27 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/harbour/contrib/hbqt/qtcore/hbqt_init.cpp b/harbour/contrib/hbqt/qtcore/hbqt_init.cpp index 9453b94852..756ff517e0 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_init.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_init.cpp @@ -409,37 +409,15 @@ static void hbqt_registerCallbacks( void ) HB_FUNC( __HBQTCORE ) {;} -static QList s_PHB_ITEM_tobedeleted; - -void hbqt_addDeleteList( PHB_ITEM item ) -{ - s_PHB_ITEM_tobedeleted << item ; -} - - static void hbqt_lib_init( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); - - QTextCodec * codec = QTextCodec::codecForName( "UTF8" ); - QTextCodec::setCodecForTr( codec ); - QTextCodec::setCodecForCStrings( codec ); - hbqt_registerCallbacks(); } static void hbqt_lib_exit( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); - - HB_TRACE( HB_TR_ALWAYS, ( "hbqt_lib_exit, len=%d", s_PHB_ITEM_tobedeleted.size() ) ); - - int i; - for( i = 0; i < s_PHB_ITEM_tobedeleted.size(); ++i ) - { - hb_itemRelease( s_PHB_ITEM_tobedeleted.at( i ) ); - HB_TRACE( HB_TR_ALWAYS, ( "hbqt_lib_exit, deleted item %d", i )); - } } HB_CALL_ON_STARTUP_BEGIN( _hbqtcore_init_ ) diff --git a/harbour/contrib/hbqt/qtgui/hbqt_init.cpp b/harbour/contrib/hbqt/qtgui/hbqt_init.cpp index cb23620b59..a3673bd9de 100644 --- a/harbour/contrib/hbqt/qtgui/hbqt_init.cpp +++ b/harbour/contrib/hbqt/qtgui/hbqt_init.cpp @@ -58,6 +58,7 @@ #include "hbqtinit.h" #include "hbapierr.h" +#include "hbapiitm.h" #include "hbvm.h" #include "hbinit.h" @@ -82,6 +83,7 @@ #include #include +#include HB_EXTERN_BEGIN extern void * hbqt_gcAllocate_QColor( void * pObj, bool bNew ); @@ -592,9 +594,7 @@ static void hbqt_registerCallbacks( void ) /*----------------------------------------------------------------------*/ static QApplication * s_app = NULL; - -//static int s_argc; -//static char ** s_argv; +static QList s_PHB_ITEM_tobedeleted; HB_FUNC_EXTERN( __HBQTCORE ); @@ -612,6 +612,12 @@ QApplication * __hbqtgui_app( void ) return s_app; } +void hbqt_addDeleteList( PHB_ITEM item ) +{ + HB_TRACE( HB_TR_DEBUG, ( "-------------------------hbqt_addDeleteList # %d", s_PHB_ITEM_tobedeleted.size() ) ); + s_PHB_ITEM_tobedeleted << item ; +} + static void hbqt_lib_init( void * cargo ) { static int s_argc; @@ -631,11 +637,26 @@ static void hbqt_lib_init( void * cargo ) HB_TRACE( HB_TR_DEBUG, ( "hbqt_lib_init %p", s_app ) ); hbqt_registerCallbacks(); + + QTextCodec * codec = QTextCodec::codecForName( "UTF8" ); + QTextCodec::setCodecForTr( codec ); + QTextCodec::setCodecForCStrings( codec ); } static void hbqt_lib_exit( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); + int i; + for( i = s_PHB_ITEM_tobedeleted.size() - 1; i >= 0; --i ) + { + if( s_PHB_ITEM_tobedeleted.at( i ) != NULL ) + { + HB_TRACE( HB_TR_DEBUG, ( "hbqt_lib_exit, deleted item %d", i )); + hb_itemRelease( s_PHB_ITEM_tobedeleted.at( i ) ); + s_PHB_ITEM_tobedeleted[ i ] = NULL; + HB_TRACE( HB_TR_DEBUG, ( " hbqt_lib_exit, deleted item %d", i )); + } + } }