GNOME Bugzilla – Bug 668753
can't reopen hamster applet after closing it: 'NoneType' object has no attribute 'show' in main
Last modified: 2012-02-10 20:39:47 UTC
Forwarded from Ubuntu: I can start Hamster from the Launcher, and use it normally. If I close the main window eg by pressing Escape, it closes, and the icon is inactive (loses the little arrow) in my Launcher. If I click it again, it does not start, I get an apport window, and I see this traceback in .xsession-errors: Traceback (most recent call last):
+ Trace 229525
getattr(server, window)()
return self._proxy_method(*args, **keywords)
**keywords)
message, timeout)
File "/usr/lib/python2.7/dist-packages/dbus/service.py", line 702, in _message_cb retval = candidate_method(self, *args, **keywords) File "/usr/bin/hamster-time-tracker", line 562, in main self.app.window.show() AttributeError: 'NoneType' object has no attribute 'show' I can see there are still hamster processes running: 6815 ? Sl 0:04 python /usr/bin/hamster-time-tracker 6821 ? S 0:00 /usr/bin/python /usr/bin/hamster-service I think this bug is something to do with connecting to them, or restarting them. If I kill them manually then I can start Hamster again.
Rick Spencer had the following to say in a comment: I thing what may be going on is when the window is being destroyed: def close_window(self, *args): self.save_window_position() self.window.destroy() self.window = None self.show_in_tray() def on_delete_window(self, event, data): self.save_window_position() self.window.destroy() self.window = None self.show_in_tray() The app object is not destroyed. So then on re-entrancy: @dbus.service.method("org.gnome.Hamster.WindowServer") def main(self): if self.app: self.app.window.show() self.app.window.present() else: self.app = ProjectHamster() since there is an application object, it assumes there is a window object. I suspect the right fix is to test if the self.app.window is not None, and recreate the window if necessary. It may also be simply to hide self.window instead of destroy it.
Created attachment 206194 [details] [review] Fix for 668753 Based on Rick's analysis, I created the following patch that seems to work well.
Review of attachment 206194 [details] [review]: thanks, the current codebase has moved out the windowserver in an dbus-instantiable service and thus this bug has been solved by going around the problem