GNOME Bugzilla – Bug 753353
fix gom_filter_new_sql with gobject introspection
Last modified: 2015-08-12 08:52:07 UTC
Created attachment 308892 [details] [review] copy the values into a new array Small fix to copy values when creating from a new GArray<GValue>. I think this is what we need to fix using this function from GObject Introspection.
This indeed fixes the issue I was seeing with Python GI bindings. Without this patch, the GI stack would unset the GValue, and because it wasn't copied into the filter, then by the time find_async function was called the GValue would be null. With this patch applied, I can use an SQL filter like so: filter = Gom.Filter.new_sql("items.name == ?", ["item2"]) group = repository.find_async(ItemResource, filter, find_cb, None) And it just works.
If you copy the GArray into the filter, shouldn't you also free it in gom_filter_finalize?
Created attachment 308904 [details] [review] Add a gom_filter_new_sql unit test
The unit test I just attached to this bug report also shows the problem that is fixed by Christian's patch. Without applying it, the unit test fails (because I unset the GValue right after creating the filter), but once I apply the patch, then the unit test just works. So that allows triggering the problem, without going through GObject-Introspection and Python.
Created attachment 308908 [details] [review] copy the values into a new array Oh look at that, we were previously leaking the GArray too! I figured that was being handled correctly so I didn't even check. New patch with fix to free the array on finalize.
Review of attachment 308904 [details] [review]: ++
Review of attachment 308908 [details] [review]: Looks good as well.
Attachment 308908 [details] pushed as 7d18349 - copy the values into a new array Attachment 308904 [details] pushed as 0e0ef51 - Add a gom_filter_new_sql unit test