On Sun, 18 May 2014 at 15:45:35 -0500, Doug Torrance wrote:
> On 05/17/2014 09:43 AM, Christophe wrote:
> >From: Christophe CURIS <[email protected]>
> >
> >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?

I guess we should revert this part to the original version. Something
like this?

diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c
index 256a74d..cbbcaa7 100644
--- a/WPrefs.app/Appearance.c
+++ b/WPrefs.app/Appearance.c
@@ -510,15 +510,15 @@ static Pixmap renderTexture(WMScreen * scr, WMPropList * 
texture, int width, int
 
                str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
                path = wfindfileinarray(GetObjectForKey("PixmapPath"), str);
-               if (path) {
+               if (path)
                        timage = RLoadImage(rc, path, 0);
-                       if (!timage) {
+
+               if (!path || !timage) {
                                wwarning("could not load file '%s': %s", path ? 
path : str, RMessageForError(RErrorCode));
                                texture = 
WMCreatePropListFromDescription("(solid, black)");
                                type = "solid";
-                       }
-                       wfree(path);
                }
+               wfree(path);
        }
 
        if (strcasecmp(type, "solid") == 0) {


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

Reply via email to