Forum: Ruby-Gnome 2 [Patch] don't ignore return of g_list_append

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2006-05-09 13:09
(Received via mailing list)
Hi,

  Some code in rbglib_completion ignores the return value of
g_list_append,
  this might cause problems as the start of the list can move around.
Attached
  trivial patch fixes this.

  Sjoerd
Masao M. (Guest)
on 2006-05-09 21:37
(Received via mailing list)
Hi,

On Tue, 9 May 2006 11:06:54 +0200
removed_email_address@domain.invalid (Sjoerd S.) wrote:

> Hi,
>
>   Some code in rbglib_completion ignores the return value of g_list_append,
>   this might cause problems as the start of the list can move around. Attached
>   trivial patch fixes this.

Could you show me a sample to explain this problem?

--
.:% Masao M.<removed_email_address@domain.invalid>


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709...
unknown (Guest)
on 2006-05-09 23:36
(Received via mailing list)
On Wed, May 10, 2006 at 02:35:46AM +0900, Masao M. wrote:
> Hi,
>
> On Tue, 9 May 2006 11:06:54 +0200
> removed_email_address@domain.invalid (Sjoerd S.) wrote:
> >   Some code in rbglib_completion ignores the return value of g_list_append,
> >   this might cause problems as the start of the list can move around.
> >   Attached trivial patch fixes this.
>
> Could you show me a sample to explain this problem?

Sure. But while creating the example i noticed there was more wrong then
the
little (common) error i spotted initially. I've also added some
Check_Type
calls to ensure the parameters are actually arrays. Updated patch
attached.

For an example:
require 'glib2'

c = GLib::Completion.new

c.add_items(["One", "Two", "Three"])
p c.items.keys
c.remove_items(["Two", "One"])
p c.items.keys

p c.complete("")


Without the patch it outputs:
["Two", "One", "Three"]
["One", "Three"]
[["Three", "Two", "One"], nil]

With the patch it gives the correct output:
["Two", "One", "Three"]
["Three"]
[["Three"], nil]

  Sjoerd
This topic is locked and can not be replied to.