[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: trivial KDE program crashing
From:       Greg Turpin <gregturp () home ! com>
Date:       2001-09-09 4:12:31
[Download RAW message or body]

On Saturday 08 September 2001  9:58 pm, George Petri wrote:
> So I can use QT as if I was programming in Java i.e. do not deallocate
> memory? I'm just worried that if I don't delete objects, I'll get a memory
> leak. How is it technically possible to automatically delete objects in
> C++?
>

Only for Qt objects.  If you use other dynamically allocated memory for
anything else, then you must delete it.
Qt deletes them.  Whenever the parent dies it deletes all of it's children.

Greg

> Thanks again,
> george
>
> On Sunday 09 September 2001 11:19, David Watson wrote:
> > I'm pretty sure that all QWidgets need to be allocated on the heap, not
> > the stack, because of the auto-deletion stuff - your KApplication deletes
> > the KMainWindow (that's why you pass a pointer). Since you dynamically
> > allocated your main window in the non-crashing version, it's fine when it
> > gets deleted.
> >
> > Basically, you need to use new for all widgets, and you DON'T delete them
> > manually (except in certain cases), because QT does it for you when the
> > parent is destroyed.
> >
> > Hope this helps :).
> >
> > -David
> >
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> >> unsubscribe <<
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic