mattn / go-gtk

Go binding for GTK
http://mattn.github.com/go-gtk
BSD 3-Clause "New" or "Revised" License
2.12k stars 247 forks source link

Getters constructing new widgets #138

Open bytting opened 11 years ago

bytting commented 11 years ago

I have been looking at some of the get* functions, like this one

func (v *Dialog) GetWidgetForResponse(id int) *Widget {
    panic_if_version_older(2, 20, 0, "gtk_dialog_get_widget_for_response()")
    return &Widget{C._gtk_dialog_get_widget_for_response(DIALOG(v), gint(id))}
}

and it seems to me that this function constructs a new Widget every time it is called.

Even if the GC will get rid of these duplicates at some point it still seems wrong to me. Wouldn't it be more correct to have it return the same Widget?

mattn commented 9 years ago

Impossible. If doing this, We must have pool of Widget struct array.