GNOME Bugzilla – Bug 343882
camel_store_get_folder returns instances with refcount of two
Last modified: 2018-12-11 06:39:33 UTC
It looks like camel_store_get_folder often returns instances with a refcount of two. While the folder camelobject that was once asked for, using the same get_folder method on the store instance and the same folder-id, got unreferenced (for sure). I have to unreference it in a while ref_count>=1 loop cause of this :(. It might be a bug that I introduced myself. If that's the case, I will soon close this bug myself. I'm planning to create little test-cases and/or unit tests for this soon. I also have to cancel the camel-operation if I want it to be fully cleared (the memory of the folder instance) while the folder is loading and I destroy the folder during that event. For example: The folder is loading, the user decides (while loading the folder) to remove the account from the configuration. So now my code has to start destroying folder instances. This wont work for the folder being loaded (it will not freeup the memory, but the refcount will be zero -- measured with valgrind --) until I launch a forced cancellation on the operation.
Thanks for a bug report. This would need to retest on something more recent, like 3.30.x, because there changed many things in Camel since 2006. The ref-count on the folder can be higher in case of the store using search folders (like Trash and/or Junk), which reference the created folder when it is added to them as a subfolder. You are not supposed to unref it that many times for sure. The folder will be freed when the store is properly freed (and all other search folders which would have the got folder used as a subfolder of itself).