Reloading edited bitmaps does not take effect immediately, but after several seconds/mins (Caching of bitmaps?)

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
6 posts • Page 1 of 1
moto3101
Posts:37
Joined: Tue Aug 22, 2017 2:04 pm

Reloading edited bitmaps does not take effect immediately, but after several seconds/mins (Caching of bitmaps?)

Post by moto3101 »

Hello together,

we created a message editor, which allows the user to create and change messages, which are saved as bitmap graphics to the pictures folder of Winccoa. The filename is always the same in our example and must not change.

Code: Select all

string filePath = "C:/foo.jpg";
A panel is connected to a trigger datapoint and reloads the bitmap on every change of this dp in a table (its more complicated, but for this example its enough)

Code: Select all

dpConnect("onGraphicChanged", true, "Pump1.Request.TriggerReload");

Code: Select all

void onGraphicChanged(string dp, bool trigger) {
  table1.cellFillRC(1, "picture", "[pattern,[fit,any," + filePath + "]]");
}
We encounter, however, that the bitmap does not update even if it has changed, it always takes some time before it is updated (sometimes seconds, sometimes much longer). Also deleting the whole table content and reloading the bitmap has no effect.

It seems that if a bitmap with a filename is loaded, it is cached internally by WccOA to minimize computation efforts.
How can we disable this functionality or reduce the time between the checks for a newer content? We rely on the bitmap being reloaded instantly and we cannot change the filename, unfortunately.

I hope I described the problem precisely. If not, please let me know.

Thanks in advance and with best regards,
moTo

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: Reloading edited bitmaps does not take effect immediately, but after several seconds/mins (Caching of bitmaps?)

Post by mkoller »

Yes, bitmaps are cached inside the UI manager.
To allow explicit reload from disk, we introduced a new CTRL function in 3.16 Patch 1:

int deleteImageFromCache(string fileName)

With that function you can delete a specific file (filename) from the pixmap cache. On the next usage of that file (filename) it will be read again from the disk and put into the pixmap cache.

moto3101
Posts:37
Joined: Tue Aug 22, 2017 2:04 pm

Re: Reloading edited bitmaps does not take effect immediately, but after several seconds/mins (Caching of bitmaps?)

Post by moto3101 »

Thanks for your answer!

We are using WccOA 3.14. Is there a way we can get a similar functionality in this version?

Best regards,
moTo

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: Reloading edited bitmaps does not take effect immediately, but after several seconds/mins (Caching of bitmaps?)

Post by mkoller »

Checking 3.14 code, I found a possible workaround:
use the CTRL function imageToFile() as follows:
imageToFile(QVarPicture(getPath(PICTURES_REL_PATH, "picture.png")), "picture.png")

Where "picture.png" is the filename of your picture.
This call loads the file, saves it back and removes its path from the cache.

moto3101
Posts:37
Joined: Tue Aug 22, 2017 2:04 pm

Re: Reloading edited bitmaps does not take effect immediately, but after several seconds/mins (Caching of bitmaps?)

Post by moto3101 »

Thank you Martin!
I will test this and get back to you asap.

Best regards

moto3101
Posts:37
Joined: Tue Aug 22, 2017 2:04 pm

Re: Reloading edited bitmaps does not take effect immediately, but after several seconds/mins (Caching of bitmaps?)

Post by moto3101 »

Just wanted to get back to you on this topic.

Your solution works perfectly, even the performance is more than acceptable.

Thanks a lot!

Best regards

6 posts • Page 1 of 1