After unregisterResource , why still can use the resource



  • hi,

    in my case , I want to dinamic Switch the resource.

    so i have two rcc files, they have picture with same alias, like this

    A.rcc
    @
    <RCC>
    <qresource prefix="/">
    <file alias="cover">a.png</file>
    </qresource>
    </RCC>
    @

    B.rcc
    @
    <RCC>
    <qresource prefix="/">
    <file alias="cover">b.png</file>
    </qresource>
    </RCC>
    @

    I first registerResource A.rcc , used a.png

    then unregisterResource A.rcc

    then,
    @
    Image { id: ttt }
    ...
    ttt.source="qrc:/cover";
    @
    it works, used a.png . why???

    then,
    registerResource B.rcc
    still used a.png. why???


  • Moderators

    Is the image element created after the resource file is changed? Or is it created before?

    If the Image element is persistent through the changing of the resource file, try briefly setting ttt.source="" and then resetting ttt.source="qrc:/cover" again. Does it then reload the proper image?



  • [quote author="mlong" date="1313012387"]Is the image element created after the resource file is changed? Or is it created before?

    If the Image element is persistent through the changing of the resource file, try briefly setting ttt.source="" and then resetting ttt.source="qrc:/cover" again. Does it then reload the proper image? [/quote]

    the image element created after the resource file is changed



  • A resource file can only be unloaded if it's not being used. Are you sure you're not using it elsewhere?



  • I can Detailed description Process :

    1. registerResource A.rcc

    2. createQmlObject a Image_A created , used a.png in A.rcc

    3. then, destroy Image_A and unregisterResource A.rcc

    4. Next process, is Confusing. a new created Image_B can set source = "qrc:/cover" , it works used a.png

    5. then I registerResource B.rcc . a new created Image_C set source = "qrc:/cover" , it works still used a.png . why?

    btw, I write a plugin that can call registerResource and unregisterResource in QML.



  • Hi,

    QML does a lot of caching behind the scenes, and images are one of the things that are cached. From your description it sounds like the cached image is what is continually being used, regardless of changing the underlying resource file.

    QtQuick 1.1 (not yet released, but available as the HEAD of 4.7, or with the recent 4.8 pre-releases) adds a cache property to Image that should allow you to turn off this caching, which might solve your problem.

    Regards,
    Michael



  • Thanks for Details answers


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.