[PyKDE] main-loop and segfault

Hans-Peter Jansen hpj at urpla.net
Mon Jul 1 10:09:01 BST 2002


On Mon, 1 Jul 2002 00:29:38 +0200
"Willi Richert" <mennosimons at gmx.net> wrote:

> Hi,
> 
> I stumbled across the following crazy behaviour: If the application is 
> executed from within a main()-method and then exit it prints only "1" and 
> after that issues a segmentation fault:
> 
> def main():
>     a=QApplication(sys.argv)
>     w=MyWindow()
>     a.setMainWidget(w)
>     w.resize(400,500)
>     w.show()
>     a.exec_loop()
>     print "1"
> 
> if __name__ == '__main__':
>     main()
>     print "2"
>     
> print "3"
> 

What about providing a complete example and version/system infos.

import sys
from qt import *

def main():
    a=QApplication(sys.argv)
    w=QWidget()
    a.setMainWidget(w)
    w.resize(400,500)
    w.show()
    a.exec_loop()
    print "1"

if __name__ == '__main__':
    main()
    print "2"

print "3"

This one is working fine. I bet, your problem is somewhere down under 
your MyWindow class.

> 
> However, if QApplication is executed in the top level block it works fine. 
> Does anybody know, why?

Problems like this are almost always programmers aka. your fault.
 
> Thanks,
> willi

Hans-Peter




More information about the PyQt mailing list