QResource: unregister .rcc files

自闭症网瘾萝莉.ら 提交于 2019-12-25 07:45:12

问题


We have an application with multiple themes, whom calls other minor apps. So, on main app there is something like that:

// User opens app with theme A
QResource::registerResource("theme_a.rcc");      // returns TRUE

// User changes theme to B
QResource::unregisterResource("theme_a.rcc");    // returns TRUE
QResource::registerResource("theme_b.rcc");      // returns TRUE

Everything works fine on main application. The problem begins when this software calls other qt apps.

Inside those minor apps we follow the same flow of register and unregister. The weird part is that register always works and unregister never works (only inside minors apps). It's happening something like that:

// User opens app with theme A
QResource::registerResource("minor_theme_a.rcc");      // returns TRUE

// User changes theme to B
QResource::unregisterResource("minor_theme_a.rcc");    // returns FALSE
QResource::registerResource("minor_theme_b.rcc");      // returns TRUE

Why is it happening? Is there a solution?


回答1:


unregisterResource returns true if the resource is successfully unloaded and no references exist for the resource.

So in your case there could be still some more references from some other forms.

Important documentation with respect to unregisterResource:

If there are QResources that currently reference resources related to the unregistered file, they will continue to be valid but the resource file itself will be removed from the resource roots, and thus no further QResource can be created pointing into this resource data. The resource itself will be unmapped from memory when the last QResource that points to it is destroyed.

So my strong guess is some QResource is still pointing to the one that you tried to unregister.



来源:https://stackoverflow.com/questions/43766738/qresource-unregister-rcc-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!