Re: a nasty accident of API design



> consider:
>
> 	Glib::RefPtr<Gtk::TreeStore> model = ListStore::create ();
>
> 	....
>
> 	model->clear();
> 	model.clear();
>
> those last two lines both compile, but they have a completely different
> effect. the first clears the model, the second "clears" the refptr.
>
> it seems to me that it would be wise to make sure that envelope classes
> like RefPtr have no methods that are likely to also exist in the wrapped
> classes.

Yes, this causes confusion quite often.

I wanted to remove RefPtr::clear(), or at least deprecated it. I seem to
have had some problem creating an operator=() to replace it:

From
http://cvs.gnome.org/viewcvs/glibmm/ChangeLog?view=markup
"
Wanted to remove clear()
	too, but there is no =0 equivalent yet.
"

It's a bit late now (we can't break API), but a patch would be welcome.

Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]