From cc01ca5c6bb388d759138e6ba207570134566885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sat, 28 Sep 2013 15:33:52 +0200 Subject: [PATCH] wIconChangeImageFile get image block swapped MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch swaps the if and the else blocks for the image value. Now, if the image doesn't exist, and because error is always "0" (is not changed after the definition), we can exist from the wIconChangeImageFile function. Before this patch, if the image was NULL, the error variable was set to "1", so we must return !error, then return "0". Because the "path" variable is not NULL, we must wfree it. Now, the "Set the new image" block is moved out the if block. Signed-off-by: Rodolfo García Peñas (kix) --- src/icon.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/icon.c b/src/icon.c index c30aeb44..c454049e 100644 --- a/src/icon.c +++ b/src/icon.c @@ -368,17 +368,16 @@ int wIconChangeImageFile(WIcon *icon, const char *file) return 0; image = get_rimage_from_file(scr, path, wPreferences.icon_size); - - /* New image! */ - if (!error && image) { - /* Set the new image */ - set_icon_image_from_image(icon, image); - icon->file = wstrdup(path); - update_icon_pixmap(icon); - } else { - error = 1; + if (!image) { + wfree(path); + return 0; } + /* Set the new image */ + set_icon_image_from_image(icon, image); + icon->file = wstrdup(path); + update_icon_pixmap(icon); + if (path) wfree(path);