From 6014b51850d2b3d696daaef7bf2229bd0848aed9 Mon Sep 17 00:00:00 2001 From: o9000 Date: Wed, 20 May 2015 15:42:27 +0200 Subject: [PATCH] Better error handling in systray icon rendering --- src/systray/systraybar.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/systray/systraybar.c b/src/systray/systraybar.c index 0609546..e9fb61d 100644 --- a/src/systray/systraybar.c +++ b/src/systray/systraybar.c @@ -610,17 +610,20 @@ void systray_render_icon_now(void* t) return; } + int empty = 1; XImage *ximage = XGetImage(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height, AllPlanes, XYPixmap); - XColor color; - int x, y, empty = 1; - for (x = 0; empty && x < traywin->width; x++) { - for (y = 0; empty && y < traywin->height; y++) { - color.pixel = XGetPixel(ximage, x, y); - if (color.pixel != 0) - empty = 0; + if (ximage) { + XColor color; + int x, y; + for (x = 0; empty && x < traywin->width; x++) { + for (y = 0; empty && y < traywin->height; y++) { + color.pixel = XGetPixel(ximage, x, y); + if (color.pixel != 0) + empty = 0; + } } + XFree(ximage); } - XFree(ximage); if (traywin->empty != empty) { traywin->empty = empty; systray.area.resize = 1;