Slot issues

Jacek Wojdel wojdel at
Mon Mar 27 11:01:57 UTC 2000

On Sat, 25 Mar 2000, you wrote:
> I have a Qt 2.0 MDI application that I've been working on and have a small
> problem with calling slots.
> For some reason, when I close a window using the Close keycombo, or the
> close menu option, the application will call the slot function, call the
> close event function, then try to call the slot function again.
> Obviously, because the close event function destroys the windows that's
> being closed, the program crashes.
> This doesn't happen all of the time.  I have to open a lot of windows and
> then try to close them all again.  I haven't been able to pin it down to a
> certain number of windows that I have to close.  It just seems to randomly
> pick one.
> If anyone has any ideas, let me know.
> Tim

I had somehow similar problems with closing and destructing windows in Qt 1.x.
What I did wrong was assuming that I have to take care of cleaning up the heap.
So for each window I had classmembers with pointers to all the child widgets
and did 'delete' on each of them in parent's destructor. It worked sometimes,
it segfaulted in other cases. It proves that Qt takes care of destructing child
widgets when destructing parent so there's no need to do it yourself. The cases
in which it segfaulted where when Qt decided to delete one of the children
before killing parent... in this way parent's destructor called a delete on
defunc pointer. Does it seem to be relevant to your problem ?

|from: J.C.Wojdel                     |
|      J.C.Wojdel at       |

More information about the KDevelop mailing list