# Problem with Gtk::Entry#completion=

**URL:** <https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124>\
**Category:** Ruby-Gnome 2\
**Created:** [September 22, 2011, 5:24pm UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124 "2011-09-22T17:24:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [September 22, 2011, 5:24pm UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124/1 "2011-09-22T17:24:13Z")

</div>

Hi!

Gtk::Entry#completion= should call G\_CHILD\_SET so that the completion  
won’t be GC’d.

Is the addition of a G\_CHILD\_SET(self, rb\_intern(“completion”),  
completion); the correct way of doing this?

If so, can I apply a patch to Subversion?

(There are probably a lot more of these cases that need fixing. I’ll  
try to go through them when I update all the other memory management  
issues that I’ve seen.)

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [September 23, 2011, 2:42pm UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124/2 "2011-09-23T14:42:44Z")

</div>

Nikolai W. wrote in post #1023313:

> Hi!
> 
> Gtk::Entry#completion= should call G\_CHILD\_SET so that the completion  
> won’t be GC’d.

Woot.

I keep my completion in instance variable to circumvent this bug. It  
took me 3 or 4 days to understand what was happening.

It makes me realize that I never submitted this bug.

Thanks for your work.

Simon

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [September 23, 2011, 2:51pm UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124/3 "2011-09-23T14:51:44Z")

</div>

Hi,

In [CADdV=MuvFvHhpu5q=removed\_email\_address@domain.invalid](mailto:CADdV=MuvFvHhpu5q=removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] Problem with Gtk::Entry#completion=” on Thu,  
22 Sep 2011 17:23:26 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Gtk::Entry#completion= should call G\_CHILD\_SET so that the completion  
> wont be GCd.
> 
> Is the addition of a G\_CHILD\_SET(self, rb\_intern(“completion”),  
> completion); the correct way of doing this?

Please use G\_CHILD\_ADD() and G\_CHILD\_REMOVE().

> If so, can I apply a patch to Subversion?

Yes, please. But please use G\_CHILD\_ADD() and  
G\_CHILD\_REMOVE() instead.

> (There are probably a lot more of these cases that need fixing. Ill  
> try to go through them when I update all the other memory management  
> issues that Ive seen.)

Thanks!!!

–  
kou

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [September 23, 2011, 3:33pm UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124/4 "2011-09-23T15:33:06Z")

</div>

2011/9/23 Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Gtk::Entry#completion= should call G\_CHILD\_SET so that the completion  
> > won’t be GC’d.
> > 
> > Is the addition of a G\_CHILD\_SET(self, rb\_intern(“completion”),  
> > completion); the correct way of doing this?

> Please use G\_CHILD\_ADD() and G\_CHILD\_REMOVE().

But how should I use G\_CHILD\_REMOVE()? The key for G\_CHILD\_REMOVE is  
the child itself, which I don’t have a reference to on the next call  
to set\_completion.

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [September 23, 2011, 3:34pm UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124/5 "2011-09-23T15:34:57Z")

</div>

On Fri, Sep 23, 2011 at 14:42, Simon A.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Nikolai W. wrote in post #1023313:

> > Gtk::Entry#completion= should call G\_CHILD\_SET so that the completion  
> > won’t be GC’d.

> I keep my completion in instance variable to circumvent this bug. It  
> took me 3 or 4 days to understand what was happening.

That’s how I tested if that was the source of the bug :-).

It took me a couple of minutes to realize what was happening, but I  
perhaps know the source code a bit better and knew that  
Gtk::Entry#completion= wasn’t implemented as a property and might thus  
require a G\_CHILD\_\*() call.

> It makes me realize that I never submitted this bug.
> 
> Thanks for your work.

No problem.

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [September 23, 2011, 4:03pm UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124/6 "2011-09-23T16:03:59Z")

</div>

Hi,

In [CADdV=MsWVtk-hkaOjZVh8mO4zZJcvmniOkDZP5hTYm=removed\_email\_address@domain.invalid](mailto:CADdV=MsWVtk-hkaOjZVh8mO4zZJcvmniOkDZP5hTYm=removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] Problem with Gtk::Entry#completion=” on  
Fri, 23 Sep 2011 15:32:25 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> to set\_completion.  
> It seems that you will be able to get the child by  
> entry\_get\_complet(self).

But it’s OK to use G\_CHILD\_SET(). It seems that  
G\_CHILD\_ADD() and G\_CHILD\_REMOVE() may be complex a bit for  
this case.

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [September 23, 2011, 3:36pm UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124/7 "2011-09-23T15:36:11Z")

</div>

On Fri, Sep 23, 2011 at 15:34, Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> That’s how I tested if that was the source of the bug :-).
> 
> It took me a couple of minutes to realize what was happening, but I  
> perhaps know the source code a bit better and knew that  
> Gtk::Entry#completion= wasn’t implemented as a property and might thus  
> require a G\_CHILD\_\*() call.

(That wasn’t a comparison of skill, by the way. Sorry if it sounded  
like it was.)

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [September 23, 2011, 4:50pm UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124/8 "2011-09-23T16:50:17Z")

</div>

2011/9/23 Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > to set\_completion.  
> > It seems that you will be able to get the child by  
> > entry\_get\_complet(self).

Would that work even if the completion had been changed out-side of  
Ruby-GNOME2?

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [September 24, 2011, 2:12am UTC](https://www.ruby-forum.com/t/problem-with-gtk-entry-completion/212124/9 "2011-09-24T02:12:27Z")

</div>

Hi,

In [CADdV=Mus7ZVf82=removed\_email\_address@domain.invalid](mailto:CADdV=Mus7ZVf82=removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] Problem with Gtk::Entry#completion=” on  
Fri, 23 Sep 2011 16:49:21 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > to set\_completion.
> 
> > It seems that you will be able to get the child by  
> > entry\_get\_complet(self).
> 
> Would that work even if the completion had been changed out-side of Ruby-GNOME2?

In the case, G\_CHILD\_SET() has a similar problem:

1. set completion by Gtk::Entry#completion=.
2. set copmletion by gtk\_entry\_set\_completion().  
XXX. (completion object set by 1. will not be GCed.)
3. set completion by Gtk::Entry#completion=.  
(completion object set by 1. will be GCed.)

G\_CHILD\_ADD()/G\_CHILD\_REMOVE() can’t solve XXX. but  
G\_CHILD\_SET() can solve it by 3.. But if 3. isn’t done,  
G\_CHILD\_SET() has the same problem as  
G\_CHILD\_ADD()/G\_CHILD\_REMOVE().

(Sure, It’s OK for me to use G\_CHILD\_SET(). 🙂

## Thanks,

kou
