Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

ImageView and ImageTracker Caching?

Here's what I'm doing:

 

1) Load an image into an ImageView

2) Modify the image file

3) Press the "Back" button to return to my main screen.

4) Go back into the screen which loads the image into the ImageView.

5) Result: It still displays the unmodified file, not the file I saved back to the SD card.

 

The same result occurs if I use an ImageTracker to load the image.

 

Is there some kind of caching being used?  If so, how can I disable it?

Developer
Posts: 1,622
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: ImageView and ImageTracker Caching?

I had this problem  awhile back.  It appears that ImageView will not refresh the image unless the URL changes.

You can try resetting the URL or ImageSource and then set the URL back to your original URL.

Developer
Posts: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: ImageView and ImageTracker Caching?

Something that I did try was setting the URL of the ImageTracker to "" and then setting it back to my image, and that didn't seem to help.  The caching seems deeper than that.

 

One way I can get around it is to use a QImage to load the image, then convert it to bb::ImageData, then convert that to bb::Image, and finally, set the Image property of the ImageView.  That seems to avoid the caching problem -- but it significantly reduces the performance of image loading, because all of those conversions between different image type take time.

Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: ImageView and ImageTracker Caching?

Just a thought,

 

You could try destroying the imageview and then recreating it and see if that loads the new image

Developer
Posts: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: ImageView and ImageTracker Caching?

A good thought, but I'm pretty sure I am creating new ImageViews.  I close the screen (via Back button) and then reload the screen.

 

Each time I load the page, I do:

 

var newPage = photosPageDefinition.createObject();

 

... and then call a method that creates the ImageView objects dynamically in C++.

Developer
Posts: 1,622
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: ImageView and ImageTracker Caching?

not sure if this helps but this is how i did in my imagefx app

 

QImage *pictureImage; // load your image here

 

        img_obj->setImage(fromQImage(pictureImage));

or

 

       img_obj->setImage(bb::cascades::Image(fromQImage(pictureImage)));

 

Highlighted
Developer
Posts: 257
Registered: ‎01-08-2013
My Device: Z10 LE
My Carrier: SiMobil

Re: ImageView and ImageTracker Caching?

When you use

var newPage = photosPageDefinition.createObject();

 I am assuming you never destroy newPage?
 I found in some samples that you should use this:

 

property variant newPage 

//....

newPage = photosPageDefinition.createObject();

//....

onPopTransitionEnded: { if (newPage == page) page.destroy(); }

 It might not fix your issue though