Forum: Ruby-Gnome 2 Problem with Gtk::Entry#completion=

Posted by Nikolai Weibull (Guest)
on 2011-09-22 17:24
(Received via mailing list)
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.)
Posted by Simon Arnaud (sarnaud)
on 2011-09-23 14:42
Nikolai Weibull 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
Posted by Kouhei Sutou (Guest)
on 2011-09-23 14:51
(Received via mailing list)
Hi,

In <CADdV=MuvFvHhpu5q=Ye_TNXSVUFwF4tNbVPobuwiozg8iXzANA@mail.gmail.com>
  "[ruby-gnome2-devel-en] Problem with Gtk::Entry#completion=" on Thu, 
22 Sep 2011 17:23:26 +0200,
  Nikolai Weibull <now@bitwi.se> 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
Posted by Nikolai Weibull (Guest)
on 2011-09-23 15:33
(Received via mailing list)
2011/9/23 Kouhei Sutou <kou@cozmixng.org>:

>  Nikolai Weibull <now@bitwi.se> 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.
Posted by Nikolai Weibull (Guest)
on 2011-09-23 15:34
(Received via mailing list)
On Fri, Sep 23, 2011 at 14:42, Simon Arnaud
<ruby-forum-incoming@andreas-s.net> wrote:
> Nikolai Weibull 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.
Posted by Nikolai Weibull (Guest)
on 2011-09-23 15:36
(Received via mailing list)
On Fri, Sep 23, 2011 at 15:34, Nikolai Weibull <now@bitwi.se> 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.)
Posted by Kouhei Sutou (Guest)
on 2011-09-23 16:03
(Received via mailing list)
Hi,

In <CADdV=MsWVtk-hkaOjZVh8mO4zZJcvmniOkDZP5hTYm=+70jUJQ@mail.gmail.com>
  "Re: [ruby-gnome2-devel-en] Problem with Gtk::Entry#completion=" on 
Fri, 23 Sep 2011 15:32:25 +0200,
  Nikolai Weibull <now@bitwi.se> 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
Posted by Nikolai Weibull (Guest)
on 2011-09-23 16:50
(Received via mailing list)
2011/9/23 Kouhei Sutou <kou@cozmixng.org>:

>  Nikolai Weibull <now@bitwi.se> 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?
Posted by Kouhei Sutou (Guest)
on 2011-09-24 02:12
(Received via mailing list)
Hi,

In <CADdV=Mus7ZVf82=XMDoQSeXhRnBx82TREk_pTSq5rOs+YndikA@mail.gmail.com>
  "Re: [ruby-gnome2-devel-en] Problem with Gtk::Entry#completion=" on 
Fri, 23 Sep 2011 16:49:21 +0200,
  Nikolai Weibull <now@bitwi.se> 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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.