RE: [Qt-root-l] How to terminate PyRoot+PyQt properly

From: Fine, Valeri <fine_at_bnl.gov>
Date: Fri, 28 Aug 2009 09:56:25 -0400

 

Hello!
I modified the qtexample.py. The application is stopped, but with crash: [pclhcb43] /afs/cern.ch/lhcb/software/DEV/FEICIM/FEICIM_v0r1 > gdb python GNU gdb Red Hat Linux (6.3.0.0-1.162.el4rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) run qtexample.py
Starting program:
/afs/cern.ch/sw/lcg/external/Python/2.5/slc4_ia32_gcc34/bin/python qtexample.py
Qt: Undefined variable.
[Thread debugging using libthread_db enabled] [New Thread -1208854848 (LWP 30108)]
Detaching after fork from child process 30275. ** $Id: TGQt.cxx 26689 2008-12-06 07:03:04Z brun $ this=0x9423b90 Symbol font family found: Standard Symbols L [New Thread -1212462176 (LWP 30281)]
TClass::TClass:0: RuntimeWarning: no dictionary for class QObject is available
TClass::TClass:0: RuntimeWarning: no dictionary for class QWidget is available
Bye bye...
[Thread -1212462176 (LWP 30281) exited]

Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1208854848 (LWP 30108)] 0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0x024459fa in ROOT::delete_TQtWidget () from
/afs/cern.ch/sw/lcg/app/releases/ROOT/5.22.00c/slc4_ia32_gcc34/root/lib/libGQt.so
#2 0x014af7ec in TClass::Destructor () from
/afs/cern.ch/sw/lcg/app/releases/ROOT/5.22.00c/slc4_ia32_gcc34/root/lib/libCore.so
#3 0x00ae9ac9 in PyROOT::op_dealloc_nofree () from

/afs/cern.ch/sw/lcg/app/releases/ROOT/5.22.00c/slc4_ia32_gcc34/root/lib/libPyROOT.so

#4 0x00ae9edd in PyROOT::(anonymous namespace)::op_dealloc () from
/afs/cern.ch/sw/lcg/app/releases/ROOT/5.22.00c/slc4_ia32_gcc34/root/lib/libPyROOT.so
#5 0x004c0213 in subtype_dealloc (self=0xb7c02e64) at
Objects/typeobject.c:709
#6 0x004a97ec in dict_dealloc (mp=0xb7bfe4f4) at Objects/dictobject.c:855
#7 0x003753e8 in initsip () from

/afs/cern.ch/sw/lcg/external/sip/4.7.9_python2.5/slc4_ia32_gcc34/lib/python/2.5/site-packages/sip.so
#8 0x003754f4 in initsip () from

/afs/cern.ch/sw/lcg/external/sip/4.7.9_python2.5/slc4_ia32_gcc34/lib/python/2.5/site-packages/sip.so
#9 0x004c0213 in subtype_dealloc (self=0xb7c32c2c) at
Objects/typeobject.c:709
#10 0x004a926a in PyDict_SetItem (op=0xb7f00acc, key=0xb7ef30e0,
value=0x55b268) at Objects/dictobject.c:420
#11 0x004ace74 in _PyModule_Clear (m=0xb7ee50ec) at
Objects/moduleobject.c:136
#12 0x0050ab87 in PyImport_Cleanup () at Python/import.c:439
#13 0x005188c4 in Py_Finalize () at Python/pythonrun.c:399
#14 0x0051794a in Py_Exit (sts=0) at Python/pythonrun.c:1618
#15 0x00517a91 in handle_system_exit () at Python/pythonrun.c:1054
#16 0x00517b35 in PyErr_PrintEx (set_sys_last_vars=1) at
Python/pythonrun.c:1064
#17 0x00517e46 in PyErr_Print () at Python/pythonrun.c:978
#18 0x005181ea in PyRun_SimpleFileExFlags (fp=0x890a008,
filename=0xbfefb5e6 "qtexample.py", closeit=1, flags=0xbfe01f0c) at Python/pythonrun.c:883
#19 0x00518ae9 in PyRun_AnyFileExFlags (fp=0x890a008,
filename=0xbfefb5e6 "qtexample.py", closeit=1, flags=0xbfe01f0c) at Python/pythonrun.c:698
#20 0x00523cf0 in Py_Main (argc=1, argv=0xbfe02044) at Modules/main.c:532
#21 0x080485aa in main (argc=2, argv=0xbfe02044) at ./Modules/python.c:23

I think it is a pyRoot problem.
I also attached the modified qtexample.py what I am using.

Thanks,
Zoltan


From: qt-root-l-bounces_at_lists.bnl.gov on behalf of Qt-Root integration project Sent: Thu 8/27/2009 6:59 PM
To: Qt-Root integration project; roottalk_at_root.cern.ch Subject: Re: [Qt-root-l] How to terminate PyRoot+PyQt properly

Hello Zoltan,

I have looked up your "qtexample.py".

 3 observations:

  1. You certainly should NOT call

        ROOT.gApplication.Terminate()

      To terminate the application please
      consider connecting your "Quit" button
      with the "closeAllWindows" signal:
http://qt.nokia.com/doc/4.5/qapplication.html#closeAllWindows

  2) You certainly should not start the ROOT event loop:

     ROOT.gApplication.Run(1)
     Your application is so-called "ROOT-based Qt-application."
     As such, it should start the Qt event loop with
     via  QCoreApplication::exec () method
http://qt.nokia.com/doc/4.5/qcoreapplication.html#exec See: http://zetcode.com/tutorials/pyqt4/firstprograms Pay you attention to the clause from
http://zetcode.com/tutorials/pyqt4/firstprograms " . . .

   You wonder why the exec_() method has the underscore?    Everything has a meaning.
   This is obviously, because the exec is a python keyword.    And thus, exec_() was used instead.
 . . . "       

 3) You certainly should connect the

    the "lastWindowClosed" signal
http://qt.nokia.com/doc/4.5/qapplication.html#lastWindowClosed

   with the "TerminateAndQuit()" slot of "CintSlot()" receiver. It is your "terminator". You connected it with "Terminate", you should connect it with "TerminateAndQuit()" instead.

I still have some concern about the hidden redundant for Qt application thread that PyRoot used to start. May be people who fought this issue in past can remind us the final solution.

Anyway, the corrections mentioned above have to applied first.

Can you try that to see whether it makes any difference? If your crash will persist, please start your application under gdb and send me the "Call stack"

Thank you.       

Best Regards

                         Valeri Fine


Brookhaven National Laboratory
Upton, NY 11973, USA
Phone: +1 631 344 7806
Fax: +1 631 344 4206
E-mail: fine_at_bnl.gov

Best Regards

                         Valeri Fine


Brookhaven National Laboratory
Upton, NY 11973, USA
Phone: +1 631 344 7806
Fax: +1 631 344 4206
E-mail: fine_at_bnl.gov
> -----Original Message-----
> From: qt-root-l-bounces_at_lists.bnl.gov [mailto:qt-root-l-
> bounces_at_lists.bnl.gov] On Behalf Of Qt-Root integration project
> Sent: Thursday, August 27, 2009 2:34 PM
> To: roottalk_at_root.cern.ch
> Cc: qt-root-l_at_lists.bnl.gov
> Subject: [Qt-root-l] How to terminate PyRoot+PyQt properly
>
>
> Hello,
> I am trying to summarize  the ROOT and qtRoot usage from afs.
> After when I hard coded the .rootrc file. I used the following lines:
>
> ROOT.gEnv.SetValue("Gui.Backend","qt")
> ROOT.gEnv.SetValue("Gui.Factory","qtgui")
> ROOT.gEnv.SaveLevel(kEnvLocal);
>
> my application is working fine! But I can not stop it. I think
> lastWindowClosed() slot is not comming!
> I have the following lines:
>
>   gLogger.debug('main')
>
>   application = qApp
>   terminator = ROOT.TQtRootSlot.CintSlot()
>   termAddress =

sip.wrapinstance(ROOT.AddressOf(terminator)[0],QObject) > QObject.connect(application,
SIGNAL("lastWindowClosed()"),termAddress
> ,SLOT("Terminate()"))
>   from
> Feicim.Gui.FeicimMainWidget
> import FeicimMainWidget
>   mainWidget = FeicimMainWidget()
>   mainWidget.show()
>   mainWidget.start()
>   ROOT.gApplication.Run(1)
>
> If I coded ROOT.gApplication.Terminate() when I click in the File/Exit
> menu item, the application is crash.
>
> You can check qtexample.py I attached the file. You can not exit the
> program without crash.
> Can you help me?
> Thanks!
> Zoltan
_______________________________________________
Qt-Root-l mailing list
Qt-Root-l_at_lists.bnl.gov
https://lists.bnl.gov/mailman/listinfo/qt-root-l

Received on Fri Aug 28 2009 - 16:00:43 CEST

This archive was generated by hypermail 2.2.0 : Fri Aug 28 2009 - 23:50:02 CEST