Problem with Gtk::Entry#completion=

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.)

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

Hi,

In [email protected]
“[ruby-gnome2-devel-en] Problem with Gtk::Entry#completion=” on Thu,
22 Sep 2011 17:23:26 +0200,
Nikolai W. [email protected] 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

2011/9/23 Kouhei S. [email protected]:

Nikolai W. [email protected] 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.

On Fri, Sep 23, 2011 at 14:42, Simon A.
[email protected] 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.

Hi,

In 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. [email protected] 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

On Fri, Sep 23, 2011 at 15:34, Nikolai W. [email protected] 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.)

2011/9/23 Kouhei S. [email protected]:

Nikolai W. [email protected] 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?

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] Problem with Gtk::Entry#completion=” on
Fri, 23 Sep 2011 16:49:21 +0200,
Nikolai W. [email protected] 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(). :slight_smile:

Thanks,

kou