From 9cdf566db1fed79dc7f234f9dbc317c527779b9a Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 8 Dec 2009 00:31:10 +0000 Subject: [PATCH] 2009-12-07 16:30 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbide/hbide.prg + Added some more debug code. Now HBIDE exits cleanly. * contrib/hbqt/hbqt_destruct.cpp - Removed HBQT_QTPTR_FROM_GCPOINTER() + Added ISEQUALGCQTPOINTER() * contrib/hbqt/hbqt_slots.cpp ! Fixed MainWindow::~MainWindow() calls. Was a reason FOR many GPFs. * contrib/hbqt/qtgui/QApplication.cpp * contrib/hbqt/qth/QApplication.qth - Removed call to Qt_destroy_codeblocks(). * contrib/hbxbp/xbpfontdialog.prg ! Proper destruction of font and font metrix. * contrib/hbxbp/xbptabpage.prg % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() * contrib/hbxbp/xbptreeview.prg % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() * contrib/hbxbp/xbpwindow.prg % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() * contrib/hbxbp/tests/demoxbp.prg ! Test calls to overview memory usage with different modes to release Qt pointers. Now it exits cleanly. * contrib/hbide/hbide.prg + Added some more debug code. Now HBIDE exits cleanly. * contrib/hbqt/hbqt_destruct.cpp - Removed HBQT_QTPTR_FROM_GCPOINTER() + Added ISEQUALGCQTPOINTER() * contrib/hbqt/hbqt_slots.cpp ! Matched hb_vmRequestReenter() / hb_vmRequestRestore() calls. ! Fixed MainWindow::~MainWindow() calls. Was a reason FOR many GPFs. * contrib/hbqt/qtgui/QApplication.cpp * contrib/hbqt/qth/QApplication.qth - Removed call to Qt_destroy_codeblocks(). * contrib/hbxbp/xbpfontdialog.prg ! Proper destruction of font and font metrix. * contrib/hbxbp/xbptabpage.prg % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() * contrib/hbxbp/xbptreeview.prg % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() * contrib/hbxbp/xbpwindow.prg % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() * contrib/hbxbp/tests/demoxbp.prg ! Test calls to overview memory usage with different modes to release Qt pointers. Now it exits cleanly. --- harbour/ChangeLog | 56 +++++++++++++++++++ harbour/contrib/hbide/hbide.prg | 60 ++++++++------------- harbour/contrib/hbqt/hbqt_destruct.cpp | 8 ++- harbour/contrib/hbqt/hbqt_slots.cpp | 45 +--------------- harbour/contrib/hbqt/qtgui/QApplication.cpp | 2 +- harbour/contrib/hbqt/qth/QApplication.qth | 2 +- harbour/contrib/hbxbp/tests/demoxbp.prg | 4 ++ harbour/contrib/hbxbp/xbpfontdialog.prg | 3 ++ harbour/contrib/hbxbp/xbptabpage.prg | 2 +- harbour/contrib/hbxbp/xbptreeview.prg | 10 ++-- harbour/contrib/hbxbp/xbpwindow.prg | 6 +-- 11 files changed, 101 insertions(+), 97 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0bcfc561d6..6ea310d962 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,61 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-07 16:30 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbide/hbide.prg + + Added some more debug code. + Now HBIDE exits cleanly. + + * contrib/hbqt/hbqt_destruct.cpp + - Removed HBQT_QTPTR_FROM_GCPOINTER() + + Added ISEQUALGCQTPOINTER() + + * contrib/hbqt/hbqt_slots.cpp + ! Fixed MainWindow::~MainWindow() calls. Was a reason FOR many GPFs. + + * contrib/hbqt/qtgui/QApplication.cpp + * contrib/hbqt/qth/QApplication.qth + - Removed call to Qt_destroy_codeblocks(). + + * contrib/hbxbp/xbpfontdialog.prg + ! Proper destruction of font and font metrix. + * contrib/hbxbp/xbptabpage.prg + % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() + * contrib/hbxbp/xbptreeview.prg + % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() + * contrib/hbxbp/xbpwindow.prg + % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() + * contrib/hbxbp/tests/demoxbp.prg + ! Test calls to overview memory usage with different modes to release Qt pointers. + Now it exits cleanly. + * contrib/hbide/hbide.prg + + Added some more debug code. + Now HBIDE exits cleanly. + + * contrib/hbqt/hbqt_destruct.cpp + - Removed HBQT_QTPTR_FROM_GCPOINTER() + + Added ISEQUALGCQTPOINTER() + + * contrib/hbqt/hbqt_slots.cpp + ! Matched hb_vmRequestReenter() / hb_vmRequestRestore() calls. + ! Fixed MainWindow::~MainWindow() calls. Was a reason FOR many GPFs. + + * contrib/hbqt/qtgui/QApplication.cpp + * contrib/hbqt/qth/QApplication.qth + - Removed call to Qt_destroy_codeblocks(). + + * contrib/hbxbp/xbpfontdialog.prg + ! Proper destruction of font and font metrix. + * contrib/hbxbp/xbptabpage.prg + % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() + * contrib/hbxbp/xbptreeview.prg + % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() + * contrib/hbxbp/xbpwindow.prg + % Replaced call to HBQT_QTPTR_FROM_GCPOINTER() => IsEqualGcQtPointer() + * contrib/hbxbp/tests/demoxbp.prg + ! Test calls to overview memory usage with different modes to release Qt pointers. + Now it exits cleanly. + 2009-12-08 01:09 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + contrib/hbqt/hbqt_hbqtsyntaxhighlighter.cpp + contrib/hbqt/hbqt_hbqtdbfmodel.cpp @@ -39,6 +94,7 @@ * contrib/rddads/ads1.c * Minor formatting. +>>>>>>> .r13156 2009-12-07 19:29 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/config/global.mk ! fixed variable name in output message diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index f6a095f165..dc2ffd7f39 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -86,6 +86,10 @@ STATIC s_pathSep PROCEDURE Main( cProjIni ) LOCAL oIde + HBQT_SET_RELEASE_METHOD( HBQT_RELEASE_WITH_DESTRUTOR ) // Exits cleanly + //HBQT_SET_RELEASE_METHOD( HBQT_RELEASE_WITH_DELETE ) // Exits cleanly + //HBQT_SET_RELEASE_METHOD( HBQT_RELEASE_WITH_DELETE_LATER ) // Exits cleanly + s_resPath := hb_DirBase() + "resources" + hb_OsPathSeparator() s_pathSep := hb_OsPathSeparator() @@ -255,7 +259,6 @@ METHOD HbIde:new( cProjIni ) /*----------------------------------------------------------------------*/ METHOD HbIde:create( cProjIni ) - // LOCAL qWidget ::loadConfig( cProjIni ) @@ -274,36 +277,6 @@ METHOD HbIde:create( cProjIni ) ::buildFuncList() ::buildBottomArea() -#if 0 - ::qLeftLayout := QGridLayout():new() - ::qLeftLayout:setContentsMargins( 0,0,0,0 ) - ::qLeftLayout:setHorizontalSpacing( 0 ) - ::qLeftLayout:setVerticalSpacing( 0 ) - - ::qMidLayout := QGridLayout():new() - ::qMidLayout:setContentsMargins( 0,0,0,0 ) - ::qMidLayout:setHorizontalSpacing( 0 ) - ::qMidLayout:setVerticalSpacing( 0 ) - - ::qLeftArea := QWidget():new() - ::qLeftArea:setLayout( QT_PTROF( ::qLeftLayout ) ) -// qWidget:oWidget:setLayout( QT_PTROF( ::qLeftLayout ) ) - ::qMidArea := QWidget():new() - ::qMidArea:setLayout( QT_PTROF( ::qMidLayout ) ) - - ::qLeftLayout:addWidget_1( QT_PTROFXBP( ::oProjTree ), 0, 0, 1, 1 ) - ::qLeftLayout:addWidget_1( QT_PTROFXBP( qWidget ), 1, 0, 1, 1 ) - - ::qMidLayout:addWidget_1( QT_PTROFXBP( ::oDa:oTabWidget ), 0, 0, 1, 1 ) - - ::qSplitter := QSplitter():new( QT_PTROF( ::oDa:oWidget ) ) - - ::qSplitter:addWidget( QT_PTROF( ::qLeftArea ) ) - ::qSplitter:addWidget( QT_PTROF( ::qMidArea ) ) - - ::qSplitter:show() - -#else ::qLayout := QGridLayout():new() ::qLayout:setContentsMargins( 0,0,0,0 ) ::qLayout:setHorizontalSpacing( 0 ) @@ -319,7 +292,6 @@ METHOD HbIde:create( cProjIni ) ::qSplitter:addWidget( QT_PTROFXBP( ::oDa:oTabWidget ) ) ::qSplitter:show() -#endif ::qCursor := QTextCursor():new() @@ -381,13 +353,22 @@ METHOD HbIde:create( cProjIni ) ::oXbp:handleEvent( ::nEvent, ::mp1, ::mp2 ) ENDDO - HBXBP_DEBUG( "EXITING.................." ) - /* Very important - destroy resources */ + HBXBP_DEBUG( "Before", "::oDlg:destroy()" ) ::oDlg:destroy() + HBXBP_DEBUG( "After", "::oDlg:destroy()" ) + + ::qCursor:pPtr := 0 + ::oFont := NIL HBXBP_DEBUG( "EXITING after destroy .................." ) + /* A NOTE: + + ::qSplitter and ::qLayout are released automatically + when ~MainWindow() is called and GC engine reports it as relaesed. + This is a good testimony that all the memory is recaptured properly. + */ RETURN self /*----------------------------------------------------------------------*/ @@ -419,7 +400,8 @@ METHOD HbIde:saveConfig() aadd( txt_, "[FILES]" ) FOR n := 1 TO nTabs pTab := ::qTabWidget:widget( n-1 ) - nTab := ascan( ::aTabs, {|e_| HBQT_QTPTR_FROM_GCPOINTER( QT_PTROFXBP( e_[ 1 ] ) ) == pTab } ) + //nTab := ascan( ::aTabs, {|e_| HBQT_QTPTR_FROM_GCPOINTER( QT_PTROFXBP( e_[ 1 ] ) ) == pTab } ) + nTab := ascan( ::aTabs, {|e_| IsEqualGcQtPointer( QT_PTROFXBP( e_[ 1 ] ), pTab ) } ) qEdit := ::aTabs[ nTab, 2 ] qHScr := QScrollBar():configure( qEdit:horizontalScrollBar() ) qVScr := QScrollBar():configure( qEdit:verticalScrollBar() ) @@ -870,7 +852,7 @@ METHOD HbIde:getCurrentTab() LOCAL qTab, nTab qTab := ::qTabWidget:currentWidget() - nTab := ascan( ::aTabs, {|e_| HBQT_QTPTR_FROM_GCPOINTER( e_[ 1 ]:oWidget:pPtr ) == qTab } ) + nTab := ascan( ::aTabs, {|e_| IsEqualGcQtPointer( e_[ 1 ]:oWidget:pPtr, qTab ) } ) RETURN nTab @@ -1702,16 +1684,16 @@ METHOD HbIde:fetchProjectProperties() qPrpDlg:exec() + Qt_DisConnect_Signal( QT_PTROF( oTabWidget ), "currentChanged(int)" ) + oPBOk:destroy() oPBSv:destroy() oPBCn:destroy() oPBSelect:destroy() - Qt_DisConnect_Signal( QT_PTROF( oTabWidget ), "currentChanged(int)" ) + ::aPrpObjs := {} ENDIF - ::aPrpObjs := {} - RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/hbqt_destruct.cpp b/harbour/contrib/hbqt/hbqt_destruct.cpp index 4f52969b1f..ab8effa3e3 100644 --- a/harbour/contrib/hbqt/hbqt_destruct.cpp +++ b/harbour/contrib/hbqt/hbqt_destruct.cpp @@ -115,13 +115,17 @@ HB_FUNC( HBQT_SET_RELEASE_METHOD ) s_iObjectReleaseMethod = hb_parni( 1 ); } -HB_FUNC( HBQT_QTPTR_FROM_GCPOINTER ) +HB_FUNC( ISEQUALGCQTPOINTER ) { QGC_POINTER * p = ( QGC_POINTER * ) hb_parptrGC( gcFuncs(), 1 ); if( p && p->ph ) { - hb_retptr( p->ph ); + hb_retl( p->ph == hb_parptr( 2 ) ); + } + else + { + hb_retl( false ); } } diff --git a/harbour/contrib/hbqt/hbqt_slots.cpp b/harbour/contrib/hbqt/hbqt_slots.cpp index d82035cffe..a2cb496abf 100644 --- a/harbour/contrib/hbqt/hbqt_slots.cpp +++ b/harbour/contrib/hbqt/hbqt_slots.cpp @@ -1120,50 +1120,8 @@ HB_FUNC( QT_SLOTS_DESTROY ) qt_getEventSlots()->~Slots(); } - -/* - * harbour function to release all codeblocks stored - */ -HB_FUNC( RELEASE_CODEBLOCKS ) -{ - Slots * s_s = qt_getEventSlots(); - - if( s_s ) - { - for( int i = 0; i < s_s->listBlock.size(); ++i ) - { - if( s_s->listBlock.at( i ) ) - { - hb_itemRelease( s_s->listBlock.at( i ) ); - s_s->listBlock[ i ] = NULL; - } - } - } -} - -/* - * C function to release all codeblocks storeds - * called at end of the program - * see qapplication.cpp - */ -void release_codeblocks( void ) -{ - Slots * s_s = qt_getEventSlots(); - - if( s_s ) - { - for( int i = 0; i < s_s->listBlock.size(); ++i ) - { - if( s_s->listBlock.at( i ) ) - { - hb_itemRelease( s_s->listBlock.at( i ) ); - s_s->listBlock[ i ] = NULL; - } - } - } -} - /*----------------------------------------------------------------------*/ + Events::Events( QObject * parent ) : QObject( parent ) { } @@ -1313,7 +1271,6 @@ MyMainWindow::~MyMainWindow( void ) hbqt_debug( " MyMainWindow::~MyMainWindow 0" ); #endif hb_itemRelease( block ); - destroy(); #if defined( __HB_DEBUG__ ) hbqt_debug( " MyMainWindow::~MyMainWindow 1" ); #endif diff --git a/harbour/contrib/hbqt/qtgui/QApplication.cpp b/harbour/contrib/hbqt/qtgui/QApplication.cpp index d320f441d2..bc4336ba16 100644 --- a/harbour/contrib/hbqt/qtgui/QApplication.cpp +++ b/harbour/contrib/hbqt/qtgui/QApplication.cpp @@ -113,7 +113,7 @@ static void hbqt_Exit( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); - release_codeblocks(); + //release_codeblocks(); } static void hbqt_Init( void * cargo ) diff --git a/harbour/contrib/hbqt/qth/QApplication.qth b/harbour/contrib/hbqt/qth/QApplication.qth index 24ea23634b..5c0544a398 100644 --- a/harbour/contrib/hbqt/qth/QApplication.qth +++ b/harbour/contrib/hbqt/qth/QApplication.qth @@ -104,7 +104,7 @@ static void hbqt_Exit( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); - release_codeblocks(); + //release_codeblocks(); } static void hbqt_Init( void * cargo ) diff --git a/harbour/contrib/hbxbp/tests/demoxbp.prg b/harbour/contrib/hbxbp/tests/demoxbp.prg index 35ee4d27d5..297b86135e 100644 --- a/harbour/contrib/hbxbp/tests/demoxbp.prg +++ b/harbour/contrib/hbxbp/tests/demoxbp.prg @@ -92,6 +92,10 @@ STATIC oMLE PROCEDURE Main() + HBQT_SET_RELEASE_METHOD( HBQT_RELEASE_WITH_DESTRUTOR ) // Exits cleanly + //HBQT_SET_RELEASE_METHOD( HBQT_RELEASE_WITH_DELETE ) // Exits cleanly + //HBQT_SET_RELEASE_METHOD( HBQT_RELEASE_WITH_DELETE_LATER ) // Exit with GPF + //hb_threadStart( {|| _BuildADialog() } ) _BuildADialog() diff --git a/harbour/contrib/hbxbp/xbpfontdialog.prg b/harbour/contrib/hbxbp/xbpfontdialog.prg index 13a12e71c0..0f26a70c04 100644 --- a/harbour/contrib/hbxbp/xbpfontdialog.prg +++ b/harbour/contrib/hbxbp/xbpfontdialog.prg @@ -460,6 +460,9 @@ METHOD XbpFont:configure() METHOD XbpFont:destroy() + ::oFontInfo:pPtr := 0 + ::oWidget:pPtr := 0 + RETURN NIL /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbptabpage.prg b/harbour/contrib/hbxbp/xbptabpage.prg index d9c740f36c..9681e2f0bd 100644 --- a/harbour/contrib/hbxbp/xbptabpage.prg +++ b/harbour/contrib/hbxbp/xbptabpage.prg @@ -295,7 +295,7 @@ METHOD XbpTabWidget:exeBlock( nMode, iIndex ) IF !empty( ::aChildren ) .and. iIndex >= 0 .and. iIndex < len( ::aChildren ) qTab := ::oWidget:widget( iIndex ) - IF ( nIndex := ascan( ::aChildren, {|o| HBQT_QTPTR_FROM_GCPOINTER( o:oWidget:pPtr ) == qTab } ) ) > 0 + IF ( nIndex := ascan( ::aChildren, {|o| IsEqualGcQtPointer( o:oWidget:pPtr, qTab ) } ) ) > 0 oTab := ::aChildren[ nIndex ] DO CASE diff --git a/harbour/contrib/hbxbp/xbptreeview.prg b/harbour/contrib/hbxbp/xbptreeview.prg index c2d4371d6a..801fe5f96f 100644 --- a/harbour/contrib/hbxbp/xbptreeview.prg +++ b/harbour/contrib/hbxbp/xbptreeview.prg @@ -199,7 +199,7 @@ METHOD XbpTreeView:ExeBlock( nMsg, p1, p2 ) HB_SYMBOL_UNUSED( p2 ) IF hb_isPointer( p1 ) - IF ( n := ascan( ::aItems, {|o| o:qPointer == p1 } ) ) > 0 + IF ( n := ascan( ::aItems, {|o| IsEqualGcQtPointer( o:oWidget:pPtr, p1 ) } ) ) > 0 oItem := ::aItems[ n ] ENDIF ENDIF @@ -221,7 +221,6 @@ METHOD XbpTreeView:ExeBlock( nMsg, p1, p2 ) eval( ::sl_itemSelected, oItem, {0,0,0,0}, self ) ENDIF CASE nMsg == 7 // "itemEntered(QTWItem)" - //::oWidget:setToolTip( oItem:caption ) CASE nMsg == 8 // "itemExpanded(QTWItem)" IF hb_isBlock( ::sl_itemExpanded ) eval( ::sl_itemExpanded, oItem, {0,0,0,0}, self ) @@ -347,7 +346,6 @@ CLASS XbpTreeViewItem INHERIT XbpDataRef DATA hItem DATA oParent DATA oXbpTree - DATA qPointer DATA aChilds INIT {} @@ -384,7 +382,6 @@ METHOD XbpTreeViewItem:addItem( xItem, xNormalImage, xMarkedImage, xExpandedImag oItem:caption := xItem oItem:oWidget := QTreeWidgetItem():new() oItem:oWidget:setText( 0, oItem:caption ) - oItem:qPointer := HBQT_QTPTR_FROM_GCPOINTER( oItem:oWidget:pPtr ) ELSE oItem := xItem // aNode ENDIF @@ -478,10 +475,11 @@ METHOD XbpTreeViewItem:setMarkedImage( nResIdoBitmap ) METHOD XbpTreeViewItem:delItem( oItem ) LOCAL n - IF ( n := ascan( ::aChilds, {|o| o:caption == oItem:caption } ) ) > 0 + IF ( n := ascan( ::aChilds, {|o| o == oItem } ) ) > 0 ::oWidget:removeChild( ::aChilds[ n ]:oWidget:pPtr ) ::aChilds[ n ]:oWidget:pPtr := 0 - adel( ::aChilds, n ) ; asize( ::aChilds, len( ::aChilds )-1 ) + adel( ::aChilds, n ) + asize( ::aChilds, len( ::aChilds )-1 ) ENDIF RETURN NIL diff --git a/harbour/contrib/hbxbp/xbpwindow.prg b/harbour/contrib/hbxbp/xbpwindow.prg index 188dc5c3fe..bd45e26c81 100644 --- a/harbour/contrib/hbxbp/xbpwindow.prg +++ b/harbour/contrib/hbxbp/xbpwindow.prg @@ -768,11 +768,11 @@ METHOD XbpWindow:destroy() Qt_Slots_Destroy() Qt_Events_Destroy() Qt_MyMainWindow_Destroy( QT_PTROF( ::oWidget ) ) + ELSE + ::oWidget:pPtr := 0 + ::oWidget := NIL ENDIF - ::oWidget:pPtr := 0 - ::oWidget := NIL - //HBXBP_DEBUG( ThreadID()," Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ), memory( 1001 ), hbqt_getMemUsed() ) RETURN NIL