saltastro / pysalt

Python/Pyraf software for the reduction and analysis of SALT data
Other
15 stars 19 forks source link

Fixing errors that arise when running interactive windows multiple times #133

Closed rirze closed 7 years ago

rirze commented 7 years ago

When running an interactive specidentify window multiple times, one after another in a for-loop, I came upon some errors that caused my script. The relevant part of my code that caused this exit is:

for f in images:
    #some other code
    iraf.specidentify(images=f, linelist=lamplines, outfile=idfile,
                          guesstype='rss', inter=True, # automethod='FitXcor',
                          rstep=600 / ccdsum,
                          rstart=200 / ccdsum, startext=1, clobber='yes',
                          #startext=1, clobber='yes',
                          verbose='no', mode='hl', logfile='salt.log',
                          mdiff=2, function='legendre')

Around the third time going through the loop, I get these messages flooding the terminal:

(python:7472): Gtk-CRITICAL **: IA__gtk_container_add: assertion 'GTK_IS_CONTAINER (container)' failed

(python:7472): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion 'GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed

(python:7472): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion 'GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed

Then at the fourth time, I get a segmentation fault:

2017-05-16 15:01:02 MESSAGE ------------------------------------------
Proccessing extension 1 in  mos/arc*blurred*.fits

Grating GR-ANGLE    AR-ANGLE    Slit    WCEN    R
PG0900    20.000      39.913    1.50    7557.97 1364.187390

Segmentation fault (core dumped)

My setup is with pysalt (at the latest current commit #36bd0f6), Ubuntu 15.10, python 2.7. It might be worth mentioning fellow users who run this script on mac OSs don't encounter this issue.

Turns out that, if a script is running more than one QApplication, then deletion of objects may not be consistent. In this case, it's trying to insert widgets into an App that was thoroughly deleted previously. I encountered the solution code in this stackoverflow question.

In my experience, this seems to be an OS specific error, and I believe that my pull does not affect the operability of this pyqt application on other OSs. If someone could test this that would be great since I do not have access to a mac machine for testing. Also, I would recommend this fix to other interactive window apps in this library.

crawfordsm commented 7 years ago

@rirze Thanks so much for the contribution. I'll take a look at this and see how this works on my side, but this is a problem that has been in the code for awhile, but I haven't had time to really investigate. So, if this at least works for some OSes, that will be a big help.