From 38453c726404f4b934199731c0b436c9145d83af Mon Sep 17 00:00:00 2001 From: coderkun Date: Thu, 15 Jan 2015 19:19:32 +0100 Subject: [PATCH] check if password exists in keyring before attempt to delete it --- gui/gtk.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gui/gtk.py b/gui/gtk.py index 7d8284d..258c802 100755 --- a/gui/gtk.py +++ b/gui/gtk.py @@ -255,7 +255,11 @@ class Window(Gtk.ApplicationWindow): self._settings.set_string(Application.SETTING_HOST, host) self._settings.set_int(Application.SETTING_PORT, port) if use_keyring: - keyring.set_password(Application.KEYRING_SYSTEM, Application.KEYRING_USERNAME, password) + if password: + keyring.set_password(Application.KEYRING_SYSTEM, Application.KEYRING_USERNAME, password) + else: + if keyring.get_password(Application.KEYRING_SYSTEM, Application.KEYRING_USERNAME): + keyring.delete_password(Application.KEYRING_SYSTEM, Application.KEYRING_USERNAME) self._settings.set_string(Application.SETTING_IMAGE_DIR, image_dir)