On 05/17/2014 09:43 AM, Christophe wrote:
From: Christophe CURIS <christophe.cu...@free.fr>

It makes code simpler and less prone to errors.
---
  WPrefs.app/Appearance.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c
index 21dad63..ce54e3f 100644
--- a/WPrefs.app/Appearance.c
+++ b/WPrefs.app/Appearance.c
@@ -512,13 +512,13 @@ static Pixmap renderTexture(WMScreen * scr, WMPropList * 
texture, int width, int
                path = wfindfileinarray(GetObjectForKey("PixmapPath"), str);
                if (path != NULL) {
                        timage = RLoadImage(rc, path, 0);
+                       if (timage != NULL) {
+                               wwarning("could not load file '%s': %s", path ? 
path : str, RMessageForError(RErrorCode));
+                               texture = WMCreatePropListFromDescription("(solid, 
black)");
+                               type = "solid";
+                       }
+                       wfree(path);
                }
-               if (!path || !timage) {
-                       wwarning("could not load file '%s': %s", path ? path : 
str, RMessageForError(RErrorCode));
-                       texture = WMCreatePropListFromDescription("(solid, 
black)");
-                       type = "solid";
-               }
-               wfree(path);
        }
if (strcasecmp(type, "solid") == 0) {
This patch ends up causing the wrong behavior: when an image is successfully loaded, the warning message is given and the default black texture is loaded.

I just sent a patch to fix this thinking it was my own mistake, but now I think my original code did the right thing, even if it didn't do it quite as well as it might have. :)

I realize now that even my new patch doesn't replicate the original behavior as I had intended. In addition to RLoadImage failing to load the image (i.e., when timage == NULL, the warning/default texture should also occur when wfindfileinarray fails to find the image, i.e when path == NULL. Hence the original if (!path || !timage).

What would be the best way to implement the desired behavior?

Thanks!
Doug


--
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to