go-gtk icon indicating copy to clipboard operation
go-gtk copied to clipboard

Getters constructing new widgets

Open bytting opened this issue 12 years ago • 1 comments

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?

bytting avatar Dec 08 '12 19:12 bytting

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

mattn avatar Dec 25 '14 09:12 mattn