[Gambas-user] ComboBox Error when ComboBox.Remove("1") / possible bug in gb.gtk?

Benoit Minisini gambas at ...1...
Thu Nov 27 00:50:48 CET 2008


On jeudi 27 novembre 2008, Nicolas Koch wrote:
> Hello Gambas Users,
>
> Ok an interesting problem I've noticed in gb.gtk or with gb.gui.  If
> you have a ComboBox with items in it and you try to hide one of the
> items from listing invoking ComboBox1.Remove("1") you'll get this
> error.
>
> (test 26729): Gtk-WARNING **: gtktreemodel.c:429: Negative numbers in
> path -1 passed to gtk_tree_path_new_from_string
>
> The reason why I am trying to hide the hidden folders beginning with .
> but show the non hidden folders in the ComboBox1
>
> Although the console spits out this error it does what it is supposed
> to and removes the hidden folder.
>
> There is no error on gb.QT and works with the same code.
>

I don't have the warning, so I think you should upgrade to Gambas 2.9, or wait 
for Gambas 2.10.

> Without ComboBox1.Remove("1") the error disappears and shows hidden
> folders like the following
>
> .data
> save
> pictures
> tmp
>
> With ComboBox1.Remove("1") the error shows, but works
>
> save
> pictures
> tmp
>
> Here is the code:
>
> PUBLIC $DIR AS String
> PUBLIC sPath AS String
> 'PRIVATE SHOW_HIDDEN_FILES AS Boolean
>
> PUBLIC SUB sPath($FILE AS String)
>   sPath = "~/src/test"
>
>   ComboBox11.Clear
>   FOR EACH $DIR IN Dir(sPath, "*")
>     ComboBox1.Add($DIR)
>   NEXT
>   ComboBox1.Remove("1")
>
> END
>
>
> Is there a better way of doing this?

Many. :-)

The argument of Remove is an integer, not a string.

You should not create public global variables when you just need local 
variables.

You can do: ComboBox.List = Dir(sPath)

Regards,

-- 
Benoit Minisini




More information about the User mailing list