Hi Victor I wanted to say (one dirty solution ...) Here is another using static instead of PUBLIC ...
STATIC FUNCTION Dialogs( cType, w, l ) static oDlg,oDlg2,oDlg3,oDlg4,oDlg5,oDlg6 local oUrl DO CASE CASE cType == "PageSetup" if oDlg1 ==Nil oDlg1 := QPageSetupDialog():new() oDlg1:setWindowTitle( "Harbour-QT čššPageSetup Dialog" ) endif oDlg1:show() CASE cType == "Preview" if oDlg2 ==Nil oDlg2 := QPrintPreviewDialog():new() oDlg2:setWindowTitle( "Harbour-QT Preview Dialog" ) endif oDlg2:show() CASE cType == "Wizard" if oDlg3 ==Nil oDlg3 := QWizard():new() oDlg3:setWindowTitle( "Harbour-QT Wizard to Show Slides etc." ) endif oDlg3:show() CASE cType == "Colors" if oDlg4 ==Nil oDlg4 := QColorDialog():new() oDlg4:setWindowTitle( "Harbour-QT Color Selection Dialog" ) endif oDlg4:show() CASE cType == "WebPage" if oDlg5 ==Nil oDlg5 := QWebView():new() oUrl := QUrl():new() oUrl:setUrl( "http://www.harbour.vouch.info" ) QT_QWebView_SetUrl( QT_PTROF( oDlg5 ), QT_PTROF( oUrl ) ) oDlg5:setWindowTitle( "Harbour-QT Web Page Navigator" ) endif oDlg5:show() CASE cType == "Fonts" if oDlg6 ==Nil oDlg6 := QFontDialog():new() oDlg6:setWindowTitle( "Harbour-QT Font Selector" ) endif oDlg6:show() ENDCASE RETURN nil My intention was to show why webpage when visited increases size of used memory. With this solution memory is increased only first time. Of course, there are better solutions. BRGS Franček Viktor Szakáts wrote: > > > On 2009.09.16., at 10:16, Franček Prijatelj wrote: > >> >> Hi Pritpal >> >> In STATIC FUNCTION Dialogs You are using local oDlg which >> is overwriten many times (you should delete QWidgets pointed to by it, >> before allocating new ones) >> >> One solution (not going in other leaks) is this: >> >> >> PROCEDURE Main() >> Local oLabel, oBtn, oDA, oTabBar >> Local oWnd, oSize >> Local oMenuBar, pIcon >> Local oMenuA, pAction >> LOCAL oPS, oPPrv, oMB, oWZ, oCD, oWP, oSBar, oStyle >> **** Add code >> PUBLIC oDlg1:=oDlg2:=oDlg3:=oDlg4:=oDlg5:=oDlg6:=Nil >> ********* > > Sorry to jump in, but if there is anything else we > can use instead of PUBLICs we should rather try to > do so. For me it looks bad example to use PUBLIC vars > in example code, as I'd surely wouldn't like to copy > that in any sort of production code. Perhaps a local > array could replace it. > > The other thing I don't understand is how is it > possible to create leaks merely by using valid > .prg code? Is it possible to solve this problem > so that such thing cannot happen? Is there a manual > way to free these objects? > > Brgds, > Viktor > > _______________________________________________ > Harbour mailing list > Harbour@harbour-project.org > http://lists.harbour-project.org/mailman/listinfo/harbour > > -- View this message in context: http://www.nabble.com/demoqt-tests-with-debug_new---Leaked-objects-tp25434990p25468128.html Sent from the Harbour - Dev mailing list archive at Nabble.com. _______________________________________________ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour