Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86088

QResource::unregisterResource() function does not remove the resource from memory

    XMLWordPrintable

Details

    • macOS, Windows
    • f3d9e9214b (qt/qtdeclarative/dev) f3d9e9214b (qt/tqtc-qtdeclarative/dev) 45ba50f7bd (qt/qtdeclarative/6.4) 45ba50f7bd (qt/tqtc-qtdeclarative/6.4)

    Description

      QResource::unregisterResource() returns false if the resource is either not found, or if it is still in use by something. 

      I am trying to run a simple example where I dynamically load a red rectangle into the display, and unregister it from the resource system when the object is destroyed.

      The code and rcc files are attached.

      In the example that I wrote, you can register a resource, create the object, delete the object from the Loader QML type, and unregister the resource. 

      These are the steps to reproduce the bug:

      1. Click the load resource button
      2. Click the create button
      3. Click the Kill button
      4. Click the unregister button

      With this logic, the resource should successfully be unregistered, but remains in memory, and the unregisterResource function returns false.

      After the unregisterResource function returns false, the creating of the component for that QML file still works.

       

      What is preventing QResource::unregisterResource() from completely removing this resource from memory?

       

      A small working example that seems to have the same outcome each time:

      QResource::registerResource(resourcePath, mapRoot); 
      QQmlComponent *component = new QQmlComponent(engine_, pathInsideResource); 
      component->deleteLater(); // wait til destruction 
      QResource::unregisterResource(resourcePath, mapRoot);
      

      If you don’t create the component (only register, unregister), unregister always returns true. if you create a component based on something inside the resource, it will always return false, regardless of if the component has been destroyed or not. This createComponent part can occur in C++ or QML and it has the same result
       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ulherman Ulf Hermann
            olsen Carter Olsen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes