From 528871d72c401bc8ba11088016e30826ffd57e16 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Sat, 14 Jan 2006 12:56:38 +0000 Subject: [PATCH] catch WinAPI LoadImage exception and do not set new image when raised (hey at least we do not fail :P) --- src/systraywin32.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/systraywin32.py b/src/systraywin32.py index c4d88175e..89d63dfeb 100644 --- a/src/systraywin32.py +++ b/src/systraywin32.py @@ -310,6 +310,8 @@ class SystrayWin32(systray.Systray): else: state = self.status hicon = self.tray_ico_imgs[state] + if hicon is None: + return self.systray_winapi.add_notify_icon(self.systray_context_menu, hicon, 'Gajim') @@ -336,8 +338,12 @@ class SystrayWin32(systray.Systray): if os.path.exists(path_to_ico): hinst = win32gui.GetModuleHandle(None) img_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE - image = win32gui.LoadImage(hinst, path_to_ico, win32con.IMAGE_ICON, - 0, 0, img_flags) - imgs[state] = image - + try: + image = win32gui.LoadImage(hinst, path_to_ico, + win32con.IMAGE_ICON, 0, 0, img_flags) + except pywintypes.error: + imgs[state] = None + else: + imgs[state] = image + return imgs