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

From: Fine, Valeri <fine_at_bnl.gov>
Date: Thu, 27 Aug 2009 18:59:23 -0400


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
Received on Fri Aug 28 2009 - 01:00:33 CEST

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