GNOME Bugzilla – Bug 610342
Virtual functions in completion proposal and provider should return allocated string.
Last modified: 2010-02-21 22:03:19 UTC
Currently vfuncs listed below returns a pointer to internal string, which poses a problem for bindings wrapping them [1]: In GtkSourceCompletionProposal: - get_label() - get_markup() - get_text() - get_info() In GtkSourceCompletionProvider: - get_name() Solution could be turning those strings into properties or return a g_strdup() of them. [1] Details about this is on opened-hand bugzilla - such situation happened already in Clutter: http://bugzilla.o-hand.com/show_bug.cgi?id=1403
well, for the Proposal is a bit unfortunate since it is just meant as a container object for those information. That said, strdup should not be too bad either... would you be able to provide a patch?
(In reply to comment #1) > That said, strdup should not be too bad either... would you be able to provide > a patch? Sure. I decided to split those patches into 3 parts. First fixes provider, second completion and third is a small patch fixing resulting warning in test-completion.
Created attachment 154336 [details] [review] Fixes provider.
Created attachment 154337 [details] [review] Fixes proposal.
Created attachment 154338 [details] [review] Fixes a warning in test-completion.
All three patches look good, thanks a lot. Please push. We'll also need to fix pygtksourceview and gedit and notify anjuta guys.
Pushed. I already had a look at gedit and anjuta (but not pygtksourceview) by grepping sources with command: grep -nrHEe "GtkSourceCompletionProposal|GtkSourceCompletionProvider|GtkSourceCompletionWords|GTK_TYPE_SOURCE_COMPLETION_PROPOSAL|GTK_TYPE_SOURCE_COMPLETION_PROVIDER|GTK_TYPE_SOURCE_COMPLETION_WORDS|gtk_source_completion_proposal|gtk_source_completion_provider|gtk_source_completion_words" --exclude-dir=.git . gedit - found nothing. gedit-plugins - found something, but after examination I noticed it does neither use nor override any of affected functions. anjuta - sourceview plugin implements provider, so its get_name implementation should be changed. Its provider also implements IAnjutaProvider interface, which also defines a get_name() function returning const gchar* instead of gchar*. In the end affected plugins are sourceview, language-support-cpp-java and language-support-js. I even could provide a patch. pygtksourceview - I have no clue how are python bindings are generated, but probably it should have .defs file regenerated and that is all (assuming that functions returning a gchar* are automatically marked at those, whose result should be freed - if not, probably an override should be written.)
For pygsv, I would not be surprised if the current bindings actually leak those strings (as that is the whole problem as far as I understand). And yes, changing the defs should be enough I think. With regard to the use of completion, there is at least snippets that uses it, but that's a python plugin, so no changes needed there.
If you feel like providing a patch for anjuta, I would review it.
I'll post patches in respective bugs I filed: pygsv - bug 610635 anjuta - bug 610636