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) <[email protected]>
---
 src/icon.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index 554db7d..fdfea00 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -370,17 +370,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);
 
-- 
1.8.4.rc3


-- 
To unsubscribe, send mail to [email protected].

Reply via email to