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

List:       kde-devel
Subject:    Re: trivial KDE program crashing
From:       Julian Rockey <linux () jrockey ! com>
Date:       2001-09-09 1:17:16
[Download RAW message or body]

The design of QT (and hence KDE as many KDE classes derive from QT) is such 
that widgets etc. automatically delete themselves. The implication of this is 
that all widgets should be created on the heap, and you don't need to delete 
them. There is a school of thought that considers this to be bad design, but 
that's another discussion.
rgds Julian

On Saturday 08 September 2001 06:01 pm, George Petri wrote:
> Hi!
>
> I am experienced in C++ but am a complete newbie to KDE programming.
> I was wondering if anyone knows why the following program crashes _on
> exit_?:
>
> #include <kmainwindow.h>
> #include <kapp.h>
>
> int main (int argc, char *argv [])
> {
>         KApplication app (argc, argv, "Test");
>         KMainWindow window;
>         app.setMainWidget (&window);
>         window.show ();
>         return app.exec ();
> }
>
> It produces the following backtrace:
> 0x40acae39 in wait4 () from /lib/libc.so.6
> #0  0x40acae39 in wait4 () from /lib/libc.so.6
> #1  0x40b2b8e0 in __check_rhosts_file () from /lib/libc.so.6
> #2  0x4061030d in KCrash::defaultCrashHandler () from
> /usr/lib/libkdecore.so.3
>
> #3  0x40a68008 in sigaction () from /lib/libc.so.6
> #4  0x40a03ff4 in __builtin_delete () from
> /usr/lib/libstdc++-libc6.1-2.so.3 #5  0x407819b8 in
> KMainWindow::~KMainWindow () from /usr/lib/libkdeui.so.3 #6  0x4025ca04 in
> QWidget::close () from /usr/lib/libqt.so.2
>
> If I make "window" a pointer, then it doesn't crash at all:
>
> #include <kmainwindow.h>
> #include <kapp.h>
>
> int main (int argc, char *argv [])
> {
>         KApplication app (argc, argv, "Test");
>         KMainWindow *window = new KMainWindow;
>         app.setMainWidget (window);
>         window->show ();
>         return app.exec ();
> }
>
> Why is this so?  Wouldn't this cause a memory leak?
>
> Thanks in advance,
> George
>
> >> 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