Re: Glib::RefPtr and Pointer



Yes. You need to check pointers (or RefPtrs) for null before
dereferencing them. For instance
if(list_store)
  list_store->do_something().

This is the relevant text from your valgrind report:

==26799== Invalid read of size 4
==26799==    at 0x4200125: Gtk::ListStore::append() (in /usr/lib/libgtkmm-2.4.so.1.0.30)
==26799==    by 0x80572CA: IconBrowser::showFileList(std::list<Link*, std::allocator<Link*> > const*) (IconBrowser.cpp:85)
==26799==    by 0x80544CA: SideBar::onTreeviewRowActivated(Gtk::TreePath const&, Gtk::TreeViewColumn*) (SideBar.cpp:77)
==26799==    by 0x8055C0A: sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*>::operator()(Gtk::TreePath const&, Gtk::TreeViewColumn* const&) const (mem_fun.h:1917)
==26799==    by 0x8055C2F: sigc::adaptor_functor<sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*> >::deduce_result_type<Gtk::TreePath const&, Gtk::TreeViewColumn* const&, void, void, void, void, void>::type sigc::adaptor_functor<sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*> >::operator()<Gtk::TreePath const&, Gtk::TreeViewColumn* const&>(Gtk::TreePath const&, Gtk::TreeViewColumn* const&) const (adaptor_trait.h:103)
==26799==    by 0x8055C59: sigc::internal::slot_call2<sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*>, void, Gtk::TreePath const&, Gtk::TreeViewColumn*>::call_it(sigc::internal::slot_rep*, Gtk::TreePath const&, Gtk::TreeViewColumn* const&) (slot.h:173)
==26799==    by 0x42735B9: (within /usr/lib/libgtkmm-2.4.so.1.0.30)
==26799==    by 0x454EFAC: (within /usr/lib/libgtk-x11-2.0.so.0.1000.14)
==26799==    by 0x4E3793A: g_closure_invoke (in /usr/lib/libgobject-2.0.so.0.1200.13)
==26799==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==26799== 
==26799== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==26799==  Access not within mapped region at address 0x0
==26799==    at 0x4200125: Gtk::ListStore::append() (in /usr/lib/libgtkmm-2.4.so.1.0.30)
==26799==    by 0x80572CA: IconBrowser::showFileList(std::list<Link*, std::allocator<Link*> > const*) (IconBrowser.cpp:85)
==26799==    by 0x80544CA: SideBar::onTreeviewRowActivated(Gtk::TreePath const&, Gtk::TreeViewColumn*) (SideBar.cpp:77)
==26799==    by 0x8055C0A: sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*>::operator()(Gtk::TreePath const&, Gtk::TreeViewColumn* const&) const (mem_fun.h:1917)
==26799==    by 0x8055C2F: sigc::adaptor_functor<sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*> >::deduce_result_type<Gtk::TreePath const&, Gtk::TreeViewColumn* const&, void, void, void, void, void>::type sigc::adaptor_functor<sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*> >::operator()<Gtk::TreePath const&, Gtk::TreeViewColumn* const&>(Gtk::TreePath const&, Gtk::TreeViewColumn* const&) const (adaptor_trait.h:103)
==26799==    by 0x8055C59: sigc::internal::slot_call2<sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*>, void, Gtk::TreePath const&, Gtk::TreeViewColumn*>::call_it(sigc::internal::slot_rep*, Gtk::TreePath const&, Gtk::TreeViewColumn* const&) (slot.h:173)
==26799==    by 0x42735B9: (within /usr/lib/libgtkmm-2.4.so.1.0.30)
==26799==    by 0x454EFAC: (within /usr/lib/libgtk-x11-2.0.so.0.1000.14)
==26799==    by 0x4E3793A: g_closure_invoke (in /usr/lib/libgobject-2.0.so.0.1200.13)
==26799== 
==26799== Invalid free() / delete / delete[]
==26799==    at 0x402195A: free (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==26799==    by 0x53CAFBD: (within /lib/libc-2.6.1.so)
==26799==    by 0x53CAB06: __libc_freeres (in /lib/libc-2.6.1.so)
==26799==    by 0x401C276: _vgnU_freeres (in /usr/lib/valgrind/x86-linux/vgpreload_core.so)
==26799==    by 0xBEC41C03: ???
==26799==    by 0x80572CA: IconBrowser::showFileList(std::list<Link*, std::allocator<Link*> > const*) (IconBrowser.cpp:85)
==26799==    by 0x80544CA: SideBar::onTreeviewRowActivated(Gtk::TreePath const&, Gtk::TreeViewColumn*) (SideBar.cpp:77)
==26799==    by 0x8055C0A: sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*>::operator()(Gtk::TreePath const&, Gtk::TreeViewColumn* const&) const (mem_fun.h:1917)
==26799==    by 0x8055C2F: sigc::adaptor_functor<sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*> >::deduce_result_type<Gtk::TreePath const&, Gtk::TreeViewColumn* const&, void, void, void, void, void>::type sigc::adaptor_functor<sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*> >::operator()<Gtk::TreePath const&, Gtk::TreeViewColumn* const&>(Gtk::TreePath const&, Gtk::TreeViewColumn* const&) const (adaptor_trait.h:103)
==26799==    by 0x8055C59: sigc::internal::slot_call2<sigc::bound_mem_functor2<void, SideBar, Gtk::TreePath const&, Gtk::TreeViewColumn*>, void, Gtk::TreePath const&, Gtk::TreeViewColumn*>::call_it(sigc::internal::slot_rep*, Gtk::TreePath const&, Gtk::TreeViewColumn* const&) (slot.h:173)
==26799==    by 0x42735B9: (within /usr/lib/libgtkmm-2.4.so.1.0.30)
==26799==    by 0x454EFAC: (within /usr/lib/libgtk-x11-2.0.so.0.1000.14)
==26799==  Address 0x5E6DBA8 is not stack'd, malloc'd or (recently) free'd
-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com



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