Weird apparent cache problem with snippets

Please post all questions and comments regarding Help & Manual 7 here.

Moderators: Alexander Halser, Tim Green

Post Reply
User avatar
Ed Hawco
Posts: 165
Joined: Thu Nov 07, 2013 5:50 pm
Location: Montreal
Contact:

Weird apparent cache problem with snippets

Unread post by Ed Hawco »

I'm experiencing an annoying problem involving snippets, and it seems to be some kind of cache problem within H&M. (Using H&M 7.1.0 build 3925 on Windows 10.)

The example below uses a sad face and a happy face metaphorically to keep it simple.

SETUP

I have a dedicated “snippets” project that includes a topic file called “look at this face.” The topic includes an embedded graphic of a sad face called “face.png.”

I import that snippet topic file into another project called “PROJECT.” It’s imported as a linked file, with both checkboxes checked (“use search path” and “begins new paragraph”). The search path is in PROJECT’s list of search paths.


WHAT HAPPENS

In the snippet project I change the source graphic to show a happy face. I DO NOT change the file name; same file name, different image. It works in the snippet project; I now see a happy face.

Over in PROJECT I look at the embedded snippet and it still shows a sad face.


In the snippet project I add some text and re-size the image of a happy face.

In PROJECT I see the added text, and the image is resized, but it still shows a sad face. (This shows that the embedded snippet is reading the changes from the snippet file.)


In the snippet project I swap out “face.png” for a picture of a pineapple, with the filename “pineapple.png.”

In PROJECT I see the pineapple. (This shows that it understands that I'm using a different image file.)


Back in the snippet project I remove pineapple.png and put face.png back (showing a happy face.)

In PROJECT I see a sad face. (The conclusion is that there seems to be a cache in H&M that won't update a graphic file unless the filename changes.)


At this point I look in a mirror and I see an annoyed face! ;-)

Additional notes:
- I tried opening and closing both the snippet project and the PROJECT project. No change.
- This is NOT browser-related, because the failure to update occurs in H&M, not in a compiled project -- although when I compile PROJECT the sad face still comes through.
- I've been using snippets like this for several years without any such problems. I know my snippets. I highly doubt this is "pilot error."
- I even tried deleting the snippet from PROJECT, saving the file, and then re-importing the snippet. Did not fix.
- When I import the snippet into a project where it has not already existed, I get the happy face (i.e., it works correctly).

Any idea what's going on?
e
d
============================================
Ed Hawco
User avatar
Martin Wynne
Posts: 2656
Joined: Mon May 12, 2003 3:21 pm
Location: West of the Severn, UK

Re: Weird apparent cache problem with snippets

Unread post by Martin Wynne »

Hi Ed,

You probably have a sub-folder called \images\ in your project folder. H&M has put a copy of your image file in there. Not necessarily from your snippet, you may have inserted an image with the same name in your project at some time in the past.

H&M never records the path to anything, only the file name, which it searches for each time it needs it.

There are some solutions:

1. never re-use image file names. If you create a new version of an image, give it a new file name and edit the location where it is used (in this case in your snippet).

or

2. change the order of items in your Project Search Path (at Configuration > Common Properties), so that the project folder is at the end of the list. H&M will then look everywhere else for your image first, including your snippets folder, before looking in its own saved locations.

or

3. always save and edit your images in the project \images\ folder when you create them, before using them in H&M.

regards,

Martin.
User avatar
Ed Hawco
Posts: 165
Joined: Thu Nov 07, 2013 5:50 pm
Location: Montreal
Contact:

Re: Weird apparent cache problem with snippets

Unread post by Ed Hawco »

You probably have a sub-folder called \images\ in your project folder. H&M has put a copy of your image file in there. Not necessarily from your snippet, you may have inserted an image with the same name in your project at some time in the past.

OMG, that's exactly what it was! I didn't realize that a snippet's call for a graphic would check the local directory first.


For posterity, here's my forensic analysis of what happened:

The snippet text and graphics were originally normal text and graphics in PROJECT A.

I created PROJECT B, which also required that text and graphics, so I moved the text and graphics to a SNIPPET PROJECT, then went back and imported the snippet text and graphics into PROJECT A and PROJECT B.

Unfortunately I neglected to delete the graphics from the graphics folder for PROJECT A.

Result: Snippet worked properly in PROJECT B, but in PROJECT A it was grabbing the graphics from PROJECT A's graphics folder. Thus, when I updated the "face.png" graphic in the SNIPPET PROJECT's graphics folder, PROJECT B was using the updated graphic but PROJECT A was using the old one from its own local graphics folder.


Thanks!
e
d
============================================
Ed Hawco
Post Reply