Re: Glib::RefPtr and Pointer
- From: Murray Cumming <murrayc murrayc com>
- To: Andreas Volz <lists brachttal net>
- Cc: gtkmm-list gnome org
- Subject: Re: Glib::RefPtr and Pointer
- Date: Fri, 09 Nov 2007 08:34:13 +0100
On Thu, 2007-11-08 at 23:39 +0100, Andreas Volz wrote:
> Am Thu, 08 Nov 2007 08:52:44 +0100 schrieb Murray Cumming:
> > Yes. You need to check pointers (or RefPtrs) for null before
> > dereferencing them. For instance
> > if(list_store)
> > list_store->do_something().
> After some hours of searching I found the problem.
> Glib::RefPtr<Gtk::ListStore> m_refListModel;
> Now I tried to clear my ListStore:
> m_refListModel.clear ();
> This compiled nice, but m_refListModel was NULL after calling this.
> m_refListModel->clear ();
> This worked as I expected. After reading the documentation of RefPtr, I
> know the problem. This was a *really* hard to find bug!
We've all made that mistake once.
I would rename the clear() method on some classes if it didn't meant
that hundreds of applications would break.
murrayc murrayc com
] [Thread Prev