Forum Discussion

DLC's avatar
DLC
Visitor
13 years ago

layer.Clear()

Hello,

Just a simple question on roImageCanvas, in the doc you can find :

Void ClearLayer(Integer zOrder)
Clear all content from a layer (see SetLayer for the layer definition)

Void Clear(Void)
Clear all content from all layers.


Do these functions also delete the layer itself? In my app, the number of layers is dynamic and I sometimes face weird behavior. For example, I have lines of text that appear where they shouldn't, i have rectangles that are supposed to be separate and that are not. It is just like if what i had drawn before was not really cleared and remained on the screen.
I tried using AllowUpdates() and put some Sleep() to be sure to let the time to the box to clear everything before drawing again, but it didn't change.
Any idea of what can cause this? A function I have forgotten maybe?

Thank you.

Denis

6 Replies

  • Does someone faced unexpected behavior with those two functions? I tried removing them from my code and i don't have problems anymore. I just create my layers without clearing the ones already created and it is ok. Looks like they are bugged, or maybe it is the roImageCanvas that has a problem? Or maybe there is still something I am missing but I really don't see what.
    Any idea?

    Denis
  • I've run into a problem where I overwrite a specific file using roUrlTransfer and roImageCanvas caches the previous image.

    In that case, the workaround is to call PurgeCachedImages() BEFORE you clear the layer or AFTER you reset the layer because the purge only happens to the images referenced in the layer at time of the call to purge.

    That could lead to what you describe, but it doesn't sound like that is quite the issue you've found.

    It might help if you created a function that replicated the problem.
  • Well I've been working on it till you propose that and it works fine now, though the screen needs one second to show each time i click on one of the remote button. It is a bit disappointed but i will do with it.
    Thank you very much.
  • No problem. If there are speed issues, you may want to consider re-implementing that particular screen using an roScreen, which has its own usage requirements on what you can and can't do, but in general roScreen is much faster but less convenient/less easy to use.
  • I tried using roScreen a few weeks ago and i gave up, though i can't remember why :oops: ... Maybe i'll take another look.
    Thanks.