[Qt-interest] Modal dialogs and their variable still exists after the EXEC?

Giancarlo Amati ilferraresebono at hotmail.it
Tue Apr 7 19:12:29 CEST 2009


Many thanks....and the problem was that somehow I called the delete prtDlg in the execution of my application before accessing the method getSourceList().
GC.

CC: qt-interest at trolltech.com
From: israel at frontierflying.com
To: ilferraresebono at hotmail.it
Subject: Re: [Qt-interest] Modal dialogs and their variable still exists after the EXEC?
Date: Tue, 7 Apr 2009 09:02:07 -0800


 
On Apr 6, 2009, at 11:42 PM, Giancarlo Amati wrote:Hello everybody,

I have this code:

CPointRegDlg *ptrDlg = new CPointRegDlg();
    ptrDlg->setModal(true);
    int accept = ptrDlg->exec();
    PointList l1 =  ptrDlg->getSourceList();


where ptrDlg is my dialog window derived from a QDialog and I call the exec() function as I want a Modal execution. Now, I wonder if after having called the function I still have the access to its members variable, one of them accessed by getSourceList() (I created this function) or the memory is deallocated after the execution.
The problem I have is that l1 is always NULL and it shouldn't.

No, the memory is not deallocated until you call delete on ptrDlg. As such, you need to make sure that you call delete on it somewhere in your code, or else you have a memory leak. The only exception to this (that I am aware of) would be if you have a Qt object with a parent defined - in that case, the child object would be deleted when the parent object is. However, here you have no parent defined for your object, and even if you did it is not being deleted, so your object remains intact. As mentioned by one of the other respondents, if the memory had been deallocated, you should be getting a segfault on calling getSourceList, not NULL. Use the debugger to trace the execution of the getSourceList() function and make sure it is performing as expected. If that looks right, you will need to go back farther and look at where the member variable is set.
-----------------------------------------------Israel BrewsterComputer Support Technician IIFrontier Flying Service Inc.5245 Airport Industrial RdFairbanks, AK 99709(907) 450-7250 x293-----------------------------------------------

Kind Regards.
Giancarlo

Il remix esclusivo di Messenger. Scaricalo gratis! _______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


_________________________________________________________________
25 GB di spazio gratuito su Internet! Prova SkyDrive
http://clk.atdmt.com/GBL/go/140630371/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090407/282a2b5c/attachment.html 


More information about the Qt-interest-old mailing list