Skip to content

Commit

Permalink
Run exit only if __init__ completes
Browse files Browse the repository at this point in the history
  • Loading branch information
nrfulton committed Nov 28, 2015
1 parent 7fc8de3 commit 641c12d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/fluxgui/fluxapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FluxGUI(object):
FluxGUI initializes/destroys the app
"""
def __init__(self):
self.initialized = False
self.pidfile = os.path.expanduser("~/.fluxgui.pid")
self.check_pid()
try:
Expand All @@ -29,6 +30,8 @@ def __init__(self):
print "Critical error. Exiting."
self.exit(1)

self.initialized = True

def __del__(self):
self.exit()

Expand All @@ -41,13 +44,14 @@ def signal_exit(self, signum, frame):
self.exit()

def exit(self, code=0):
try:
self.xflux_controller.stop()
except MethodUnavailableError:
pass
os.unlink(self.pidfile)
gtk.main_quit()
sys.exit(code)
if self.initialized:
try:
self.xflux_controller.stop()
except MethodUnavailableError:
pass
os.unlink(self.pidfile)
gtk.main_quit()
sys.exit(code)

def run(self):
gtk.main()
Expand Down

0 comments on commit 641c12d

Please sign in to comment.